| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   622 class EqualityCompareComp : public ComparisonComp { |   622 class EqualityCompareComp : public ComparisonComp { | 
|   623  public: |   623  public: | 
|   624   EqualityCompareComp(intptr_t token_pos, |   624   EqualityCompareComp(intptr_t token_pos, | 
|   625                       intptr_t try_index, |   625                       intptr_t try_index, | 
|   626                       Token::Kind kind, |   626                       Token::Kind kind, | 
|   627                       Value* left, |   627                       Value* left, | 
|   628                       Value* right) |   628                       Value* right) | 
|   629       : ComparisonComp(kind, left, right), |   629       : ComparisonComp(kind, left, right), | 
|   630         token_pos_(token_pos), |   630         token_pos_(token_pos), | 
|   631         try_index_(try_index), |   631         try_index_(try_index), | 
|   632         receiver_class_id_(kObject) { |   632         receiver_class_id_(kObjectCid) { | 
|   633     ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); |   633     ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); | 
|   634   } |   634   } | 
|   635  |   635  | 
|   636   DECLARE_COMPUTATION(EqualityCompare) |   636   DECLARE_COMPUTATION(EqualityCompare) | 
|   637  |   637  | 
|   638   intptr_t token_pos() const { return token_pos_; } |   638   intptr_t token_pos() const { return token_pos_; } | 
|   639   intptr_t try_index() const { return try_index_; } |   639   intptr_t try_index() const { return try_index_; } | 
|   640  |   640  | 
|   641   void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } |   641   void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } | 
|   642   intptr_t receiver_class_id() const { return receiver_class_id_; } |   642   intptr_t receiver_class_id() const { return receiver_class_id_; } | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|   656 class RelationalOpComp : public ComparisonComp { |   656 class RelationalOpComp : public ComparisonComp { | 
|   657  public: |   657  public: | 
|   658   RelationalOpComp(intptr_t token_pos, |   658   RelationalOpComp(intptr_t token_pos, | 
|   659                    intptr_t try_index, |   659                    intptr_t try_index, | 
|   660                    Token::Kind kind, |   660                    Token::Kind kind, | 
|   661                    Value* left, |   661                    Value* left, | 
|   662                    Value* right) |   662                    Value* right) | 
|   663       : ComparisonComp(kind, left, right), |   663       : ComparisonComp(kind, left, right), | 
|   664         token_pos_(token_pos), |   664         token_pos_(token_pos), | 
|   665         try_index_(try_index), |   665         try_index_(try_index), | 
|   666         operands_class_id_(kObject) { |   666         operands_class_id_(kObjectCid) { | 
|   667     ASSERT(Token::IsRelationalOperator(kind)); |   667     ASSERT(Token::IsRelationalOperator(kind)); | 
|   668   } |   668   } | 
|   669  |   669  | 
|   670   DECLARE_COMPUTATION(RelationalOp) |   670   DECLARE_COMPUTATION(RelationalOp) | 
|   671  |   671  | 
|   672   intptr_t token_pos() const { return token_pos_; } |   672   intptr_t token_pos() const { return token_pos_; } | 
|   673   intptr_t try_index() const { return try_index_; } |   673   intptr_t try_index() const { return try_index_; } | 
|   674  |   674  | 
|   675   // TODO(srdjan): instead of class-id pass an enum that can differentiate |   675   // TODO(srdjan): instead of class-id pass an enum that can differentiate | 
|   676   // between boxed and unboxed doubles and integers. |   676   // between boxed and unboxed doubles and integers. | 
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   943  |   943  | 
|   944  |   944  | 
|   945 class LoadIndexedComp : public TemplateComputation<2> { |   945 class LoadIndexedComp : public TemplateComputation<2> { | 
|   946  public: |   946  public: | 
|   947   LoadIndexedComp(intptr_t token_pos, |   947   LoadIndexedComp(intptr_t token_pos, | 
|   948                   intptr_t try_index, |   948                   intptr_t try_index, | 
|   949                   Value* array, |   949                   Value* array, | 
|   950                   Value* index) |   950                   Value* index) | 
|   951       : token_pos_(token_pos), |   951       : token_pos_(token_pos), | 
|   952         try_index_(try_index), |   952         try_index_(try_index), | 
|   953         receiver_type_(kIllegalObjectKind) { |   953         receiver_type_(kIllegalCid) { | 
|   954     ASSERT(array != NULL); |   954     ASSERT(array != NULL); | 
|   955     ASSERT(index != NULL); |   955     ASSERT(index != NULL); | 
|   956     inputs_[0] = array; |   956     inputs_[0] = array; | 
|   957     inputs_[1] = index; |   957     inputs_[1] = index; | 
|   958   } |   958   } | 
|   959  |   959  | 
|   960   DECLARE_COMPUTATION(LoadIndexed) |   960   DECLARE_COMPUTATION(LoadIndexed) | 
|   961  |   961  | 
|   962   intptr_t token_pos() const { return token_pos_; } |   962   intptr_t token_pos() const { return token_pos_; } | 
|   963   intptr_t try_index() const { return try_index_; } |   963   intptr_t try_index() const { return try_index_; } | 
|   964   Value* array() const { return inputs_[0]; } |   964   Value* array() const { return inputs_[0]; } | 
|   965   Value* index() const { return inputs_[1]; } |   965   Value* index() const { return inputs_[1]; } | 
|   966  |   966  | 
|   967   void set_receiver_type(ObjectKind receiver_type) { |   967   void set_receiver_type(intptr_t receiver_type) { | 
|   968     receiver_type_ = receiver_type; |   968     receiver_type_ = receiver_type; | 
|   969   } |   969   } | 
|   970  |   970  | 
|   971   ObjectKind receiver_type() const { |   971   intptr_t receiver_type() const { | 
|   972     return receiver_type_; |   972     return receiver_type_; | 
|   973   } |   973   } | 
|   974  |   974  | 
|   975   virtual bool CanDeoptimize() const { return true; } |   975   virtual bool CanDeoptimize() const { return true; } | 
|   976  |   976  | 
|   977  private: |   977  private: | 
|   978   const intptr_t token_pos_; |   978   const intptr_t token_pos_; | 
|   979   const intptr_t try_index_; |   979   const intptr_t try_index_; | 
|   980   ObjectKind receiver_type_; |   980   intptr_t receiver_type_; | 
|   981  |   981  | 
|   982   DISALLOW_COPY_AND_ASSIGN(LoadIndexedComp); |   982   DISALLOW_COPY_AND_ASSIGN(LoadIndexedComp); | 
|   983 }; |   983 }; | 
|   984  |   984  | 
|   985  |   985  | 
|   986 // Not simply an InstanceCall because it has somewhat more complicated |   986 // Not simply an InstanceCall because it has somewhat more complicated | 
|   987 // semantics: the value operand is preserved before the call. |   987 // semantics: the value operand is preserved before the call. | 
|   988 class StoreIndexedComp : public TemplateComputation<3> { |   988 class StoreIndexedComp : public TemplateComputation<3> { | 
|   989  public: |   989  public: | 
|   990   StoreIndexedComp(intptr_t token_pos, |   990   StoreIndexedComp(intptr_t token_pos, | 
|   991                    intptr_t try_index, |   991                    intptr_t try_index, | 
|   992                    Value* array, |   992                    Value* array, | 
|   993                    Value* index, |   993                    Value* index, | 
|   994                    Value* value) |   994                    Value* value) | 
|   995       : token_pos_(token_pos), |   995       : token_pos_(token_pos), | 
|   996         try_index_(try_index), |   996         try_index_(try_index), | 
|   997         receiver_type_(kIllegalObjectKind) { |   997         receiver_type_(kIllegalCid) { | 
|   998     inputs_[0] = array; |   998     inputs_[0] = array; | 
|   999     inputs_[1] = index; |   999     inputs_[1] = index; | 
|  1000     inputs_[2] = value; |  1000     inputs_[2] = value; | 
|  1001   } |  1001   } | 
|  1002  |  1002  | 
|  1003   DECLARE_COMPUTATION(StoreIndexed) |  1003   DECLARE_COMPUTATION(StoreIndexed) | 
|  1004  |  1004  | 
|  1005   intptr_t token_pos() const { return token_pos_; } |  1005   intptr_t token_pos() const { return token_pos_; } | 
|  1006   intptr_t try_index() const { return try_index_; } |  1006   intptr_t try_index() const { return try_index_; } | 
|  1007   Value* array() const { return inputs_[0]; } |  1007   Value* array() const { return inputs_[0]; } | 
|  1008   Value* index() const { return inputs_[1]; } |  1008   Value* index() const { return inputs_[1]; } | 
|  1009   Value* value() const { return inputs_[2]; } |  1009   Value* value() const { return inputs_[2]; } | 
|  1010  |  1010  | 
|  1011   void set_receiver_type(ObjectKind receiver_type) { |  1011   void set_receiver_type(intptr_t receiver_type) { | 
|  1012     receiver_type_ = receiver_type; |  1012     receiver_type_ = receiver_type; | 
|  1013   } |  1013   } | 
|  1014  |  1014  | 
|  1015   ObjectKind receiver_type() const { |  1015   intptr_t receiver_type() const { | 
|  1016     return receiver_type_; |  1016     return receiver_type_; | 
|  1017   } |  1017   } | 
|  1018  |  1018  | 
|  1019   virtual bool CanDeoptimize() const { return true; } |  1019   virtual bool CanDeoptimize() const { return true; } | 
|  1020  |  1020  | 
|  1021  private: |  1021  private: | 
|  1022   const intptr_t token_pos_; |  1022   const intptr_t token_pos_; | 
|  1023   const intptr_t try_index_; |  1023   const intptr_t try_index_; | 
|  1024   ObjectKind receiver_type_; |  1024   intptr_t receiver_type_; | 
|  1025  |  1025  | 
|  1026   DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); |  1026   DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); | 
|  1027 }; |  1027 }; | 
|  1028  |  1028  | 
|  1029  |  1029  | 
|  1030 // Note overrideable, built-in: value? false : true. |  1030 // Note overrideable, built-in: value? false : true. | 
|  1031 class BooleanNegateComp : public TemplateComputation<1> { |  1031 class BooleanNegateComp : public TemplateComputation<1> { | 
|  1032  public: |  1032  public: | 
|  1033   explicit BooleanNegateComp(Value* value) { |  1033   explicit BooleanNegateComp(Value* value) { | 
|  1034     inputs_[0] = value; |  1034     inputs_[0] = value; | 
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1643   const intptr_t token_pos_; |  1643   const intptr_t token_pos_; | 
|  1644   const intptr_t try_index_; |  1644   const intptr_t try_index_; | 
|  1645  |  1645  | 
|  1646   DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp); |  1646   DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp); | 
|  1647 }; |  1647 }; | 
|  1648  |  1648  | 
|  1649  |  1649  | 
|  1650 class ToDoubleComp : public TemplateComputation<1> { |  1650 class ToDoubleComp : public TemplateComputation<1> { | 
|  1651  public: |  1651  public: | 
|  1652   ToDoubleComp(Value* value, |  1652   ToDoubleComp(Value* value, | 
|  1653                ObjectKind from, |  1653                intptr_t from, | 
|  1654                InstanceCallComp* instance_call) |  1654                InstanceCallComp* instance_call) | 
|  1655       : from_(from), instance_call_(instance_call) { |  1655       : from_(from), instance_call_(instance_call) { | 
|  1656     ASSERT(value != NULL); |  1656     ASSERT(value != NULL); | 
|  1657     inputs_[0] = value; |  1657     inputs_[0] = value; | 
|  1658   } |  1658   } | 
|  1659  |  1659  | 
|  1660   Value* value() const { return inputs_[0]; } |  1660   Value* value() const { return inputs_[0]; } | 
|  1661   ObjectKind from() const { return from_; } |  1661   intptr_t from() const { return from_; } | 
|  1662  |  1662  | 
|  1663   InstanceCallComp* instance_call() const { return instance_call_; } |  1663   InstanceCallComp* instance_call() const { return instance_call_; } | 
|  1664  |  1664  | 
|  1665   virtual void PrintOperandsTo(BufferFormatter* f) const; |  1665   virtual void PrintOperandsTo(BufferFormatter* f) const; | 
|  1666  |  1666  | 
|  1667   DECLARE_COMPUTATION(ToDouble) |  1667   DECLARE_COMPUTATION(ToDouble) | 
|  1668  |  1668  | 
|  1669   virtual bool CanDeoptimize() const { return true; } |  1669   virtual bool CanDeoptimize() const { return true; } | 
|  1670  |  1670  | 
|  1671  private: |  1671  private: | 
|  1672   const ObjectKind from_; |  1672   const intptr_t from_; | 
|  1673   InstanceCallComp* instance_call_; |  1673   InstanceCallComp* instance_call_; | 
|  1674  |  1674  | 
|  1675   DISALLOW_COPY_AND_ASSIGN(ToDoubleComp); |  1675   DISALLOW_COPY_AND_ASSIGN(ToDoubleComp); | 
|  1676 }; |  1676 }; | 
|  1677  |  1677  | 
|  1678  |  1678  | 
|  1679 #undef DECLARE_COMPUTATION |  1679 #undef DECLARE_COMPUTATION | 
|  1680  |  1680  | 
|  1681  |  1681  | 
|  1682 // Implementation of type testers and cast functins. |  1682 // Implementation of type testers and cast functins. | 
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2765   const GrowableArray<BlockEntryInstr*>& block_order_; |  2765   const GrowableArray<BlockEntryInstr*>& block_order_; | 
|  2766  |  2766  | 
|  2767  private: |  2767  private: | 
|  2768   DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |  2768   DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 
|  2769 }; |  2769 }; | 
|  2770  |  2770  | 
|  2771  |  2771  | 
|  2772 }  // namespace dart |  2772 }  // namespace dart | 
|  2773  |  2773  | 
|  2774 #endif  // VM_INTERMEDIATE_LANGUAGE_H_ |  2774 #endif  // VM_INTERMEDIATE_LANGUAGE_H_ | 
| OLD | NEW |