| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 class Computation : public ZoneAllocated { | 136 class Computation : public ZoneAllocated { |
| 137 public: | 137 public: |
| 138 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) { | 138 Computation() : deopt_id_(Isolate::kNoDeoptId), ic_data_(NULL), locs_(NULL) { |
| 139 Isolate* isolate = Isolate::Current(); | 139 Isolate* isolate = Isolate::Current(); |
| 140 deopt_id_ = isolate->GetNextDeoptId(); | 140 deopt_id_ = isolate->GetNextDeoptId(); |
| 141 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_); | 141 ic_data_ = isolate->GetICDataForDeoptId(deopt_id_); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Unique id used for deoptimization. | 144 // Unique id used for deoptimization. |
| 145 intptr_t deopt_id() const { return deopt_id_; } | 145 intptr_t deopt_id() const { |
| 146 ASSERT(CanDeoptimize()); |
| 147 return deopt_id_; |
| 148 } |
| 146 | 149 |
| 147 const ICData* ic_data() const { return ic_data_; } | 150 const ICData* ic_data() const { return ic_data_; } |
| 148 void set_ic_data(const ICData* value) { ic_data_ = value; } | 151 void set_ic_data(const ICData* value) { ic_data_ = value; } |
| 149 bool HasICData() const { | 152 bool HasICData() const { |
| 150 return (ic_data() != NULL) && !ic_data()->IsNull(); | 153 return (ic_data() != NULL) && !ic_data()->IsNull(); |
| 151 } | 154 } |
| 152 | 155 |
| 153 // Visiting support. | 156 // Visiting support. |
| 154 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; | 157 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr) = 0; |
| 155 | 158 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 bool is_eliminated() const { | 559 bool is_eliminated() const { |
| 557 return is_eliminated_; | 560 return is_eliminated_; |
| 558 } | 561 } |
| 559 void eliminate() { | 562 void eliminate() { |
| 560 ASSERT(!is_eliminated_); | 563 ASSERT(!is_eliminated_); |
| 561 is_eliminated_ = true; | 564 is_eliminated_ = true; |
| 562 } | 565 } |
| 563 | 566 |
| 564 virtual void PrintOperandsTo(BufferFormatter* f) const; | 567 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 565 | 568 |
| 566 virtual bool CanDeoptimize() const { return false; } | 569 virtual bool CanDeoptimize() const { return true; } |
| 567 virtual intptr_t ResultCid() const { return kDynamicCid; } | 570 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 568 | 571 |
| 569 private: | 572 private: |
| 570 const intptr_t token_pos_; | 573 const intptr_t token_pos_; |
| 571 const intptr_t try_index_; | 574 const intptr_t try_index_; |
| 572 const AbstractType& dst_type_; | 575 const AbstractType& dst_type_; |
| 573 const String& dst_name_; | 576 const String& dst_name_; |
| 574 bool is_eliminated_; | 577 bool is_eliminated_; |
| 575 | 578 |
| 576 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); | 579 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 598 bool is_eliminated() const { | 601 bool is_eliminated() const { |
| 599 return is_eliminated_; | 602 return is_eliminated_; |
| 600 } | 603 } |
| 601 void eliminate() { | 604 void eliminate() { |
| 602 ASSERT(!is_eliminated_); | 605 ASSERT(!is_eliminated_); |
| 603 is_eliminated_ = true; | 606 is_eliminated_ = true; |
| 604 } | 607 } |
| 605 | 608 |
| 606 virtual void PrintOperandsTo(BufferFormatter* f) const; | 609 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 607 | 610 |
| 608 virtual bool CanDeoptimize() const { return false; } | 611 virtual bool CanDeoptimize() const { return true; } |
| 609 virtual intptr_t ResultCid() const { return kBoolCid; } | 612 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 610 | 613 |
| 611 private: | 614 private: |
| 612 const intptr_t token_pos_; | 615 const intptr_t token_pos_; |
| 613 const intptr_t try_index_; | 616 const intptr_t try_index_; |
| 614 bool is_eliminated_; | 617 bool is_eliminated_; |
| 615 | 618 |
| 616 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); | 619 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); |
| 617 }; | 620 }; |
| 618 | 621 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 Token::Kind token_kind() const { return token_kind_; } | 724 Token::Kind token_kind() const { return token_kind_; } |
| 722 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 725 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| 723 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 726 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 724 return (*arguments_)[index]; | 727 return (*arguments_)[index]; |
| 725 } | 728 } |
| 726 const Array& argument_names() const { return argument_names_; } | 729 const Array& argument_names() const { return argument_names_; } |
| 727 intptr_t checked_argument_count() const { return checked_argument_count_; } | 730 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 728 | 731 |
| 729 virtual void PrintOperandsTo(BufferFormatter* f) const; | 732 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 730 | 733 |
| 731 virtual bool CanDeoptimize() const { return false; } | 734 virtual bool CanDeoptimize() const { return true; } |
| 732 virtual intptr_t ResultCid() const { return kDynamicCid; } | 735 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 733 | 736 |
| 734 private: | 737 private: |
| 735 const intptr_t token_pos_; | 738 const intptr_t token_pos_; |
| 736 const intptr_t try_index_; | 739 const intptr_t try_index_; |
| 737 const String& function_name_; | 740 const String& function_name_; |
| 738 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. | 741 const Token::Kind token_kind_; // Binary op, unary op, kGET or kILLEGAL. |
| 739 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; | 742 ZoneGrowableArray<PushArgumentInstr*>* const arguments_; |
| 740 const Array& argument_names_; | 743 const Array& argument_names_; |
| 741 const intptr_t checked_argument_count_; | 744 const intptr_t checked_argument_count_; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 925 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| 923 PushArgumentInstr* ArgumentAt(intptr_t index) const { | 926 PushArgumentInstr* ArgumentAt(intptr_t index) const { |
| 924 return (*arguments_)[index]; | 927 return (*arguments_)[index]; |
| 925 } | 928 } |
| 926 | 929 |
| 927 MethodRecognizer::Kind recognized() const { return recognized_; } | 930 MethodRecognizer::Kind recognized() const { return recognized_; } |
| 928 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } | 931 void set_recognized(MethodRecognizer::Kind kind) { recognized_ = kind; } |
| 929 | 932 |
| 930 virtual void PrintOperandsTo(BufferFormatter* f) const; | 933 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 931 | 934 |
| 932 virtual bool CanDeoptimize() const { return false; } | 935 virtual bool CanDeoptimize() const { return true; } |
| 933 virtual intptr_t ResultCid() const { return kDynamicCid; } | 936 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 934 | 937 |
| 935 private: | 938 private: |
| 936 const intptr_t token_pos_; | 939 const intptr_t token_pos_; |
| 937 const intptr_t try_index_; | 940 const intptr_t try_index_; |
| 938 const Function& function_; | 941 const Function& function_; |
| 939 const Array& argument_names_; | 942 const Array& argument_names_; |
| 940 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 943 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 941 MethodRecognizer::Kind recognized_; | 944 MethodRecognizer::Kind recognized_; |
| 942 | 945 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 Value* instantiator() const { return inputs_[1]; } | 1256 Value* instantiator() const { return inputs_[1]; } |
| 1254 Value* instantiator_type_arguments() const { return inputs_[2]; } | 1257 Value* instantiator_type_arguments() const { return inputs_[2]; } |
| 1255 | 1258 |
| 1256 bool negate_result() const { return negate_result_; } | 1259 bool negate_result() const { return negate_result_; } |
| 1257 const AbstractType& type() const { return type_; } | 1260 const AbstractType& type() const { return type_; } |
| 1258 intptr_t token_pos() const { return token_pos_; } | 1261 intptr_t token_pos() const { return token_pos_; } |
| 1259 intptr_t try_index() const { return try_index_; } | 1262 intptr_t try_index() const { return try_index_; } |
| 1260 | 1263 |
| 1261 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1264 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1262 | 1265 |
| 1263 virtual bool CanDeoptimize() const { return false; } | 1266 virtual bool CanDeoptimize() const { return true; } |
| 1264 virtual intptr_t ResultCid() const { return kBoolCid; } | 1267 virtual intptr_t ResultCid() const { return kBoolCid; } |
| 1265 | 1268 |
| 1266 private: | 1269 private: |
| 1267 const intptr_t token_pos_; | 1270 const intptr_t token_pos_; |
| 1268 const intptr_t try_index_; | 1271 const intptr_t try_index_; |
| 1269 Value* value_; | 1272 Value* value_; |
| 1270 Value* instantiator_; | 1273 Value* instantiator_; |
| 1271 Value* type_arguments_; | 1274 Value* type_arguments_; |
| 1272 const AbstractType& type_; | 1275 const AbstractType& type_; |
| 1273 const bool negate_result_; | 1276 const bool negate_result_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) | 1330 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) |
| 1328 | 1331 |
| 1329 const Function& constructor() const { return ast_node_.constructor(); } | 1332 const Function& constructor() const { return ast_node_.constructor(); } |
| 1330 intptr_t token_pos() const { return ast_node_.token_pos(); } | 1333 intptr_t token_pos() const { return ast_node_.token_pos(); } |
| 1331 intptr_t try_index() const { return try_index_; } | 1334 intptr_t try_index() const { return try_index_; } |
| 1332 | 1335 |
| 1333 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1336 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1334 | 1337 |
| 1335 virtual bool CanDeoptimize() const { return false; } | 1338 virtual bool CanDeoptimize() const { return true; } |
| 1336 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1339 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 1337 | 1340 |
| 1338 private: | 1341 private: |
| 1339 const ConstructorCallNode& ast_node_; | 1342 const ConstructorCallNode& ast_node_; |
| 1340 const intptr_t try_index_; | 1343 const intptr_t try_index_; |
| 1341 | 1344 |
| 1342 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); | 1345 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); |
| 1343 }; | 1346 }; |
| 1344 | 1347 |
| 1345 | 1348 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1519 |
| 1517 Value* instantiator() const { return inputs_[0]; } | 1520 Value* instantiator() const { return inputs_[0]; } |
| 1518 const AbstractTypeArguments& type_arguments() const { | 1521 const AbstractTypeArguments& type_arguments() const { |
| 1519 return type_arguments_; | 1522 return type_arguments_; |
| 1520 } | 1523 } |
| 1521 intptr_t token_pos() const { return token_pos_; } | 1524 intptr_t token_pos() const { return token_pos_; } |
| 1522 intptr_t try_index() const { return try_index_; } | 1525 intptr_t try_index() const { return try_index_; } |
| 1523 | 1526 |
| 1524 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1527 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1525 | 1528 |
| 1526 virtual bool CanDeoptimize() const { return false; } | 1529 virtual bool CanDeoptimize() const { return true; } |
| 1527 virtual intptr_t ResultCid() const { return kDynamicCid; } | 1530 virtual intptr_t ResultCid() const { return kDynamicCid; } |
| 1528 | 1531 |
| 1529 private: | 1532 private: |
| 1530 const intptr_t token_pos_; | 1533 const intptr_t token_pos_; |
| 1531 const intptr_t try_index_; | 1534 const intptr_t try_index_; |
| 1532 const AbstractTypeArguments& type_arguments_; | 1535 const AbstractTypeArguments& type_arguments_; |
| 1533 | 1536 |
| 1534 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); | 1537 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); |
| 1535 }; | 1538 }; |
| 1536 | 1539 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 ASSERT(context_value != NULL); | 1661 ASSERT(context_value != NULL); |
| 1659 inputs_[0] = context_value; | 1662 inputs_[0] = context_value; |
| 1660 } | 1663 } |
| 1661 | 1664 |
| 1662 intptr_t token_pos() const { return token_pos_; } | 1665 intptr_t token_pos() const { return token_pos_; } |
| 1663 intptr_t try_index() const { return try_index_; } | 1666 intptr_t try_index() const { return try_index_; } |
| 1664 Value* context_value() const { return inputs_[0]; } | 1667 Value* context_value() const { return inputs_[0]; } |
| 1665 | 1668 |
| 1666 DECLARE_COMPUTATION(CloneContext) | 1669 DECLARE_COMPUTATION(CloneContext) |
| 1667 | 1670 |
| 1668 virtual bool CanDeoptimize() const { return false; } | 1671 virtual bool CanDeoptimize() const { return true; } |
| 1669 virtual intptr_t ResultCid() const { return kIllegalCid; } | 1672 virtual intptr_t ResultCid() const { return kIllegalCid; } |
| 1670 | 1673 |
| 1671 private: | 1674 private: |
| 1672 const intptr_t token_pos_; | 1675 const intptr_t token_pos_; |
| 1673 const intptr_t try_index_; | 1676 const intptr_t try_index_; |
| 1674 | 1677 |
| 1675 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); | 1678 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); |
| 1676 }; | 1679 }; |
| 1677 | 1680 |
| 1678 | 1681 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1984 public: | 1987 public: |
| 1985 CheckStackOverflowComp(intptr_t token_pos, intptr_t try_index) | 1988 CheckStackOverflowComp(intptr_t token_pos, intptr_t try_index) |
| 1986 : token_pos_(token_pos), | 1989 : token_pos_(token_pos), |
| 1987 try_index_(try_index) {} | 1990 try_index_(try_index) {} |
| 1988 | 1991 |
| 1989 intptr_t token_pos() const { return token_pos_; } | 1992 intptr_t token_pos() const { return token_pos_; } |
| 1990 intptr_t try_index() const { return try_index_; } | 1993 intptr_t try_index() const { return try_index_; } |
| 1991 | 1994 |
| 1992 DECLARE_COMPUTATION(CheckStackOverflow) | 1995 DECLARE_COMPUTATION(CheckStackOverflow) |
| 1993 | 1996 |
| 1994 virtual bool CanDeoptimize() const { return false; } | 1997 virtual bool CanDeoptimize() const { return true; } |
| 1995 virtual intptr_t ResultCid() const { return kIllegalCid; } | 1998 virtual intptr_t ResultCid() const { return kIllegalCid; } |
| 1996 | 1999 |
| 1997 private: | 2000 private: |
| 1998 const intptr_t token_pos_; | 2001 const intptr_t token_pos_; |
| 1999 const intptr_t try_index_; | 2002 const intptr_t try_index_; |
| 2000 | 2003 |
| 2001 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp); | 2004 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp); |
| 2002 }; | 2005 }; |
| 2003 | 2006 |
| 2004 | 2007 |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3424 ForwardInstructionIterator* current_iterator_; | 3427 ForwardInstructionIterator* current_iterator_; |
| 3425 | 3428 |
| 3426 private: | 3429 private: |
| 3427 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 3430 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 3428 }; | 3431 }; |
| 3429 | 3432 |
| 3430 | 3433 |
| 3431 } // namespace dart | 3434 } // namespace dart |
| 3432 | 3435 |
| 3433 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 3436 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |