| 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) \ |
| 51 V(::, sqrt, MathSqrt, 1662640002) \ | 52 V(::, sqrt, MathSqrt, 1662640002) \ |
| 52 | 53 |
| 53 // Class that recognizes the name and owner of a function and returns the | 54 // Class that recognizes the name and owner of a function and returns the |
| 54 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable | 55 // corresponding enum. See RECOGNIZED_LIST above for list of recognizable |
| 55 // functions. | 56 // functions. |
| 56 class MethodRecognizer : public AllStatic { | 57 class MethodRecognizer : public AllStatic { |
| 57 public: | 58 public: |
| 58 enum Kind { | 59 enum Kind { |
| 59 kUnknown, | 60 kUnknown, |
| 60 #define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp) k##enum_name, | 61 #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... |
| 267 M(MathSqrt) \ | 268 M(MathSqrt) \ |
| 268 M(UnboxDouble) \ | 269 M(UnboxDouble) \ |
| 269 M(BoxDouble) \ | 270 M(BoxDouble) \ |
| 270 M(UnboxInteger) \ | 271 M(UnboxInteger) \ |
| 271 M(BoxInteger) \ | 272 M(BoxInteger) \ |
| 272 M(BinaryMintOp) \ | 273 M(BinaryMintOp) \ |
| 273 M(ShiftMintOp) \ | 274 M(ShiftMintOp) \ |
| 274 M(UnaryMintOp) \ | 275 M(UnaryMintOp) \ |
| 275 M(CheckArrayBound) \ | 276 M(CheckArrayBound) \ |
| 276 M(Constraint) \ | 277 M(Constraint) \ |
| 277 M(StringFromCharCode) | 278 M(StringFromCharCode) \ |
| 279 M(InvokeMathCFunction) \ |
| 278 | 280 |
| 279 | 281 |
| 280 #define FORWARD_DECLARATION(type) class type##Instr; | 282 #define FORWARD_DECLARATION(type) class type##Instr; |
| 281 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 283 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 282 #undef FORWARD_DECLARATION | 284 #undef FORWARD_DECLARATION |
| 283 | 285 |
| 284 | 286 |
| 285 // Functions required in all concrete instruction classes. | 287 // Functions required in all concrete instruction classes. |
| 286 #define DECLARE_INSTRUCTION(type) \ | 288 #define DECLARE_INSTRUCTION(type) \ |
| 287 virtual Tag tag() const { return k##type; } \ | 289 virtual Tag tag() const { return k##type; } \ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 friend class ShiftMintOpInstr; | 510 friend class ShiftMintOpInstr; |
| 509 friend class UnaryMintOpInstr; | 511 friend class UnaryMintOpInstr; |
| 510 friend class MathSqrtInstr; | 512 friend class MathSqrtInstr; |
| 511 friend class CheckClassInstr; | 513 friend class CheckClassInstr; |
| 512 friend class CheckSmiInstr; | 514 friend class CheckSmiInstr; |
| 513 friend class CheckArrayBoundInstr; | 515 friend class CheckArrayBoundInstr; |
| 514 friend class CheckEitherNonSmiInstr; | 516 friend class CheckEitherNonSmiInstr; |
| 515 friend class LICM; | 517 friend class LICM; |
| 516 friend class DoubleToSmiInstr; | 518 friend class DoubleToSmiInstr; |
| 517 friend class DoubleToDoubleInstr; | 519 friend class DoubleToDoubleInstr; |
| 520 friend class InvokeMathCFunctionInstr; |
| 518 | 521 |
| 519 intptr_t deopt_id_; | 522 intptr_t deopt_id_; |
| 520 intptr_t lifetime_position_; // Position used by register allocator. | 523 intptr_t lifetime_position_; // Position used by register allocator. |
| 521 Instruction* previous_; | 524 Instruction* previous_; |
| 522 Instruction* next_; | 525 Instruction* next_; |
| 523 Environment* env_; | 526 Environment* env_; |
| 524 intptr_t expr_id_; | 527 intptr_t expr_id_; |
| 525 | 528 |
| 526 DISALLOW_COPY_AND_ASSIGN(Instruction); | 529 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 527 }; | 530 }; |
| (...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4049 | 4052 |
| 4050 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } | 4053 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } |
| 4051 | 4054 |
| 4052 private: | 4055 private: |
| 4053 const MethodRecognizer::Kind recognized_kind_; | 4056 const MethodRecognizer::Kind recognized_kind_; |
| 4054 | 4057 |
| 4055 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); | 4058 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleInstr); |
| 4056 }; | 4059 }; |
| 4057 | 4060 |
| 4058 | 4061 |
| 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 |
| 4059 class CheckClassInstr : public TemplateInstruction<1> { | 4132 class CheckClassInstr : public TemplateInstruction<1> { |
| 4060 public: | 4133 public: |
| 4061 CheckClassInstr(Value* value, | 4134 CheckClassInstr(Value* value, |
| 4062 intptr_t deopt_id, | 4135 intptr_t deopt_id, |
| 4063 const ICData& unary_checks); | 4136 const ICData& unary_checks); |
| 4064 | 4137 |
| 4065 DECLARE_INSTRUCTION(CheckClass) | 4138 DECLARE_INSTRUCTION(CheckClass) |
| 4066 virtual RawAbstractType* CompileType() const; | 4139 virtual RawAbstractType* CompileType() const; |
| 4067 | 4140 |
| 4068 virtual intptr_t ArgumentCount() const { return 0; } | 4141 virtual intptr_t ArgumentCount() const { return 0; } |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4385 ForwardInstructionIterator* current_iterator_; | 4458 ForwardInstructionIterator* current_iterator_; |
| 4386 | 4459 |
| 4387 private: | 4460 private: |
| 4388 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4461 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4389 }; | 4462 }; |
| 4390 | 4463 |
| 4391 | 4464 |
| 4392 } // namespace dart | 4465 } // namespace dart |
| 4393 | 4466 |
| 4394 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4467 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |