| 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 30 matching lines...) Expand all Loading... |
| 41 V(_StringBase, get:length, StringBaseLength, 320803993) \ | 41 V(_StringBase, get:length, StringBaseLength, 320803993) \ |
| 42 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 711547329) \ | 42 V(_StringBase, get:isEmpty, StringBaseIsEmpty, 711547329) \ |
| 43 V(_StringBase, charCodeAt, StringBaseCharCodeAt, 984449525) \ | 43 V(_StringBase, charCodeAt, StringBaseCharCodeAt, 984449525) \ |
| 44 V(_StringBase, [], StringBaseCharAt, 1062366987) \ | 44 V(_StringBase, [], StringBaseCharAt, 1062366987) \ |
| 45 V(_IntegerImplementation, toDouble, IntegerToDouble, 733149324) \ | 45 V(_IntegerImplementation, toDouble, IntegerToDouble, 733149324) \ |
| 46 V(_Double, toInt, DoubleToInteger, 362666636) \ | 46 V(_Double, toInt, DoubleToInteger, 362666636) \ |
| 47 V(_Double, truncate, DoubleTruncate, 620870996) \ | 47 V(_Double, truncate, DoubleTruncate, 620870996) \ |
| 48 V(_Double, round, DoubleRound, 620870996) \ | 48 V(_Double, round, DoubleRound, 620870996) \ |
| 49 V(_Double, floor, DoubleFloor, 620870996) \ | 49 V(_Double, floor, DoubleFloor, 620870996) \ |
| 50 V(_Double, ceil, DoubleCeil, 620870996) \ | 50 V(_Double, ceil, DoubleCeil, 620870996) \ |
| 51 V(_Double, pow, DoublePow, 1131958048) \ | |
| 52 V(::, sqrt, MathSqrt, 1662640002) \ | 51 V(::, sqrt, MathSqrt, 1662640002) \ |
| 53 | 52 |
| 54 // Class that recognizes the name and owner of a function and returns the | 53 // Class that recognizes the name and owner of a function and returns the |
| 55 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable | 54 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable |
| 56 // functions. | 55 // functions. |
| 57 class MethodRecognizer : public AllStatic { | 56 class MethodRecognizer : public AllStatic { |
| 58 public: | 57 public: |
| 59 enum Kind { | 58 enum Kind { |
| 60 kUnknown, | 59 kUnknown, |
| 61 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, | 60 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 M(MathSqrt) \ | 267 M(MathSqrt) \ |
| 269 M(UnboxDouble) \ | 268 M(UnboxDouble) \ |
| 270 M(BoxDouble) \ | 269 M(BoxDouble) \ |
| 271 M(UnboxInteger) \ | 270 M(UnboxInteger) \ |
| 272 M(BoxInteger) \ | 271 M(BoxInteger) \ |
| 273 M(BinaryMintOp) \ | 272 M(BinaryMintOp) \ |
| 274 M(ShiftMintOp) \ | 273 M(ShiftMintOp) \ |
| 275 M(UnaryMintOp) \ | 274 M(UnaryMintOp) \ |
| 276 M(CheckArrayBound) \ | 275 M(CheckArrayBound) \ |
| 277 M(Constraint) \ | 276 M(Constraint) \ |
| 278 M(StringFromCharCode) \ | 277 M(StringFromCharCode) |
| 279 M(InvokeMathCFunction) \ | |
| 280 | 278 |
| 281 | 279 |
| 282 #define FORWARD_DECLARATION(type) class type##Instr; | 280 #define FORWARD_DECLARATION(type) class type##Instr; |
| 283 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 281 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 284 #undef FORWARD_DECLARATION | 282 #undef FORWARD_DECLARATION |
| 285 | 283 |
| 286 | 284 |
| 287 // Functions required in all concrete instruction classes. | 285 // Functions required in all concrete instruction classes. |
| 288 #define DECLARE_INSTRUCTION(type) \ | 286 #define DECLARE_INSTRUCTION(type) \ |
| 289 virtual Tag tag() const { return k##type; } \ | 287 virtual Tag tag() const { return k##type; } \ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 friend class ShiftMintOpInstr; | 508 friend class ShiftMintOpInstr; |
| 511 friend class UnaryMintOpInstr; | 509 friend class UnaryMintOpInstr; |
| 512 friend class MathSqrtInstr; | 510 friend class MathSqrtInstr; |
| 513 friend class CheckClassInstr; | 511 friend class CheckClassInstr; |
| 514 friend class CheckSmiInstr; | 512 friend class CheckSmiInstr; |
| 515 friend class CheckArrayBoundInstr; | 513 friend class CheckArrayBoundInstr; |
| 516 friend class CheckEitherNonSmiInstr; | 514 friend class CheckEitherNonSmiInstr; |
| 517 friend class LICM; | 515 friend class LICM; |
| 518 friend class DoubleToSmiInstr; | 516 friend class DoubleToSmiInstr; |
| 519 friend class DoubleToDoubleInstr; | 517 friend class DoubleToDoubleInstr; |
| 520 friend class InvokeMathCFunctionInstr; | |
| 521 | 518 |
| 522 intptr_t deopt_id_; | 519 intptr_t deopt_id_; |
| 523 intptr_t lifetime_position_; // Position used by register allocator. | 520 intptr_t lifetime_position_; // Position used by register allocator. |
| 524 Instruction* previous_; | 521 Instruction* previous_; |
| 525 Instruction* next_; | 522 Instruction* next_; |
| 526 Environment* env_; | 523 Environment* env_; |
| 527 intptr_t expr_id_; | 524 intptr_t expr_id_; |
| 528 | 525 |
| 529 DISALLOW_COPY_AND_ASSIGN(Instruction); | 526 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 530 }; | 527 }; |
| (...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 | 4049 |
| 4053 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } | 4050 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } |
| 4054 | 4051 |
| 4055 private: | 4052 private: |
| 4056 const MethodRecognizer::Kind recognized_kind_; | 4053 const MethodRecognizer::Kind recognized_kind_; |
| 4057 | 4054 |
| 4058 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); | 4055 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); |
| 4059 }; | 4056 }; |
| 4060 | 4057 |
| 4061 | 4058 |
| 4062 class InvokeMathCFunctionInstr : public Definition { | |
| 4063 public: | |
| 4064 InvokeMathCFunctionInstr(ZoneGrowableArray<Value*>* inputs, | |
| 4065 InstanceCallInstr* instance_call, | |
| 4066 MethodRecognizer::Kind recognized_kind) | |
| 4067 : inputs_(inputs), locs_(NULL), recognized_kind_(recognized_kind) { | |
| 4068 ASSERT(inputs_->length() == ArgumentCountFor(recognized_kind_)); | |
| 4069 deopt_id_ = instance_call->deopt_id(); | |
| 4070 } | |
| 4071 | |
| 4072 static intptr_t ArgumentCountFor(MethodRecognizer::Kind recognized_kind_); | |
| 4073 | |
| 4074 const RuntimeEntry& TargetFunction() const; | |
| 4075 | |
| 4076 MethodRecognizer::Kind recognized_kind() const { return recognized_kind_; } | |
| 4077 | |
| 4078 DECLARE_INSTRUCTION(InvokeMathCFunction) | |
| 4079 virtual RawAbstractType* CompileType() const; | |
| 4080 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 4081 | |
| 4082 virtual bool CanDeoptimize() const { return false; } | |
| 4083 | |
| 4084 virtual bool HasSideEffect() const { return false; } | |
| 4085 | |
| 4086 virtual intptr_t ResultCid() const { return kDoubleCid; } | |
| 4087 | |
| 4088 virtual Representation representation() const { | |
| 4089 return kUnboxedDouble; | |
| 4090 } | |
| 4091 | |
| 4092 virtual Representation RequiredInputRepresentation(intptr_t idx) const { | |
| 4093 ASSERT((0 <= idx) && (idx < InputCount())); | |
| 4094 return kUnboxedDouble; | |
| 4095 } | |
| 4096 | |
| 4097 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } | |
| 4098 | |
| 4099 virtual intptr_t InputCount() const { | |
| 4100 return inputs_->length(); | |
| 4101 } | |
| 4102 | |
| 4103 virtual Value* InputAt(intptr_t i) const { | |
| 4104 return (*inputs_)[i]; | |
| 4105 } | |
| 4106 | |
| 4107 virtual void SetInputAt(intptr_t i, Value* value) { | |
| 4108 ASSERT(value != NULL); | |
| 4109 (*inputs_)[i] = value; | |
| 4110 } | |
| 4111 | |
| 4112 // Returns a structure describing the location constraints required | |
| 4113 // to emit native code for this definition. | |
| 4114 LocationSummary* locs() { | |
| 4115 if (locs_ == NULL) { | |
| 4116 locs_ = MakeLocationSummary(); | |
| 4117 } | |
| 4118 return locs_; | |
| 4119 } | |
| 4120 | |
| 4121 private: | |
| 4122 ZoneGrowableArray<Value*>* inputs_; | |
| 4123 | |
| 4124 LocationSummary* locs_; | |
| 4125 | |
| 4126 const MethodRecognizer::Kind recognized_kind_; | |
| 4127 | |
| 4128 DISALLOW_COPY_AND_ASSIGN(InvokeMathCFunctionInstr); | |
| 4129 }; | |
| 4130 | |
| 4131 | |
| 4132 class CheckClassInstr : public TemplateInstruction<1> { | 4059 class CheckClassInstr : public TemplateInstruction<1> { |
| 4133 public: | 4060 public: |
| 4134 CheckClassInstr(Value* value, | 4061 CheckClassInstr(Value* value, |
| 4135 intptr_t deopt_id, | 4062 intptr_t deopt_id, |
| 4136 const ICData& unary_checks); | 4063 const ICData& unary_checks); |
| 4137 | 4064 |
| 4138 DECLARE_INSTRUCTION(CheckClass) | 4065 DECLARE_INSTRUCTION(CheckClass) |
| 4139 virtual RawAbstractType* CompileType() const; | 4066 virtual RawAbstractType* CompileType() const; |
| 4140 | 4067 |
| 4141 virtual intptr_t ArgumentCount() const { return 0; } | 4068 virtual intptr_t ArgumentCount() const { return 0; } |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4458 ForwardInstructionIterator* current_iterator_; | 4385 ForwardInstructionIterator* current_iterator_; |
| 4459 | 4386 |
| 4460 private: | 4387 private: |
| 4461 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4388 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4462 }; | 4389 }; |
| 4463 | 4390 |
| 4464 | 4391 |
| 4465 } // namespace dart | 4392 } // namespace dart |
| 4466 | 4393 |
| 4467 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4394 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |