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

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

Issue 10264031: Switch from AST node ids to computation ids (cid). In addition to computations,… (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_compiler_x64.cc ('k') | runtime/vm/isolate.h » ('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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 M(CloneContext, CloneContextComp) \ 61 M(CloneContext, CloneContextComp) \
62 M(CatchEntry, CatchEntryComp) \ 62 M(CatchEntry, CatchEntryComp) \
63 63
64 64
65 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 65 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
66 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 66 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
67 #undef FORWARD_DECLARATION 67 #undef FORWARD_DECLARATION
68 68
69 class Computation : public ZoneAllocated { 69 class Computation : public ZoneAllocated {
70 public: 70 public:
71 Computation() { } 71 static const int kNoCid = -1;
72
73 Computation() : cid_(GetNextCid()) { }
74
75 // Unique computation/instruction id, used for deoptimization.
76 intptr_t cid() const { return cid_; }
72 77
73 // Visiting support. 78 // Visiting support.
74 virtual void Accept(FlowGraphVisitor* visitor) = 0; 79 virtual void Accept(FlowGraphVisitor* visitor) = 0;
75 80
76 private: 81 private:
82 friend class Instruction;
83 static intptr_t GetNextCid() {
84 Isolate* isolate = Isolate::Current();
85 intptr_t tmp = isolate->computation_id();
86 isolate->set_computation_id(tmp + 1);
87 return tmp;
88 }
89
90 const intptr_t cid_;
91
77 DISALLOW_COPY_AND_ASSIGN(Computation); 92 DISALLOW_COPY_AND_ASSIGN(Computation);
78 }; 93 };
79 94
80 95
81 class Value : public Computation { 96 class Value : public Computation {
82 public: 97 public:
83 Value() { } 98 Value() { }
84 99
85 #define DEFINE_TESTERS(ShortName, ClassName) \ 100 #define DEFINE_TESTERS(ShortName, ClassName) \
86 virtual ClassName* As##ShortName() { return NULL; } \ 101 virtual ClassName* As##ShortName() { return NULL; } \
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const Object& value_; 166 const Object& value_;
152 167
153 DISALLOW_COPY_AND_ASSIGN(ConstantVal); 168 DISALLOW_COPY_AND_ASSIGN(ConstantVal);
154 }; 169 };
155 170
156 #undef DECLARE_VALUE 171 #undef DECLARE_VALUE
157 172
158 173
159 class AssertAssignableComp : public Computation { 174 class AssertAssignableComp : public Computation {
160 public: 175 public:
161 AssertAssignableComp(intptr_t node_id, 176 AssertAssignableComp(intptr_t token_index,
162 intptr_t token_index,
163 intptr_t try_index, 177 intptr_t try_index,
164 Value* value, 178 Value* value,
165 Value* instantiator_type_arguments, // Can be NULL. 179 Value* instantiator_type_arguments, // Can be NULL.
166 const AbstractType& dst_type, 180 const AbstractType& dst_type,
167 const String& dst_name) 181 const String& dst_name)
168 : node_id_(node_id), 182 : token_index_(token_index),
169 token_index_(token_index),
170 try_index_(try_index), 183 try_index_(try_index),
171 value_(value), 184 value_(value),
172 instantiator_type_arguments_(instantiator_type_arguments), 185 instantiator_type_arguments_(instantiator_type_arguments),
173 dst_type_(dst_type), 186 dst_type_(dst_type),
174 dst_name_(dst_name) { 187 dst_name_(dst_name) {
175 ASSERT(value_ != NULL); 188 ASSERT(value_ != NULL);
176 ASSERT(!dst_type.IsNull()); 189 ASSERT(!dst_type.IsNull());
177 ASSERT(!dst_name.IsNull()); 190 ASSERT(!dst_name.IsNull());
178 } 191 }
179 192
180 DECLARE_COMPUTATION(AssertAssignable) 193 DECLARE_COMPUTATION(AssertAssignable)
181 194
182 intptr_t node_id() const { return node_id_; }
183 intptr_t token_index() const { return token_index_; } 195 intptr_t token_index() const { return token_index_; }
184 intptr_t try_index() const { return try_index_; } 196 intptr_t try_index() const { return try_index_; }
185 Value* value() const { return value_; } 197 Value* value() const { return value_; }
186 Value* instantiator_type_arguments() const { 198 Value* instantiator_type_arguments() const {
187 return instantiator_type_arguments_; 199 return instantiator_type_arguments_;
188 } 200 }
189 const AbstractType& dst_type() const { return dst_type_; } 201 const AbstractType& dst_type() const { return dst_type_; }
190 const String& dst_name() const { return dst_name_; } 202 const String& dst_name() const { return dst_name_; }
191 203
192 private: 204 private:
193 const intptr_t node_id_;
194 const intptr_t token_index_; 205 const intptr_t token_index_;
195 const intptr_t try_index_; 206 const intptr_t try_index_;
196 Value* value_; 207 Value* value_;
197 Value* instantiator_type_arguments_; 208 Value* instantiator_type_arguments_;
198 const AbstractType& dst_type_; 209 const AbstractType& dst_type_;
199 const String& dst_name_; 210 const String& dst_name_;
200 211
201 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); 212 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp);
202 }; 213 };
203 214
204 215
205 class AssertBooleanComp : public Computation { 216 class AssertBooleanComp : public Computation {
206 public: 217 public:
207 AssertBooleanComp(intptr_t node_id, 218 AssertBooleanComp(intptr_t token_index,
208 intptr_t token_index,
209 intptr_t try_index, 219 intptr_t try_index,
210 Value* value) 220 Value* value)
211 : node_id_(node_id), 221 : token_index_(token_index),
212 token_index_(token_index),
213 try_index_(try_index), 222 try_index_(try_index),
214 value_(value) { 223 value_(value) {
215 ASSERT(value_ != NULL); 224 ASSERT(value_ != NULL);
216 } 225 }
217 226
218 DECLARE_COMPUTATION(AssertBoolean) 227 DECLARE_COMPUTATION(AssertBoolean)
219 228
220 intptr_t node_id() const { return node_id_; }
221 intptr_t token_index() const { return token_index_; } 229 intptr_t token_index() const { return token_index_; }
222 intptr_t try_index() const { return try_index_; } 230 intptr_t try_index() const { return try_index_; }
223 Value* value() const { return value_; } 231 Value* value() const { return value_; }
224 232
225 private: 233 private:
226 const intptr_t node_id_;
227 const intptr_t token_index_; 234 const intptr_t token_index_;
228 const intptr_t try_index_; 235 const intptr_t try_index_;
229 Value* value_; 236 Value* value_;
230 237
231 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); 238 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp);
232 }; 239 };
233 240
234 241
235 // Denotes the current context, normally held in a register. This is 242 // Denotes the current context, normally held in a register. This is
236 // a computation, not a value, because it's mutable. 243 // a computation, not a value, because it's mutable.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 const intptr_t try_index_; 297 const intptr_t try_index_;
291 Value* context_; 298 Value* context_;
292 ZoneGrowableArray<Value*>* arguments_; 299 ZoneGrowableArray<Value*>* arguments_;
293 300
294 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); 301 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp);
295 }; 302 };
296 303
297 304
298 class InstanceCallComp : public Computation { 305 class InstanceCallComp : public Computation {
299 public: 306 public:
300 InstanceCallComp(intptr_t node_id, 307 InstanceCallComp(intptr_t token_index,
301 intptr_t token_index,
302 intptr_t try_index, 308 intptr_t try_index,
303 const String& function_name, 309 const String& function_name,
304 ZoneGrowableArray<Value*>* arguments, 310 ZoneGrowableArray<Value*>* arguments,
305 const Array& argument_names, 311 const Array& argument_names,
306 intptr_t checked_argument_count) 312 intptr_t checked_argument_count)
307 : node_id_(node_id), 313 : token_index_(token_index),
308 token_index_(token_index),
309 try_index_(try_index), 314 try_index_(try_index),
310 function_name_(function_name), 315 function_name_(function_name),
311 arguments_(arguments), 316 arguments_(arguments),
312 argument_names_(argument_names), 317 argument_names_(argument_names),
313 checked_argument_count_(checked_argument_count) { 318 checked_argument_count_(checked_argument_count) {
314 ASSERT(function_name.IsZoneHandle()); 319 ASSERT(function_name.IsZoneHandle());
315 ASSERT(!arguments->is_empty()); 320 ASSERT(!arguments->is_empty());
316 ASSERT(argument_names.IsZoneHandle()); 321 ASSERT(argument_names.IsZoneHandle());
317 } 322 }
318 323
319 DECLARE_COMPUTATION(InstanceCall) 324 DECLARE_COMPUTATION(InstanceCall)
320 325
321 intptr_t node_id() const { return node_id_; }
322 intptr_t token_index() const { return token_index_; } 326 intptr_t token_index() const { return token_index_; }
323 intptr_t try_index() const { return try_index_; } 327 intptr_t try_index() const { return try_index_; }
324 const String& function_name() const { return function_name_; } 328 const String& function_name() const { return function_name_; }
325 intptr_t ArgumentCount() const { return arguments_->length(); } 329 intptr_t ArgumentCount() const { return arguments_->length(); }
326 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } 330 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; }
327 const Array& argument_names() const { return argument_names_; } 331 const Array& argument_names() const { return argument_names_; }
328 intptr_t checked_argument_count() const { return checked_argument_count_; } 332 intptr_t checked_argument_count() const { return checked_argument_count_; }
329 333
330 private: 334 private:
331 const intptr_t node_id_;
332 const intptr_t token_index_; 335 const intptr_t token_index_;
333 const intptr_t try_index_; 336 const intptr_t try_index_;
334 const String& function_name_; 337 const String& function_name_;
335 ZoneGrowableArray<Value*>* const arguments_; 338 ZoneGrowableArray<Value*>* const arguments_;
336 const Array& argument_names_; 339 const Array& argument_names_;
337 const intptr_t checked_argument_count_; 340 const intptr_t checked_argument_count_;
338 341
339 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); 342 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp);
340 }; 343 };
341 344
(...skipping 15 matching lines...) Expand all
357 const Token::Kind kind_; 360 const Token::Kind kind_;
358 Value* left_; 361 Value* left_;
359 Value* right_; 362 Value* right_;
360 363
361 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 364 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
362 }; 365 };
363 366
364 367
365 class EqualityCompareComp : public Computation { 368 class EqualityCompareComp : public Computation {
366 public: 369 public:
367 EqualityCompareComp(intptr_t node_id, 370 EqualityCompareComp(intptr_t token_index,
368 intptr_t token_index,
369 intptr_t try_index, 371 intptr_t try_index,
370 Value* left, 372 Value* left,
371 Value* right) 373 Value* right)
372 : node_id_(node_id), 374 : token_index_(token_index),
373 token_index_(token_index),
374 try_index_(try_index), 375 try_index_(try_index),
375 left_(left), 376 left_(left),
376 right_(right) { 377 right_(right) {
377 ASSERT(left_ != NULL); 378 ASSERT(left_ != NULL);
378 ASSERT(right_ != NULL); 379 ASSERT(right_ != NULL);
379 } 380 }
380 381
381 DECLARE_COMPUTATION(EqualityCompareComp) 382 DECLARE_COMPUTATION(EqualityCompareComp)
382 383
383 intptr_t node_id() const { return node_id_; }
384 intptr_t token_index() const { return token_index_; } 384 intptr_t token_index() const { return token_index_; }
385 intptr_t try_index() const { return try_index_; } 385 intptr_t try_index() const { return try_index_; }
386 Value* left() const { return left_; } 386 Value* left() const { return left_; }
387 Value* right() const { return right_; } 387 Value* right() const { return right_; }
388 388
389 private: 389 private:
390 const intptr_t node_id_;
391 const intptr_t token_index_; 390 const intptr_t token_index_;
392 const intptr_t try_index_; 391 const intptr_t try_index_;
393 Value* left_; 392 Value* left_;
394 Value* right_; 393 Value* right_;
395 394
396 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); 395 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp);
397 }; 396 };
398 397
399 398
400 class StaticCallComp : public Computation { 399 class StaticCallComp : public Computation {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, 532 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node,
534 Value* instance, 533 Value* instance,
535 Value* value) 534 Value* value)
536 : ast_node_(*ast_node), instance_(instance), value_(value) { 535 : ast_node_(*ast_node), instance_(instance), value_(value) {
537 ASSERT(instance_ != NULL); 536 ASSERT(instance_ != NULL);
538 ASSERT(value_ != NULL); 537 ASSERT(value_ != NULL);
539 } 538 }
540 539
541 DECLARE_COMPUTATION(StoreInstanceField) 540 DECLARE_COMPUTATION(StoreInstanceField)
542 541
543 intptr_t node_id() const { return ast_node_.id(); }
544 intptr_t token_index() const { return ast_node_.token_index(); } 542 intptr_t token_index() const { return ast_node_.token_index(); }
545 const Field& field() const { return ast_node_.field(); } 543 const Field& field() const { return ast_node_.field(); }
546 544
547 Value* instance() const { return instance_; } 545 Value* instance() const { return instance_; }
548 Value* value() const { return value_; } 546 Value* value() const { return value_; }
549 547
550 private: 548 private:
551 const StoreInstanceFieldNode& ast_node_; 549 const StoreInstanceFieldNode& ast_node_;
552 Value* instance_; 550 Value* instance_;
553 Value* value_; 551 Value* value_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 Value* const value_; 588 Value* const value_;
591 589
592 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); 590 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp);
593 }; 591 };
594 592
595 593
596 // Not simply an InstanceCall because it has somewhat more complicated 594 // Not simply an InstanceCall because it has somewhat more complicated
597 // semantics: the value operand is preserved before the call. 595 // semantics: the value operand is preserved before the call.
598 class StoreIndexedComp : public Computation { 596 class StoreIndexedComp : public Computation {
599 public: 597 public:
600 StoreIndexedComp(intptr_t node_id, 598 StoreIndexedComp(intptr_t token_index,
601 intptr_t token_index,
602 intptr_t try_index, 599 intptr_t try_index,
603 Value* array, 600 Value* array,
604 Value* index, 601 Value* index,
605 Value* value) 602 Value* value)
606 : node_id_(node_id), 603 : token_index_(token_index),
607 token_index_(token_index),
608 try_index_(try_index), 604 try_index_(try_index),
609 array_(array), 605 array_(array),
610 index_(index), 606 index_(index),
611 value_(value) { } 607 value_(value) { }
612 608
613 DECLARE_COMPUTATION(StoreIndexed) 609 DECLARE_COMPUTATION(StoreIndexed)
614 610
615 intptr_t node_id() const { return node_id_; }
616 intptr_t token_index() const { return token_index_; } 611 intptr_t token_index() const { return token_index_; }
617 intptr_t try_index() const { return try_index_; } 612 intptr_t try_index() const { return try_index_; }
618 Value* array() const { return array_; } 613 Value* array() const { return array_; }
619 Value* index() const { return index_; } 614 Value* index() const { return index_; }
620 Value* value() const { return value_; } 615 Value* value() const { return value_; }
621 616
622 private: 617 private:
623 const intptr_t node_id_;
624 const intptr_t token_index_; 618 const intptr_t token_index_;
625 const intptr_t try_index_; 619 const intptr_t try_index_;
626 Value* array_; 620 Value* array_;
627 Value* index_; 621 Value* index_;
628 Value* value_; 622 Value* value_;
629 623
630 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); 624 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp);
631 }; 625 };
632 626
633 627
634 // Not simply an InstanceCall because it has somewhat more complicated 628 // Not simply an InstanceCall because it has somewhat more complicated
635 // semantics: the value operand is preserved before the call. 629 // semantics: the value operand is preserved before the call.
636 class InstanceSetterComp : public Computation { 630 class InstanceSetterComp : public Computation {
637 public: 631 public:
638 InstanceSetterComp(intptr_t node_id, 632 InstanceSetterComp(intptr_t token_index,
639 intptr_t token_index,
640 intptr_t try_index, 633 intptr_t try_index,
641 const String& field_name, 634 const String& field_name,
642 Value* receiver, 635 Value* receiver,
643 Value* value) 636 Value* value)
644 : node_id_(node_id), 637 : token_index_(token_index),
645 token_index_(token_index),
646 try_index_(try_index), 638 try_index_(try_index),
647 field_name_(field_name), 639 field_name_(field_name),
648 receiver_(receiver), 640 receiver_(receiver),
649 value_(value) { } 641 value_(value) { }
650 642
651 DECLARE_COMPUTATION(InstanceSetter) 643 DECLARE_COMPUTATION(InstanceSetter)
652 644
653 intptr_t node_id() const { return node_id_; }
654 intptr_t token_index() const { return token_index_; } 645 intptr_t token_index() const { return token_index_; }
655 intptr_t try_index() const { return try_index_; } 646 intptr_t try_index() const { return try_index_; }
656 const String& field_name() const { return field_name_; } 647 const String& field_name() const { return field_name_; }
657 Value* receiver() const { return receiver_; } 648 Value* receiver() const { return receiver_; }
658 Value* value() const { return value_; } 649 Value* value() const { return value_; }
659 650
660 private: 651 private:
661 const intptr_t node_id_;
662 const intptr_t token_index_; 652 const intptr_t token_index_;
663 const intptr_t try_index_; 653 const intptr_t try_index_;
664 const String& field_name_; 654 const String& field_name_;
665 Value* const receiver_; 655 Value* const receiver_;
666 Value* const value_; 656 Value* const value_;
667 657
668 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); 658 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp);
669 }; 659 };
670 660
671 661
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 700
711 private: 701 private:
712 Value* value_; 702 Value* value_;
713 703
714 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); 704 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp);
715 }; 705 };
716 706
717 707
718 class InstanceOfComp : public Computation { 708 class InstanceOfComp : public Computation {
719 public: 709 public:
720 InstanceOfComp(intptr_t node_id, 710 InstanceOfComp(intptr_t token_index,
721 intptr_t token_index,
722 intptr_t try_index, 711 intptr_t try_index,
723 Value* value, 712 Value* value,
724 Value* type_arguments, // Can be NULL. 713 Value* type_arguments, // Can be NULL.
725 const AbstractType& type, 714 const AbstractType& type,
726 bool negate_result) 715 bool negate_result)
727 : node_id_(node_id), 716 : token_index_(token_index),
728 token_index_(token_index),
729 try_index_(try_index), 717 try_index_(try_index),
730 value_(value), 718 value_(value),
731 type_arguments_(type_arguments), 719 type_arguments_(type_arguments),
732 type_(type), 720 type_(type),
733 negate_result_(negate_result) { 721 negate_result_(negate_result) {
734 ASSERT(value_ != NULL); 722 ASSERT(value_ != NULL);
735 ASSERT(!type.IsNull()); 723 ASSERT(!type.IsNull());
736 } 724 }
737 725
738 DECLARE_COMPUTATION(InstanceOf) 726 DECLARE_COMPUTATION(InstanceOf)
739 727
740 Value* value() const { return value_; } 728 Value* value() const { return value_; }
741 Value* type_arguments() const { return type_arguments_; } 729 Value* type_arguments() const { return type_arguments_; }
742 bool negate_result() const { return negate_result_; } 730 bool negate_result() const { return negate_result_; }
743 const AbstractType& type() const { return type_; } 731 const AbstractType& type() const { return type_; }
744 intptr_t node_id() const { return node_id_; }
745 intptr_t token_index() const { return token_index_; } 732 intptr_t token_index() const { return token_index_; }
746 intptr_t try_index() const { return try_index_; } 733 intptr_t try_index() const { return try_index_; }
747 734
748 private: 735 private:
749 const intptr_t node_id_;
750 const intptr_t token_index_; 736 const intptr_t token_index_;
751 const intptr_t try_index_; 737 const intptr_t try_index_;
752 Value* value_; 738 Value* value_;
753 Value* type_arguments_; 739 Value* type_arguments_;
754 const AbstractType& type_; 740 const AbstractType& type_;
755 const bool negate_result_; 741 const bool negate_result_;
756 742
757 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); 743 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp);
758 }; 744 };
759 745
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 ASSERT(instantiator_ != NULL); 858 ASSERT(instantiator_ != NULL);
873 } 859 }
874 860
875 DECLARE_COMPUTATION(ExtractFactoryTypeArguments) 861 DECLARE_COMPUTATION(ExtractFactoryTypeArguments)
876 862
877 Value* instantiator() const { return instantiator_; } 863 Value* instantiator() const { return instantiator_; }
878 const AbstractTypeArguments& type_arguments() const { 864 const AbstractTypeArguments& type_arguments() const {
879 return ast_node_.type_arguments(); 865 return ast_node_.type_arguments();
880 } 866 }
881 const Function& factory() const { return ast_node_.constructor(); } 867 const Function& factory() const { return ast_node_.constructor(); }
882 intptr_t node_id() const { return ast_node_.id(); }
883 intptr_t token_index() const { return ast_node_.token_index(); } 868 intptr_t token_index() const { return ast_node_.token_index(); }
884 intptr_t try_index() const { return try_index_; } 869 intptr_t try_index() const { return try_index_; }
885 870
886 private: 871 private:
887 const ConstructorCallNode& ast_node_; 872 const ConstructorCallNode& ast_node_;
888 const intptr_t try_index_; 873 const intptr_t try_index_;
889 Value* instantiator_; 874 Value* instantiator_;
890 875
891 DISALLOW_COPY_AND_ASSIGN(ExtractFactoryTypeArgumentsComp); 876 DISALLOW_COPY_AND_ASSIGN(ExtractFactoryTypeArgumentsComp);
892 }; 877 };
893 878
894 879
895 class ExtractConstructorTypeArgumentsComp : public Computation { 880 class ExtractConstructorTypeArgumentsComp : public Computation {
896 public: 881 public:
897 ExtractConstructorTypeArgumentsComp(ConstructorCallNode* ast_node, 882 ExtractConstructorTypeArgumentsComp(ConstructorCallNode* ast_node,
898 Value* instantiator) 883 Value* instantiator)
899 : ast_node_(*ast_node), instantiator_(instantiator) { 884 : ast_node_(*ast_node), instantiator_(instantiator) {
900 ASSERT(instantiator_ != NULL); 885 ASSERT(instantiator_ != NULL);
901 } 886 }
902 887
903 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) 888 DECLARE_COMPUTATION(ExtractConstructorTypeArguments)
904 889
905 Value* instantiator() const { return instantiator_; } 890 Value* instantiator() const { return instantiator_; }
906 const AbstractTypeArguments& type_arguments() const { 891 const AbstractTypeArguments& type_arguments() const {
907 return ast_node_.type_arguments(); 892 return ast_node_.type_arguments();
908 } 893 }
909 const Function& constructor() const { return ast_node_.constructor(); } 894 const Function& constructor() const { return ast_node_.constructor(); }
910 intptr_t node_id() const { return ast_node_.id(); }
911 intptr_t token_index() const { return ast_node_.token_index(); } 895 intptr_t token_index() const { return ast_node_.token_index(); }
912 896
913 private: 897 private:
914 const ConstructorCallNode& ast_node_; 898 const ConstructorCallNode& ast_node_;
915 Value* instantiator_; 899 Value* instantiator_;
916 900
917 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); 901 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp);
918 }; 902 };
919 903
920 904
921 class ExtractConstructorInstantiatorComp : public Computation { 905 class ExtractConstructorInstantiatorComp : public Computation {
922 public: 906 public:
923 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node, 907 ExtractConstructorInstantiatorComp(ConstructorCallNode* ast_node,
924 Value* instantiator, 908 Value* instantiator,
925 Value* discard_value) 909 Value* discard_value)
926 : ast_node_(*ast_node), 910 : ast_node_(*ast_node),
927 instantiator_(instantiator), 911 instantiator_(instantiator),
928 discard_value_(discard_value) { 912 discard_value_(discard_value) {
929 ASSERT(instantiator_ != NULL); 913 ASSERT(instantiator_ != NULL);
930 } 914 }
931 915
932 DECLARE_COMPUTATION(ExtractConstructorInstantiator) 916 DECLARE_COMPUTATION(ExtractConstructorInstantiator)
933 917
934 Value* instantiator() const { return instantiator_; } 918 Value* instantiator() const { return instantiator_; }
935 Value* discard_value() const { return discard_value_; } 919 Value* discard_value() const { return discard_value_; }
936 const AbstractTypeArguments& type_arguments() const { 920 const AbstractTypeArguments& type_arguments() const {
937 return ast_node_.type_arguments(); 921 return ast_node_.type_arguments();
938 } 922 }
939 const Function& constructor() const { return ast_node_.constructor(); } 923 const Function& constructor() const { return ast_node_.constructor(); }
940 intptr_t node_id() const { return ast_node_.id(); }
941 intptr_t token_index() const { return ast_node_.token_index(); } 924 intptr_t token_index() const { return ast_node_.token_index(); }
942 925
943 private: 926 private:
944 const ConstructorCallNode& ast_node_; 927 const ConstructorCallNode& ast_node_;
945 Value* instantiator_; 928 Value* instantiator_;
946 Value* discard_value_; 929 Value* discard_value_;
947 930
948 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); 931 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp);
949 }; 932 };
950 933
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 969
987 private: 970 private:
988 Value* context_value_; 971 Value* context_value_;
989 972
990 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); 973 DISALLOW_COPY_AND_ASSIGN(ChainContextComp);
991 }; 974 };
992 975
993 976
994 class CloneContextComp : public Computation { 977 class CloneContextComp : public Computation {
995 public: 978 public:
996 CloneContextComp(intptr_t node_id, 979 CloneContextComp(intptr_t token_index,
997 intptr_t token_index,
998 intptr_t try_index, 980 intptr_t try_index,
999 Value* context_value) 981 Value* context_value)
1000 : node_id_(node_id), 982 : token_index_(token_index),
1001 token_index_(token_index),
1002 try_index_(try_index), 983 try_index_(try_index),
1003 context_value_(context_value) { 984 context_value_(context_value) {
1004 ASSERT(context_value_ != NULL); 985 ASSERT(context_value_ != NULL);
1005 } 986 }
1006 987
1007 intptr_t node_id() const { return node_id_; }
1008 intptr_t token_index() const { return token_index_; } 988 intptr_t token_index() const { return token_index_; }
1009 intptr_t try_index() const { return try_index_; } 989 intptr_t try_index() const { return try_index_; }
1010 Value* context_value() const { return context_value_; } 990 Value* context_value() const { return context_value_; }
1011 991
1012 DECLARE_COMPUTATION(CloneContext) 992 DECLARE_COMPUTATION(CloneContext)
1013 993
1014 private: 994 private:
1015 const intptr_t node_id_;
1016 const intptr_t token_index_; 995 const intptr_t token_index_;
1017 const intptr_t try_index_; 996 const intptr_t try_index_;
1018 Value* context_value_; 997 Value* context_value_;
1019 998
1020 DISALLOW_COPY_AND_ASSIGN(CloneContextComp); 999 DISALLOW_COPY_AND_ASSIGN(CloneContextComp);
1021 }; 1000 };
1022 1001
1023 1002
1024 class CatchEntryComp : public Computation { 1003 class CatchEntryComp : public Computation {
1025 public: 1004 public:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1058
1080 // Functions required in all concrete instruction classes. 1059 // Functions required in all concrete instruction classes.
1081 #define DECLARE_INSTRUCTION(type) \ 1060 #define DECLARE_INSTRUCTION(type) \
1082 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ 1061 virtual Instruction* Accept(FlowGraphVisitor* visitor); \
1083 virtual bool Is##type() const { return true; } \ 1062 virtual bool Is##type() const { return true; } \
1084 virtual type##Instr* As##type() { return this; } \ 1063 virtual type##Instr* As##type() { return this; } \
1085 1064
1086 1065
1087 class Instruction : public ZoneAllocated { 1066 class Instruction : public ZoneAllocated {
1088 public: 1067 public:
1089 Instruction() { } 1068 Instruction() : cid_(Computation::GetNextCid()) { }
1069
1070 // Unique computation/instruction id, used for deoptimization, e.g. for
1071 // ReturnInstr, ThrowInstr and ReThrowInstr.
1072 intptr_t cid() const { return cid_; }
1090 1073
1091 virtual bool IsBlockEntry() const { return false; } 1074 virtual bool IsBlockEntry() const { return false; }
1092 BlockEntryInstr* AsBlockEntry() { 1075 BlockEntryInstr* AsBlockEntry() {
1093 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL; 1076 return IsBlockEntry() ? reinterpret_cast<BlockEntryInstr*>(this) : NULL;
1094 } 1077 }
1095 1078
1096 // Visiting support. 1079 // Visiting support.
1097 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0; 1080 virtual Instruction* Accept(FlowGraphVisitor* visitor) = 0;
1098 1081
1099 virtual Instruction* StraightLineSuccessor() const = 0; 1082 virtual Instruction* StraightLineSuccessor() const = 0;
(...skipping 19 matching lines...) Expand all
1119 UNREACHABLE(); 1102 UNREACHABLE();
1120 } 1103 }
1121 1104
1122 #define INSTRUCTION_TYPE_CHECK(type) \ 1105 #define INSTRUCTION_TYPE_CHECK(type) \
1123 virtual bool Is##type() const { return false; } \ 1106 virtual bool Is##type() const { return false; } \
1124 virtual type##Instr* As##type() { return NULL; } 1107 virtual type##Instr* As##type() { return NULL; }
1125 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) 1108 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK)
1126 #undef INSTRUCTION_TYPE_CHECK 1109 #undef INSTRUCTION_TYPE_CHECK
1127 1110
1128 private: 1111 private:
1112 const intptr_t cid_;
1129 DISALLOW_COPY_AND_ASSIGN(Instruction); 1113 DISALLOW_COPY_AND_ASSIGN(Instruction);
1130 }; 1114 };
1131 1115
1132 1116
1133 // Basic block entries are administrative nodes. Joins are the only nodes 1117 // Basic block entries are administrative nodes. Joins are the only nodes
1134 // with multiple predecessors. Targets are the other basic block entries. 1118 // with multiple predecessors. Targets are the other basic block entries.
1135 // The types enforce edge-split form---joins are forbidden as the successors 1119 // The types enforce edge-split form---joins are forbidden as the successors
1136 // of branches. 1120 // of branches.
1137 class BlockEntryInstr : public Instruction { 1121 class BlockEntryInstr : public Instruction {
1138 public: 1122 public:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 const intptr_t destination_; 1373 const intptr_t destination_;
1390 const intptr_t source_; 1374 const intptr_t source_;
1391 Instruction* successor_; 1375 Instruction* successor_;
1392 1376
1393 DISALLOW_COPY_AND_ASSIGN(TuckTempInstr); 1377 DISALLOW_COPY_AND_ASSIGN(TuckTempInstr);
1394 }; 1378 };
1395 1379
1396 1380
1397 class ReturnInstr : public Instruction { 1381 class ReturnInstr : public Instruction {
1398 public: 1382 public:
1399 ReturnInstr(intptr_t node_id, intptr_t token_index, Value* value) 1383 ReturnInstr(intptr_t token_index, Value* value)
1400 : node_id_(node_id), token_index_(token_index), value_(value) { 1384 : token_index_(token_index), value_(value) {
1401 ASSERT(value_ != NULL); 1385 ASSERT(value_ != NULL);
1402 } 1386 }
1403 1387
1404 DECLARE_INSTRUCTION(Return) 1388 DECLARE_INSTRUCTION(Return)
1405 1389
1406 Value* value() const { return value_; } 1390 Value* value() const { return value_; }
1407 intptr_t token_index() const { return token_index_; } 1391 intptr_t token_index() const { return token_index_; }
1408 intptr_t node_id() const { return node_id_; }
1409 1392
1410 virtual Instruction* StraightLineSuccessor() const { return NULL; } 1393 virtual Instruction* StraightLineSuccessor() const { return NULL; }
1411 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } 1394 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); }
1412 1395
1413 private: 1396 private:
1414 const intptr_t node_id_;
1415 const intptr_t token_index_; 1397 const intptr_t token_index_;
1416 Value* value_; 1398 Value* value_;
1417 1399
1418 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 1400 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
1419 }; 1401 };
1420 1402
1421 1403
1422 class ThrowInstr : public Instruction { 1404 class ThrowInstr : public Instruction {
1423 public: 1405 public:
1424 ThrowInstr(intptr_t node_id, 1406 ThrowInstr(intptr_t token_index,
1425 intptr_t token_index,
1426 intptr_t try_index, 1407 intptr_t try_index,
1427 Value* exception) 1408 Value* exception)
1428 : node_id_(node_id), 1409 : token_index_(token_index),
1429 token_index_(token_index),
1430 try_index_(try_index), 1410 try_index_(try_index),
1431 exception_(exception), 1411 exception_(exception),
1432 successor_(NULL) { 1412 successor_(NULL) {
1433 ASSERT(exception_ != NULL); 1413 ASSERT(exception_ != NULL);
1434 } 1414 }
1435 1415
1436 DECLARE_INSTRUCTION(Throw) 1416 DECLARE_INSTRUCTION(Throw)
1437 1417
1438 intptr_t node_id() const { return node_id_; }
1439 intptr_t token_index() const { return token_index_; } 1418 intptr_t token_index() const { return token_index_; }
1440 intptr_t try_index() const { return try_index_; } 1419 intptr_t try_index() const { return try_index_; }
1441 Value* exception() const { return exception_; } 1420 Value* exception() const { return exception_; }
1442 1421
1443 // Parser can generate a throw within an expression tree. 1422 // Parser can generate a throw within an expression tree.
1444 virtual Instruction* StraightLineSuccessor() const { 1423 virtual Instruction* StraightLineSuccessor() const {
1445 return successor_; 1424 return successor_;
1446 } 1425 }
1447 virtual void SetSuccessor(Instruction* instr) { 1426 virtual void SetSuccessor(Instruction* instr) {
1448 ASSERT(successor_ == NULL); 1427 ASSERT(successor_ == NULL);
1449 successor_ = instr; 1428 successor_ = instr;
1450 } 1429 }
1451 1430
1452 private: 1431 private:
1453 const intptr_t node_id_;
1454 const intptr_t token_index_; 1432 const intptr_t token_index_;
1455 const intptr_t try_index_; 1433 const intptr_t try_index_;
1456 Value* exception_; 1434 Value* exception_;
1457 Instruction* successor_; 1435 Instruction* successor_;
1458 1436
1459 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 1437 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
1460 }; 1438 };
1461 1439
1462 1440
1463 class ReThrowInstr : public Instruction { 1441 class ReThrowInstr : public Instruction {
1464 public: 1442 public:
1465 ReThrowInstr(intptr_t node_id, 1443 ReThrowInstr(intptr_t token_index,
1466 intptr_t token_index, 1444 intptr_t try_index,
1467 intptr_t try_index, 1445 Value* exception,
1468 Value* exception, 1446 Value* stack_trace)
1469 Value* stack_trace) 1447 : token_index_(token_index),
1470 : node_id_(node_id),
1471 token_index_(token_index),
1472 try_index_(try_index), 1448 try_index_(try_index),
1473 exception_(exception), 1449 exception_(exception),
1474 stack_trace_(stack_trace), 1450 stack_trace_(stack_trace),
1475 successor_(NULL) { 1451 successor_(NULL) {
1476 ASSERT(exception_ != NULL); 1452 ASSERT(exception_ != NULL);
1477 ASSERT(stack_trace_ != NULL); 1453 ASSERT(stack_trace_ != NULL);
1478 } 1454 }
1479 1455
1480 DECLARE_INSTRUCTION(ReThrow) 1456 DECLARE_INSTRUCTION(ReThrow)
1481 1457
1482 intptr_t node_id() const { return node_id_; }
1483 intptr_t token_index() const { return token_index_; } 1458 intptr_t token_index() const { return token_index_; }
1484 intptr_t try_index() const { return try_index_; } 1459 intptr_t try_index() const { return try_index_; }
1485 Value* exception() const { return exception_; } 1460 Value* exception() const { return exception_; }
1486 Value* stack_trace() const { return stack_trace_; } 1461 Value* stack_trace() const { return stack_trace_; }
1487 1462
1488 // Parser can generate a rethrow within an expression tree. 1463 // Parser can generate a rethrow within an expression tree.
1489 virtual Instruction* StraightLineSuccessor() const { 1464 virtual Instruction* StraightLineSuccessor() const {
1490 return successor_; 1465 return successor_;
1491 } 1466 }
1492 virtual void SetSuccessor(Instruction* instr) { 1467 virtual void SetSuccessor(Instruction* instr) {
1493 ASSERT(successor_ == NULL); 1468 ASSERT(successor_ == NULL);
1494 successor_ = instr; 1469 successor_ = instr;
1495 } 1470 }
1496 1471
1497 private: 1472 private:
1498 const intptr_t node_id_;
1499 const intptr_t token_index_; 1473 const intptr_t token_index_;
1500 const intptr_t try_index_; 1474 const intptr_t try_index_;
1501 Value* exception_; 1475 Value* exception_;
1502 Value* stack_trace_; 1476 Value* stack_trace_;
1503 Instruction* successor_; 1477 Instruction* successor_;
1504 1478
1505 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 1479 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
1506 }; 1480 };
1507 1481
1508 1482
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 const GrowableArray<BlockEntryInstr*>& block_order_; 1553 const GrowableArray<BlockEntryInstr*>& block_order_;
1580 1554
1581 private: 1555 private:
1582 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 1556 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
1583 }; 1557 };
1584 1558
1585 1559
1586 } // namespace dart 1560 } // namespace dart
1587 1561
1588 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 1562 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698