Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 10399051: First shot at static type propagation and type test elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 of the computation.
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
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
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
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
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
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
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
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
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
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
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)
933 : offset_in_bytes_(offset_in_bytes), type_(type) {
929 ASSERT(value != NULL); 934 ASSERT(value != NULL);
935 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance.
930 inputs_[0] = value; 936 inputs_[0] = value;
931 } 937 }
932 938
933 DECLARE_COMPUTATION(NativeLoadField) 939 DECLARE_COMPUTATION(NativeLoadField)
934 940
935 Value* value() { return inputs_[0]; } 941 Value* value() const { return inputs_[0]; }
936 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 942 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
943 const AbstractType& type() const { return type_; }
937 944
938 private: 945 private:
939 const intptr_t offset_in_bytes_; 946 const intptr_t offset_in_bytes_;
947 const AbstractType& type_;
940 948
941 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); 949 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp);
942 }; 950 };
943 951
944 952
945 class NativeStoreFieldComp : public TemplateComputation<2> { 953 class NativeStoreFieldComp : public TemplateComputation<2> {
946 public: 954 public:
947 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value) 955 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value)
948 : offset_in_bytes_(offset_in_bytes) { 956 : offset_in_bytes_(offset_in_bytes) {
949 ASSERT(value != NULL); 957 ASSERT(value != NULL);
950 inputs_[0] = dest; 958 inputs_[0] = dest;
951 inputs_[1] = value; 959 inputs_[1] = value;
952 } 960 }
953 961
954 DECLARE_COMPUTATION(NativeStoreField) 962 DECLARE_COMPUTATION(NativeStoreField)
955 963
956 Value* dest() { return inputs_[0]; } 964 Value* dest() const { return inputs_[0]; }
957 Value* value() { return inputs_[1]; } 965 Value* value() const { return inputs_[1]; }
958 intptr_t offset_in_bytes() const { return offset_in_bytes_; } 966 intptr_t offset_in_bytes() const { return offset_in_bytes_; }
959 967
960 private: 968 private:
961 const intptr_t offset_in_bytes_; 969 const intptr_t offset_in_bytes_;
962 970
963 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); 971 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp);
964 }; 972 };
965 973
966 974
967 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { 975 class InstantiateTypeArgumentsComp : public TemplateComputation<1> {
968 public: 976 public:
969 InstantiateTypeArgumentsComp(intptr_t token_index, 977 InstantiateTypeArgumentsComp(intptr_t token_index,
970 intptr_t try_index, 978 intptr_t try_index,
971 const AbstractTypeArguments& type_arguments, 979 const AbstractTypeArguments& type_arguments,
972 Value* instantiator) 980 Value* instantiator)
973 : token_index_(token_index), 981 : token_index_(token_index),
974 try_index_(try_index), 982 try_index_(try_index),
975 type_arguments_(type_arguments) { 983 type_arguments_(type_arguments) {
976 ASSERT(instantiator != NULL); 984 ASSERT(instantiator != NULL);
977 inputs_[0] = instantiator; 985 inputs_[0] = instantiator;
978 } 986 }
979 987
980 DECLARE_COMPUTATION(InstantiateTypeArguments) 988 DECLARE_COMPUTATION(InstantiateTypeArguments)
981 989
982 Value* instantiator() { return inputs_[0]; } 990 Value* instantiator() const { return inputs_[0]; }
983 const AbstractTypeArguments& type_arguments() const { 991 const AbstractTypeArguments& type_arguments() const {
984 return type_arguments_; 992 return type_arguments_;
985 } 993 }
986 intptr_t token_index() const { return token_index_; } 994 intptr_t token_index() const { return token_index_; }
987 intptr_t try_index() const { return try_index_; } 995 intptr_t try_index() const { return try_index_; }
988 996
989 private: 997 private:
990 const intptr_t token_index_; 998 const intptr_t token_index_;
991 const intptr_t try_index_; 999 const intptr_t try_index_;
992 const AbstractTypeArguments& type_arguments_; 1000 const AbstractTypeArguments& type_arguments_;
(...skipping 11 matching lines...) Expand all
1004 Value* instantiator) 1012 Value* instantiator)
1005 : token_index_(token_index), 1013 : token_index_(token_index),
1006 try_index_(try_index), 1014 try_index_(try_index),
1007 type_arguments_(type_arguments) { 1015 type_arguments_(type_arguments) {
1008 ASSERT(instantiator != NULL); 1016 ASSERT(instantiator != NULL);
1009 inputs_[0] = instantiator; 1017 inputs_[0] = instantiator;
1010 } 1018 }
1011 1019
1012 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) 1020 DECLARE_COMPUTATION(ExtractConstructorTypeArguments)
1013 1021
1014 Value* instantiator() { return inputs_[0]; } 1022 Value* instantiator() const { return inputs_[0]; }
1015 const AbstractTypeArguments& type_arguments() const { 1023 const AbstractTypeArguments& type_arguments() const {
1016 return type_arguments_; 1024 return type_arguments_;
1017 } 1025 }
1018 intptr_t token_index() const { return token_index_; } 1026 intptr_t token_index() const { return token_index_; }
1019 intptr_t try_index() const { return try_index_; } 1027 intptr_t try_index() const { return try_index_; }
1020 1028
1021 private: 1029 private:
1022 const intptr_t token_index_; 1030 const intptr_t token_index_;
1023 const intptr_t try_index_; 1031 const intptr_t try_index_;
1024 const AbstractTypeArguments& type_arguments_; 1032 const AbstractTypeArguments& type_arguments_;
1025 1033
1026 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); 1034 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp);
1027 }; 1035 };
1028 1036
1029 1037
1030 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { 1038 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> {
1031 public: 1039 public:
1032 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node, 1040 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node,
1033 Value* instantiator) 1041 Value* instantiator)
1034 : ast_node_(*ast_node) { 1042 : ast_node_(*ast_node) {
1035 ASSERT(instantiator != NULL); 1043 ASSERT(instantiator != NULL);
1036 inputs_[0] = instantiator; 1044 inputs_[0] = instantiator;
1037 } 1045 }
1038 1046
1039 DECLARE_COMPUTATION(ExtractConstructorInstantiator) 1047 DECLARE_COMPUTATION(ExtractConstructorInstantiator)
1040 1048
1041 Value* instantiator() { return inputs_[0]; } 1049 Value* instantiator() const { return inputs_[0]; }
1042 const AbstractTypeArguments& type_arguments() const { 1050 const AbstractTypeArguments& type_arguments() const {
1043 return ast_node_.type_arguments(); 1051 return ast_node_.type_arguments();
1044 } 1052 }
1045 const Function& constructor() const { return ast_node_.constructor(); } 1053 const Function& constructor() const { return ast_node_.constructor(); }
1046 intptr_t token_index() const { return ast_node_.token_index(); } 1054 intptr_t token_index() const { return ast_node_.token_index(); }
1047 1055
1048 private: 1056 private:
1049 const ConstructorCallNode& ast_node_; 1057 const ConstructorCallNode& ast_node_;
1050 1058
1051 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); 1059 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp);
(...skipping 26 matching lines...) Expand all
1078 1086
1079 class ChainContextComp : public TemplateComputation<1> { 1087 class ChainContextComp : public TemplateComputation<1> {
1080 public: 1088 public:
1081 explicit ChainContextComp(Value* context_value) { 1089 explicit ChainContextComp(Value* context_value) {
1082 ASSERT(context_value != NULL); 1090 ASSERT(context_value != NULL);
1083 inputs_[0] = context_value; 1091 inputs_[0] = context_value;
1084 } 1092 }
1085 1093
1086 DECLARE_COMPUTATION(ChainContext) 1094 DECLARE_COMPUTATION(ChainContext)
1087 1095
1088 Value* context_value() { return inputs_[0]; } 1096 Value* context_value() const { return inputs_[0]; }
1089 1097
1090 private: 1098 private:
1091 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); 1099 DISALLOW_COPY_AND_ASSIGN(ChainContextComp);
1092 }; 1100 };
1093 1101
1094 1102
1095 class CloneContextComp : public TemplateComputation<1> { 1103 class CloneContextComp : public TemplateComputation<1> {
1096 public: 1104 public:
1097 CloneContextComp(intptr_t token_index, 1105 CloneContextComp(intptr_t token_index,
1098 intptr_t try_index, 1106 intptr_t try_index,
1099 Value* context_value) 1107 Value* context_value)
1100 : token_index_(token_index), 1108 : token_index_(token_index),
1101 try_index_(try_index) { 1109 try_index_(try_index) {
1102 ASSERT(context_value != NULL); 1110 ASSERT(context_value != NULL);
1103 inputs_[0] = context_value; 1111 inputs_[0] = context_value;
1104 } 1112 }
1105 1113
1106 intptr_t token_index() const { return token_index_; } 1114 intptr_t token_index() const { return token_index_; }
1107 intptr_t try_index() const { return try_index_; } 1115 intptr_t try_index() const { return try_index_; }
1108 Value* context_value() { return inputs_[0]; } 1116 Value* context_value() const { return inputs_[0]; }
1109 1117
1110 DECLARE_COMPUTATION(CloneContext) 1118 DECLARE_COMPUTATION(CloneContext)
1111 1119
1112 private: 1120 private:
1113 const intptr_t token_index_; 1121 const intptr_t token_index_;
1114 const intptr_t try_index_; 1122 const intptr_t try_index_;
1115 1123
1116 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); 1124 DISALLOW_COPY_AND_ASSIGN(CloneContextComp);
1117 }; 1125 };
1118 1126
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 // Mutate assigned_vars to add the local variable index for all 1244 // Mutate assigned_vars to add the local variable index for all
1237 // frame-allocated locals assigned to by the instruction. 1245 // frame-allocated locals assigned to by the instruction.
1238 virtual void RecordAssignedVars(BitVector* assigned_vars); 1246 virtual void RecordAssignedVars(BitVector* assigned_vars);
1239 1247
1240 #define INSTRUCTION_TYPE_CHECK(type) \ 1248 #define INSTRUCTION_TYPE_CHECK(type) \
1241 virtual bool Is##type() const { return false; } \ 1249 virtual bool Is##type() const { return false; } \
1242 virtual type##Instr* As##type() { return NULL; } 1250 virtual type##Instr* As##type() { return NULL; }
1243 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 1251 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
1244 #undef INSTRUCTION_TYPE_CHECK 1252 #undef INSTRUCTION_TYPE_CHECK
1245 1253
1254 // Static type of the instruction.
1255 virtual RawAbstractType* StaticType() const {
1256 UNREACHABLE();
1257 return AbstractType::null();
1258 }
1259
1246 private: 1260 private:
1247 intptr_t cid_; 1261 intptr_t cid_;
1248 ICData* ic_data_; 1262 ICData* ic_data_;
1249 DISALLOW_COPY_AND_ASSIGN(Instruction); 1263 DISALLOW_COPY_AND_ASSIGN(Instruction);
1250 }; 1264 };
1251 1265
1252 1266
1253 // Basic block entries are administrative nodes. There is a distinguished 1267 // Basic block entries are administrative nodes. There is a distinguished
1254 // graph entry with no predecessor. Joins are the only nodes with multiple 1268 // graph entry with no predecessor. Joins are the only nodes with multiple
1255 // predecessors. Targets are all other basic block entries. The types 1269 // predecessors. Targets are all other basic block entries. The types
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 Computation* computation() const { return computation_; } 1490 Computation* computation() const { return computation_; }
1477 1491
1478 virtual Instruction* StraightLineSuccessor() const { 1492 virtual Instruction* StraightLineSuccessor() const {
1479 return successor_; 1493 return successor_;
1480 } 1494 }
1481 virtual void SetSuccessor(Instruction* instr) { 1495 virtual void SetSuccessor(Instruction* instr) {
1482 ASSERT(successor_ == NULL); 1496 ASSERT(successor_ == NULL);
1483 successor_ = instr; 1497 successor_ = instr;
1484 } 1498 }
1485 1499
1500 // Static type of the underlying computation.
1501 virtual RawAbstractType* StaticType() const {
1502 return computation()->StaticType();
1503 }
1504
1486 virtual void RecordAssignedVars(BitVector* assigned_vars); 1505 virtual void RecordAssignedVars(BitVector* assigned_vars);
1487 1506
1488 private: 1507 private:
1489 Computation* computation_; 1508 Computation* computation_;
1490 Instruction* successor_; 1509 Instruction* successor_;
1491 1510
1492 DISALLOW_COPY_AND_ASSIGN(BindInstr); 1511 DISALLOW_COPY_AND_ASSIGN(BindInstr);
1493 }; 1512 };
1494 1513
1495 1514
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 const GrowableArray<BlockEntryInstr*>& block_order_; 1687 const GrowableArray<BlockEntryInstr*>& block_order_;
1669 1688
1670 private: 1689 private:
1671 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 1690 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
1672 }; 1691 };
1673 1692
1674 1693
1675 } // namespace dart 1694 } // namespace dart
1676 1695
1677 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 1696 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698