OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 M(UnarySmiOp) \ | 232 M(UnarySmiOp) \ |
233 M(NumberNegate) \ | 233 M(NumberNegate) \ |
234 M(CheckStackOverflow) \ | 234 M(CheckStackOverflow) \ |
235 M(DoubleToDouble) \ | 235 M(DoubleToDouble) \ |
236 M(SmiToDouble) \ | 236 M(SmiToDouble) \ |
237 M(CheckClass) \ | 237 M(CheckClass) \ |
238 M(CheckSmi) \ | 238 M(CheckSmi) \ |
239 M(Constant) \ | 239 M(Constant) \ |
240 M(CheckEitherNonSmi) \ | 240 M(CheckEitherNonSmi) \ |
241 M(UnboxedDoubleBinaryOp) \ | 241 M(UnboxedDoubleBinaryOp) \ |
| 242 M(MathSqrt) \ |
242 M(UnboxDouble) \ | 243 M(UnboxDouble) \ |
243 M(BoxDouble) \ | 244 M(BoxDouble) \ |
244 M(CheckArrayBound) \ | 245 M(CheckArrayBound) \ |
245 | 246 |
246 | 247 |
247 #define FORWARD_DECLARATION(type) class type##Instr; | 248 #define FORWARD_DECLARATION(type) class type##Instr; |
248 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 249 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
249 #undef FORWARD_DECLARATION | 250 #undef FORWARD_DECLARATION |
250 | 251 |
251 | 252 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 intptr_t GetDeoptId() const { | 430 intptr_t GetDeoptId() const { |
430 return deopt_id_; | 431 return deopt_id_; |
431 } | 432 } |
432 | 433 |
433 private: | 434 private: |
434 friend class Definition; // Needed for InsertBefore, InsertAfter. | 435 friend class Definition; // Needed for InsertBefore, InsertAfter. |
435 | 436 |
436 // Classes that set deopt_id_. | 437 // Classes that set deopt_id_. |
437 friend class UnboxDoubleInstr; | 438 friend class UnboxDoubleInstr; |
438 friend class UnboxedDoubleBinaryOpInstr; | 439 friend class UnboxedDoubleBinaryOpInstr; |
| 440 friend class MathSqrtInstr; |
439 friend class CheckClassInstr; | 441 friend class CheckClassInstr; |
440 friend class CheckSmiInstr; | 442 friend class CheckSmiInstr; |
441 friend class CheckArrayBoundInstr; | 443 friend class CheckArrayBoundInstr; |
442 friend class CheckEitherNonSmiInstr; | 444 friend class CheckEitherNonSmiInstr; |
443 friend class LICM; | 445 friend class LICM; |
444 | 446 |
445 intptr_t deopt_id_; | 447 intptr_t deopt_id_; |
446 intptr_t lifetime_position_; // Position used by register allocator. | 448 intptr_t lifetime_position_; // Position used by register allocator. |
447 Instruction* previous_; | 449 Instruction* previous_; |
448 Instruction* next_; | 450 Instruction* next_; |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 | 1979 |
1978 class StaticCallInstr : public TemplateDefinition<0> { | 1980 class StaticCallInstr : public TemplateDefinition<0> { |
1979 public: | 1981 public: |
1980 StaticCallInstr(intptr_t token_pos, | 1982 StaticCallInstr(intptr_t token_pos, |
1981 const Function& function, | 1983 const Function& function, |
1982 const Array& argument_names, | 1984 const Array& argument_names, |
1983 ZoneGrowableArray<PushArgumentInstr*>* arguments) | 1985 ZoneGrowableArray<PushArgumentInstr*>* arguments) |
1984 : token_pos_(token_pos), | 1986 : token_pos_(token_pos), |
1985 function_(function), | 1987 function_(function), |
1986 argument_names_(argument_names), | 1988 argument_names_(argument_names), |
1987 arguments_(arguments), | 1989 arguments_(arguments) { |
1988 recognized_(MethodRecognizer::kUnknown) { | |
1989 ASSERT(function.IsZoneHandle()); | 1990 ASSERT(function.IsZoneHandle()); |
1990 ASSERT(argument_names.IsZoneHandle()); | 1991 ASSERT(argument_names.IsZoneHandle()); |
1991 } | 1992 } |
1992 | 1993 |
1993 DECLARE_INSTRUCTION(StaticCall) | 1994 DECLARE_INSTRUCTION(StaticCall) |
1994 virtual RawAbstractType* CompileType() const; | 1995 virtual RawAbstractType* CompileType() const; |
1995 | 1996 |
1996 // Accessors forwarded to the AST node. | 1997 // Accessors forwarded to the AST node. |
1997 const Function& function() const { return function_; } | 1998 const Function& function() const { return function_; } |
1998 const Array& argument_names() const { return argument_names_; } | 1999 const Array& argument_names() const { return argument_names_; } |
1999 intptr_t token_pos() const { return token_pos_; } | 2000 intptr_t token_pos() const { return token_pos_; } |
2000 | 2001 |
2001 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 2002 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
2002 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 2003 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
2003 return (*arguments_)[index]; | 2004 return (*arguments_)[index]; |
2004 } | 2005 } |
2005 | 2006 |
2006 MethodRecognizer::Kind recognized() const { return recognized_; } | |
2007 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } | |
2008 | |
2009 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2007 virtual void PrintOperandsTo(BufferFormatter* f) const; |
2010 | 2008 |
2011 virtual bool CanDeoptimize() const { return true; } | 2009 virtual bool CanDeoptimize() const { return true; } |
2012 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2010 virtual intptr_t ResultCid() const { return kDynamicCid; } |
2013 | 2011 |
2014 private: | 2012 private: |
2015 const intptr_t token_pos_; | 2013 const intptr_t token_pos_; |
2016 const Function& function_; | 2014 const Function& function_; |
2017 const Array& argument_names_; | 2015 const Array& argument_names_; |
2018 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 2016 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
2019 MethodRecognizer::Kind recognized_; | |
2020 | 2017 |
2021 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); | 2018 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); |
2022 }; | 2019 }; |
2023 | 2020 |
2024 | 2021 |
2025 class LoadLocalInstr : public TemplateDefinition<0> { | 2022 class LoadLocalInstr : public TemplateDefinition<0> { |
2026 public: | 2023 public: |
2027 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) | 2024 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) |
2028 : local_(local), | 2025 : local_(local), |
2029 context_level_(context_level) { } | 2026 context_level_(context_level) { } |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 virtual bool AttributesEqual(Definition* other) const { return true; } | 2844 virtual bool AttributesEqual(Definition* other) const { return true; } |
2848 | 2845 |
2849 DECLARE_INSTRUCTION(UnboxDouble) | 2846 DECLARE_INSTRUCTION(UnboxDouble) |
2850 virtual RawAbstractType* CompileType() const; | 2847 virtual RawAbstractType* CompileType() const; |
2851 | 2848 |
2852 private: | 2849 private: |
2853 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); | 2850 DISALLOW_COPY_AND_ASSIGN(UnboxDoubleInstr); |
2854 }; | 2851 }; |
2855 | 2852 |
2856 | 2853 |
| 2854 class MathSqrtInstr : public TemplateDefinition<1> { |
| 2855 public: |
| 2856 MathSqrtInstr(Value* value, StaticCallInstr* instance_call) { |
| 2857 ASSERT(value != NULL); |
| 2858 inputs_[0] = value; |
| 2859 deopt_id_ = instance_call->deopt_id(); |
| 2860 } |
| 2861 |
| 2862 Value* value() const { return inputs_[0]; } |
| 2863 |
| 2864 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2865 |
| 2866 virtual bool CanDeoptimize() const { return false; } |
| 2867 virtual bool HasSideEffect() const { return false; } |
| 2868 |
| 2869 virtual bool AttributesEqual(Definition* other) const { |
| 2870 return true; |
| 2871 } |
| 2872 |
| 2873 // The output is not an instance but when it is boxed it becomes double. |
| 2874 virtual intptr_t ResultCid() const { return kDoubleCid; } |
| 2875 |
| 2876 virtual Representation representation() const { |
| 2877 return kUnboxedDouble; |
| 2878 } |
| 2879 |
| 2880 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 2881 ASSERT(idx == 0); |
| 2882 return kUnboxedDouble; |
| 2883 } |
| 2884 |
| 2885 virtual intptr_t DeoptimizationTarget() const { |
| 2886 // Direct access since this instuction cannot deoptimize, and the deopt-id |
| 2887 // was inherited from another instuction that could deoptimize. |
| 2888 return deopt_id_; |
| 2889 } |
| 2890 |
| 2891 DECLARE_INSTRUCTION(MathSqrt) |
| 2892 virtual RawAbstractType* CompileType() const; |
| 2893 |
| 2894 private: |
| 2895 DISALLOW_COPY_AND_ASSIGN(MathSqrtInstr); |
| 2896 }; |
| 2897 |
| 2898 |
2857 class UnboxedDoubleBinaryOpInstr : public TemplateDefinition<2> { | 2899 class UnboxedDoubleBinaryOpInstr : public TemplateDefinition<2> { |
2858 public: | 2900 public: |
2859 UnboxedDoubleBinaryOpInstr(Token::Kind op_kind, | 2901 UnboxedDoubleBinaryOpInstr(Token::Kind op_kind, |
2860 Value* left, | 2902 Value* left, |
2861 Value* right, | 2903 Value* right, |
2862 InstanceCallInstr* instance_call) | 2904 InstanceCallInstr* instance_call) |
2863 : op_kind_(op_kind) { | 2905 : op_kind_(op_kind) { |
2864 ASSERT(left != NULL); | 2906 ASSERT(left != NULL); |
2865 ASSERT(right != NULL); | 2907 ASSERT(right != NULL); |
2866 inputs_[0] = left; | 2908 inputs_[0] = left; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 ForwardInstructionIterator* current_iterator_; | 3440 ForwardInstructionIterator* current_iterator_; |
3399 | 3441 |
3400 private: | 3442 private: |
3401 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 3443 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
3402 }; | 3444 }; |
3403 | 3445 |
3404 | 3446 |
3405 } // namespace dart | 3447 } // namespace dart |
3406 | 3448 |
3407 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 3449 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |