| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 M(PolymorphicInstanceCall, PolymorphicInstanceCallComp) \ | 68 M(PolymorphicInstanceCall, PolymorphicInstanceCallComp) \ |
| 69 M(StaticCall, StaticCallComp) \ | 69 M(StaticCall, StaticCallComp) \ |
| 70 M(LoadLocal, LoadLocalComp) \ | 70 M(LoadLocal, LoadLocalComp) \ |
| 71 M(StoreLocal, StoreLocalComp) \ | 71 M(StoreLocal, StoreLocalComp) \ |
| 72 M(StrictCompare, StrictCompareComp) \ | 72 M(StrictCompare, StrictCompareComp) \ |
| 73 M(EqualityCompare, EqualityCompareComp) \ | 73 M(EqualityCompare, EqualityCompareComp) \ |
| 74 M(RelationalOp, RelationalOpComp) \ | 74 M(RelationalOp, RelationalOpComp) \ |
| 75 M(NativeCall, NativeCallComp) \ | 75 M(NativeCall, NativeCallComp) \ |
| 76 M(LoadIndexed, LoadIndexedComp) \ | 76 M(LoadIndexed, LoadIndexedComp) \ |
| 77 M(StoreIndexed, StoreIndexedComp) \ | 77 M(StoreIndexed, StoreIndexedComp) \ |
| 78 M(InstanceSetter, InstanceSetterComp) \ | |
| 79 M(LoadInstanceField, LoadInstanceFieldComp) \ | 78 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 80 M(StoreInstanceField, StoreInstanceFieldComp) \ | 79 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 81 M(LoadStaticField, LoadStaticFieldComp) \ | 80 M(LoadStaticField, LoadStaticFieldComp) \ |
| 82 M(StoreStaticField, StoreStaticFieldComp) \ | 81 M(StoreStaticField, StoreStaticFieldComp) \ |
| 83 M(BooleanNegate, BooleanNegateComp) \ | 82 M(BooleanNegate, BooleanNegateComp) \ |
| 84 M(InstanceOf, InstanceOfComp) \ | 83 M(InstanceOf, InstanceOfComp) \ |
| 85 M(CreateArray, CreateArrayComp) \ | 84 M(CreateArray, CreateArrayComp) \ |
| 86 M(CreateClosure, CreateClosureComp) \ | 85 M(CreateClosure, CreateClosureComp) \ |
| 87 M(AllocateObject, AllocateObjectComp) \ | 86 M(AllocateObject, AllocateObjectComp) \ |
| 88 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \ | 87 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \ |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 token_kind_(token_kind), | 524 token_kind_(token_kind), |
| 526 arguments_(arguments), | 525 arguments_(arguments), |
| 527 argument_names_(argument_names), | 526 argument_names_(argument_names), |
| 528 checked_argument_count_(checked_argument_count) { | 527 checked_argument_count_(checked_argument_count) { |
| 529 ASSERT(function_name.IsZoneHandle()); | 528 ASSERT(function_name.IsZoneHandle()); |
| 530 ASSERT(!arguments->is_empty()); | 529 ASSERT(!arguments->is_empty()); |
| 531 ASSERT(argument_names.IsZoneHandle()); | 530 ASSERT(argument_names.IsZoneHandle()); |
| 532 ASSERT(Token::IsBinaryToken(token_kind) || | 531 ASSERT(Token::IsBinaryToken(token_kind) || |
| 533 Token::IsUnaryToken(token_kind) || | 532 Token::IsUnaryToken(token_kind) || |
| 534 token_kind == Token::kGET || | 533 token_kind == Token::kGET || |
| 534 token_kind == Token::kSET || |
| 535 token_kind == Token::kILLEGAL); | 535 token_kind == Token::kILLEGAL); |
| 536 } | 536 } |
| 537 | 537 |
| 538 DECLARE_CALL_COMPUTATION(InstanceCall) | 538 DECLARE_CALL_COMPUTATION(InstanceCall) |
| 539 | 539 |
| 540 intptr_t token_pos() const { return token_pos_; } | 540 intptr_t token_pos() const { return token_pos_; } |
| 541 intptr_t try_index() const { return try_index_; } | 541 intptr_t try_index() const { return try_index_; } |
| 542 const String& function_name() const { return function_name_; } | 542 const String& function_name() const { return function_name_; } |
| 543 Token::Kind token_kind() const { return token_kind_; } | 543 Token::Kind token_kind() const { return token_kind_; } |
| 544 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | 544 virtual intptr_t ArgumentCount() const { return arguments_->length(); } |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 | 876 |
| 877 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 877 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 878 }; | 878 }; |
| 879 | 879 |
| 880 | 880 |
| 881 class StoreInstanceFieldComp : public TemplateComputation<2> { | 881 class StoreInstanceFieldComp : public TemplateComputation<2> { |
| 882 public: | 882 public: |
| 883 StoreInstanceFieldComp(const Field& field, | 883 StoreInstanceFieldComp(const Field& field, |
| 884 Value* instance, | 884 Value* instance, |
| 885 Value* value, | 885 Value* value, |
| 886 InstanceSetterComp* original) // Maybe NULL. | 886 InstanceCallComp* original) // Maybe NULL. |
| 887 : field_(field), original_(original) { | 887 : field_(field), original_(original) { |
| 888 ASSERT(instance != NULL); | 888 ASSERT(instance != NULL); |
| 889 ASSERT(value != NULL); | 889 ASSERT(value != NULL); |
| 890 inputs_[0] = instance; | 890 inputs_[0] = instance; |
| 891 inputs_[1] = value; | 891 inputs_[1] = value; |
| 892 } | 892 } |
| 893 | 893 |
| 894 DECLARE_COMPUTATION(StoreInstanceField) | 894 DECLARE_COMPUTATION(StoreInstanceField) |
| 895 | 895 |
| 896 const Field& field() const { return field_; } | 896 const Field& field() const { return field_; } |
| 897 | 897 |
| 898 Value* instance() const { return inputs_[0]; } | 898 Value* instance() const { return inputs_[0]; } |
| 899 Value* value() const { return inputs_[1]; } | 899 Value* value() const { return inputs_[1]; } |
| 900 | 900 |
| 901 const InstanceSetterComp* original() const { return original_; } | 901 const InstanceCallComp* original() const { return original_; } |
| 902 | 902 |
| 903 virtual void PrintOperandsTo(BufferFormatter* f) const; | 903 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 904 | 904 |
| 905 virtual bool CanDeoptimize() const { return true; } | 905 virtual bool CanDeoptimize() const { return true; } |
| 906 | 906 |
| 907 private: | 907 private: |
| 908 const Field& field_; | 908 const Field& field_; |
| 909 const InstanceSetterComp* original_; // For optimizations. | 909 const InstanceCallComp* original_; // For optimizations. |
| 910 | 910 |
| 911 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 911 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 912 }; | 912 }; |
| 913 | 913 |
| 914 | 914 |
| 915 class LoadStaticFieldComp : public TemplateComputation<0> { | 915 class LoadStaticFieldComp : public TemplateComputation<0> { |
| 916 public: | 916 public: |
| 917 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} | 917 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
| 918 | 918 |
| 919 DECLARE_COMPUTATION(LoadStaticField); | 919 DECLARE_COMPUTATION(LoadStaticField); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 | 1034 |
| 1035 private: | 1035 private: |
| 1036 const intptr_t token_pos_; | 1036 const intptr_t token_pos_; |
| 1037 const intptr_t try_index_; | 1037 const intptr_t try_index_; |
| 1038 ObjectKind receiver_type_; | 1038 ObjectKind receiver_type_; |
| 1039 | 1039 |
| 1040 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); | 1040 DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp); |
| 1041 }; | 1041 }; |
| 1042 | 1042 |
| 1043 | 1043 |
| 1044 // TODO(fschneider): Make this an instance call. | |
| 1045 class InstanceSetterComp : public Computation { | |
| 1046 public: | |
| 1047 InstanceSetterComp(intptr_t token_pos, | |
| 1048 intptr_t try_index, | |
| 1049 const String& field_name, | |
| 1050 ZoneGrowableArray<PushArgumentInstr*>* arguments) | |
| 1051 : token_pos_(token_pos), | |
| 1052 try_index_(try_index), | |
| 1053 field_name_(field_name), | |
| 1054 arguments_(arguments) { } | |
| 1055 | |
| 1056 DECLARE_CALL_COMPUTATION(InstanceSetter) | |
| 1057 | |
| 1058 intptr_t token_pos() const { return token_pos_; } | |
| 1059 intptr_t try_index() const { return try_index_; } | |
| 1060 const String& field_name() const { return field_name_; } | |
| 1061 | |
| 1062 virtual intptr_t ArgumentCount() const { return arguments_->length(); } | |
| 1063 PushArgumentInstr* ArgumentAt(intptr_t index) const { | |
| 1064 return (*arguments_)[index]; | |
| 1065 } | |
| 1066 | |
| 1067 virtual bool CanDeoptimize() const { return true; } | |
| 1068 | |
| 1069 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 1070 | |
| 1071 private: | |
| 1072 const intptr_t token_pos_; | |
| 1073 const intptr_t try_index_; | |
| 1074 const String& field_name_; | |
| 1075 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | |
| 1076 | |
| 1077 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); | |
| 1078 }; | |
| 1079 | |
| 1080 | |
| 1081 // Note overrideable, built-in: value? false : true. | 1044 // Note overrideable, built-in: value? false : true. |
| 1082 class BooleanNegateComp : public TemplateComputation<1> { | 1045 class BooleanNegateComp : public TemplateComputation<1> { |
| 1083 public: | 1046 public: |
| 1084 explicit BooleanNegateComp(Value* value) { | 1047 explicit BooleanNegateComp(Value* value) { |
| 1085 inputs_[0] = value; | 1048 inputs_[0] = value; |
| 1086 } | 1049 } |
| 1087 | 1050 |
| 1088 DECLARE_COMPUTATION(BooleanNegate) | 1051 DECLARE_COMPUTATION(BooleanNegate) |
| 1089 | 1052 |
| 1090 Value* value() const { return inputs_[0]; } | 1053 Value* value() const { return inputs_[0]; } |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 const GrowableArray<BlockEntryInstr*>& block_order_; | 2752 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2790 | 2753 |
| 2791 private: | 2754 private: |
| 2792 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2755 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2793 }; | 2756 }; |
| 2794 | 2757 |
| 2795 | 2758 |
| 2796 } // namespace dart | 2759 } // namespace dart |
| 2797 | 2760 |
| 2798 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2761 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |