| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 V(_StringBase, [], StringBaseCharAt, 1062366987) \ | 64 V(_StringBase, [], StringBaseCharAt, 1062366987) \ |
| 65 V(_IntegerImplementation, toDouble, IntegerToDouble, 1267108971) \ | 65 V(_IntegerImplementation, toDouble, IntegerToDouble, 1267108971) \ |
| 66 V(_Double, toInt, DoubleToInteger, 362666636) \ | 66 V(_Double, toInt, DoubleToInteger, 362666636) \ |
| 67 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ | 67 V(_Double, truncateToDouble, DoubleTruncate, 620870996) \ |
| 68 V(_Double, roundToDouble, DoubleRound, 620870996) \ | 68 V(_Double, roundToDouble, DoubleRound, 620870996) \ |
| 69 V(_Double, floorToDouble, DoubleFloor, 620870996) \ | 69 V(_Double, floorToDouble, DoubleFloor, 620870996) \ |
| 70 V(_Double, ceilToDouble, DoubleCeil, 620870996) \ | 70 V(_Double, ceilToDouble, DoubleCeil, 620870996) \ |
| 71 V(_Double, pow, DoublePow, 631903778) \ | 71 V(_Double, pow, DoublePow, 631903778) \ |
| 72 V(_Double, _modulo, DoubleMod, 437099337) \ | 72 V(_Double, _modulo, DoubleMod, 437099337) \ |
| 73 V(::, sqrt, MathSqrt, 1662640002) \ | 73 V(::, sqrt, MathSqrt, 1662640002) \ |
| 74 V(_Float32x4, get:xxxx, Float32x4ShuffleXXXX, 42621627) \ |
| 75 V(_Float32x4, get:yyyy, Float32x4ShuffleYYYY, 42621627) \ |
| 76 V(_Float32x4, get:zzzz, Float32x4ShuffleZZZZ, 42621627) \ |
| 77 V(_Float32x4, get:wwww, Float32x4ShuffleWWWW, 42621627) \ |
| 78 V(_Float32x4, get:x, Float32x4ShuffleX, 211144022) \ |
| 79 V(_Float32x4, get:y, Float32x4ShuffleY, 211144022) \ |
| 80 V(_Float32x4, get:z, Float32x4ShuffleZ, 211144022) \ |
| 81 V(_Float32x4, get:w, Float32x4ShuffleW, 211144022) \ |
| 74 | 82 |
| 75 // Class that recognizes the name and owner of a function and returns the | 83 // Class that recognizes the name and owner of a function and returns the |
| 76 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable | 84 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable |
| 77 // functions. | 85 // functions. |
| 78 class MethodRecognizer : public AllStatic { | 86 class MethodRecognizer : public AllStatic { |
| 79 public: | 87 public: |
| 80 enum Kind { | 88 enum Kind { |
| 81 kUnknown, | 89 kUnknown, |
| 82 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, | 90 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, |
| 83 RECOGNIZED_LIST(DEFINE_ENUM_LIST) | 91 RECOGNIZED_LIST(DEFINE_ENUM_LIST) |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 M(BinaryMintOp) \ | 506 M(BinaryMintOp) \ |
| 499 M(ShiftMintOp) \ | 507 M(ShiftMintOp) \ |
| 500 M(UnaryMintOp) \ | 508 M(UnaryMintOp) \ |
| 501 M(CheckArrayBound) \ | 509 M(CheckArrayBound) \ |
| 502 M(Constraint) \ | 510 M(Constraint) \ |
| 503 M(StringFromCharCode) \ | 511 M(StringFromCharCode) \ |
| 504 M(InvokeMathCFunction) \ | 512 M(InvokeMathCFunction) \ |
| 505 M(GuardField) \ | 513 M(GuardField) \ |
| 506 M(IfThenElse) \ | 514 M(IfThenElse) \ |
| 507 M(BinaryFloat32x4Op) \ | 515 M(BinaryFloat32x4Op) \ |
| 516 M(Float32x4Shuffle) \ |
| 508 | 517 |
| 509 #define FORWARD_DECLARATION(type) class type##Instr; | 518 #define FORWARD_DECLARATION(type) class type##Instr; |
| 510 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 519 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 511 #undef FORWARD_DECLARATION | 520 #undef FORWARD_DECLARATION |
| 512 | 521 |
| 513 | 522 |
| 514 // Functions required in all concrete instruction classes. | 523 // Functions required in all concrete instruction classes. |
| 515 #define DECLARE_INSTRUCTION(type) \ | 524 #define DECLARE_INSTRUCTION(type) \ |
| 516 virtual Tag tag() const { return k##type; } \ | 525 virtual Tag tag() const { return k##type; } \ |
| 517 virtual void Accept(FlowGraphVisitor* visitor); \ | 526 virtual void Accept(FlowGraphVisitor* visitor); \ |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 757 |
| 749 private: | 758 private: |
| 750 friend class Definition; // Needed for InsertBefore, InsertAfter. | 759 friend class Definition; // Needed for InsertBefore, InsertAfter. |
| 751 | 760 |
| 752 // Classes that set deopt_id_. | 761 // Classes that set deopt_id_. |
| 753 friend class UnboxIntegerInstr; | 762 friend class UnboxIntegerInstr; |
| 754 friend class UnboxDoubleInstr; | 763 friend class UnboxDoubleInstr; |
| 755 friend class UnboxFloat32x4Instr; | 764 friend class UnboxFloat32x4Instr; |
| 756 friend class BinaryDoubleOpInstr; | 765 friend class BinaryDoubleOpInstr; |
| 757 friend class BinaryFloat32x4OpInstr; | 766 friend class BinaryFloat32x4OpInstr; |
| 767 friend class Float32x4ShuffleInstr; |
| 758 friend class BinaryMintOpInstr; | 768 friend class BinaryMintOpInstr; |
| 759 friend class BinarySmiOpInstr; | 769 friend class BinarySmiOpInstr; |
| 760 friend class UnarySmiOpInstr; | 770 friend class UnarySmiOpInstr; |
| 761 friend class ShiftMintOpInstr; | 771 friend class ShiftMintOpInstr; |
| 762 friend class UnaryMintOpInstr; | 772 friend class UnaryMintOpInstr; |
| 763 friend class MathSqrtInstr; | 773 friend class MathSqrtInstr; |
| 764 friend class CheckClassInstr; | 774 friend class CheckClassInstr; |
| 765 friend class GuardFieldInstr; | 775 friend class GuardFieldInstr; |
| 766 friend class CheckSmiInstr; | 776 friend class CheckSmiInstr; |
| 767 friend class CheckArrayBoundInstr; | 777 friend class CheckArrayBoundInstr; |
| (...skipping 3365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 DECLARE_INSTRUCTION(BinaryFloat32x4Op) | 4143 DECLARE_INSTRUCTION(BinaryFloat32x4Op) |
| 4134 virtual CompileType ComputeType() const; | 4144 virtual CompileType ComputeType() const; |
| 4135 | 4145 |
| 4136 private: | 4146 private: |
| 4137 const Token::Kind op_kind_; | 4147 const Token::Kind op_kind_; |
| 4138 | 4148 |
| 4139 DISALLOW_COPY_AND_ASSIGN(BinaryFloat32x4OpInstr); | 4149 DISALLOW_COPY_AND_ASSIGN(BinaryFloat32x4OpInstr); |
| 4140 }; | 4150 }; |
| 4141 | 4151 |
| 4142 | 4152 |
| 4153 class Float32x4ShuffleInstr : public TemplateDefinition<1> { |
| 4154 public: |
| 4155 Float32x4ShuffleInstr(MethodRecognizer::Kind op_kind, Value* value, |
| 4156 InstanceCallInstr* instance_call) |
| 4157 : op_kind_(op_kind) { |
| 4158 SetInputAt(0, value); |
| 4159 deopt_id_ = instance_call->deopt_id(); |
| 4160 } |
| 4161 |
| 4162 Value* value() const { return inputs_[0]; } |
| 4163 |
| 4164 MethodRecognizer::Kind op_kind() const { return op_kind_; } |
| 4165 |
| 4166 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 4167 |
| 4168 virtual bool CanDeoptimize() const { return false; } |
| 4169 |
| 4170 virtual bool HasSideEffect() const { return false; } |
| 4171 |
| 4172 virtual bool AffectedBySideEffect() const { return false; } |
| 4173 |
| 4174 virtual bool AttributesEqual(Instruction* other) const { |
| 4175 return op_kind() == other->AsFloat32x4Shuffle()->op_kind(); |
| 4176 } |
| 4177 |
| 4178 virtual Representation representation() const { |
| 4179 if ((op_kind_ == MethodRecognizer::kFloat32x4ShuffleX) || |
| 4180 (op_kind_ == MethodRecognizer::kFloat32x4ShuffleY) || |
| 4181 (op_kind_ == MethodRecognizer::kFloat32x4ShuffleZ) || |
| 4182 (op_kind_ == MethodRecognizer::kFloat32x4ShuffleW)) { |
| 4183 return kUnboxedDouble; |
| 4184 } |
| 4185 return kUnboxedFloat32x4; |
| 4186 } |
| 4187 |
| 4188 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 4189 ASSERT(idx == 0); |
| 4190 return kUnboxedFloat32x4; |
| 4191 } |
| 4192 |
| 4193 virtual intptr_t DeoptimizationTarget() const { |
| 4194 // Direct access since this instruction cannot deoptimize, and the deopt-id |
| 4195 // was inherited from another instruction that could deoptimize. |
| 4196 return deopt_id_; |
| 4197 } |
| 4198 |
| 4199 DECLARE_INSTRUCTION(Float32x4Shuffle) |
| 4200 virtual CompileType ComputeType() const; |
| 4201 |
| 4202 private: |
| 4203 const MethodRecognizer::Kind op_kind_; |
| 4204 |
| 4205 DISALLOW_COPY_AND_ASSIGN(Float32x4ShuffleInstr); |
| 4206 }; |
| 4207 |
| 4208 |
| 4143 class BinaryMintOpInstr : public TemplateDefinition<2> { | 4209 class BinaryMintOpInstr : public TemplateDefinition<2> { |
| 4144 public: | 4210 public: |
| 4145 BinaryMintOpInstr(Token::Kind op_kind, | 4211 BinaryMintOpInstr(Token::Kind op_kind, |
| 4146 Value* left, | 4212 Value* left, |
| 4147 Value* right, | 4213 Value* right, |
| 4148 InstanceCallInstr* instance_call) | 4214 InstanceCallInstr* instance_call) |
| 4149 : op_kind_(op_kind), | 4215 : op_kind_(op_kind), |
| 4150 instance_call_(instance_call) { | 4216 instance_call_(instance_call) { |
| 4151 SetInputAt(0, left); | 4217 SetInputAt(0, left); |
| 4152 SetInputAt(1, right); | 4218 SetInputAt(1, right); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4941 ForwardInstructionIterator* current_iterator_; | 5007 ForwardInstructionIterator* current_iterator_; |
| 4942 | 5008 |
| 4943 private: | 5009 private: |
| 4944 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 5010 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4945 }; | 5011 }; |
| 4946 | 5012 |
| 4947 | 5013 |
| 4948 } // namespace dart | 5014 } // namespace dart |
| 4949 | 5015 |
| 4950 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 5016 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |