Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 // Unique computation/instruction id, used for deoptimization. | 81 // Unique computation/instruction id, used for deoptimization. |
| 82 intptr_t cid() const { return cid_; } | 82 intptr_t cid() const { return cid_; } |
| 83 | 83 |
| 84 const ICData* ic_data() const { return ic_data_; } | 84 const ICData* ic_data() const { return ic_data_; } |
| 85 | 85 |
| 86 // Visiting support. | 86 // Visiting support. |
| 87 virtual void Accept(FlowGraphVisitor* visitor) = 0; | 87 virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| 88 | 88 |
| 89 virtual intptr_t InputCount() const = 0; | 89 virtual intptr_t InputCount() const = 0; |
| 90 | 90 |
| 91 // Static type propagation support. | |
|
srdjan
2012/05/16 20:16:15
Maybe instead: "Static type of the computation".
regis
2012/05/16 23:20:37
Done.
| |
| 92 virtual RawAbstractType* StaticType() const = 0; | |
| 93 | |
| 91 // Mutate assigned_vars to add the local variable index for all | 94 // Mutate assigned_vars to add the local variable index for all |
| 92 // frame-allocated locals assigned to by the computation. | 95 // frame-allocated locals assigned to by the computation. |
| 93 virtual void RecordAssignedVars(BitVector* assigned_vars); | 96 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 94 | 97 |
| 95 private: | 98 private: |
| 96 friend class Instruction; | 99 friend class Instruction; |
| 97 static intptr_t GetNextCid(Isolate* isolate) { | 100 static intptr_t GetNextCid(Isolate* isolate) { |
| 98 intptr_t tmp = isolate->computation_id(); | 101 intptr_t tmp = isolate->computation_id(); |
| 99 isolate->set_computation_id(tmp + 1); | 102 isolate->set_computation_id(tmp + 1); |
| 100 return tmp; | 103 return tmp; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 | 124 |
| 122 // An embedded container with N elements of type T. Used (with partial | 125 // An embedded container with N elements of type T. Used (with partial |
| 123 // specialization for N=0) because embedded arrays cannot have size 0. | 126 // specialization for N=0) because embedded arrays cannot have size 0. |
| 124 template<typename T, intptr_t N> | 127 template<typename T, intptr_t N> |
| 125 class EmbeddedArray { | 128 class EmbeddedArray { |
| 126 public: | 129 public: |
| 127 EmbeddedArray() : elements_() { } | 130 EmbeddedArray() : elements_() { } |
| 128 | 131 |
| 129 intptr_t length() { return N; } | 132 intptr_t length() const { return N; } |
| 133 const T& operator[](intptr_t i) const { | |
| 134 ASSERT(i < length()); | |
| 135 return elements_[i]; | |
| 136 } | |
| 130 T& operator[](intptr_t i) { | 137 T& operator[](intptr_t i) { |
| 131 ASSERT(i < length()); | 138 ASSERT(i < length()); |
| 132 return elements_[i]; | 139 return elements_[i]; |
| 133 } | 140 } |
| 134 | 141 |
| 135 private: | 142 private: |
| 136 T elements_[N]; | 143 T elements_[N]; |
| 137 }; | 144 }; |
| 138 | 145 |
| 139 | 146 |
| 140 template<typename T> | 147 template<typename T> |
| 141 class EmbeddedArray<T, 0> { | 148 class EmbeddedArray<T, 0> { |
| 142 public: | 149 public: |
| 143 int length() { return 0; } | 150 int length() const { return 0; } |
| 144 T& operator[](intptr_t i) { | |
| 145 UNREACHABLE(); | |
| 146 static T sentinel = 0; | |
| 147 return sentinel; | |
| 148 } | |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 | 153 |
| 152 class Value; | 154 class Value; |
| 153 | 155 |
| 154 template<intptr_t N> | 156 template<intptr_t N> |
| 155 class TemplateComputation : public Computation { | 157 class TemplateComputation : public Computation { |
| 156 public: | 158 public: |
| 157 virtual intptr_t InputCount() const { return N; } | 159 virtual intptr_t InputCount() const { return N; } |
| 158 | 160 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 173 #undef DEFINE_TESTERS | 175 #undef DEFINE_TESTERS |
| 174 | 176 |
| 175 private: | 177 private: |
| 176 DISALLOW_COPY_AND_ASSIGN(Value); | 178 DISALLOW_COPY_AND_ASSIGN(Value); |
| 177 }; | 179 }; |
| 178 | 180 |
| 179 | 181 |
| 180 // Functions defined in all concrete computation classes. | 182 // Functions defined in all concrete computation classes. |
| 181 #define DECLARE_COMPUTATION(ShortName) \ | 183 #define DECLARE_COMPUTATION(ShortName) \ |
| 182 virtual void Accept(FlowGraphVisitor* visitor); \ | 184 virtual void Accept(FlowGraphVisitor* visitor); \ |
| 185 virtual RawAbstractType* StaticType() const; \ | |
| 183 | 186 |
| 184 // Functions defined in all concrete value classes. | 187 // Functions defined in all concrete value classes. |
| 185 #define DECLARE_VALUE(ShortName) \ | 188 #define DECLARE_VALUE(ShortName) \ |
| 186 DECLARE_COMPUTATION(ShortName) \ | 189 DECLARE_COMPUTATION(ShortName) \ |
| 187 virtual ShortName##Val* As##ShortName() { return this; } | 190 virtual ShortName##Val* As##ShortName() { return this; } |
| 188 | 191 |
| 189 | 192 |
| 190 // Definitions and uses are mutually recursive. | 193 // Definitions and uses are mutually recursive. |
| 191 class Definition; | 194 class Definition; |
| 192 | 195 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 : token_index_(token_index), | 279 : token_index_(token_index), |
| 277 try_index_(try_index) { | 280 try_index_(try_index) { |
| 278 ASSERT(value != NULL); | 281 ASSERT(value != NULL); |
| 279 inputs_[0] = value; | 282 inputs_[0] = value; |
| 280 } | 283 } |
| 281 | 284 |
| 282 DECLARE_COMPUTATION(AssertBoolean) | 285 DECLARE_COMPUTATION(AssertBoolean) |
| 283 | 286 |
| 284 intptr_t token_index() const { return token_index_; } | 287 intptr_t token_index() const { return token_index_; } |
| 285 intptr_t try_index() const { return try_index_; } | 288 intptr_t try_index() const { return try_index_; } |
| 286 Value* value() { return inputs_[0]; } | 289 Value* value() const { return inputs_[0]; } |
| 287 | 290 |
| 288 private: | 291 private: |
| 289 const intptr_t token_index_; | 292 const intptr_t token_index_; |
| 290 const intptr_t try_index_; | 293 const intptr_t try_index_; |
| 291 | 294 |
| 292 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); | 295 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); |
| 293 }; | 296 }; |
| 294 | 297 |
| 295 | 298 |
| 296 // Denotes the current context, normally held in a register. This is | 299 // Denotes the current context, normally held in a register. This is |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 308 | 311 |
| 309 class StoreContextComp : public TemplateComputation<1> { | 312 class StoreContextComp : public TemplateComputation<1> { |
| 310 public: | 313 public: |
| 311 explicit StoreContextComp(Value* value) { | 314 explicit StoreContextComp(Value* value) { |
| 312 ASSERT(value != NULL); | 315 ASSERT(value != NULL); |
| 313 inputs_[0] = value; | 316 inputs_[0] = value; |
| 314 } | 317 } |
| 315 | 318 |
| 316 DECLARE_COMPUTATION(StoreContext); | 319 DECLARE_COMPUTATION(StoreContext); |
| 317 | 320 |
| 318 Value* value() { return inputs_[0]; } | 321 Value* value() const { return inputs_[0]; } |
| 319 | 322 |
| 320 private: | 323 private: |
| 321 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); | 324 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); |
| 322 }; | 325 }; |
| 323 | 326 |
| 324 | 327 |
| 325 class ClosureCallComp : public Computation { | 328 class ClosureCallComp : public Computation { |
| 326 public: | 329 public: |
| 327 ClosureCallComp(ClosureCallNode* node, | 330 ClosureCallComp(ClosureCallNode* node, |
| 328 intptr_t try_index, | 331 intptr_t try_index, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 StrictCompareComp(Token::Kind kind, Value* left, Value* right) | 408 StrictCompareComp(Token::Kind kind, Value* left, Value* right) |
| 406 : kind_(kind) { | 409 : kind_(kind) { |
| 407 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); | 410 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); |
| 408 inputs_[0] = left; | 411 inputs_[0] = left; |
| 409 inputs_[1] = right; | 412 inputs_[1] = right; |
| 410 } | 413 } |
| 411 | 414 |
| 412 DECLARE_COMPUTATION(StrictCompare) | 415 DECLARE_COMPUTATION(StrictCompare) |
| 413 | 416 |
| 414 Token::Kind kind() const { return kind_; } | 417 Token::Kind kind() const { return kind_; } |
| 415 Value* left() { return inputs_[0]; } | 418 Value* left() const { return inputs_[0]; } |
| 416 Value* right() { return inputs_[1]; } | 419 Value* right() const { return inputs_[1]; } |
| 417 | 420 |
| 418 private: | 421 private: |
| 419 const Token::Kind kind_; | 422 const Token::Kind kind_; |
| 420 | 423 |
| 421 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); | 424 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
| 422 }; | 425 }; |
| 423 | 426 |
| 424 | 427 |
| 425 class EqualityCompareComp : public TemplateComputation<2> { | 428 class EqualityCompareComp : public TemplateComputation<2> { |
| 426 public: | 429 public: |
| 427 EqualityCompareComp(intptr_t token_index, | 430 EqualityCompareComp(intptr_t token_index, |
| 428 intptr_t try_index, | 431 intptr_t try_index, |
| 429 Value* left, | 432 Value* left, |
| 430 Value* right) | 433 Value* right) |
| 431 : token_index_(token_index), | 434 : token_index_(token_index), |
| 432 try_index_(try_index) { | 435 try_index_(try_index) { |
| 433 ASSERT(left != NULL); | 436 ASSERT(left != NULL); |
| 434 ASSERT(right != NULL); | 437 ASSERT(right != NULL); |
| 435 inputs_[0] = left; | 438 inputs_[0] = left; |
| 436 inputs_[1] = right; | 439 inputs_[1] = right; |
| 437 } | 440 } |
| 438 | 441 |
| 439 DECLARE_COMPUTATION(EqualityCompareComp) | 442 DECLARE_COMPUTATION(EqualityCompareComp) |
| 440 | 443 |
| 441 intptr_t token_index() const { return token_index_; } | 444 intptr_t token_index() const { return token_index_; } |
| 442 intptr_t try_index() const { return try_index_; } | 445 intptr_t try_index() const { return try_index_; } |
| 443 Value* left() { return inputs_[0]; } | 446 Value* left() const { return inputs_[0]; } |
| 444 Value* right() { return inputs_[1]; } | 447 Value* right() const { return inputs_[1]; } |
| 445 | 448 |
| 446 private: | 449 private: |
| 447 const intptr_t token_index_; | 450 const intptr_t token_index_; |
| 448 const intptr_t try_index_; | 451 const intptr_t try_index_; |
| 449 | 452 |
| 450 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 453 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
| 451 }; | 454 }; |
| 452 | 455 |
| 453 | 456 |
| 454 class StaticCallComp : public Computation { | 457 class StaticCallComp : public Computation { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 StoreLocalComp(const LocalVariable& local, | 517 StoreLocalComp(const LocalVariable& local, |
| 515 Value* value, | 518 Value* value, |
| 516 intptr_t context_level) | 519 intptr_t context_level) |
| 517 : local_(local), context_level_(context_level) { | 520 : local_(local), context_level_(context_level) { |
| 518 inputs_[0] = value; | 521 inputs_[0] = value; |
| 519 } | 522 } |
| 520 | 523 |
| 521 DECLARE_COMPUTATION(StoreLocal) | 524 DECLARE_COMPUTATION(StoreLocal) |
| 522 | 525 |
| 523 const LocalVariable& local() const { return local_; } | 526 const LocalVariable& local() const { return local_; } |
| 524 Value* value() { return inputs_[0]; } | 527 Value* value() const { return inputs_[0]; } |
| 525 intptr_t context_level() const { return context_level_; } | 528 intptr_t context_level() const { return context_level_; } |
| 526 | 529 |
| 527 virtual void RecordAssignedVars(BitVector* assigned_vars); | 530 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 528 | 531 |
| 529 private: | 532 private: |
| 530 const LocalVariable& local_; | 533 const LocalVariable& local_; |
| 531 const intptr_t context_level_; | 534 const intptr_t context_level_; |
| 532 | 535 |
| 533 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 536 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 534 }; | 537 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) | 574 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) |
| 572 : ast_node_(*ast_node) { | 575 : ast_node_(*ast_node) { |
| 573 ASSERT(instance != NULL); | 576 ASSERT(instance != NULL); |
| 574 inputs_[0] = instance; | 577 inputs_[0] = instance; |
| 575 } | 578 } |
| 576 | 579 |
| 577 DECLARE_COMPUTATION(LoadInstanceField) | 580 DECLARE_COMPUTATION(LoadInstanceField) |
| 578 | 581 |
| 579 const Field& field() const { return ast_node_.field(); } | 582 const Field& field() const { return ast_node_.field(); } |
| 580 | 583 |
| 581 Value* instance() { return inputs_[0]; } | 584 Value* instance() const { return inputs_[0]; } |
| 582 | 585 |
| 583 private: | 586 private: |
| 584 const LoadInstanceFieldNode& ast_node_; | 587 const LoadInstanceFieldNode& ast_node_; |
| 585 | 588 |
| 586 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 589 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 587 }; | 590 }; |
| 588 | 591 |
| 589 | 592 |
| 590 class StoreInstanceFieldComp : public TemplateComputation<2> { | 593 class StoreInstanceFieldComp : public TemplateComputation<2> { |
| 591 public: | 594 public: |
| 592 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, | 595 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, |
| 593 Value* instance, | 596 Value* instance, |
| 594 Value* value) | 597 Value* value) |
| 595 : ast_node_(*ast_node) { | 598 : ast_node_(*ast_node) { |
| 596 ASSERT(instance != NULL); | 599 ASSERT(instance != NULL); |
| 597 ASSERT(value != NULL); | 600 ASSERT(value != NULL); |
| 598 inputs_[0] = instance; | 601 inputs_[0] = instance; |
| 599 inputs_[1] = value; | 602 inputs_[1] = value; |
| 600 } | 603 } |
| 601 | 604 |
| 602 DECLARE_COMPUTATION(StoreInstanceField) | 605 DECLARE_COMPUTATION(StoreInstanceField) |
| 603 | 606 |
| 604 intptr_t token_index() const { return ast_node_.token_index(); } | 607 intptr_t token_index() const { return ast_node_.token_index(); } |
| 605 const Field& field() const { return ast_node_.field(); } | 608 const Field& field() const { return ast_node_.field(); } |
| 606 | 609 |
| 607 Value* instance() { return inputs_[0]; } | 610 Value* instance() const { return inputs_[0]; } |
| 608 Value* value() { return inputs_[1]; } | 611 Value* value() const { return inputs_[1]; } |
| 609 | 612 |
| 610 private: | 613 private: |
| 611 const StoreInstanceFieldNode& ast_node_; | 614 const StoreInstanceFieldNode& ast_node_; |
| 612 | 615 |
| 613 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 616 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 614 }; | 617 }; |
| 615 | 618 |
| 616 | 619 |
| 617 class LoadStaticFieldComp : public TemplateComputation<0> { | 620 class LoadStaticFieldComp : public TemplateComputation<0> { |
| 618 public: | 621 public: |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 634 StoreStaticFieldComp(const Field& field, Value* value) | 637 StoreStaticFieldComp(const Field& field, Value* value) |
| 635 : field_(field) { | 638 : field_(field) { |
| 636 ASSERT(field.IsZoneHandle()); | 639 ASSERT(field.IsZoneHandle()); |
| 637 ASSERT(value != NULL); | 640 ASSERT(value != NULL); |
| 638 inputs_[0] = value; | 641 inputs_[0] = value; |
| 639 } | 642 } |
| 640 | 643 |
| 641 DECLARE_COMPUTATION(StoreStaticField); | 644 DECLARE_COMPUTATION(StoreStaticField); |
| 642 | 645 |
| 643 const Field& field() const { return field_; } | 646 const Field& field() const { return field_; } |
| 644 Value* value() { return inputs_[0]; } | 647 Value* value() const { return inputs_[0]; } |
| 645 | 648 |
| 646 private: | 649 private: |
| 647 const Field& field_; | 650 const Field& field_; |
| 648 | 651 |
| 649 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); | 652 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
| 650 }; | 653 }; |
| 651 | 654 |
| 652 | 655 |
| 653 // Not simply an InstanceCall because it has somewhat more complicated | 656 // Not simply an InstanceCall because it has somewhat more complicated |
| 654 // semantics: the value operand is preserved before the call. | 657 // semantics: the value operand is preserved before the call. |
| 655 class StoreIndexedComp : public TemplateComputation<3> { | 658 class StoreIndexedComp : public TemplateComputation<3> { |
| 656 public: | 659 public: |
| 657 StoreIndexedComp(intptr_t token_index, | 660 StoreIndexedComp(intptr_t token_index, |
| 658 intptr_t try_index, | 661 intptr_t try_index, |
| 659 Value* array, | 662 Value* array, |
| 660 Value* index, | 663 Value* index, |
| 661 Value* value) | 664 Value* value) |
| 662 : token_index_(token_index), | 665 : token_index_(token_index), |
| 663 try_index_(try_index) { | 666 try_index_(try_index) { |
| 664 inputs_[0] = array; | 667 inputs_[0] = array; |
| 665 inputs_[1] = index; | 668 inputs_[1] = index; |
| 666 inputs_[2] = value; | 669 inputs_[2] = value; |
| 667 } | 670 } |
| 668 | 671 |
| 669 DECLARE_COMPUTATION(StoreIndexed) | 672 DECLARE_COMPUTATION(StoreIndexed) |
| 670 | 673 |
| 671 intptr_t token_index() const { return token_index_; } | 674 intptr_t token_index() const { return token_index_; } |
| 672 intptr_t try_index() const { return try_index_; } | 675 intptr_t try_index() const { return try_index_; } |
| 673 Value* array() { return inputs_[0]; } | 676 Value* array() const { return inputs_[0]; } |
| 674 Value* index() { return inputs_[1]; } | 677 Value* index() const { return inputs_[1]; } |
| 675 Value* value() { return inputs_[2]; } | 678 Value* value() const { return inputs_[2]; } |
| 676 | 679 |
| 677 private: | 680 private: |
| 678 const intptr_t token_index_; | 681 const intptr_t token_index_; |
| 679 const intptr_t try_index_; | 682 const intptr_t try_index_; |
| 680 | 683 |
| 681 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); | 684 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); |
| 682 }; | 685 }; |
| 683 | 686 |
| 684 | 687 |
| 685 // Not simply an InstanceCall because it has somewhat more complicated | 688 // Not simply an InstanceCall because it has somewhat more complicated |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 696 field_name_(field_name) { | 699 field_name_(field_name) { |
| 697 inputs_[0] = receiver; | 700 inputs_[0] = receiver; |
| 698 inputs_[1] = value; | 701 inputs_[1] = value; |
| 699 } | 702 } |
| 700 | 703 |
| 701 DECLARE_COMPUTATION(InstanceSetter) | 704 DECLARE_COMPUTATION(InstanceSetter) |
| 702 | 705 |
| 703 intptr_t token_index() const { return token_index_; } | 706 intptr_t token_index() const { return token_index_; } |
| 704 intptr_t try_index() const { return try_index_; } | 707 intptr_t try_index() const { return try_index_; } |
| 705 const String& field_name() const { return field_name_; } | 708 const String& field_name() const { return field_name_; } |
| 706 Value* receiver() { return inputs_[0]; } | 709 Value* receiver() const { return inputs_[0]; } |
| 707 Value* value() { return inputs_[1]; } | 710 Value* value() const { return inputs_[1]; } |
| 708 | 711 |
| 709 private: | 712 private: |
| 710 const intptr_t token_index_; | 713 const intptr_t token_index_; |
| 711 const intptr_t try_index_; | 714 const intptr_t try_index_; |
| 712 const String& field_name_; | 715 const String& field_name_; |
| 713 | 716 |
| 714 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); | 717 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); |
| 715 }; | 718 }; |
| 716 | 719 |
| 717 | 720 |
| 718 // Not simply a StaticCall because it has somewhat more complicated | 721 // Not simply a StaticCall because it has somewhat more complicated |
| 719 // semantics: the value operand is preserved before the call. | 722 // semantics: the value operand is preserved before the call. |
| 720 class StaticSetterComp : public TemplateComputation<1> { | 723 class StaticSetterComp : public TemplateComputation<1> { |
| 721 public: | 724 public: |
| 722 StaticSetterComp(intptr_t token_index, | 725 StaticSetterComp(intptr_t token_index, |
| 723 intptr_t try_index, | 726 intptr_t try_index, |
| 724 const Function& setter_function, | 727 const Function& setter_function, |
| 725 Value* value) | 728 Value* value) |
| 726 : token_index_(token_index), | 729 : token_index_(token_index), |
| 727 try_index_(try_index), | 730 try_index_(try_index), |
| 728 setter_function_(setter_function) { | 731 setter_function_(setter_function) { |
| 729 inputs_[0] = value; | 732 inputs_[0] = value; |
| 730 } | 733 } |
| 731 | 734 |
| 732 DECLARE_COMPUTATION(StaticSetter) | 735 DECLARE_COMPUTATION(StaticSetter) |
| 733 | 736 |
| 734 intptr_t token_index() const { return token_index_; } | 737 intptr_t token_index() const { return token_index_; } |
| 735 intptr_t try_index() const { return try_index_; } | 738 intptr_t try_index() const { return try_index_; } |
| 736 const Function& setter_function() const { return setter_function_; } | 739 const Function& setter_function() const { return setter_function_; } |
| 737 Value* value() { return inputs_[0]; } | 740 Value* value() const { return inputs_[0]; } |
| 738 | 741 |
| 739 private: | 742 private: |
| 740 const intptr_t token_index_; | 743 const intptr_t token_index_; |
| 741 const intptr_t try_index_; | 744 const intptr_t try_index_; |
| 742 const Function& setter_function_; | 745 const Function& setter_function_; |
| 743 | 746 |
| 744 DISALLOW_COPY_AND_ASSIGN(StaticSetterComp); | 747 DISALLOW_COPY_AND_ASSIGN(StaticSetterComp); |
| 745 }; | 748 }; |
| 746 | 749 |
| 747 | 750 |
| 748 // Note overrideable, built-in: value? false : true. | 751 // Note overrideable, built-in: value? false : true. |
| 749 class BooleanNegateComp : public TemplateComputation<1> { | 752 class BooleanNegateComp : public TemplateComputation<1> { |
| 750 public: | 753 public: |
| 751 explicit BooleanNegateComp(Value* value) { | 754 explicit BooleanNegateComp(Value* value) { |
| 752 inputs_[0] = value; | 755 inputs_[0] = value; |
| 753 } | 756 } |
| 754 | 757 |
| 755 DECLARE_COMPUTATION(BooleanNegate) | 758 DECLARE_COMPUTATION(BooleanNegate) |
| 756 | 759 |
| 757 Value* value() { return inputs_[0]; } | 760 Value* value() const { return inputs_[0]; } |
| 758 | 761 |
| 759 private: | 762 private: |
| 760 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); | 763 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); |
| 761 }; | 764 }; |
| 762 | 765 |
| 763 | 766 |
| 764 class InstanceOfComp : public Computation { | 767 class InstanceOfComp : public Computation { |
| 765 public: | 768 public: |
| 766 InstanceOfComp(intptr_t token_index, | 769 InstanceOfComp(intptr_t token_index, |
| 767 intptr_t try_index, | 770 intptr_t try_index, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 const ClosureNode& ast_node_; | 920 const ClosureNode& ast_node_; |
| 918 const intptr_t try_index_; | 921 const intptr_t try_index_; |
| 919 Value* type_arguments_; | 922 Value* type_arguments_; |
| 920 | 923 |
| 921 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); | 924 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); |
| 922 }; | 925 }; |
| 923 | 926 |
| 924 | 927 |
| 925 class NativeLoadFieldComp : public TemplateComputation<1> { | 928 class NativeLoadFieldComp : public TemplateComputation<1> { |
| 926 public: | 929 public: |
| 927 NativeLoadFieldComp(Value* value, intptr_t offset_in_bytes) | 930 NativeLoadFieldComp(Value* value, |
| 928 : offset_in_bytes_(offset_in_bytes) { | 931 intptr_t offset_in_bytes, |
| 932 const AbstractType& type) | |
|
srdjan
2012/05/16 20:16:15
Can type be null or can you assert !type.IsNull()
regis
2012/05/16 23:20:37
Added assert for ZoneHandle and comment about allo
| |
| 933 : offset_in_bytes_(offset_in_bytes), type_(type) { | |
| 929 ASSERT(value != NULL); | 934 ASSERT(value != NULL); |
| 930 inputs_[0] = value; | 935 inputs_[0] = value; |
| 931 } | 936 } |
| 932 | 937 |
| 933 DECLARE_COMPUTATION(NativeLoadField) | 938 DECLARE_COMPUTATION(NativeLoadField) |
| 934 | 939 |
| 935 Value* value() { return inputs_[0]; } | 940 Value* value() const { return inputs_[0]; } |
| 936 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 941 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 942 const AbstractType& type() const { return type_; } | |
| 937 | 943 |
| 938 private: | 944 private: |
| 939 const intptr_t offset_in_bytes_; | 945 const intptr_t offset_in_bytes_; |
| 946 const AbstractType& type_; // Null type if loaded field is not an instance. | |
| 940 | 947 |
| 941 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); | 948 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); |
| 942 }; | 949 }; |
| 943 | 950 |
| 944 | 951 |
| 945 class NativeStoreFieldComp : public TemplateComputation<2> { | 952 class NativeStoreFieldComp : public TemplateComputation<2> { |
| 946 public: | 953 public: |
| 947 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value) | 954 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value) |
| 948 : offset_in_bytes_(offset_in_bytes) { | 955 : offset_in_bytes_(offset_in_bytes) { |
| 949 ASSERT(value != NULL); | 956 ASSERT(value != NULL); |
| 950 inputs_[0] = dest; | 957 inputs_[0] = dest; |
| 951 inputs_[1] = value; | 958 inputs_[1] = value; |
| 952 } | 959 } |
| 953 | 960 |
| 954 DECLARE_COMPUTATION(NativeStoreField) | 961 DECLARE_COMPUTATION(NativeStoreField) |
| 955 | 962 |
| 956 Value* dest() { return inputs_[0]; } | 963 Value* dest() const { return inputs_[0]; } |
| 957 Value* value() { return inputs_[1]; } | 964 Value* value() const { return inputs_[1]; } |
| 958 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 965 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 959 | 966 |
| 960 private: | 967 private: |
| 961 const intptr_t offset_in_bytes_; | 968 const intptr_t offset_in_bytes_; |
| 962 | 969 |
| 963 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); | 970 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); |
| 964 }; | 971 }; |
| 965 | 972 |
| 966 | 973 |
| 967 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { | 974 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { |
| 968 public: | 975 public: |
| 969 InstantiateTypeArgumentsComp(intptr_t token_index, | 976 InstantiateTypeArgumentsComp(intptr_t token_index, |
| 970 intptr_t try_index, | 977 intptr_t try_index, |
| 971 const AbstractTypeArguments& type_arguments, | 978 const AbstractTypeArguments& type_arguments, |
| 972 Value* instantiator) | 979 Value* instantiator) |
| 973 : token_index_(token_index), | 980 : token_index_(token_index), |
| 974 try_index_(try_index), | 981 try_index_(try_index), |
| 975 type_arguments_(type_arguments) { | 982 type_arguments_(type_arguments) { |
| 976 ASSERT(instantiator != NULL); | 983 ASSERT(instantiator != NULL); |
| 977 inputs_[0] = instantiator; | 984 inputs_[0] = instantiator; |
| 978 } | 985 } |
| 979 | 986 |
| 980 DECLARE_COMPUTATION(InstantiateTypeArguments) | 987 DECLARE_COMPUTATION(InstantiateTypeArguments) |
| 981 | 988 |
| 982 Value* instantiator() { return inputs_[0]; } | 989 Value* instantiator() const { return inputs_[0]; } |
| 983 const AbstractTypeArguments& type_arguments() const { | 990 const AbstractTypeArguments& type_arguments() const { |
| 984 return type_arguments_; | 991 return type_arguments_; |
| 985 } | 992 } |
| 986 intptr_t token_index() const { return token_index_; } | 993 intptr_t token_index() const { return token_index_; } |
| 987 intptr_t try_index() const { return try_index_; } | 994 intptr_t try_index() const { return try_index_; } |
| 988 | 995 |
| 989 private: | 996 private: |
| 990 const intptr_t token_index_; | 997 const intptr_t token_index_; |
| 991 const intptr_t try_index_; | 998 const intptr_t try_index_; |
| 992 const AbstractTypeArguments& type_arguments_; | 999 const AbstractTypeArguments& type_arguments_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1004 Value* instantiator) | 1011 Value* instantiator) |
| 1005 : token_index_(token_index), | 1012 : token_index_(token_index), |
| 1006 try_index_(try_index), | 1013 try_index_(try_index), |
| 1007 type_arguments_(type_arguments) { | 1014 type_arguments_(type_arguments) { |
| 1008 ASSERT(instantiator != NULL); | 1015 ASSERT(instantiator != NULL); |
| 1009 inputs_[0] = instantiator; | 1016 inputs_[0] = instantiator; |
| 1010 } | 1017 } |
| 1011 | 1018 |
| 1012 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) | 1019 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) |
| 1013 | 1020 |
| 1014 Value* instantiator() { return inputs_[0]; } | 1021 Value* instantiator() const { return inputs_[0]; } |
| 1015 const AbstractTypeArguments& type_arguments() const { | 1022 const AbstractTypeArguments& type_arguments() const { |
| 1016 return type_arguments_; | 1023 return type_arguments_; |
| 1017 } | 1024 } |
| 1018 intptr_t token_index() const { return token_index_; } | 1025 intptr_t token_index() const { return token_index_; } |
| 1019 intptr_t try_index() const { return try_index_; } | 1026 intptr_t try_index() const { return try_index_; } |
| 1020 | 1027 |
| 1021 private: | 1028 private: |
| 1022 const intptr_t token_index_; | 1029 const intptr_t token_index_; |
| 1023 const intptr_t try_index_; | 1030 const intptr_t try_index_; |
| 1024 const AbstractTypeArguments& type_arguments_; | 1031 const AbstractTypeArguments& type_arguments_; |
| 1025 | 1032 |
| 1026 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); | 1033 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); |
| 1027 }; | 1034 }; |
| 1028 | 1035 |
| 1029 | 1036 |
| 1030 class ExtractConstructorInstantiatorComp : public TemplateComputation<2> { | 1037 class ExtractConstructorInstantiatorComp : public TemplateComputation<2> { |
| 1031 public: | 1038 public: |
| 1032 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node, | 1039 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node, |
| 1033 Value* instantiator, | 1040 Value* instantiator, |
| 1034 Value* discard_value) | 1041 Value* discard_value) |
| 1035 : ast_node_(*ast_node) { | 1042 : ast_node_(*ast_node) { |
| 1036 ASSERT(instantiator != NULL); | 1043 ASSERT(instantiator != NULL); |
| 1037 inputs_[0] = instantiator; | 1044 inputs_[0] = instantiator; |
| 1038 inputs_[1] = discard_value; | 1045 inputs_[1] = discard_value; |
| 1039 } | 1046 } |
| 1040 | 1047 |
| 1041 DECLARE_COMPUTATION(ExtractConstructorInstantiator) | 1048 DECLARE_COMPUTATION(ExtractConstructorInstantiator) |
| 1042 | 1049 |
| 1043 Value* instantiator() { return inputs_[0]; } | 1050 Value* instantiator() const { return inputs_[0]; } |
| 1044 Value* discard_value() { return inputs_[1]; } | 1051 Value* discard_value() const { return inputs_[1]; } |
| 1045 const AbstractTypeArguments& type_arguments() const { | 1052 const AbstractTypeArguments& type_arguments() const { |
| 1046 return ast_node_.type_arguments(); | 1053 return ast_node_.type_arguments(); |
| 1047 } | 1054 } |
| 1048 const Function& constructor() const { return ast_node_.constructor(); } | 1055 const Function& constructor() const { return ast_node_.constructor(); } |
| 1049 intptr_t token_index() const { return ast_node_.token_index(); } | 1056 intptr_t token_index() const { return ast_node_.token_index(); } |
| 1050 | 1057 |
| 1051 private: | 1058 private: |
| 1052 const ConstructorCallNode& ast_node_; | 1059 const ConstructorCallNode& ast_node_; |
| 1053 | 1060 |
| 1054 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); | 1061 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1081 | 1088 |
| 1082 class ChainContextComp : public TemplateComputation<1> { | 1089 class ChainContextComp : public TemplateComputation<1> { |
| 1083 public: | 1090 public: |
| 1084 explicit ChainContextComp(Value* context_value) { | 1091 explicit ChainContextComp(Value* context_value) { |
| 1085 ASSERT(context_value != NULL); | 1092 ASSERT(context_value != NULL); |
| 1086 inputs_[0] = context_value; | 1093 inputs_[0] = context_value; |
| 1087 } | 1094 } |
| 1088 | 1095 |
| 1089 DECLARE_COMPUTATION(ChainContext) | 1096 DECLARE_COMPUTATION(ChainContext) |
| 1090 | 1097 |
| 1091 Value* context_value() { return inputs_[0]; } | 1098 Value* context_value() const { return inputs_[0]; } |
| 1092 | 1099 |
| 1093 private: | 1100 private: |
| 1094 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); | 1101 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); |
| 1095 }; | 1102 }; |
| 1096 | 1103 |
| 1097 | 1104 |
| 1098 class CloneContextComp : public TemplateComputation<1> { | 1105 class CloneContextComp : public TemplateComputation<1> { |
| 1099 public: | 1106 public: |
| 1100 CloneContextComp(intptr_t token_index, | 1107 CloneContextComp(intptr_t token_index, |
| 1101 intptr_t try_index, | 1108 intptr_t try_index, |
| 1102 Value* context_value) | 1109 Value* context_value) |
| 1103 : token_index_(token_index), | 1110 : token_index_(token_index), |
| 1104 try_index_(try_index) { | 1111 try_index_(try_index) { |
| 1105 ASSERT(context_value != NULL); | 1112 ASSERT(context_value != NULL); |
| 1106 inputs_[0] = context_value; | 1113 inputs_[0] = context_value; |
| 1107 } | 1114 } |
| 1108 | 1115 |
| 1109 intptr_t token_index() const { return token_index_; } | 1116 intptr_t token_index() const { return token_index_; } |
| 1110 intptr_t try_index() const { return try_index_; } | 1117 intptr_t try_index() const { return try_index_; } |
| 1111 Value* context_value() { return inputs_[0]; } | 1118 Value* context_value() const { return inputs_[0]; } |
| 1112 | 1119 |
| 1113 DECLARE_COMPUTATION(CloneContext) | 1120 DECLARE_COMPUTATION(CloneContext) |
| 1114 | 1121 |
| 1115 private: | 1122 private: |
| 1116 const intptr_t token_index_; | 1123 const intptr_t token_index_; |
| 1117 const intptr_t try_index_; | 1124 const intptr_t try_index_; |
| 1118 | 1125 |
| 1119 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); | 1126 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); |
| 1120 }; | 1127 }; |
| 1121 | 1128 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1239 // Mutate assigned_vars to add the local variable index for all | 1246 // Mutate assigned_vars to add the local variable index for all |
| 1240 // frame-allocated locals assigned to by the instruction. | 1247 // frame-allocated locals assigned to by the instruction. |
| 1241 virtual void RecordAssignedVars(BitVector* assigned_vars); | 1248 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 1242 | 1249 |
| 1243 #define INSTRUCTION_TYPE_CHECK(type) \ | 1250 #define INSTRUCTION_TYPE_CHECK(type) \ |
| 1244 virtual bool Is##type() const { return false; } \ | 1251 virtual bool Is##type() const { return false; } \ |
| 1245 virtual type##Instr* As##type() { return NULL; } | 1252 virtual type##Instr* As##type() { return NULL; } |
| 1246 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) | 1253 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
| 1247 #undef INSTRUCTION_TYPE_CHECK | 1254 #undef INSTRUCTION_TYPE_CHECK |
| 1248 | 1255 |
| 1256 // Static type propagation support. | |
| 1257 virtual RawAbstractType* StaticType() const = 0; | |
| 1258 | |
| 1249 private: | 1259 private: |
| 1250 intptr_t cid_; | 1260 intptr_t cid_; |
| 1251 ICData* ic_data_; | 1261 ICData* ic_data_; |
| 1252 DISALLOW_COPY_AND_ASSIGN(Instruction); | 1262 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| 1253 }; | 1263 }; |
| 1254 | 1264 |
| 1255 | 1265 |
| 1256 // Basic block entries are administrative nodes. There is a distinguished | 1266 // Basic block entries are administrative nodes. There is a distinguished |
| 1257 // graph entry with no predecessor. Joins are the only nodes with multiple | 1267 // graph entry with no predecessor. Joins are the only nodes with multiple |
| 1258 // predecessors. Targets are all other basic block entries. The types | 1268 // predecessors. Targets are all other basic block entries. The types |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1271 | 1281 |
| 1272 intptr_t postorder_number() const { return postorder_number_; } | 1282 intptr_t postorder_number() const { return postorder_number_; } |
| 1273 void set_postorder_number(intptr_t number) { postorder_number_ = number; } | 1283 void set_postorder_number(intptr_t number) { postorder_number_ = number; } |
| 1274 | 1284 |
| 1275 BlockEntryInstr* dominator() const { return dominator_; } | 1285 BlockEntryInstr* dominator() const { return dominator_; } |
| 1276 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } | 1286 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| 1277 | 1287 |
| 1278 Instruction* last_instruction() const { return last_instruction_; } | 1288 Instruction* last_instruction() const { return last_instruction_; } |
| 1279 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } | 1289 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } |
| 1280 | 1290 |
| 1291 virtual RawAbstractType* StaticType() const { | |
| 1292 UNREACHABLE(); | |
| 1293 return Type::VoidType(); | |
| 1294 } | |
| 1295 | |
| 1281 virtual void DiscoverBlocks( | 1296 virtual void DiscoverBlocks( |
| 1282 BlockEntryInstr* current_block, | 1297 BlockEntryInstr* current_block, |
| 1283 GrowableArray<BlockEntryInstr*>* preorder, | 1298 GrowableArray<BlockEntryInstr*>* preorder, |
| 1284 GrowableArray<BlockEntryInstr*>* postorder, | 1299 GrowableArray<BlockEntryInstr*>* postorder, |
| 1285 GrowableArray<intptr_t>* parent, | 1300 GrowableArray<intptr_t>* parent, |
| 1286 GrowableArray<BitVector*>* assigned_vars, | 1301 GrowableArray<BitVector*>* assigned_vars, |
| 1287 intptr_t variable_count); | 1302 intptr_t variable_count); |
| 1288 | 1303 |
| 1289 protected: | 1304 protected: |
| 1290 BlockEntryInstr() | 1305 BlockEntryInstr() |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 Computation* computation() const { return computation_; } | 1451 Computation* computation() const { return computation_; } |
| 1437 | 1452 |
| 1438 virtual Instruction* StraightLineSuccessor() const { | 1453 virtual Instruction* StraightLineSuccessor() const { |
| 1439 return successor_; | 1454 return successor_; |
| 1440 } | 1455 } |
| 1441 virtual void SetSuccessor(Instruction* instr) { | 1456 virtual void SetSuccessor(Instruction* instr) { |
| 1442 ASSERT(successor_ == NULL); | 1457 ASSERT(successor_ == NULL); |
| 1443 successor_ = instr; | 1458 successor_ = instr; |
| 1444 } | 1459 } |
| 1445 | 1460 |
| 1461 // Static type propagation support. | |
| 1462 virtual RawAbstractType* StaticType() const { | |
| 1463 return computation()->StaticType(); | |
|
srdjan
2012/05/16 20:16:15
When would you need the static type of a DoInstr?
regis
2012/05/16 23:20:37
You are right. Never needed. Changed to UNREACHABL
| |
| 1464 } | |
| 1465 | |
| 1446 virtual void RecordAssignedVars(BitVector* assigned_vars); | 1466 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 1447 | 1467 |
| 1448 private: | 1468 private: |
| 1449 Computation* computation_; | 1469 Computation* computation_; |
| 1450 Instruction* successor_; | 1470 Instruction* successor_; |
| 1451 | 1471 |
| 1452 DISALLOW_COPY_AND_ASSIGN(DoInstr); | 1472 DISALLOW_COPY_AND_ASSIGN(DoInstr); |
| 1453 }; | 1473 }; |
| 1454 | 1474 |
| 1455 | 1475 |
| 1456 class Definition : public Instruction { | 1476 class Definition : public Instruction { |
| 1457 public: | 1477 public: |
| 1458 Definition() : temp_index_(-1) { } | 1478 Definition() : temp_index_(-1) { } |
| 1459 | 1479 |
| 1460 virtual bool IsDefinition() const { return true; } | 1480 virtual bool IsDefinition() const { return true; } |
| 1461 | 1481 |
| 1462 intptr_t temp_index() const { return temp_index_; } | 1482 intptr_t temp_index() const { return temp_index_; } |
| 1463 void set_temp_index(intptr_t index) { temp_index_ = index; } | 1483 void set_temp_index(intptr_t index) { temp_index_ = index; } |
| 1464 | 1484 |
| 1485 // Static type propagation support. | |
| 1486 virtual RawAbstractType* StaticType() const = 0; | |
| 1487 | |
| 1465 private: | 1488 private: |
| 1466 intptr_t temp_index_; | 1489 intptr_t temp_index_; |
| 1467 | 1490 |
| 1468 DISALLOW_COPY_AND_ASSIGN(Definition); | 1491 DISALLOW_COPY_AND_ASSIGN(Definition); |
| 1469 }; | 1492 }; |
| 1470 | 1493 |
| 1471 | 1494 |
| 1472 class BindInstr : public Definition { | 1495 class BindInstr : public Definition { |
| 1473 public: | 1496 public: |
| 1474 explicit BindInstr(Computation* computation) | 1497 explicit BindInstr(Computation* computation) |
| 1475 : Definition(), computation_(computation), successor_(NULL) { } | 1498 : Definition(), computation_(computation), successor_(NULL) { } |
| 1476 | 1499 |
| 1477 DECLARE_INSTRUCTION(Bind) | 1500 DECLARE_INSTRUCTION(Bind) |
| 1478 | 1501 |
| 1479 Computation* computation() const { return computation_; } | 1502 Computation* computation() const { return computation_; } |
| 1480 | 1503 |
| 1481 virtual Instruction* StraightLineSuccessor() const { | 1504 virtual Instruction* StraightLineSuccessor() const { |
| 1482 return successor_; | 1505 return successor_; |
| 1483 } | 1506 } |
| 1484 virtual void SetSuccessor(Instruction* instr) { | 1507 virtual void SetSuccessor(Instruction* instr) { |
| 1485 ASSERT(successor_ == NULL); | 1508 ASSERT(successor_ == NULL); |
| 1486 successor_ = instr; | 1509 successor_ = instr; |
| 1487 } | 1510 } |
| 1488 | 1511 |
| 1512 // Static type propagation support. | |
| 1513 virtual RawAbstractType* StaticType() const { | |
| 1514 return computation()->StaticType(); | |
| 1515 } | |
| 1516 | |
| 1489 virtual void RecordAssignedVars(BitVector* assigned_vars); | 1517 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 1490 | 1518 |
| 1491 private: | 1519 private: |
| 1492 Computation* computation_; | 1520 Computation* computation_; |
| 1493 Instruction* successor_; | 1521 Instruction* successor_; |
| 1494 | 1522 |
| 1495 DISALLOW_COPY_AND_ASSIGN(BindInstr); | 1523 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
| 1496 }; | 1524 }; |
| 1497 | 1525 |
| 1498 | 1526 |
| 1499 class ReturnInstr : public Instruction { | 1527 class ReturnInstr : public Instruction { |
| 1500 public: | 1528 public: |
| 1501 ReturnInstr(intptr_t token_index, Value* value) | 1529 ReturnInstr(intptr_t token_index, Value* value) |
| 1502 : token_index_(token_index), value_(value) { | 1530 : token_index_(token_index), value_(value) { |
| 1503 ASSERT(value_ != NULL); | 1531 ASSERT(value_ != NULL); |
| 1504 } | 1532 } |
| 1505 | 1533 |
| 1506 DECLARE_INSTRUCTION(Return) | 1534 DECLARE_INSTRUCTION(Return) |
| 1507 | 1535 |
| 1508 Value* value() const { return value_; } | 1536 Value* value() const { return value_; } |
| 1509 intptr_t token_index() const { return token_index_; } | 1537 intptr_t token_index() const { return token_index_; } |
| 1510 | 1538 |
| 1511 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 1539 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 1512 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1540 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1513 | 1541 |
| 1542 virtual RawAbstractType* StaticType() const { | |
| 1543 UNREACHABLE(); | |
| 1544 return Type::VoidType(); | |
|
srdjan
2012/05/16 20:16:15
Maybe move this into Instructions, so that you do
regis
2012/05/16 23:20:37
Good point. Done.
| |
| 1545 } | |
| 1546 | |
| 1514 private: | 1547 private: |
| 1515 const intptr_t token_index_; | 1548 const intptr_t token_index_; |
| 1516 Value* value_; | 1549 Value* value_; |
| 1517 | 1550 |
| 1518 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); | 1551 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); |
| 1519 }; | 1552 }; |
| 1520 | 1553 |
| 1521 | 1554 |
| 1522 class ThrowInstr : public Instruction { | 1555 class ThrowInstr : public Instruction { |
| 1523 public: | 1556 public: |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1537 intptr_t try_index() const { return try_index_; } | 1570 intptr_t try_index() const { return try_index_; } |
| 1538 Value* exception() const { return exception_; } | 1571 Value* exception() const { return exception_; } |
| 1539 | 1572 |
| 1540 // Parser can generate a throw within an expression tree. We never | 1573 // Parser can generate a throw within an expression tree. We never |
| 1541 // add successor instructions to the graph. | 1574 // add successor instructions to the graph. |
| 1542 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 1575 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 1543 virtual void SetSuccessor(Instruction* instr) { | 1576 virtual void SetSuccessor(Instruction* instr) { |
| 1544 ASSERT(successor_ == NULL); | 1577 ASSERT(successor_ == NULL); |
| 1545 } | 1578 } |
| 1546 | 1579 |
| 1580 virtual RawAbstractType* StaticType() const { | |
| 1581 UNREACHABLE(); | |
| 1582 return Type::VoidType(); | |
| 1583 } | |
| 1584 | |
| 1547 private: | 1585 private: |
| 1548 const intptr_t token_index_; | 1586 const intptr_t token_index_; |
| 1549 const intptr_t try_index_; | 1587 const intptr_t try_index_; |
| 1550 Value* exception_; | 1588 Value* exception_; |
| 1551 Instruction* successor_; | 1589 Instruction* successor_; |
| 1552 | 1590 |
| 1553 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); | 1591 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
| 1554 }; | 1592 }; |
| 1555 | 1593 |
| 1556 | 1594 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1578 | 1616 |
| 1579 // Parser can generate a rethrow within an expression tree. We | 1617 // Parser can generate a rethrow within an expression tree. We |
| 1580 // never add successor instructions to the graph. | 1618 // never add successor instructions to the graph. |
| 1581 virtual Instruction* StraightLineSuccessor() const { | 1619 virtual Instruction* StraightLineSuccessor() const { |
| 1582 return NULL; | 1620 return NULL; |
| 1583 } | 1621 } |
| 1584 virtual void SetSuccessor(Instruction* instr) { | 1622 virtual void SetSuccessor(Instruction* instr) { |
| 1585 ASSERT(successor_ == NULL); | 1623 ASSERT(successor_ == NULL); |
| 1586 } | 1624 } |
| 1587 | 1625 |
| 1626 virtual RawAbstractType* StaticType() const { | |
| 1627 UNREACHABLE(); | |
| 1628 return Type::VoidType(); | |
| 1629 } | |
| 1630 | |
| 1588 private: | 1631 private: |
| 1589 const intptr_t token_index_; | 1632 const intptr_t token_index_; |
| 1590 const intptr_t try_index_; | 1633 const intptr_t try_index_; |
| 1591 Value* exception_; | 1634 Value* exception_; |
| 1592 Value* stack_trace_; | 1635 Value* stack_trace_; |
| 1593 Instruction* successor_; | 1636 Instruction* successor_; |
| 1594 | 1637 |
| 1595 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); | 1638 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
| 1596 }; | 1639 }; |
| 1597 | 1640 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1616 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1659 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1617 | 1660 |
| 1618 virtual void DiscoverBlocks( | 1661 virtual void DiscoverBlocks( |
| 1619 BlockEntryInstr* current_block, | 1662 BlockEntryInstr* current_block, |
| 1620 GrowableArray<BlockEntryInstr*>* preorder, | 1663 GrowableArray<BlockEntryInstr*>* preorder, |
| 1621 GrowableArray<BlockEntryInstr*>* postorder, | 1664 GrowableArray<BlockEntryInstr*>* postorder, |
| 1622 GrowableArray<intptr_t>* parent, | 1665 GrowableArray<intptr_t>* parent, |
| 1623 GrowableArray<BitVector*>* assigned_vars, | 1666 GrowableArray<BitVector*>* assigned_vars, |
| 1624 intptr_t variable_count); | 1667 intptr_t variable_count); |
| 1625 | 1668 |
| 1669 virtual RawAbstractType* StaticType() const { | |
| 1670 UNREACHABLE(); | |
| 1671 return Type::VoidType(); | |
| 1672 } | |
| 1673 | |
| 1626 private: | 1674 private: |
| 1627 Value* value_; | 1675 Value* value_; |
| 1628 TargetEntryInstr* true_successor_; | 1676 TargetEntryInstr* true_successor_; |
| 1629 TargetEntryInstr* false_successor_; | 1677 TargetEntryInstr* false_successor_; |
| 1630 | 1678 |
| 1631 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 1679 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
| 1632 }; | 1680 }; |
| 1633 | 1681 |
| 1634 #undef DECLARE_INSTRUCTION | 1682 #undef DECLARE_INSTRUCTION |
| 1635 | 1683 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1671 const GrowableArray<BlockEntryInstr*>& block_order_; | 1719 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1672 | 1720 |
| 1673 private: | 1721 private: |
| 1674 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1722 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1675 }; | 1723 }; |
| 1676 | 1724 |
| 1677 | 1725 |
| 1678 } // namespace dart | 1726 } // namespace dart |
| 1679 | 1727 |
| 1680 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1728 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |