| 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 friend class UnaryMintOpInstr; | 512 friend class UnaryMintOpInstr; |
| 513 friend class MathSqrtInstr; | 513 friend class MathSqrtInstr; |
| 514 friend class CheckClassInstr; | 514 friend class CheckClassInstr; |
| 515 friend class CheckSmiInstr; | 515 friend class CheckSmiInstr; |
| 516 friend class CheckArrayBoundInstr; | 516 friend class CheckArrayBoundInstr; |
| 517 friend class CheckEitherNonSmiInstr; | 517 friend class CheckEitherNonSmiInstr; |
| 518 friend class LICM; | 518 friend class LICM; |
| 519 friend class DoubleToSmiInstr; | 519 friend class DoubleToSmiInstr; |
| 520 friend class DoubleToDoubleInstr; | 520 friend class DoubleToDoubleInstr; |
| 521 friend class InvokeMathCFunctionInstr; | 521 friend class InvokeMathCFunctionInstr; |
| 522 friend class FlowGraphOptimizer; |
| 522 | 523 |
| 523 intptr_t deopt_id_; | 524 intptr_t deopt_id_; |
| 524 intptr_t lifetime_position_; // Position used by register allocator. | 525 intptr_t lifetime_position_; // Position used by register allocator. |
| 525 Instruction* previous_; | 526 Instruction* previous_; |
| 526 Instruction* next_; | 527 Instruction* next_; |
| 527 Environment* env_; | 528 Environment* env_; |
| 528 intptr_t expr_id_; | 529 intptr_t expr_id_; |
| 529 | 530 |
| 530 DISALLOW_COPY_AND_ASSIGN(Instruction); | 531 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 531 }; | 532 }; |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 class ThrowInstr : public TemplateInstruction<0> { | 1401 class ThrowInstr : public TemplateInstruction<0> { |
| 1401 public: | 1402 public: |
| 1402 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1403 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
| 1403 | 1404 |
| 1404 DECLARE_INSTRUCTION(Throw) | 1405 DECLARE_INSTRUCTION(Throw) |
| 1405 | 1406 |
| 1406 virtual intptr_t ArgumentCount() const { return 1; } | 1407 virtual intptr_t ArgumentCount() const { return 1; } |
| 1407 | 1408 |
| 1408 intptr_t token_pos() const { return token_pos_; } | 1409 intptr_t token_pos() const { return token_pos_; } |
| 1409 | 1410 |
| 1410 virtual bool CanDeoptimize() const { return false; } | 1411 virtual bool CanDeoptimize() const { return true; } |
| 1411 | 1412 |
| 1412 virtual bool HasSideEffect() const { return true; } | 1413 virtual bool HasSideEffect() const { return true; } |
| 1413 | 1414 |
| 1414 private: | 1415 private: |
| 1415 const intptr_t token_pos_; | 1416 const intptr_t token_pos_; |
| 1416 | 1417 |
| 1417 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); | 1418 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
| 1418 }; | 1419 }; |
| 1419 | 1420 |
| 1420 | 1421 |
| 1421 class ReThrowInstr : public TemplateInstruction<0> { | 1422 class ReThrowInstr : public TemplateInstruction<0> { |
| 1422 public: | 1423 public: |
| 1423 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } | 1424 explicit ReThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } |
| 1424 | 1425 |
| 1425 DECLARE_INSTRUCTION(ReThrow) | 1426 DECLARE_INSTRUCTION(ReThrow) |
| 1426 | 1427 |
| 1427 virtual intptr_t ArgumentCount() const { return 2; } | 1428 virtual intptr_t ArgumentCount() const { return 2; } |
| 1428 | 1429 |
| 1429 intptr_t token_pos() const { return token_pos_; } | 1430 intptr_t token_pos() const { return token_pos_; } |
| 1430 | 1431 |
| 1431 virtual bool CanDeoptimize() const { return false; } | 1432 virtual bool CanDeoptimize() const { return true; } |
| 1432 | 1433 |
| 1433 virtual bool HasSideEffect() const { return true; } | 1434 virtual bool HasSideEffect() const { return true; } |
| 1434 | 1435 |
| 1435 private: | 1436 private: |
| 1436 const intptr_t token_pos_; | 1437 const intptr_t token_pos_; |
| 1437 | 1438 |
| 1438 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); | 1439 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
| 1439 }; | 1440 }; |
| 1440 | 1441 |
| 1441 | 1442 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 bool is_eliminated() const { | 1899 bool is_eliminated() const { |
| 1899 return is_eliminated_; | 1900 return is_eliminated_; |
| 1900 } | 1901 } |
| 1901 void eliminate() { | 1902 void eliminate() { |
| 1902 ASSERT(!is_eliminated_); | 1903 ASSERT(!is_eliminated_); |
| 1903 is_eliminated_ = true; | 1904 is_eliminated_ = true; |
| 1904 } | 1905 } |
| 1905 | 1906 |
| 1906 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1907 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1907 | 1908 |
| 1908 virtual bool CanDeoptimize() const { return false; } | 1909 virtual bool CanDeoptimize() const { return true; } |
| 1909 | 1910 |
| 1910 virtual bool HasSideEffect() const { return false; } | 1911 virtual bool HasSideEffect() const { return false; } |
| 1911 | 1912 |
| 1912 virtual bool AffectedBySideEffect() const { return false; } | 1913 virtual bool AffectedBySideEffect() const { return false; } |
| 1913 virtual bool AttributesEqual(Instruction* other) const; | 1914 virtual bool AttributesEqual(Instruction* other) const; |
| 1914 | 1915 |
| 1915 virtual intptr_t ResultCid() const { return value()->ResultCid(); } | 1916 virtual intptr_t ResultCid() const { return value()->ResultCid(); } |
| 1916 virtual intptr_t GetPropagatedCid(); | 1917 virtual intptr_t GetPropagatedCid(); |
| 1917 | 1918 |
| 1918 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 1919 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1945 bool is_eliminated() const { | 1946 bool is_eliminated() const { |
| 1946 return is_eliminated_; | 1947 return is_eliminated_; |
| 1947 } | 1948 } |
| 1948 void eliminate() { | 1949 void eliminate() { |
| 1949 ASSERT(!is_eliminated_); | 1950 ASSERT(!is_eliminated_); |
| 1950 is_eliminated_ = true; | 1951 is_eliminated_ = true; |
| 1951 } | 1952 } |
| 1952 | 1953 |
| 1953 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1954 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1954 | 1955 |
| 1955 virtual bool CanDeoptimize() const { return false; } | 1956 virtual bool CanDeoptimize() const { return true; } |
| 1956 | 1957 |
| 1957 virtual bool HasSideEffect() const { return false; } | 1958 virtual bool HasSideEffect() const { return false; } |
| 1958 | 1959 |
| 1959 virtual bool AffectedBySideEffect() const { return false; } | 1960 virtual bool AffectedBySideEffect() const { return false; } |
| 1960 virtual bool AttributesEqual(Instruction* other) const { return true; } | 1961 virtual bool AttributesEqual(Instruction* other) const { return true; } |
| 1961 | 1962 |
| 1962 virtual intptr_t ResultCid() const { return kBoolCid; } | 1963 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 1963 | 1964 |
| 1964 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); | 1965 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer); |
| 1965 | 1966 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1987 intptr_t formal_parameter_index() const { | 1988 intptr_t formal_parameter_index() const { |
| 1988 return ast_node_.formal_parameter_index(); | 1989 return ast_node_.formal_parameter_index(); |
| 1989 } | 1990 } |
| 1990 const String& formal_parameter_name() const { | 1991 const String& formal_parameter_name() const { |
| 1991 return ast_node_.formal_parameter_name(); | 1992 return ast_node_.formal_parameter_name(); |
| 1992 } | 1993 } |
| 1993 Value* saved_arguments_descriptor() const { return inputs_[0]; } | 1994 Value* saved_arguments_descriptor() const { return inputs_[0]; } |
| 1994 | 1995 |
| 1995 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1996 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1996 | 1997 |
| 1997 virtual bool CanDeoptimize() const { return false; } | 1998 virtual bool CanDeoptimize() const { return true; } |
| 1998 | 1999 |
| 1999 virtual bool HasSideEffect() const { return true; } | 2000 virtual bool HasSideEffect() const { return true; } |
| 2000 | 2001 |
| 2001 virtual intptr_t ResultCid() const { return kBoolCid; } | 2002 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 2002 | 2003 |
| 2003 private: | 2004 private: |
| 2004 const ArgumentDefinitionTestNode& ast_node_; | 2005 const ArgumentDefinitionTestNode& ast_node_; |
| 2005 | 2006 |
| 2006 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); | 2007 DISALLOW_COPY_AND_ASSIGN(ArgumentDefinitionTestInstr); |
| 2007 }; | 2008 }; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 return comparison()->InputAt(i); | 2218 return comparison()->InputAt(i); |
| 2218 } | 2219 } |
| 2219 | 2220 |
| 2220 | 2221 |
| 2221 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { | 2222 inline void BranchInstr::SetInputAt(intptr_t i, Value* value) { |
| 2222 comparison()->SetInputAt(i, value); | 2223 comparison()->SetInputAt(i, value); |
| 2223 } | 2224 } |
| 2224 | 2225 |
| 2225 | 2226 |
| 2226 inline bool BranchInstr::CanDeoptimize() const { | 2227 inline bool BranchInstr::CanDeoptimize() const { |
| 2227 return comparison()->CanDeoptimize(); | 2228 // Branches need a deoptimization info in checked mode if they |
| 2229 // can throw a type check error. |
| 2230 return comparison()->CanDeoptimize() || is_checked(); |
| 2228 } | 2231 } |
| 2229 | 2232 |
| 2230 | 2233 |
| 2231 inline bool BranchInstr::HasSideEffect() const { | 2234 inline bool BranchInstr::HasSideEffect() const { |
| 2232 return comparison()->HasSideEffect(); | 2235 return comparison()->HasSideEffect(); |
| 2233 } | 2236 } |
| 2234 | 2237 |
| 2235 | 2238 |
| 2236 inline LocationSummary* BranchInstr::locs() { | 2239 inline LocationSummary* BranchInstr::locs() { |
| 2237 if (comparison()->locs_ == NULL) { | 2240 if (comparison()->locs_ == NULL) { |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 Value* value() const { return inputs_[0]; } | 2868 Value* value() const { return inputs_[0]; } |
| 2866 Value* instantiator() const { return inputs_[1]; } | 2869 Value* instantiator() const { return inputs_[1]; } |
| 2867 Value* instantiator_type_arguments() const { return inputs_[2]; } | 2870 Value* instantiator_type_arguments() const { return inputs_[2]; } |
| 2868 | 2871 |
| 2869 bool negate_result() const { return negate_result_; } | 2872 bool negate_result() const { return negate_result_; } |
| 2870 const AbstractType& type() const { return type_; } | 2873 const AbstractType& type() const { return type_; } |
| 2871 intptr_t token_pos() const { return token_pos_; } | 2874 intptr_t token_pos() const { return token_pos_; } |
| 2872 | 2875 |
| 2873 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2876 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2874 | 2877 |
| 2875 virtual bool CanDeoptimize() const { return false; } | 2878 virtual bool CanDeoptimize() const { return true; } |
| 2876 | 2879 |
| 2877 virtual bool HasSideEffect() const { return true; } | 2880 virtual bool HasSideEffect() const { return true; } |
| 2878 | 2881 |
| 2879 virtual intptr_t ResultCid() const { return kBoolCid; } | 2882 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 2880 | 2883 |
| 2881 private: | 2884 private: |
| 2882 const intptr_t token_pos_; | 2885 const intptr_t token_pos_; |
| 2883 Value* value_; | 2886 Value* value_; |
| 2884 Value* instantiator_; | 2887 Value* instantiator_; |
| 2885 Value* type_arguments_; | 2888 Value* type_arguments_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 } | 2945 } |
| 2943 | 2946 |
| 2944 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) | 2947 DECLARE_INSTRUCTION(AllocateObjectWithBoundsCheck) |
| 2945 virtual RawAbstractType* CompileType() const; | 2948 virtual RawAbstractType* CompileType() const; |
| 2946 | 2949 |
| 2947 const Function& constructor() const { return ast_node_.constructor(); } | 2950 const Function& constructor() const { return ast_node_.constructor(); } |
| 2948 intptr_t token_pos() const { return ast_node_.token_pos(); } | 2951 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 2949 | 2952 |
| 2950 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2953 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2951 | 2954 |
| 2952 virtual bool CanDeoptimize() const { return false; } | 2955 virtual bool CanDeoptimize() const { return true; } |
| 2953 | 2956 |
| 2954 virtual bool HasSideEffect() const { return true; } | 2957 virtual bool HasSideEffect() const { return true; } |
| 2955 | 2958 |
| 2956 virtual intptr_t ResultCid() const { return kDynamicCid; } | 2959 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 2957 | 2960 |
| 2958 private: | 2961 private: |
| 2959 const ConstructorCallNode& ast_node_; | 2962 const ConstructorCallNode& ast_node_; |
| 2960 | 2963 |
| 2961 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); | 2964 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckInstr); |
| 2962 }; | 2965 }; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3159 virtual RawAbstractType* CompileType() const; | 3162 virtual RawAbstractType* CompileType() const; |
| 3160 | 3163 |
| 3161 Value* instantiator() const { return inputs_[0]; } | 3164 Value* instantiator() const { return inputs_[0]; } |
| 3162 const AbstractTypeArguments& type_arguments() const { | 3165 const AbstractTypeArguments& type_arguments() const { |
| 3163 return type_arguments_; | 3166 return type_arguments_; |
| 3164 } | 3167 } |
| 3165 intptr_t token_pos() const { return token_pos_; } | 3168 intptr_t token_pos() const { return token_pos_; } |
| 3166 | 3169 |
| 3167 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3170 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3168 | 3171 |
| 3169 virtual bool CanDeoptimize() const { return false; } | 3172 virtual bool CanDeoptimize() const { return true; } |
| 3170 | 3173 |
| 3171 virtual bool HasSideEffect() const { return true; } | 3174 virtual bool HasSideEffect() const { return true; } |
| 3172 | 3175 |
| 3173 virtual intptr_t ResultCid() const { return kDynamicCid; } | 3176 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 3174 | 3177 |
| 3175 private: | 3178 private: |
| 3176 const intptr_t token_pos_; | 3179 const intptr_t token_pos_; |
| 3177 const AbstractTypeArguments& type_arguments_; | 3180 const AbstractTypeArguments& type_arguments_; |
| 3178 | 3181 |
| 3179 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); | 3182 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsInstr); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3308 ASSERT(context_value != NULL); | 3311 ASSERT(context_value != NULL); |
| 3309 inputs_[0] = context_value; | 3312 inputs_[0] = context_value; |
| 3310 } | 3313 } |
| 3311 | 3314 |
| 3312 intptr_t token_pos() const { return token_pos_; } | 3315 intptr_t token_pos() const { return token_pos_; } |
| 3313 Value* context_value() const { return inputs_[0]; } | 3316 Value* context_value() const { return inputs_[0]; } |
| 3314 | 3317 |
| 3315 DECLARE_INSTRUCTION(CloneContext) | 3318 DECLARE_INSTRUCTION(CloneContext) |
| 3316 virtual RawAbstractType* CompileType() const; | 3319 virtual RawAbstractType* CompileType() const; |
| 3317 | 3320 |
| 3318 virtual bool CanDeoptimize() const { return false; } | 3321 virtual bool CanDeoptimize() const { return true; } |
| 3319 | 3322 |
| 3320 virtual bool HasSideEffect() const { return false; } | 3323 virtual bool HasSideEffect() const { return false; } |
| 3321 | 3324 |
| 3322 virtual intptr_t ResultCid() const { return kContextCid; } | 3325 virtual intptr_t ResultCid() const { return kContextCid; } |
| 3323 | 3326 |
| 3324 private: | 3327 private: |
| 3325 const intptr_t token_pos_; | 3328 const intptr_t token_pos_; |
| 3326 | 3329 |
| 3327 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); | 3330 DISALLOW_COPY_AND_ASSIGN(CloneContextInstr); |
| 3328 }; | 3331 }; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3908 explicit CheckStackOverflowInstr(intptr_t token_pos) | 3911 explicit CheckStackOverflowInstr(intptr_t token_pos) |
| 3909 : token_pos_(token_pos) {} | 3912 : token_pos_(token_pos) {} |
| 3910 | 3913 |
| 3911 intptr_t token_pos() const { return token_pos_; } | 3914 intptr_t token_pos() const { return token_pos_; } |
| 3912 | 3915 |
| 3913 DECLARE_INSTRUCTION(CheckStackOverflow) | 3916 DECLARE_INSTRUCTION(CheckStackOverflow) |
| 3914 virtual RawAbstractType* CompileType() const; | 3917 virtual RawAbstractType* CompileType() const; |
| 3915 | 3918 |
| 3916 virtual intptr_t ArgumentCount() const { return 0; } | 3919 virtual intptr_t ArgumentCount() const { return 0; } |
| 3917 | 3920 |
| 3918 virtual bool CanDeoptimize() const { return false; } | 3921 virtual bool CanDeoptimize() const { return true; } |
| 3919 | 3922 |
| 3920 virtual bool HasSideEffect() const { return false; } | 3923 virtual bool HasSideEffect() const { return false; } |
| 3921 | 3924 |
| 3922 private: | 3925 private: |
| 3923 const intptr_t token_pos_; | 3926 const intptr_t token_pos_; |
| 3924 | 3927 |
| 3925 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); | 3928 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowInstr); |
| 3926 }; | 3929 }; |
| 3927 | 3930 |
| 3928 | 3931 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4455 ForwardInstructionIterator* current_iterator_; | 4458 ForwardInstructionIterator* current_iterator_; |
| 4456 | 4459 |
| 4457 private: | 4460 private: |
| 4458 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4461 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4459 }; | 4462 }; |
| 4460 | 4463 |
| 4461 | 4464 |
| 4462 } // namespace dart | 4465 } // namespace dart |
| 4463 | 4466 |
| 4464 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4467 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |