| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "lithium-allocator.h" | 32 #include "lithium-allocator.h" |
| 33 #include "lithium.h" | 33 #include "lithium.h" |
| 34 #include "safepoint-table.h" | 34 #include "safepoint-table.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 // Forward declarations. | 39 // Forward declarations. |
| 40 class LCodeGen; | 40 class LCodeGen; |
| 41 | 41 |
| 42 | |
| 43 // Type hierarchy: | |
| 44 // | |
| 45 // LInstruction | |
| 46 // LTemplateInstruction | |
| 47 // LControlInstruction | |
| 48 // LBranch | |
| 49 // LClassOfTestAndBranch | |
| 50 // LCmpJSObjectEqAndBranch | |
| 51 // LCmpIDAndBranch | |
| 52 // LHasCachedArrayIndexAndBranch | |
| 53 // LHasInstanceTypeAndBranch | |
| 54 // LInstanceOfAndBranch | |
| 55 // LIsNullAndBranch | |
| 56 // LIsObjectAndBranch | |
| 57 // LIsSmiAndBranch | |
| 58 // LTypeofIsAndBranch | |
| 59 // LAccessArgumentsAt | |
| 60 // LArgumentsElements | |
| 61 // LArgumentsLength | |
| 62 // LAddI | |
| 63 // LApplyArguments | |
| 64 // LArithmeticD | |
| 65 // LArithmeticT | |
| 66 // LBitI | |
| 67 // LBoundsCheck | |
| 68 // LCmpID | |
| 69 // LCmpJSObjectEq | |
| 70 // LCmpT | |
| 71 // LDivI | |
| 72 // LInstanceOf | |
| 73 // LInstanceOfKnownGlobal | |
| 74 // LLoadKeyedFastElement | |
| 75 // LLoadKeyedGeneric | |
| 76 // LModI | |
| 77 // LMulI | |
| 78 // LPower | |
| 79 // LShiftI | |
| 80 // LSubI | |
| 81 // LCallConstantFunction | |
| 82 // LCallFunction | |
| 83 // LCallGlobal | |
| 84 // LCallKeyed | |
| 85 // LCallKnownGlobal | |
| 86 // LCallNamed | |
| 87 // LCallRuntime | |
| 88 // LCallStub | |
| 89 // LConstant | |
| 90 // LConstantD | |
| 91 // LConstantI | |
| 92 // LConstantT | |
| 93 // LDeoptimize | |
| 94 // LFunctionLiteral | |
| 95 // LGap | |
| 96 // LLabel | |
| 97 // LGlobalObject | |
| 98 // LGlobalReceiver | |
| 99 // LGoto | |
| 100 // LLazyBailout | |
| 101 // LLoadGlobal | |
| 102 // LCheckPrototypeMaps | |
| 103 // LLoadContextSlot | |
| 104 // LArrayLiteral | |
| 105 // LObjectLiteral | |
| 106 // LRegExpLiteral | |
| 107 // LOsrEntry | |
| 108 // LParameter | |
| 109 // LRegExpConstructResult | |
| 110 // LStackCheck | |
| 111 // LStoreKeyed | |
| 112 // LStoreKeyedFastElement | |
| 113 // LStoreKeyedGeneric | |
| 114 // LStoreNamed | |
| 115 // LStoreNamedField | |
| 116 // LStoreNamedGeneric | |
| 117 // LStringCharCodeAt | |
| 118 // LBitNotI | |
| 119 // LCallNew | |
| 120 // LCheckFunction | |
| 121 // LCheckPrototypeMaps | |
| 122 // LCheckInstanceType | |
| 123 // LCheckMap | |
| 124 // LCheckSmi | |
| 125 // LClassOfTest | |
| 126 // LDeleteProperty | |
| 127 // LDoubleToI | |
| 128 // LFixedArrayLength | |
| 129 // LHasCachedArrayIndex | |
| 130 // LHasInstanceType | |
| 131 // LInteger32ToDouble | |
| 132 // LIsNull | |
| 133 // LIsObject | |
| 134 // LIsSmi | |
| 135 // LJSArrayLength | |
| 136 // LLoadNamedField | |
| 137 // LLoadNamedGeneric | |
| 138 // LLoadFunctionPrototype | |
| 139 // LNumberTagD | |
| 140 // LNumberTagI | |
| 141 // LPushArgument | |
| 142 // LReturn | |
| 143 // LSmiTag | |
| 144 // LStoreGlobal | |
| 145 // LStringLength | |
| 146 // LTaggedToI | |
| 147 // LThrow | |
| 148 // LTypeof | |
| 149 // LTypeofIs | |
| 150 // LUnaryMathOperation | |
| 151 // LValueOf | |
| 152 // LUnknownOSRValue | |
| 153 | |
| 154 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ | 42 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ |
| 155 V(ControlInstruction) \ | 43 V(ControlInstruction) \ |
| 156 V(Constant) \ | |
| 157 V(Call) \ | 44 V(Call) \ |
| 158 V(StoreKeyed) \ | 45 V(StoreKeyed) \ |
| 159 V(StoreNamed) \ | 46 V(StoreNamed) \ |
| 160 LITHIUM_CONCRETE_INSTRUCTION_LIST(V) | 47 LITHIUM_CONCRETE_INSTRUCTION_LIST(V) |
| 161 | 48 |
| 162 | 49 |
| 163 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ | 50 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
| 164 V(AccessArgumentsAt) \ | 51 V(AccessArgumentsAt) \ |
| 165 V(AddI) \ | 52 V(AddI) \ |
| 166 V(ApplyArguments) \ | 53 V(ApplyArguments) \ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 180 V(CallKnownGlobal) \ | 67 V(CallKnownGlobal) \ |
| 181 V(CallNamed) \ | 68 V(CallNamed) \ |
| 182 V(CallNew) \ | 69 V(CallNew) \ |
| 183 V(CallRuntime) \ | 70 V(CallRuntime) \ |
| 184 V(CallStub) \ | 71 V(CallStub) \ |
| 185 V(CheckFunction) \ | 72 V(CheckFunction) \ |
| 186 V(CheckInstanceType) \ | 73 V(CheckInstanceType) \ |
| 187 V(CheckMap) \ | 74 V(CheckMap) \ |
| 188 V(CheckPrototypeMaps) \ | 75 V(CheckPrototypeMaps) \ |
| 189 V(CheckSmi) \ | 76 V(CheckSmi) \ |
| 77 V(ClassOfTest) \ |
| 78 V(ClassOfTestAndBranch) \ |
| 190 V(CmpID) \ | 79 V(CmpID) \ |
| 191 V(CmpIDAndBranch) \ | 80 V(CmpIDAndBranch) \ |
| 192 V(CmpJSObjectEq) \ | 81 V(CmpJSObjectEq) \ |
| 193 V(CmpJSObjectEqAndBranch) \ | 82 V(CmpJSObjectEqAndBranch) \ |
| 194 V(CmpMapAndBranch) \ | 83 V(CmpMapAndBranch) \ |
| 195 V(CmpT) \ | 84 V(CmpT) \ |
| 196 V(CmpTAndBranch) \ | 85 V(CmpTAndBranch) \ |
| 197 V(ConstantD) \ | 86 V(ConstantD) \ |
| 198 V(ConstantI) \ | 87 V(ConstantI) \ |
| 199 V(ConstantT) \ | 88 V(ConstantT) \ |
| 89 V(Context) \ |
| 200 V(DeleteProperty) \ | 90 V(DeleteProperty) \ |
| 201 V(Deoptimize) \ | 91 V(Deoptimize) \ |
| 202 V(DivI) \ | 92 V(DivI) \ |
| 203 V(DoubleToI) \ | 93 V(DoubleToI) \ |
| 204 V(FixedArrayLength) \ | 94 V(FixedArrayLength) \ |
| 205 V(FunctionLiteral) \ | 95 V(FunctionLiteral) \ |
| 206 V(Gap) \ | 96 V(Gap) \ |
| 207 V(GlobalObject) \ | 97 V(GlobalObject) \ |
| 208 V(GlobalReceiver) \ | 98 V(GlobalReceiver) \ |
| 209 V(Goto) \ | 99 V(Goto) \ |
| 100 V(HasCachedArrayIndex) \ |
| 101 V(HasCachedArrayIndexAndBranch) \ |
| 102 V(HasInstanceType) \ |
| 103 V(HasInstanceTypeAndBranch) \ |
| 210 V(InstanceOf) \ | 104 V(InstanceOf) \ |
| 211 V(InstanceOfAndBranch) \ | 105 V(InstanceOfAndBranch) \ |
| 212 V(InstanceOfKnownGlobal) \ | 106 V(InstanceOfKnownGlobal) \ |
| 213 V(Integer32ToDouble) \ | 107 V(Integer32ToDouble) \ |
| 214 V(IsNull) \ | 108 V(IsNull) \ |
| 215 V(IsNullAndBranch) \ | 109 V(IsNullAndBranch) \ |
| 216 V(IsObject) \ | 110 V(IsObject) \ |
| 217 V(IsObjectAndBranch) \ | 111 V(IsObjectAndBranch) \ |
| 218 V(IsSmi) \ | 112 V(IsSmi) \ |
| 219 V(IsSmiAndBranch) \ | 113 V(IsSmiAndBranch) \ |
| 220 V(JSArrayLength) \ | 114 V(JSArrayLength) \ |
| 221 V(HasInstanceType) \ | |
| 222 V(HasInstanceTypeAndBranch) \ | |
| 223 V(HasCachedArrayIndex) \ | |
| 224 V(HasCachedArrayIndexAndBranch) \ | |
| 225 V(ClassOfTest) \ | |
| 226 V(ClassOfTestAndBranch) \ | |
| 227 V(Label) \ | 115 V(Label) \ |
| 228 V(LazyBailout) \ | 116 V(LazyBailout) \ |
| 229 V(LoadContextSlot) \ | 117 V(LoadContextSlot) \ |
| 230 V(LoadElements) \ | 118 V(LoadElements) \ |
| 119 V(LoadFunctionPrototype) \ |
| 231 V(LoadGlobal) \ | 120 V(LoadGlobal) \ |
| 232 V(LoadKeyedFastElement) \ | 121 V(LoadKeyedFastElement) \ |
| 233 V(LoadKeyedGeneric) \ | 122 V(LoadKeyedGeneric) \ |
| 234 V(LoadNamedField) \ | 123 V(LoadNamedField) \ |
| 235 V(LoadNamedGeneric) \ | 124 V(LoadNamedGeneric) \ |
| 236 V(LoadFunctionPrototype) \ | |
| 237 V(ModI) \ | 125 V(ModI) \ |
| 238 V(MulI) \ | 126 V(MulI) \ |
| 239 V(NumberTagD) \ | 127 V(NumberTagD) \ |
| 240 V(NumberTagI) \ | 128 V(NumberTagI) \ |
| 241 V(NumberUntagD) \ | 129 V(NumberUntagD) \ |
| 242 V(ObjectLiteral) \ | 130 V(ObjectLiteral) \ |
| 243 V(OsrEntry) \ | 131 V(OsrEntry) \ |
| 132 V(OuterContext) \ |
| 244 V(Parameter) \ | 133 V(Parameter) \ |
| 245 V(PushArgument) \ | 134 V(PushArgument) \ |
| 246 V(RegExpLiteral) \ | 135 V(RegExpLiteral) \ |
| 247 V(Return) \ | 136 V(Return) \ |
| 248 V(ShiftI) \ | 137 V(ShiftI) \ |
| 249 V(SmiTag) \ | 138 V(SmiTag) \ |
| 250 V(SmiUntag) \ | 139 V(SmiUntag) \ |
| 251 V(StackCheck) \ | 140 V(StackCheck) \ |
| 141 V(StoreContextSlot) \ |
| 252 V(StoreGlobal) \ | 142 V(StoreGlobal) \ |
| 253 V(StoreKeyedFastElement) \ | 143 V(StoreKeyedFastElement) \ |
| 254 V(StoreKeyedGeneric) \ | 144 V(StoreKeyedGeneric) \ |
| 255 V(StoreNamedField) \ | 145 V(StoreNamedField) \ |
| 256 V(StoreNamedGeneric) \ | 146 V(StoreNamedGeneric) \ |
| 257 V(SubI) \ | |
| 258 V(StringCharCodeAt) \ | 147 V(StringCharCodeAt) \ |
| 259 V(StringLength) \ | 148 V(StringLength) \ |
| 149 V(SubI) \ |
| 260 V(TaggedToI) \ | 150 V(TaggedToI) \ |
| 261 V(Throw) \ | 151 V(Throw) \ |
| 262 V(Typeof) \ | 152 V(Typeof) \ |
| 263 V(TypeofIs) \ | 153 V(TypeofIs) \ |
| 264 V(TypeofIsAndBranch) \ | 154 V(TypeofIsAndBranch) \ |
| 155 V(IsConstructCall) \ |
| 156 V(IsConstructCallAndBranch) \ |
| 265 V(UnaryMathOperation) \ | 157 V(UnaryMathOperation) \ |
| 266 V(UnknownOSRValue) \ | 158 V(UnknownOSRValue) \ |
| 267 V(ValueOf) | 159 V(ValueOf) |
| 268 | 160 |
| 269 | 161 |
| 270 #define DECLARE_INSTRUCTION(type) \ | 162 #define DECLARE_INSTRUCTION(type) \ |
| 271 virtual bool Is##type() const { return true; } \ | 163 virtual bool Is##type() const { return true; } \ |
| 272 static L##type* cast(LInstruction* instr) { \ | 164 static L##type* cast(LInstruction* instr) { \ |
| 273 ASSERT(instr->Is##type()); \ | 165 ASSERT(instr->Is##type()); \ |
| 274 return reinterpret_cast<L##type*>(instr); \ | 166 return reinterpret_cast<L##type*>(instr); \ |
| 275 } | 167 } |
| 276 | 168 |
| 277 | 169 |
| 278 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ | 170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| 279 virtual void CompileToNative(LCodeGen* generator); \ | 171 virtual void CompileToNative(LCodeGen* generator); \ |
| 280 virtual const char* Mnemonic() const { return mnemonic; } \ | 172 virtual const char* Mnemonic() const { return mnemonic; } \ |
| 281 DECLARE_INSTRUCTION(type) | 173 DECLARE_INSTRUCTION(type) |
| 282 | 174 |
| 283 | 175 |
| 284 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 176 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
| 285 H##type* hydrogen() const { \ | 177 H##type* hydrogen() const { \ |
| 286 return H##type::cast(hydrogen_value()); \ | 178 return H##type::cast(hydrogen_value()); \ |
| 287 } | 179 } |
| 288 | 180 |
| 289 | 181 |
| 290 class LInstruction: public ZoneObject { | 182 class LInstruction: public ZoneObject { |
| 291 public: | 183 public: |
| 292 LInstruction() | 184 LInstruction() |
| 293 : hydrogen_value_(NULL) { } | 185 : environment_(NULL), |
| 186 hydrogen_value_(NULL), |
| 187 is_call_(false), |
| 188 is_save_doubles_(false) { } |
| 294 virtual ~LInstruction() { } | 189 virtual ~LInstruction() { } |
| 295 | 190 |
| 296 virtual void CompileToNative(LCodeGen* generator) = 0; | 191 virtual void CompileToNative(LCodeGen* generator) = 0; |
| 297 virtual const char* Mnemonic() const = 0; | 192 virtual const char* Mnemonic() const = 0; |
| 298 virtual void PrintTo(StringStream* stream); | 193 virtual void PrintTo(StringStream* stream); |
| 299 virtual void PrintDataTo(StringStream* stream) = 0; | 194 virtual void PrintDataTo(StringStream* stream) = 0; |
| 300 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 195 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
| 301 | 196 |
| 302 // Declare virtual type testers. | 197 // Declare virtual type testers. |
| 303 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } | 198 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } |
| 304 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) | 199 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) |
| 305 #undef DECLARE_DO | 200 #undef DECLARE_DO |
| 306 | 201 |
| 307 virtual bool IsControl() const { return false; } | 202 virtual bool IsControl() const { return false; } |
| 308 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 203 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
| 309 | 204 |
| 310 void set_environment(LEnvironment* env) { environment_.set(env); } | 205 void set_environment(LEnvironment* env) { environment_ = env; } |
| 311 LEnvironment* environment() const { return environment_.get(); } | 206 LEnvironment* environment() const { return environment_; } |
| 312 bool HasEnvironment() const { return environment_.is_set(); } | 207 bool HasEnvironment() const { return environment_ != NULL; } |
| 313 | 208 |
| 314 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 209 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
| 315 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 210 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
| 316 bool HasPointerMap() const { return pointer_map_.is_set(); } | 211 bool HasPointerMap() const { return pointer_map_.is_set(); } |
| 317 | 212 |
| 318 virtual bool HasResult() const = 0; | |
| 319 | |
| 320 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } | 213 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
| 321 HValue* hydrogen_value() const { return hydrogen_value_; } | 214 HValue* hydrogen_value() const { return hydrogen_value_; } |
| 322 | 215 |
| 323 void set_deoptimization_environment(LEnvironment* env) { | 216 void set_deoptimization_environment(LEnvironment* env) { |
| 324 deoptimization_environment_.set(env); | 217 deoptimization_environment_.set(env); |
| 325 } | 218 } |
| 326 LEnvironment* deoptimization_environment() const { | 219 LEnvironment* deoptimization_environment() const { |
| 327 return deoptimization_environment_.get(); | 220 return deoptimization_environment_.get(); |
| 328 } | 221 } |
| 329 bool HasDeoptimizationEnvironment() const { | 222 bool HasDeoptimizationEnvironment() const { |
| 330 return deoptimization_environment_.is_set(); | 223 return deoptimization_environment_.is_set(); |
| 331 } | 224 } |
| 332 | 225 |
| 226 void MarkAsCall() { is_call_ = true; } |
| 227 void MarkAsSaveDoubles() { is_save_doubles_ = true; } |
| 228 |
| 229 // Interface to the register allocator and iterators. |
| 230 bool IsMarkedAsCall() const { return is_call_; } |
| 231 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; } |
| 232 |
| 233 virtual bool HasResult() const = 0; |
| 234 virtual LOperand* result() = 0; |
| 235 |
| 236 virtual int InputCount() = 0; |
| 237 virtual LOperand* InputAt(int i) = 0; |
| 238 virtual int TempCount() = 0; |
| 239 virtual LOperand* TempAt(int i) = 0; |
| 240 |
| 241 LOperand* FirstInput() { return InputAt(0); } |
| 242 LOperand* Output() { return HasResult() ? result() : NULL; } |
| 243 |
| 244 #ifdef DEBUG |
| 245 void VerifyCall(); |
| 246 #endif |
| 247 |
| 333 private: | 248 private: |
| 334 SetOncePointer<LEnvironment> environment_; | 249 LEnvironment* environment_; |
| 335 SetOncePointer<LPointerMap> pointer_map_; | 250 SetOncePointer<LPointerMap> pointer_map_; |
| 336 HValue* hydrogen_value_; | 251 HValue* hydrogen_value_; |
| 337 SetOncePointer<LEnvironment> deoptimization_environment_; | 252 SetOncePointer<LEnvironment> deoptimization_environment_; |
| 253 bool is_call_; |
| 254 bool is_save_doubles_; |
| 338 }; | 255 }; |
| 339 | 256 |
| 340 | 257 |
| 341 template<typename ElementType, int NumElements> | 258 template<typename ElementType, int NumElements> |
| 342 class OperandContainer { | 259 class OperandContainer { |
| 343 public: | 260 public: |
| 344 OperandContainer() { | 261 OperandContainer() { |
| 345 for (int i = 0; i < NumElements; i++) elems_[i] = NULL; | 262 for (int i = 0; i < NumElements; i++) elems_[i] = NULL; |
| 346 } | 263 } |
| 347 int length() { return NumElements; } | 264 int length() { return NumElements; } |
| 348 ElementType& operator[](int i) { | 265 ElementType& operator[](int i) { |
| 349 ASSERT(i < length()); | 266 ASSERT(i < length()); |
| 350 return elems_[i]; | 267 return elems_[i]; |
| 351 } | 268 } |
| 352 void PrintOperandsTo(StringStream* stream); | 269 void PrintOperandsTo(StringStream* stream); |
| 353 | 270 |
| 354 private: | 271 private: |
| 355 ElementType elems_[NumElements]; | 272 ElementType elems_[NumElements]; |
| 356 }; | 273 }; |
| 357 | 274 |
| 358 | 275 |
| 359 template<typename ElementType> | 276 template<typename ElementType> |
| 360 class OperandContainer<ElementType, 0> { | 277 class OperandContainer<ElementType, 0> { |
| 361 public: | 278 public: |
| 362 int length() { return 0; } | 279 int length() { return 0; } |
| 363 void PrintOperandsTo(StringStream* stream) { } | 280 void PrintOperandsTo(StringStream* stream) { } |
| 281 ElementType& operator[](int i) { |
| 282 UNREACHABLE(); |
| 283 static ElementType t = 0; |
| 284 return t; |
| 285 } |
| 364 }; | 286 }; |
| 365 | 287 |
| 366 | 288 |
| 367 // R = number of result operands (0 or 1). | 289 // R = number of result operands (0 or 1). |
| 368 // I = number of input operands. | 290 // I = number of input operands. |
| 369 // T = number of temporary operands. | 291 // T = number of temporary operands. |
| 370 template<int R, int I, int T> | 292 template<int R, int I, int T> |
| 371 class LTemplateInstruction: public LInstruction { | 293 class LTemplateInstruction: public LInstruction { |
| 372 public: | 294 public: |
| 373 // Allow 0 or 1 output operands. | 295 // Allow 0 or 1 output operands. |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 LSubI(LOperand* left, LOperand* right) { | 897 LSubI(LOperand* left, LOperand* right) { |
| 976 inputs_[0] = left; | 898 inputs_[0] = left; |
| 977 inputs_[1] = right; | 899 inputs_[1] = right; |
| 978 } | 900 } |
| 979 | 901 |
| 980 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") | 902 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") |
| 981 DECLARE_HYDROGEN_ACCESSOR(Sub) | 903 DECLARE_HYDROGEN_ACCESSOR(Sub) |
| 982 }; | 904 }; |
| 983 | 905 |
| 984 | 906 |
| 985 class LConstant: public LTemplateInstruction<1, 0, 0> { | 907 class LConstantI: public LTemplateInstruction<1, 0, 0> { |
| 986 DECLARE_INSTRUCTION(Constant) | 908 public: |
| 909 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i") |
| 910 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 911 |
| 912 int32_t value() const { return hydrogen()->Integer32Value(); } |
| 987 }; | 913 }; |
| 988 | 914 |
| 989 | 915 |
| 990 class LConstantI: public LConstant { | 916 class LConstantD: public LTemplateInstruction<1, 0, 0> { |
| 991 public: | 917 public: |
| 992 explicit LConstantI(int32_t value) : value_(value) { } | 918 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d") |
| 993 int32_t value() const { return value_; } | 919 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 994 | 920 |
| 995 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i") | 921 double value() const { return hydrogen()->DoubleValue(); } |
| 996 | |
| 997 private: | |
| 998 int32_t value_; | |
| 999 }; | 922 }; |
| 1000 | 923 |
| 1001 | 924 |
| 1002 class LConstantD: public LConstant { | 925 class LConstantT: public LTemplateInstruction<1, 0, 0> { |
| 1003 public: | 926 public: |
| 1004 explicit LConstantD(double value) : value_(value) { } | 927 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t") |
| 1005 double value() const { return value_; } | 928 DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 1006 | 929 |
| 1007 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d") | 930 Handle<Object> value() const { return hydrogen()->handle(); } |
| 1008 | |
| 1009 private: | |
| 1010 double value_; | |
| 1011 }; | 931 }; |
| 1012 | 932 |
| 1013 | 933 |
| 1014 class LConstantT: public LConstant { | |
| 1015 public: | |
| 1016 explicit LConstantT(Handle<Object> value) : value_(value) { } | |
| 1017 Handle<Object> value() const { return value_; } | |
| 1018 | |
| 1019 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t") | |
| 1020 | |
| 1021 private: | |
| 1022 Handle<Object> value_; | |
| 1023 }; | |
| 1024 | |
| 1025 | |
| 1026 class LBranch: public LControlInstruction<1, 0> { | 934 class LBranch: public LControlInstruction<1, 0> { |
| 1027 public: | 935 public: |
| 1028 explicit LBranch(LOperand* value) { | 936 explicit LBranch(LOperand* value) { |
| 1029 inputs_[0] = value; | 937 inputs_[0] = value; |
| 1030 } | 938 } |
| 1031 | 939 |
| 1032 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch") | 940 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch") |
| 1033 DECLARE_HYDROGEN_ACCESSOR(Value) | 941 DECLARE_HYDROGEN_ACCESSOR(Value) |
| 1034 | 942 |
| 1035 virtual void PrintDataTo(StringStream* stream); | 943 virtual void PrintDataTo(StringStream* stream); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 }; | 1155 }; |
| 1248 | 1156 |
| 1249 | 1157 |
| 1250 class LLoadGlobal: public LTemplateInstruction<1, 0, 0> { | 1158 class LLoadGlobal: public LTemplateInstruction<1, 0, 0> { |
| 1251 public: | 1159 public: |
| 1252 DECLARE_CONCRETE_INSTRUCTION(LoadGlobal, "load-global") | 1160 DECLARE_CONCRETE_INSTRUCTION(LoadGlobal, "load-global") |
| 1253 DECLARE_HYDROGEN_ACCESSOR(LoadGlobal) | 1161 DECLARE_HYDROGEN_ACCESSOR(LoadGlobal) |
| 1254 }; | 1162 }; |
| 1255 | 1163 |
| 1256 | 1164 |
| 1257 class LStoreGlobal: public LTemplateInstruction<0, 1, 0> { | 1165 class LStoreGlobal: public LTemplateInstruction<0, 1, 1> { |
| 1258 public: | 1166 public: |
| 1259 explicit LStoreGlobal(LOperand* value) { | 1167 LStoreGlobal(LOperand* value, LOperand* temp) { |
| 1260 inputs_[0] = value; | 1168 inputs_[0] = value; |
| 1169 temps_[0] = temp; |
| 1261 } | 1170 } |
| 1262 | 1171 |
| 1263 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store-global") | 1172 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store-global") |
| 1264 DECLARE_HYDROGEN_ACCESSOR(StoreGlobal) | 1173 DECLARE_HYDROGEN_ACCESSOR(StoreGlobal) |
| 1265 }; | 1174 }; |
| 1266 | 1175 |
| 1267 | 1176 |
| 1268 class LLoadContextSlot: public LTemplateInstruction<1, 0, 0> { | 1177 class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> { |
| 1269 public: | 1178 public: |
| 1179 explicit LLoadContextSlot(LOperand* context) { |
| 1180 inputs_[0] = context; |
| 1181 } |
| 1182 |
| 1270 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot") | 1183 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot") |
| 1271 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot) | 1184 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot) |
| 1272 | 1185 |
| 1273 int context_chain_length() { return hydrogen()->context_chain_length(); } | 1186 LOperand* context() { return InputAt(0); } |
| 1274 int slot_index() { return hydrogen()->slot_index(); } | 1187 int slot_index() { return hydrogen()->slot_index(); } |
| 1275 | 1188 |
| 1276 virtual void PrintDataTo(StringStream* stream); | 1189 virtual void PrintDataTo(StringStream* stream); |
| 1277 }; | 1190 }; |
| 1278 | 1191 |
| 1279 | 1192 |
| 1193 class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> { |
| 1194 public: |
| 1195 LStoreContextSlot(LOperand* context, LOperand* value) { |
| 1196 inputs_[0] = context; |
| 1197 inputs_[1] = value; |
| 1198 } |
| 1199 |
| 1200 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot") |
| 1201 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot) |
| 1202 |
| 1203 LOperand* context() { return InputAt(0); } |
| 1204 LOperand* value() { return InputAt(1); } |
| 1205 int slot_index() { return hydrogen()->slot_index(); } |
| 1206 int needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); } |
| 1207 |
| 1208 virtual void PrintDataTo(StringStream* stream); |
| 1209 }; |
| 1210 |
| 1211 |
| 1280 class LPushArgument: public LTemplateInstruction<0, 1, 0> { | 1212 class LPushArgument: public LTemplateInstruction<0, 1, 0> { |
| 1281 public: | 1213 public: |
| 1282 explicit LPushArgument(LOperand* value) { | 1214 explicit LPushArgument(LOperand* value) { |
| 1283 inputs_[0] = value; | 1215 inputs_[0] = value; |
| 1284 } | 1216 } |
| 1285 | 1217 |
| 1286 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument") | 1218 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument") |
| 1287 }; | 1219 }; |
| 1288 | 1220 |
| 1289 | 1221 |
| 1290 class LGlobalObject: public LTemplateInstruction<1, 0, 0> { | 1222 class LContext: public LTemplateInstruction<1, 0, 0> { |
| 1291 public: | 1223 public: |
| 1292 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object") | 1224 DECLARE_CONCRETE_INSTRUCTION(Context, "context") |
| 1293 }; | 1225 }; |
| 1294 | 1226 |
| 1295 | 1227 |
| 1296 class LGlobalReceiver: public LTemplateInstruction<1, 0, 0> { | 1228 class LOuterContext: public LTemplateInstruction<1, 1, 0> { |
| 1297 public: | 1229 public: |
| 1298 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver") | 1230 explicit LOuterContext(LOperand* context) { |
| 1231 inputs_[0] = context; |
| 1232 } |
| 1233 |
| 1234 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context") |
| 1235 |
| 1236 LOperand* context() { return InputAt(0); } |
| 1299 }; | 1237 }; |
| 1300 | 1238 |
| 1301 | 1239 |
| 1240 class LGlobalObject: public LTemplateInstruction<1, 1, 0> { |
| 1241 public: |
| 1242 explicit LGlobalObject(LOperand* context) { |
| 1243 inputs_[0] = context; |
| 1244 } |
| 1245 |
| 1246 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object") |
| 1247 |
| 1248 LOperand* context() { return InputAt(0); } |
| 1249 }; |
| 1250 |
| 1251 |
| 1252 class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> { |
| 1253 public: |
| 1254 explicit LGlobalReceiver(LOperand* global_object) { |
| 1255 inputs_[0] = global_object; |
| 1256 } |
| 1257 |
| 1258 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver") |
| 1259 |
| 1260 LOperand* global() { return InputAt(0); } |
| 1261 }; |
| 1262 |
| 1263 |
| 1302 class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> { | 1264 class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> { |
| 1303 public: | 1265 public: |
| 1304 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function") | 1266 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function") |
| 1305 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction) | 1267 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction) |
| 1306 | 1268 |
| 1307 virtual void PrintDataTo(StringStream* stream); | 1269 virtual void PrintDataTo(StringStream* stream); |
| 1308 | 1270 |
| 1309 Handle<JSFunction> function() { return hydrogen()->function(); } | 1271 Handle<JSFunction> function() { return hydrogen()->function(); } |
| 1310 int arity() const { return hydrogen()->argument_count() - 1; } | 1272 int arity() const { return hydrogen()->argument_count() - 1; } |
| 1311 }; | 1273 }; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 inputs_[0] = value; | 1385 inputs_[0] = value; |
| 1424 temps_[0] = temp1; | 1386 temps_[0] = temp1; |
| 1425 temps_[1] = temp2; | 1387 temps_[1] = temp2; |
| 1426 } | 1388 } |
| 1427 | 1389 |
| 1428 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d") | 1390 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d") |
| 1429 }; | 1391 }; |
| 1430 | 1392 |
| 1431 | 1393 |
| 1432 // Sometimes truncating conversion from a tagged value to an int32. | 1394 // Sometimes truncating conversion from a tagged value to an int32. |
| 1433 class LDoubleToI: public LTemplateInstruction<1, 1, 0> { | 1395 class LDoubleToI: public LTemplateInstruction<1, 1, 1> { |
| 1434 public: | 1396 public: |
| 1435 explicit LDoubleToI(LOperand* value) { | 1397 explicit LDoubleToI(LOperand* value, LOperand* temp1) { |
| 1436 inputs_[0] = value; | 1398 inputs_[0] = value; |
| 1399 temps_[0] = temp1; |
| 1437 } | 1400 } |
| 1438 | 1401 |
| 1439 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i") | 1402 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i") |
| 1440 DECLARE_HYDROGEN_ACCESSOR(Change) | 1403 DECLARE_HYDROGEN_ACCESSOR(Change) |
| 1441 | 1404 |
| 1442 bool truncating() { return hydrogen()->CanTruncateToInt32(); } | 1405 bool truncating() { return hydrogen()->CanTruncateToInt32(); } |
| 1443 }; | 1406 }; |
| 1444 | 1407 |
| 1445 | 1408 |
| 1446 // Truncating conversion from a tagged value to an int32. | 1409 // Truncating conversion from a tagged value to an int32. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 | 1696 |
| 1734 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch") | 1697 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch") |
| 1735 DECLARE_HYDROGEN_ACCESSOR(TypeofIs) | 1698 DECLARE_HYDROGEN_ACCESSOR(TypeofIs) |
| 1736 | 1699 |
| 1737 Handle<String> type_literal() { return hydrogen()->type_literal(); } | 1700 Handle<String> type_literal() { return hydrogen()->type_literal(); } |
| 1738 | 1701 |
| 1739 virtual void PrintDataTo(StringStream* stream); | 1702 virtual void PrintDataTo(StringStream* stream); |
| 1740 }; | 1703 }; |
| 1741 | 1704 |
| 1742 | 1705 |
| 1706 class LIsConstructCall: public LTemplateInstruction<1, 0, 0> { |
| 1707 public: |
| 1708 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is-construct-call") |
| 1709 DECLARE_HYDROGEN_ACCESSOR(IsConstructCall) |
| 1710 }; |
| 1711 |
| 1712 |
| 1713 class LIsConstructCallAndBranch: public LControlInstruction<0, 1> { |
| 1714 public: |
| 1715 explicit LIsConstructCallAndBranch(LOperand* temp) { |
| 1716 temps_[0] = temp; |
| 1717 } |
| 1718 |
| 1719 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch, |
| 1720 "is-construct-call-and-branch") |
| 1721 }; |
| 1722 |
| 1723 |
| 1743 class LDeleteProperty: public LTemplateInstruction<1, 2, 0> { | 1724 class LDeleteProperty: public LTemplateInstruction<1, 2, 0> { |
| 1744 public: | 1725 public: |
| 1745 LDeleteProperty(LOperand* obj, LOperand* key) { | 1726 LDeleteProperty(LOperand* obj, LOperand* key) { |
| 1746 inputs_[0] = obj; | 1727 inputs_[0] = obj; |
| 1747 inputs_[1] = key; | 1728 inputs_[1] = key; |
| 1748 } | 1729 } |
| 1749 | 1730 |
| 1750 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property") | 1731 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property") |
| 1751 | 1732 |
| 1752 LOperand* object() { return inputs_[0]; } | 1733 LOperand* object() { return inputs_[0]; } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1781 public: | 1762 public: |
| 1782 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check") | 1763 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check") |
| 1783 }; | 1764 }; |
| 1784 | 1765 |
| 1785 | 1766 |
| 1786 class LChunkBuilder; | 1767 class LChunkBuilder; |
| 1787 class LChunk: public ZoneObject { | 1768 class LChunk: public ZoneObject { |
| 1788 public: | 1769 public: |
| 1789 explicit LChunk(HGraph* graph); | 1770 explicit LChunk(HGraph* graph); |
| 1790 | 1771 |
| 1791 int AddInstruction(LInstruction* instruction, HBasicBlock* block); | 1772 void AddInstruction(LInstruction* instruction, HBasicBlock* block); |
| 1792 LConstantOperand* DefineConstantOperand(HConstant* constant); | 1773 LConstantOperand* DefineConstantOperand(HConstant* constant); |
| 1793 Handle<Object> LookupLiteral(LConstantOperand* operand) const; | 1774 Handle<Object> LookupLiteral(LConstantOperand* operand) const; |
| 1794 Representation LookupLiteralRepresentation(LConstantOperand* operand) const; | 1775 Representation LookupLiteralRepresentation(LConstantOperand* operand) const; |
| 1795 | 1776 |
| 1796 int GetNextSpillIndex(bool is_double); | 1777 int GetNextSpillIndex(bool is_double); |
| 1797 LOperand* GetNextSpillSlot(bool is_double); | 1778 LOperand* GetNextSpillSlot(bool is_double); |
| 1798 | 1779 |
| 1799 int ParameterAt(int index); | 1780 int ParameterAt(int index); |
| 1800 int GetParameterStackSlot(int index) const; | 1781 int GetParameterStackSlot(int index) const; |
| 1801 int spill_slot_count() const { return spill_slot_count_; } | 1782 int spill_slot_count() const { return spill_slot_count_; } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 LChunkBuilder(HGraph* graph, LAllocator* allocator) | 1828 LChunkBuilder(HGraph* graph, LAllocator* allocator) |
| 1848 : chunk_(NULL), | 1829 : chunk_(NULL), |
| 1849 graph_(graph), | 1830 graph_(graph), |
| 1850 status_(UNUSED), | 1831 status_(UNUSED), |
| 1851 current_instruction_(NULL), | 1832 current_instruction_(NULL), |
| 1852 current_block_(NULL), | 1833 current_block_(NULL), |
| 1853 next_block_(NULL), | 1834 next_block_(NULL), |
| 1854 argument_count_(0), | 1835 argument_count_(0), |
| 1855 allocator_(allocator), | 1836 allocator_(allocator), |
| 1856 position_(RelocInfo::kNoPosition), | 1837 position_(RelocInfo::kNoPosition), |
| 1857 instructions_pending_deoptimization_environment_(NULL), | 1838 instruction_pending_deoptimization_environment_(NULL), |
| 1858 pending_deoptimization_ast_id_(AstNode::kNoNumber) { } | 1839 pending_deoptimization_ast_id_(AstNode::kNoNumber) { } |
| 1859 | 1840 |
| 1860 // Build the sequence for the graph. | 1841 // Build the sequence for the graph. |
| 1861 LChunk* Build(); | 1842 LChunk* Build(); |
| 1862 | 1843 |
| 1863 // Declare methods that deal with the individual node types. | 1844 // Declare methods that deal with the individual node types. |
| 1864 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node); | 1845 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node); |
| 1865 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) | 1846 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 1866 #undef DECLARE_DO | 1847 #undef DECLARE_DO |
| 1867 | 1848 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 | 1962 |
| 1982 LChunk* chunk_; | 1963 LChunk* chunk_; |
| 1983 HGraph* const graph_; | 1964 HGraph* const graph_; |
| 1984 Status status_; | 1965 Status status_; |
| 1985 HInstruction* current_instruction_; | 1966 HInstruction* current_instruction_; |
| 1986 HBasicBlock* current_block_; | 1967 HBasicBlock* current_block_; |
| 1987 HBasicBlock* next_block_; | 1968 HBasicBlock* next_block_; |
| 1988 int argument_count_; | 1969 int argument_count_; |
| 1989 LAllocator* allocator_; | 1970 LAllocator* allocator_; |
| 1990 int position_; | 1971 int position_; |
| 1991 LInstruction* instructions_pending_deoptimization_environment_; | 1972 LInstruction* instruction_pending_deoptimization_environment_; |
| 1992 int pending_deoptimization_ast_id_; | 1973 int pending_deoptimization_ast_id_; |
| 1993 | 1974 |
| 1994 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 1975 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
| 1995 }; | 1976 }; |
| 1996 | 1977 |
| 1997 #undef DECLARE_HYDROGEN_ACCESSOR | 1978 #undef DECLARE_HYDROGEN_ACCESSOR |
| 1998 #undef DECLARE_INSTRUCTION | 1979 #undef DECLARE_INSTRUCTION |
| 1999 #undef DECLARE_CONCRETE_INSTRUCTION | 1980 #undef DECLARE_CONCRETE_INSTRUCTION |
| 2000 | 1981 |
| 2001 } } // namespace v8::internal | 1982 } } // namespace v8::internal |
| 2002 | 1983 |
| 2003 #endif // V8_ARM_LITHIUM_ARM_H_ | 1984 #endif // V8_ARM_LITHIUM_ARM_H_ |
| OLD | NEW |