| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 friend class UnaryMintOpInstr; | 511 friend class UnaryMintOpInstr; |
| 512 friend class MathSqrtInstr; | 512 friend class MathSqrtInstr; |
| 513 friend class CheckClassInstr; | 513 friend class CheckClassInstr; |
| 514 friend class CheckSmiInstr; | 514 friend class CheckSmiInstr; |
| 515 friend class CheckArrayBoundInstr; | 515 friend class CheckArrayBoundInstr; |
| 516 friend class CheckEitherNonSmiInstr; | 516 friend class CheckEitherNonSmiInstr; |
| 517 friend class LICM; | 517 friend class LICM; |
| 518 friend class DoubleToSmiInstr; | 518 friend class DoubleToSmiInstr; |
| 519 friend class DoubleToDoubleInstr; | 519 friend class DoubleToDoubleInstr; |
| 520 friend class InvokeMathCFunctionInstr; | 520 friend class InvokeMathCFunctionInstr; |
| 521 friend class FlowGraphOptimizer; |
| 521 | 522 |
| 522 intptr_t deopt_id_; | 523 intptr_t deopt_id_; |
| 523 intptr_t lifetime_position_; // Position used by register allocator. | 524 intptr_t lifetime_position_; // Position used by register allocator. |
| 524 Instruction* previous_; | 525 Instruction* previous_; |
| 525 Instruction* next_; | 526 Instruction* next_; |
| 526 Environment* env_; | 527 Environment* env_; |
| 527 intptr_t expr_id_; | 528 intptr_t expr_id_; |
| 528 | 529 |
| 529 DISALLOW_COPY_AND_ASSIGN(Instruction); | 530 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 530 }; | 531 }; |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 class ThrowInstr : public TemplateInstruction<0> { | 1391 class ThrowInstr : public TemplateInstruction<0> { |
| 1391 public: | 1392 public: |
| 1392 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1393 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
| 1393 | 1394 |
| 1394 DECLARE_INSTRUCTION(Throw) | 1395 DECLARE_INSTRUCTION(Throw) |
| 1395 | 1396 |
| 1396 virtual intptr_t ArgumentCount() const { return 1; } | 1397 virtual intptr_t ArgumentCount() const { return 1; } |
| 1397 | 1398 |
| 1398 intptr_t token_pos() const { return token_pos_; } | 1399 intptr_t token_pos() const { return token_pos_; } |
| 1399 | 1400 |
| 1400 virtual bool CanDeoptimize() const { return false; } | 1401 virtual bool CanDeoptimize() const { return true; } |
| 1401 | 1402 |
| 1402 virtual bool HasSideEffect() const { return true; } | 1403 virtual bool HasSideEffect() const { return true; } |
| 1403 | 1404 |
| 1404 private: | 1405 private: |
| 1405 const intptr_t token_pos_; | 1406 const intptr_t token_pos_; |
| 1406 | 1407 |
| 1407 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); | 1408 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
| 1408 }; | 1409 }; |
| 1409 | 1410 |
| 1410 | 1411 |
| 1411 class ReThrowInstr : public TemplateInstruction<0> { | 1412 class ReThrowInstr : public TemplateInstruction<0> { |
| 1412 public: | 1413 public: |
| 1413 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1414 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
| 1414 | 1415 |
| 1415 DECLARE_INSTRUCTION(ReThrow) | 1416 DECLARE_INSTRUCTION(ReThrow) |
| 1416 | 1417 |
| 1417 virtual intptr_t ArgumentCount() const { return 2; } | 1418 virtual intptr_t ArgumentCount() const { return 2; } |
| 1418 | 1419 |
| 1419 intptr_t token_pos() const { return token_pos_; } | 1420 intptr_t token_pos() const { return token_pos_; } |
| 1420 | 1421 |
| 1421 virtual bool CanDeoptimize() const { return false; } | 1422 virtual bool CanDeoptimize() const { return true; } |
| 1422 | 1423 |
| 1423 virtual bool HasSideEffect() const { return true; } | 1424 virtual bool HasSideEffect() const { return true; } |
| 1424 | 1425 |
| 1425 private: | 1426 private: |
| 1426 const intptr_t token_pos_; | 1427 const intptr_t token_pos_; |
| 1427 | 1428 |
| 1428 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); | 1429 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
| 1429 }; | 1430 }; |
| 1430 | 1431 |
| 1431 | 1432 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 bool is_eliminated() const { | 1889 bool is_eliminated() const { |
| 1889 return is_eliminated_; | 1890 return is_eliminated_; |
| 1890 } | 1891 } |
| 1891 void eliminate() { | 1892 void eliminate() { |
| 1892 ASSERT(!is_eliminated_); | 1893 ASSERT(!is_eliminated_); |
| 1893 is_eliminated_ = true; | 1894 is_eliminated_ = true; |
| 1894 } | 1895 } |
| 1895 | 1896 |
| 1896 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1897 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1897 | 1898 |
| 1898 virtual bool CanDeoptimize() const { return false; } | 1899 virtual bool CanDeoptimize() const { return true; } |
| 1899 | 1900 |
| 1900 virtual bool HasSideEffect() const { return false; } | 1901 virtual bool HasSideEffect() const { return false; } |
| 1901 | 1902 |
| 1902 virtual bool AffectedBySideEffect() const { return false; } | 1903 virtual bool AffectedBySideEffect() const { return false; } |
| 1903 virtual bool AttributesEqual(Instruction* other) const; | 1904 virtual bool AttributesEqual(Instruction* other) const; |
| 1904 | 1905 |
| 1905 virtual intptr_t ResultCid() const { return value()->ResultCid(); } | 1906 virtual intptr_t ResultCid() const { return value()->ResultCid(); } |
| 1906 virtual intptr_t GetPropagatedCid(); | 1907 virtual intptr_t GetPropagatedCid(); |
| 1907 | 1908 |
| 1908 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 1909 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1935 bool is_eliminated() const { | 1936 bool is_eliminated() const { |
| 1936 return is_eliminated_; | 1937 return is_eliminated_; |
| 1937 } | 1938 } |
| 1938 void eliminate() { | 1939 void eliminate() { |
| 1939 ASSERT(!is_eliminated_); | 1940 ASSERT(!is_eliminated_); |
| 1940 is_eliminated_ = true; | 1941 is_eliminated_ = true; |
| 1941 } | 1942 } |
| 1942 | 1943 |
| 1943 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1944 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1944 | 1945 |
| 1945 virtual bool CanDeoptimize() const { return false; } | 1946 virtual bool CanDeoptimize() const { return true; } |
| 1946 | 1947 |
| 1947 virtual bool HasSideEffect() const { return false; } | 1948 virtual bool HasSideEffect() const { return false; } |
| 1948 | 1949 |
| 1949 virtual bool AffectedBySideEffect() const { return false; } | 1950 virtual bool AffectedBySideEffect() const { return false; } |
| 1950 virtual bool AttributesEqual(Instruction* other) const { return true; } | 1951 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 1951 | 1952 |
| 1952 virtual intptr_t ResultCid() const { return kBoolCid; } | 1953 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 1953 | 1954 |
| 1954 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 1955 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 1955 | 1956 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1977 intptr_t formal_parameter_index() const { | 1978 intptr_t formal_parameter_index() const { |
| 1978 return ast_node_.formal_parameter_index(); | 1979 return ast_node_.formal_parameter_index(); |
| 1979 } | 1980 } |
| 1980 const String& formal_parameter_name() const { | 1981 const String& formal_parameter_name() const { |
| 1981 return ast_node_.formal_parameter_name(); | 1982 return ast_node_.formal_parameter_name(); |
| 1982 } | 1983 } |
| 1983 Value* saved_arguments_descriptor() const { return inputs_[0]; } | 1984 Value* saved_arguments_descriptor() const { return inputs_[0]; } |
| 1984 | 1985 |
| 1985 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1986 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1986 | 1987 |
| 1987 virtual bool CanDeoptimize() const { return false; } | 1988 virtual bool CanDeoptimize() const { return true; } |
| 1988 | 1989 |
| 1989 virtual bool HasSideEffect() const { return true; } | 1990 virtual bool HasSideEffect() const { return true; } |
| 1990 | 1991 |
| 1991 virtual intptr_t ResultCid() const { return kBoolCid; } | 1992 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 1992 | 1993 |
| 1993 private: | 1994 private: |
| 1994 const ArgumentDefinitionTestNode& ast_node_; | 1995 const ArgumentDefinitionTestNode& ast_node_; |
| 1995 | 1996 |
| 1996 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); | 1997 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); |
| 1997 }; | 1998 }; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 return comparison()->InputAt(i); | 2208 return comparison()->InputAt(i); |
| 2208 } | 2209 } |
| 2209 | 2210 |
| 2210 | 2211 |
| 2211 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { | 2212 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { |
| 2212 comparison()->SetInputAt(i, value); | 2213 comparison()->SetInputAt(i, value); |
| 2213 } | 2214 } |
| 2214 | 2215 |
| 2215 | 2216 |
| 2216 inline bool BranchInstr::CanDeoptimize() const { | 2217 inline bool BranchInstr::CanDeoptimize() const { |
| 2217 return comparison()->CanDeoptimize(); | 2218 // Branches need a deoptimization info in checked mode if they |
| 2219 // can throw a type check error. |
| 2220 return comparison()->CanDeoptimize() || is_checked(); |
| 2218 } | 2221 } |
| 2219 | 2222 |
| 2220 | 2223 |
| 2221 inline bool BranchInstr::HasSideEffect() const { | 2224 inline bool BranchInstr::HasSideEffect() const { |
| 2222 return comparison()->HasSideEffect(); | 2225 return comparison()->HasSideEffect(); |
| 2223 } | 2226 } |
| 2224 | 2227 |
| 2225 | 2228 |
| 2226 inline LocationSummary* BranchInstr::locs() { | 2229 inline LocationSummary* BranchInstr::locs() { |
| 2227 if (comparison()->locs_ == NULL) { | 2230 if (comparison()->locs_ == NULL) { |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 Value* value() const { return inputs_[0]; } | 2858 Value* value() const { return inputs_[0]; } |
| 2856 Value* instantiator() const { return inputs_[1]; } | 2859 Value* instantiator() const { return inputs_[1]; } |
| 2857 Value* instantiator_type_arguments() const { return inputs_[2]; } | 2860 Value* instantiator_type_arguments() const { return inputs_[2]; } |
| 2858 | 2861 |
| 2859 bool negate_result() const { return negate_result_; } | 2862 bool negate_result() const { return negate_result_; } |
| 2860 const AbstractType& type() const { return type_; } | 2863 const AbstractType& type() const { return type_; } |
| 2861 intptr_t token_pos() const { return token_pos_; } | 2864 intptr_t token_pos() const { return token_pos_; } |
| 2862 | 2865 |
| 2863 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2866 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2864 | 2867 |
| 2865 virtual bool CanDeoptimize() const { return false; } | 2868 virtual bool CanDeoptimize() const { return true; } |
| 2866 | 2869 |
| 2867 virtual bool HasSideEffect() const { return true; } | 2870 virtual bool HasSideEffect() const { return true; } |
| 2868 | 2871 |
| 2869 virtual intptr_t ResultCid() const { return kBoolCid; } | 2872 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 2870 | 2873 |
| 2871 private: | 2874 private: |
| 2872 const intptr_t token_pos_; | 2875 const intptr_t token_pos_; |
| 2873 Value* value_; | 2876 Value* value_; |
| 2874 Value* instantiator_; | 2877 Value* instantiator_; |
| 2875 Value* type_arguments_; | 2878 Value* type_arguments_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2932 } | 2935 } |
| 2933 | 2936 |
| 2934 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) | 2937 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) |
| 2935 virtual RawAbstractType* CompileType() const; | 2938 virtual RawAbstractType* CompileType() const; |
| 2936 | 2939 |
| 2937 const Function& constructor() const { return ast_node_.constructor(); } | 2940 const Function& constructor() const { return ast_node_.constructor(); } |
| 2938 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2941 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 2939 | 2942 |
| 2940 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2943 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2941 | 2944 |
| 2942 virtual bool CanDeoptimize() const { return false; } | 2945 virtual bool CanDeoptimize() const { return true; } |
| 2943 | 2946 |
| 2944 virtual bool HasSideEffect() const { return true; } | 2947 virtual bool HasSideEffect() const { return true; } |
| 2945 | 2948 |
| 2946 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2949 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 2947 | 2950 |
| 2948 private: | 2951 private: |
| 2949 const ConstructorCallNode& ast_node_; | 2952 const ConstructorCallNode& ast_node_; |
| 2950 | 2953 |
| 2951 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); | 2954 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); |
| 2952 }; | 2955 }; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3149 virtual RawAbstractType* CompileType() const; | 3152 virtual RawAbstractType* CompileType() const; |
| 3150 | 3153 |
| 3151 Value* instantiator() const { return inputs_[0]; } | 3154 Value* instantiator() const { return inputs_[0]; } |
| 3152 const AbstractTypeArguments& type_arguments() const { | 3155 const AbstractTypeArguments& type_arguments() const { |
| 3153 return type_arguments_; | 3156 return type_arguments_; |
| 3154 } | 3157 } |
| 3155 intptr_t token_pos() const { return token_pos_; } | 3158 intptr_t token_pos() const { return token_pos_; } |
| 3156 | 3159 |
| 3157 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3160 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3158 | 3161 |
| 3159 virtual bool CanDeoptimize() const { return false; } | 3162 virtual bool CanDeoptimize() const { return true; } |
| 3160 | 3163 |
| 3161 virtual bool HasSideEffect() const { return true; } | 3164 virtual bool HasSideEffect() const { return true; } |
| 3162 | 3165 |
| 3163 virtual intptr_t ResultCid() const { return kDynamicCid; } | 3166 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 3164 | 3167 |
| 3165 private: | 3168 private: |
| 3166 const intptr_t token_pos_; | 3169 const intptr_t token_pos_; |
| 3167 const AbstractTypeArguments& type_arguments_; | 3170 const AbstractTypeArguments& type_arguments_; |
| 3168 | 3171 |
| 3169 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); | 3172 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 ASSERT(context_value != NULL); | 3301 ASSERT(context_value != NULL); |
| 3299 inputs_[0] = context_value; | 3302 inputs_[0] = context_value; |
| 3300 } | 3303 } |
| 3301 | 3304 |
| 3302 intptr_t token_pos() const { return token_pos_; } | 3305 intptr_t token_pos() const { return token_pos_; } |
| 3303 Value* context_value() const { return inputs_[0]; } | 3306 Value* context_value() const { return inputs_[0]; } |
| 3304 | 3307 |
| 3305 DECLARE_INSTRUCTION(CloneContext) | 3308 DECLARE_INSTRUCTION(CloneContext) |
| 3306 virtual RawAbstractType* CompileType() const; | 3309 virtual RawAbstractType* CompileType() const; |
| 3307 | 3310 |
| 3308 virtual bool CanDeoptimize() const { return false; } | 3311 virtual bool CanDeoptimize() const { return true; } |
| 3309 | 3312 |
| 3310 virtual bool HasSideEffect() const { return false; } | 3313 virtual bool HasSideEffect() const { return false; } |
| 3311 | 3314 |
| 3312 virtual intptr_t ResultCid() const { return kContextCid; } | 3315 virtual intptr_t ResultCid() const { return kContextCid; } |
| 3313 | 3316 |
| 3314 private: | 3317 private: |
| 3315 const intptr_t token_pos_; | 3318 const intptr_t token_pos_; |
| 3316 | 3319 |
| 3317 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); | 3320 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); |
| 3318 }; | 3321 }; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3898 explicit CheckStackOverflowInstr(intptr_t token_pos) | 3901 explicit CheckStackOverflowInstr(intptr_t token_pos) |
| 3899 : token_pos_(token_pos) {} | 3902 : token_pos_(token_pos) {} |
| 3900 | 3903 |
| 3901 intptr_t token_pos() const { return token_pos_; } | 3904 intptr_t token_pos() const { return token_pos_; } |
| 3902 | 3905 |
| 3903 DECLARE_INSTRUCTION(CheckStackOverflow) | 3906 DECLARE_INSTRUCTION(CheckStackOverflow) |
| 3904 virtual RawAbstractType* CompileType() const; | 3907 virtual RawAbstractType* CompileType() const; |
| 3905 | 3908 |
| 3906 virtual intptr_t ArgumentCount() const { return 0; } | 3909 virtual intptr_t ArgumentCount() const { return 0; } |
| 3907 | 3910 |
| 3908 virtual bool CanDeoptimize() const { return false; } | 3911 virtual bool CanDeoptimize() const { return true; } |
| 3909 | 3912 |
| 3910 virtual bool HasSideEffect() const { return false; } | 3913 virtual bool HasSideEffect() const { return false; } |
| 3911 | 3914 |
| 3912 private: | 3915 private: |
| 3913 const intptr_t token_pos_; | 3916 const intptr_t token_pos_; |
| 3914 | 3917 |
| 3915 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); | 3918 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); |
| 3916 }; | 3919 }; |
| 3917 | 3920 |
| 3918 | 3921 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4445 ForwardInstructionIterator* current_iterator_; | 4448 ForwardInstructionIterator* current_iterator_; |
| 4446 | 4449 |
| 4447 private: | 4450 private: |
| 4448 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4451 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4449 }; | 4452 }; |
| 4450 | 4453 |
| 4451 | 4454 |
| 4452 } // namespace dart | 4455 } // namespace dart |
| 4453 | 4456 |
| 4454 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4457 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |