| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 V(ConstantI) \ | 86 V(ConstantI) \ |
| 87 V(ConstantT) \ | 87 V(ConstantT) \ |
| 88 V(Context) \ | 88 V(Context) \ |
| 89 V(DeleteProperty) \ | 89 V(DeleteProperty) \ |
| 90 V(Deoptimize) \ | 90 V(Deoptimize) \ |
| 91 V(DivI) \ | 91 V(DivI) \ |
| 92 V(DoubleToI) \ | 92 V(DoubleToI) \ |
| 93 V(ExternalArrayLength) \ | 93 V(ExternalArrayLength) \ |
| 94 V(FixedArrayLength) \ | 94 V(FixedArrayLength) \ |
| 95 V(FunctionLiteral) \ | 95 V(FunctionLiteral) \ |
| 96 V(Gap) \ | |
| 97 V(GetCachedArrayIndex) \ | 96 V(GetCachedArrayIndex) \ |
| 98 V(GlobalObject) \ | 97 V(GlobalObject) \ |
| 99 V(GlobalReceiver) \ | 98 V(GlobalReceiver) \ |
| 100 V(Goto) \ | 99 V(Goto) \ |
| 101 V(HasCachedArrayIndex) \ | 100 V(HasCachedArrayIndex) \ |
| 102 V(HasCachedArrayIndexAndBranch) \ | 101 V(HasCachedArrayIndexAndBranch) \ |
| 103 V(HasInstanceType) \ | 102 V(HasInstanceType) \ |
| 104 V(HasInstanceTypeAndBranch) \ | 103 V(HasInstanceTypeAndBranch) \ |
| 105 V(InstanceOf) \ | 104 V(InstanceOf) \ |
| 106 V(InstanceOfAndBranch) \ | 105 V(InstanceOfAndBranch) \ |
| 107 V(InstanceOfKnownGlobal) \ | 106 V(InstanceOfKnownGlobal) \ |
| 107 V(InstructionGap) \ |
| 108 V(Integer32ToDouble) \ | 108 V(Integer32ToDouble) \ |
| 109 V(InvokeFunction) \ | 109 V(InvokeFunction) \ |
| 110 V(IsNull) \ | 110 V(IsNull) \ |
| 111 V(IsNullAndBranch) \ | 111 V(IsNullAndBranch) \ |
| 112 V(IsObject) \ | 112 V(IsObject) \ |
| 113 V(IsObjectAndBranch) \ | 113 V(IsObjectAndBranch) \ |
| 114 V(IsSmi) \ | 114 V(IsSmi) \ |
| 115 V(IsSmiAndBranch) \ | 115 V(IsSmiAndBranch) \ |
| 116 V(JSArrayLength) \ | 116 V(JSArrayLength) \ |
| 117 V(Label) \ | 117 V(Label) \ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 V(Typeof) \ | 164 V(Typeof) \ |
| 165 V(TypeofIs) \ | 165 V(TypeofIs) \ |
| 166 V(TypeofIsAndBranch) \ | 166 V(TypeofIsAndBranch) \ |
| 167 V(IsConstructCall) \ | 167 V(IsConstructCall) \ |
| 168 V(IsConstructCallAndBranch) \ | 168 V(IsConstructCallAndBranch) \ |
| 169 V(UnaryMathOperation) \ | 169 V(UnaryMathOperation) \ |
| 170 V(UnknownOSRValue) \ | 170 V(UnknownOSRValue) \ |
| 171 V(ValueOf) | 171 V(ValueOf) |
| 172 | 172 |
| 173 | 173 |
| 174 #define DECLARE_INSTRUCTION(type) \ | 174 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| 175 virtual bool Is##type() const { return true; } \ | 175 virtual Opcode opcode() const { return LInstruction::k##type; } \ |
| 176 static L##type* cast(LInstruction* instr) { \ | 176 virtual void CompileToNative(LCodeGen* generator); \ |
| 177 ASSERT(instr->Is##type()); \ | 177 virtual const char* Mnemonic() const { return mnemonic; } \ |
| 178 return reinterpret_cast<L##type*>(instr); \ | 178 static L##type* cast(LInstruction* instr) { \ |
| 179 ASSERT(instr->Is##type()); \ |
| 180 return reinterpret_cast<L##type*>(instr); \ |
| 179 } | 181 } |
| 180 | 182 |
| 181 | 183 |
| 182 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ | |
| 183 virtual void CompileToNative(LCodeGen* generator); \ | |
| 184 virtual const char* Mnemonic() const { return mnemonic; } \ | |
| 185 DECLARE_INSTRUCTION(type) | |
| 186 | |
| 187 | |
| 188 #define DECLARE_HYDROGEN_ACCESSOR(type) \ | 184 #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
| 189 H##type* hydrogen() const { \ | 185 H##type* hydrogen() const { \ |
| 190 return H##type::cast(hydrogen_value()); \ | 186 return H##type::cast(hydrogen_value()); \ |
| 191 } | 187 } |
| 192 | 188 |
| 193 | 189 |
| 194 class LInstruction: public ZoneObject { | 190 class LInstruction: public ZoneObject { |
| 195 public: | 191 public: |
| 196 LInstruction() | 192 LInstruction() |
| 197 : environment_(NULL), | 193 : environment_(NULL), |
| 198 hydrogen_value_(NULL), | 194 hydrogen_value_(NULL), |
| 199 is_call_(false), | 195 is_call_(false), |
| 200 is_save_doubles_(false) { } | 196 is_save_doubles_(false) { } |
| 201 | 197 |
| 202 virtual ~LInstruction() { } | 198 virtual ~LInstruction() { } |
| 203 | 199 |
| 204 virtual void CompileToNative(LCodeGen* generator) = 0; | 200 virtual void CompileToNative(LCodeGen* generator) = 0; |
| 205 virtual const char* Mnemonic() const = 0; | 201 virtual const char* Mnemonic() const = 0; |
| 206 virtual void PrintTo(StringStream* stream); | 202 virtual void PrintTo(StringStream* stream); |
| 207 virtual void PrintDataTo(StringStream* stream) = 0; | 203 virtual void PrintDataTo(StringStream* stream) = 0; |
| 208 virtual void PrintOutputOperandTo(StringStream* stream) = 0; | 204 virtual void PrintOutputOperandTo(StringStream* stream) = 0; |
| 209 | 205 |
| 210 // Declare virtual type testers. | 206 enum Opcode { |
| 211 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } | 207 // Declare a unique enum value for each instruction. |
| 212 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) | 208 #define DECLARE_OPCODE(type) k##type, |
| 213 #undef DECLARE_DO | 209 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 210 kNumberOfInstructions |
| 211 #undef DECLARE_OPCODE |
| 212 }; |
| 213 |
| 214 virtual Opcode opcode() const = 0; |
| 215 |
| 216 // Declare non-virtual type testers for all leaf IR classes. |
| 217 #define DECLARE_PREDICATE(type) \ |
| 218 bool Is##type() const { return opcode() == k##type; } |
| 219 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 220 #undef DECLARE_PREDICATE |
| 221 |
| 222 // Declare virtual predicates for instructions that don't have |
| 223 // an opcode. |
| 224 virtual bool IsGap() const { return false; } |
| 214 | 225 |
| 215 virtual bool IsControl() const { return false; } | 226 virtual bool IsControl() const { return false; } |
| 216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } | 227 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } |
| 217 | 228 |
| 218 void set_environment(LEnvironment* env) { environment_ = env; } | 229 void set_environment(LEnvironment* env) { environment_ = env; } |
| 219 LEnvironment* environment() const { return environment_; } | 230 LEnvironment* environment() const { return environment_; } |
| 220 bool HasEnvironment() const { return environment_ != NULL; } | 231 bool HasEnvironment() const { return environment_ != NULL; } |
| 221 | 232 |
| 222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } | 233 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
| 223 LPointerMap* pointer_map() const { return pointer_map_.get(); } | 234 LPointerMap* pointer_map() const { return pointer_map_.get(); } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 class LGap: public LTemplateInstruction<0, 0, 0> { | 341 class LGap: public LTemplateInstruction<0, 0, 0> { |
| 331 public: | 342 public: |
| 332 explicit LGap(HBasicBlock* block) | 343 explicit LGap(HBasicBlock* block) |
| 333 : block_(block) { | 344 : block_(block) { |
| 334 parallel_moves_[BEFORE] = NULL; | 345 parallel_moves_[BEFORE] = NULL; |
| 335 parallel_moves_[START] = NULL; | 346 parallel_moves_[START] = NULL; |
| 336 parallel_moves_[END] = NULL; | 347 parallel_moves_[END] = NULL; |
| 337 parallel_moves_[AFTER] = NULL; | 348 parallel_moves_[AFTER] = NULL; |
| 338 } | 349 } |
| 339 | 350 |
| 340 DECLARE_CONCRETE_INSTRUCTION(Gap, "gap") | 351 // Can't use the DECLARE-macro here because of sub-classes. |
| 352 virtual bool IsGap() const { return true; } |
| 341 virtual void PrintDataTo(StringStream* stream); | 353 virtual void PrintDataTo(StringStream* stream); |
| 354 static LGap* cast(LInstruction* instr) { |
| 355 ASSERT(instr->IsGap()); |
| 356 return reinterpret_cast<LGap*>(instr); |
| 357 } |
| 342 | 358 |
| 343 bool IsRedundant() const; | 359 bool IsRedundant() const; |
| 344 | 360 |
| 345 HBasicBlock* block() const { return block_; } | 361 HBasicBlock* block() const { return block_; } |
| 346 | 362 |
| 347 enum InnerPosition { | 363 enum InnerPosition { |
| 348 BEFORE, | 364 BEFORE, |
| 349 START, | 365 START, |
| 350 END, | 366 END, |
| 351 AFTER, | 367 AFTER, |
| 352 FIRST_INNER_POSITION = BEFORE, | 368 FIRST_INNER_POSITION = BEFORE, |
| 353 LAST_INNER_POSITION = AFTER | 369 LAST_INNER_POSITION = AFTER |
| 354 }; | 370 }; |
| 355 | 371 |
| 356 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) { | 372 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) { |
| 357 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove; | 373 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove; |
| 358 return parallel_moves_[pos]; | 374 return parallel_moves_[pos]; |
| 359 } | 375 } |
| 360 | 376 |
| 361 LParallelMove* GetParallelMove(InnerPosition pos) { | 377 LParallelMove* GetParallelMove(InnerPosition pos) { |
| 362 return parallel_moves_[pos]; | 378 return parallel_moves_[pos]; |
| 363 } | 379 } |
| 364 | 380 |
| 365 private: | 381 private: |
| 366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; | 382 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
| 367 HBasicBlock* block_; | 383 HBasicBlock* block_; |
| 368 }; | 384 }; |
| 369 | 385 |
| 370 | 386 |
| 387 class LInstructionGap: public LGap { |
| 388 public: |
| 389 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { } |
| 390 |
| 391 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap") |
| 392 }; |
| 393 |
| 394 |
| 371 class LGoto: public LTemplateInstruction<0, 0, 0> { | 395 class LGoto: public LTemplateInstruction<0, 0, 0> { |
| 372 public: | 396 public: |
| 373 LGoto(int block_id, bool include_stack_check = false) | 397 LGoto(int block_id, bool include_stack_check = false) |
| 374 : block_id_(block_id), include_stack_check_(include_stack_check) { } | 398 : block_id_(block_id), include_stack_check_(include_stack_check) { } |
| 375 | 399 |
| 376 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto") | 400 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto") |
| 377 virtual void PrintDataTo(StringStream* stream); | 401 virtual void PrintDataTo(StringStream* stream); |
| 378 virtual bool IsControl() const { return true; } | 402 virtual bool IsControl() const { return true; } |
| 379 | 403 |
| 380 int block_id() const { return block_id_; } | 404 int block_id() const { return block_id_; } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 473 |
| 450 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { | 474 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { |
| 451 public: | 475 public: |
| 452 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") | 476 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") |
| 453 }; | 477 }; |
| 454 | 478 |
| 455 | 479 |
| 456 template<int I, int T> | 480 template<int I, int T> |
| 457 class LControlInstruction: public LTemplateInstruction<0, I, T> { | 481 class LControlInstruction: public LTemplateInstruction<0, I, T> { |
| 458 public: | 482 public: |
| 459 DECLARE_INSTRUCTION(ControlInstruction) | |
| 460 virtual bool IsControl() const { return true; } | 483 virtual bool IsControl() const { return true; } |
| 461 | 484 |
| 462 int true_block_id() const { return true_block_id_; } | 485 int true_block_id() const { return true_block_id_; } |
| 463 int false_block_id() const { return false_block_id_; } | 486 int false_block_id() const { return false_block_id_; } |
| 464 void SetBranchTargets(int true_block_id, int false_block_id) { | 487 void SetBranchTargets(int true_block_id, int false_block_id) { |
| 465 true_block_id_ = true_block_id; | 488 true_block_id_ = true_block_id; |
| 466 false_block_id_ = false_block_id; | 489 false_block_id_ = false_block_id; |
| 467 } | 490 } |
| 468 | 491 |
| 469 private: | 492 private: |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { | 1108 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { |
| 1086 public: | 1109 public: |
| 1087 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) | 1110 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) |
| 1088 : op_(op) { | 1111 : op_(op) { |
| 1089 inputs_[0] = left; | 1112 inputs_[0] = left; |
| 1090 inputs_[1] = right; | 1113 inputs_[1] = right; |
| 1091 } | 1114 } |
| 1092 | 1115 |
| 1093 Token::Value op() const { return op_; } | 1116 Token::Value op() const { return op_; } |
| 1094 | 1117 |
| 1118 virtual Opcode opcode() const { return LInstruction::kArithmeticD; } |
| 1095 virtual void CompileToNative(LCodeGen* generator); | 1119 virtual void CompileToNative(LCodeGen* generator); |
| 1096 virtual const char* Mnemonic() const; | 1120 virtual const char* Mnemonic() const; |
| 1097 | 1121 |
| 1098 private: | 1122 private: |
| 1099 Token::Value op_; | 1123 Token::Value op_; |
| 1100 }; | 1124 }; |
| 1101 | 1125 |
| 1102 | 1126 |
| 1103 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { | 1127 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { |
| 1104 public: | 1128 public: |
| 1105 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) | 1129 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) |
| 1106 : op_(op) { | 1130 : op_(op) { |
| 1107 inputs_[0] = left; | 1131 inputs_[0] = left; |
| 1108 inputs_[1] = right; | 1132 inputs_[1] = right; |
| 1109 } | 1133 } |
| 1110 | 1134 |
| 1135 virtual Opcode opcode() const { return LInstruction::kArithmeticT; } |
| 1111 virtual void CompileToNative(LCodeGen* generator); | 1136 virtual void CompileToNative(LCodeGen* generator); |
| 1112 virtual const char* Mnemonic() const; | 1137 virtual const char* Mnemonic() const; |
| 1113 | 1138 |
| 1114 Token::Value op() const { return op_; } | 1139 Token::Value op() const { return op_; } |
| 1115 | 1140 |
| 1116 private: | 1141 private: |
| 1117 Token::Value op_; | 1142 Token::Value op_; |
| 1118 }; | 1143 }; |
| 1119 | 1144 |
| 1120 | 1145 |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 int argument_count_; | 2209 int argument_count_; |
| 2185 LAllocator* allocator_; | 2210 LAllocator* allocator_; |
| 2186 int position_; | 2211 int position_; |
| 2187 LInstruction* instruction_pending_deoptimization_environment_; | 2212 LInstruction* instruction_pending_deoptimization_environment_; |
| 2188 int pending_deoptimization_ast_id_; | 2213 int pending_deoptimization_ast_id_; |
| 2189 | 2214 |
| 2190 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); | 2215 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
| 2191 }; | 2216 }; |
| 2192 | 2217 |
| 2193 #undef DECLARE_HYDROGEN_ACCESSOR | 2218 #undef DECLARE_HYDROGEN_ACCESSOR |
| 2194 #undef DECLARE_INSTRUCTION | |
| 2195 #undef DECLARE_CONCRETE_INSTRUCTION | 2219 #undef DECLARE_CONCRETE_INSTRUCTION |
| 2196 | 2220 |
| 2197 } } // namespace v8::int | 2221 } } // namespace v8::int |
| 2198 | 2222 |
| 2199 #endif // V8_X64_LITHIUM_X64_H_ | 2223 #endif // V8_X64_LITHIUM_X64_H_ |
| OLD | NEW |