| 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 ZoneGrowableArray<Value*>* const arguments_; | 549 ZoneGrowableArray<Value*>* const arguments_; |
| 550 const Array& argument_names_; | 550 const Array& argument_names_; |
| 551 const intptr_t checked_argument_count_; | 551 const intptr_t checked_argument_count_; |
| 552 | 552 |
| 553 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 553 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 554 }; | 554 }; |
| 555 | 555 |
| 556 | 556 |
| 557 class PolymorphicInstanceCallComp : public Computation { | 557 class PolymorphicInstanceCallComp : public Computation { |
| 558 public: | 558 public: |
| 559 PolymorphicInstanceCallComp(InstanceCallComp* comp, | 559 explicit PolymorphicInstanceCallComp(InstanceCallComp* comp) |
| 560 const ZoneGrowableArray<intptr_t>& class_ids, | 560 : instance_call_(comp) { |
| 561 const ZoneGrowableArray<Function*>& targets) | |
| 562 : instance_call_(comp), | |
| 563 class_ids_(class_ids), | |
| 564 targets_(targets) { | |
| 565 ASSERT(instance_call_ != NULL); | 561 ASSERT(instance_call_ != NULL); |
| 566 } | 562 } |
| 567 | 563 |
| 568 InstanceCallComp* instance_call() const { return instance_call_; } | 564 InstanceCallComp* instance_call() const { return instance_call_; } |
| 569 const ZoneGrowableArray<intptr_t>& class_ids() const { return class_ids_; } | |
| 570 const ZoneGrowableArray<Function*>& targets() const { return targets_; } | |
| 571 | 565 |
| 572 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } | 566 virtual intptr_t InputCount() const { return instance_call()->InputCount(); } |
| 573 virtual Value* InputAt(intptr_t i) const { | 567 virtual Value* InputAt(intptr_t i) const { |
| 574 return instance_call()->ArgumentAt(i); | 568 return instance_call()->ArgumentAt(i); |
| 575 } | 569 } |
| 576 virtual void SetInputAt(intptr_t index, Value* value) { | 570 virtual void SetInputAt(intptr_t index, Value* value) { |
| 577 instance_call()->SetInputAt(index, value); | 571 instance_call()->SetInputAt(index, value); |
| 578 } | 572 } |
| 579 | 573 |
| 580 virtual void PrintOperandsTo(BufferFormatter* f) const { | 574 virtual void PrintOperandsTo(BufferFormatter* f) const { |
| 581 instance_call()->PrintOperandsTo(f); | 575 instance_call()->PrintOperandsTo(f); |
| 582 } | 576 } |
| 583 | 577 |
| 584 DECLARE_COMPUTATION(PolymorphicInstanceCall) | 578 DECLARE_COMPUTATION(PolymorphicInstanceCall) |
| 585 | 579 |
| 586 private: | 580 private: |
| 587 InstanceCallComp* instance_call_; | 581 InstanceCallComp* instance_call_; |
| 588 const ZoneGrowableArray<intptr_t>& class_ids_; | |
| 589 const ZoneGrowableArray<Function*>& targets_; | |
| 590 | 582 |
| 591 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); | 583 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallComp); |
| 592 }; | 584 }; |
| 593 | 585 |
| 594 | 586 |
| 595 class ComparisonComp : public TemplateComputation<2> { | 587 class ComparisonComp : public TemplateComputation<2> { |
| 596 public: | 588 public: |
| 597 ComparisonComp(Value* left, Value* right) | 589 ComparisonComp(Value* left, Value* right) |
| 598 : fused_with_branch_(NULL) { | 590 : fused_with_branch_(NULL) { |
| 599 ASSERT(left != NULL); | 591 ASSERT(left != NULL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 | 636 |
| 645 | 637 |
| 646 class EqualityCompareComp : public ComparisonComp { | 638 class EqualityCompareComp : public ComparisonComp { |
| 647 public: | 639 public: |
| 648 EqualityCompareComp(intptr_t token_index, | 640 EqualityCompareComp(intptr_t token_index, |
| 649 intptr_t try_index, | 641 intptr_t try_index, |
| 650 Value* left, | 642 Value* left, |
| 651 Value* right) | 643 Value* right) |
| 652 : ComparisonComp(left, right), | 644 : ComparisonComp(left, right), |
| 653 token_index_(token_index), | 645 token_index_(token_index), |
| 654 try_index_(try_index), | 646 try_index_(try_index) { |
| 655 class_ids_(NULL), | |
| 656 targets_(NULL) { | |
| 657 } | 647 } |
| 658 | 648 |
| 659 DECLARE_COMPUTATION(EqualityCompare) | 649 DECLARE_COMPUTATION(EqualityCompare) |
| 660 | 650 |
| 661 intptr_t token_index() const { return token_index_; } | 651 intptr_t token_index() const { return token_index_; } |
| 662 intptr_t try_index() const { return try_index_; } | 652 intptr_t try_index() const { return try_index_; } |
| 663 void SetPolymorphicTargets(ZoneGrowableArray<intptr_t>* class_ids, | |
| 664 ZoneGrowableArray<Function*>* targets) { | |
| 665 class_ids_ = class_ids; | |
| 666 targets_ = targets; | |
| 667 ASSERT(targets_ != NULL); | |
| 668 ASSERT(class_ids_ != NULL); | |
| 669 } | |
| 670 intptr_t NumTargets() const { | |
| 671 return class_ids_ == NULL ? 0 : class_ids_->length(); | |
| 672 } | |
| 673 Function* TargetAt(intptr_t ix) const { | |
| 674 ASSERT(targets_ != NULL); | |
| 675 return (*targets_)[ix]; | |
| 676 } | |
| 677 intptr_t ClassIdAt(intptr_t ix) const { | |
| 678 ASSERT(class_ids_ != NULL); | |
| 679 return (*class_ids_)[ix]; | |
| 680 } | |
| 681 | |
| 682 virtual void PrintOperandsTo(BufferFormatter* f) const; | 653 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 683 | 654 |
| 684 private: | 655 private: |
| 685 const intptr_t token_index_; | 656 const intptr_t token_index_; |
| 686 const intptr_t try_index_; | 657 const intptr_t try_index_; |
| 687 ZoneGrowableArray<intptr_t>* class_ids_; | |
| 688 ZoneGrowableArray<Function*>* targets_; | |
| 689 | 658 |
| 690 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 659 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
| 691 }; | 660 }; |
| 692 | 661 |
| 693 | 662 |
| 694 class RelationalOpComp : public ComparisonComp { | 663 class RelationalOpComp : public ComparisonComp { |
| 695 public: | 664 public: |
| 696 RelationalOpComp(intptr_t token_index, | 665 RelationalOpComp(intptr_t token_index, |
| 697 intptr_t try_index, | 666 intptr_t try_index, |
| 698 Token::Kind kind, | 667 Token::Kind kind, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 const intptr_t try_index_; | 836 const intptr_t try_index_; |
| 868 | 837 |
| 869 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); | 838 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); |
| 870 }; | 839 }; |
| 871 | 840 |
| 872 | 841 |
| 873 class LoadInstanceFieldComp : public TemplateComputation<1> { | 842 class LoadInstanceFieldComp : public TemplateComputation<1> { |
| 874 public: | 843 public: |
| 875 LoadInstanceFieldComp(const Field& field, | 844 LoadInstanceFieldComp(const Field& field, |
| 876 Value* instance, | 845 Value* instance, |
| 877 InstanceCallComp* original, // Maybe NULL. | 846 InstanceCallComp* original) // Maybe NULL. |
| 878 ZoneGrowableArray<intptr_t>* class_ids) // Maybe NULL. | 847 : field_(field), original_(original) { |
| 879 : field_(field), original_(original), class_ids_(class_ids) { | |
| 880 ASSERT(instance != NULL); | 848 ASSERT(instance != NULL); |
| 881 inputs_[0] = instance; | 849 inputs_[0] = instance; |
| 882 } | 850 } |
| 883 | 851 |
| 884 DECLARE_COMPUTATION(LoadInstanceField) | 852 DECLARE_COMPUTATION(LoadInstanceField) |
| 885 | 853 |
| 886 const Field& field() const { return field_; } | 854 const Field& field() const { return field_; } |
| 887 Value* instance() const { return inputs_[0]; } | 855 Value* instance() const { return inputs_[0]; } |
| 888 const ZoneGrowableArray<intptr_t>* class_ids() const { return class_ids_; } | |
| 889 const InstanceCallComp* original() const { return original_; } | 856 const InstanceCallComp* original() const { return original_; } |
| 890 | 857 |
| 891 virtual void PrintOperandsTo(BufferFormatter* f) const; | 858 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 892 | 859 |
| 893 private: | 860 private: |
| 894 const Field& field_; | 861 const Field& field_; |
| 895 const InstanceCallComp* original_; // For optimizations. | 862 const InstanceCallComp* original_; // For optimizations. |
| 896 // If non-NULL, the instruction is valid only for the class ids listed. | |
| 897 const ZoneGrowableArray<intptr_t>* class_ids_; | |
| 898 | 863 |
| 899 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 864 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 900 }; | 865 }; |
| 901 | 866 |
| 902 | 867 |
| 903 class StoreInstanceFieldComp : public TemplateComputation<2> { | 868 class StoreInstanceFieldComp : public TemplateComputation<2> { |
| 904 public: | 869 public: |
| 905 StoreInstanceFieldComp(const Field& field, | 870 StoreInstanceFieldComp(const Field& field, |
| 906 Value* instance, | 871 Value* instance, |
| 907 Value* value, | 872 Value* value, |
| 908 InstanceSetterComp* original, // Maybe NULL. | 873 InstanceSetterComp* original) // Maybe NULL. |
| 909 ZoneGrowableArray<intptr_t>* class_ids) // Maybe NULL. | 874 : field_(field), original_(original) { |
| 910 : field_(field), original_(original), class_ids_(class_ids) { | |
| 911 ASSERT(instance != NULL); | 875 ASSERT(instance != NULL); |
| 912 ASSERT(value != NULL); | 876 ASSERT(value != NULL); |
| 913 inputs_[0] = instance; | 877 inputs_[0] = instance; |
| 914 inputs_[1] = value; | 878 inputs_[1] = value; |
| 915 } | 879 } |
| 916 | 880 |
| 917 DECLARE_COMPUTATION(StoreInstanceField) | 881 DECLARE_COMPUTATION(StoreInstanceField) |
| 918 | 882 |
| 919 const Field& field() const { return field_; } | 883 const Field& field() const { return field_; } |
| 920 | 884 |
| 921 Value* instance() const { return inputs_[0]; } | 885 Value* instance() const { return inputs_[0]; } |
| 922 Value* value() const { return inputs_[1]; } | 886 Value* value() const { return inputs_[1]; } |
| 923 | 887 |
| 924 const ZoneGrowableArray<intptr_t>* class_ids() const { return class_ids_; } | |
| 925 const InstanceSetterComp* original() const { return original_; } | 888 const InstanceSetterComp* original() const { return original_; } |
| 926 | 889 |
| 927 virtual void PrintOperandsTo(BufferFormatter* f) const; | 890 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 928 | 891 |
| 929 private: | 892 private: |
| 930 const Field& field_; | 893 const Field& field_; |
| 931 const InstanceSetterComp* original_; // For optimizations. | 894 const InstanceSetterComp* original_; // For optimizations. |
| 932 // If non-NULL, the instruction is valid only for the class ids listed. | |
| 933 const ZoneGrowableArray<intptr_t>* class_ids_; | |
| 934 | 895 |
| 935 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 896 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 936 }; | 897 }; |
| 937 | 898 |
| 938 | 899 |
| 939 class LoadStaticFieldComp : public TemplateComputation<0> { | 900 class LoadStaticFieldComp : public TemplateComputation<0> { |
| 940 public: | 901 public: |
| 941 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} | 902 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
| 942 | 903 |
| 943 DECLARE_COMPUTATION(LoadStaticField); | 904 DECLARE_COMPUTATION(LoadStaticField); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 }; | 1284 }; |
| 1324 | 1285 |
| 1325 | 1286 |
| 1326 class LoadVMFieldComp : public TemplateComputation<1> { | 1287 class LoadVMFieldComp : public TemplateComputation<1> { |
| 1327 public: | 1288 public: |
| 1328 LoadVMFieldComp(Value* value, | 1289 LoadVMFieldComp(Value* value, |
| 1329 intptr_t offset_in_bytes, | 1290 intptr_t offset_in_bytes, |
| 1330 const AbstractType& type) | 1291 const AbstractType& type) |
| 1331 : offset_in_bytes_(offset_in_bytes), | 1292 : offset_in_bytes_(offset_in_bytes), |
| 1332 type_(type), | 1293 type_(type), |
| 1333 original_(NULL), | 1294 original_(NULL) { |
| 1334 class_ids_(NULL) { | |
| 1335 ASSERT(value != NULL); | 1295 ASSERT(value != NULL); |
| 1336 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 1296 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 1337 inputs_[0] = value; | 1297 inputs_[0] = value; |
| 1338 } | 1298 } |
| 1339 | 1299 |
| 1340 LoadVMFieldComp(Value* value, | |
| 1341 intptr_t offset_in_bytes, | |
| 1342 const AbstractType& type, | |
| 1343 InstanceCallComp* original, | |
| 1344 ZoneGrowableArray<intptr_t>* class_ids) | |
| 1345 : offset_in_bytes_(offset_in_bytes), | |
| 1346 type_(type), | |
| 1347 original_(original), | |
| 1348 class_ids_(class_ids) { | |
| 1349 ASSERT(value != NULL); | |
| 1350 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | |
| 1351 ASSERT(original != NULL); | |
| 1352 ASSERT(class_ids != NULL); | |
| 1353 inputs_[0] = value; | |
| 1354 } | |
| 1355 | |
| 1356 DECLARE_COMPUTATION(LoadVMField) | 1300 DECLARE_COMPUTATION(LoadVMField) |
| 1357 | 1301 |
| 1358 Value* value() const { return inputs_[0]; } | 1302 Value* value() const { return inputs_[0]; } |
| 1359 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 1303 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 1360 const AbstractType& type() const { return type_; } | 1304 const AbstractType& type() const { return type_; } |
| 1361 const ZoneGrowableArray<intptr_t>* class_ids() const { return class_ids_; } | |
| 1362 const InstanceCallComp* original() const { return original_; } | 1305 const InstanceCallComp* original() const { return original_; } |
| 1306 void set_original(InstanceCallComp* value) { original_ = value; } |
| 1363 | 1307 |
| 1364 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1308 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1365 | 1309 |
| 1366 private: | 1310 private: |
| 1367 const intptr_t offset_in_bytes_; | 1311 const intptr_t offset_in_bytes_; |
| 1368 const AbstractType& type_; | 1312 const AbstractType& type_; |
| 1369 const InstanceCallComp* original_; // For optimizations. | 1313 const InstanceCallComp* original_; // For optimizations. |
| 1370 // If non-NULL, the instruction is valid only for the class ids listed. | 1314 // If non-NULL, the instruction is valid only for the class ids listed. |
| 1371 const ZoneGrowableArray<intptr_t>* class_ids_; | |
| 1372 | 1315 |
| 1373 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldComp); | 1316 DISALLOW_COPY_AND_ASSIGN(LoadVMFieldComp); |
| 1374 }; | 1317 }; |
| 1375 | 1318 |
| 1376 | 1319 |
| 1377 class StoreVMFieldComp : public TemplateComputation<2> { | 1320 class StoreVMFieldComp : public TemplateComputation<2> { |
| 1378 public: | 1321 public: |
| 1379 StoreVMFieldComp(Value* dest, | 1322 StoreVMFieldComp(Value* dest, |
| 1380 intptr_t offset_in_bytes, | 1323 intptr_t offset_in_bytes, |
| 1381 Value* value, | 1324 Value* value, |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 const GrowableArray<BlockEntryInstr*>& block_order_; | 2392 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2450 | 2393 |
| 2451 private: | 2394 private: |
| 2452 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2395 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2453 }; | 2396 }; |
| 2454 | 2397 |
| 2455 | 2398 |
| 2456 } // namespace dart | 2399 } // namespace dart |
| 2457 | 2400 |
| 2458 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2401 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |