| 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 22 matching lines...) Expand all Loading... |
| 33 // | InstanceSetter <String> <Value> <Value> | 33 // | InstanceSetter <String> <Value> <Value> |
| 34 // | LoadInstanceField <LoadInstanceFieldNode> <Value> | 34 // | LoadInstanceField <LoadInstanceFieldNode> <Value> |
| 35 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> | 35 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> |
| 36 // | LoadStaticField <Field> | 36 // | LoadStaticField <Field> |
| 37 // | StoreStaticField <Field> <Value> | 37 // | StoreStaticField <Field> <Value> |
| 38 // | BooleanNegate <Value> | 38 // | BooleanNegate <Value> |
| 39 // | InstanceOf <Value> <Type> | 39 // | InstanceOf <Value> <Type> |
| 40 // | CreateArray <ArrayNode> <Value> ... | 40 // | CreateArray <ArrayNode> <Value> ... |
| 41 // | CreateClosure <ClosureNode> | 41 // | CreateClosure <ClosureNode> |
| 42 // | AllocateObject <ConstructorCallNode> | 42 // | AllocateObject <ConstructorCallNode> |
| 43 // | Throw <Value> | |
| 44 // | ReThrow <Value> <Value> | |
| 45 // | NativeLoadField <Value> <intptr_t> | 43 // | NativeLoadField <Value> <intptr_t> |
| 46 // | ExtractFactoryTypeArgumentsComp <ConstructorCallNode> <Value> | 44 // | ExtractFactoryTypeArgumentsComp <ConstructorCallNode> <Value> |
| 47 // | ExtractConstructorTypeArgumentsComp <ConstructorCallNode> <Value> | 45 // | ExtractConstructorTypeArgumentsComp <ConstructorCallNode> <Value> |
| 48 // | ExtractConstructorInstantiatorComp <ConstructorCallNode> <Value> <Value> | 46 // | ExtractConstructorInstantiatorComp <ConstructorCallNode> <Value> <Value> |
| 49 // | 47 // |
| 50 // <Value> ::= | 48 // <Value> ::= |
| 51 // Temp <int> | 49 // Temp <int> |
| 52 // | Constant <Instance> | 50 // | Constant <Instance> |
| 53 | 51 |
| 54 // M is a two argument macro. It is applied to each concrete value's | 52 // M is a two argument macro. It is applied to each concrete value's |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 M(InstanceSetter, InstanceSetterComp) \ | 73 M(InstanceSetter, InstanceSetterComp) \ |
| 76 M(LoadInstanceField, LoadInstanceFieldComp) \ | 74 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 77 M(StoreInstanceField, StoreInstanceFieldComp) \ | 75 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 78 M(LoadStaticField, LoadStaticFieldComp) \ | 76 M(LoadStaticField, LoadStaticFieldComp) \ |
| 79 M(StoreStaticField, StoreStaticFieldComp) \ | 77 M(StoreStaticField, StoreStaticFieldComp) \ |
| 80 M(BooleanNegate, BooleanNegateComp) \ | 78 M(BooleanNegate, BooleanNegateComp) \ |
| 81 M(InstanceOf, InstanceOfComp) \ | 79 M(InstanceOf, InstanceOfComp) \ |
| 82 M(CreateArray, CreateArrayComp) \ | 80 M(CreateArray, CreateArrayComp) \ |
| 83 M(CreateClosure, CreateClosureComp) \ | 81 M(CreateClosure, CreateClosureComp) \ |
| 84 M(AllocateObject, AllocateObjectComp) \ | 82 M(AllocateObject, AllocateObjectComp) \ |
| 85 M(Throw, ThrowComp) \ | |
| 86 M(ReThrow, ReThrowComp) \ | |
| 87 M(NativeLoadField, NativeLoadFieldComp) \ | 83 M(NativeLoadField, NativeLoadFieldComp) \ |
| 88 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \ | 84 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \ |
| 89 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ | 85 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ |
| 90 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ | 86 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ |
| 91 | 87 |
| 92 | 88 |
| 93 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 89 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 94 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 90 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 95 #undef FORWARD_DECLARATION | 91 #undef FORWARD_DECLARATION |
| 96 | 92 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 intptr_t token_index() const { return ast_node_.token_index(); } | 636 intptr_t token_index() const { return ast_node_.token_index(); } |
| 641 const Function& function() const { return ast_node_.function(); } | 637 const Function& function() const { return ast_node_.function(); } |
| 642 | 638 |
| 643 private: | 639 private: |
| 644 const ClosureNode& ast_node_; | 640 const ClosureNode& ast_node_; |
| 645 | 641 |
| 646 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); | 642 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); |
| 647 }; | 643 }; |
| 648 | 644 |
| 649 | 645 |
| 650 class ThrowComp : public Computation { | |
| 651 public: | |
| 652 explicit ThrowComp(intptr_t node_id, | |
| 653 intptr_t token_index, | |
| 654 Value* exception) | |
| 655 : node_id_(node_id), token_index_(token_index), exception_(exception) { | |
| 656 ASSERT(exception_ != NULL); | |
| 657 } | |
| 658 | |
| 659 DECLARE_COMPUTATION(Throw) | |
| 660 | |
| 661 intptr_t node_id() const { return node_id_; } | |
| 662 intptr_t token_index() const { return token_index_; } | |
| 663 Value* exception() const { return exception_; } | |
| 664 | |
| 665 private: | |
| 666 intptr_t node_id_; | |
| 667 intptr_t token_index_; | |
| 668 Value* exception_; | |
| 669 | |
| 670 DISALLOW_COPY_AND_ASSIGN(ThrowComp); | |
| 671 }; | |
| 672 | |
| 673 | |
| 674 class ReThrowComp : public Computation { | |
| 675 public: | |
| 676 ReThrowComp(intptr_t node_id, | |
| 677 intptr_t token_index, | |
| 678 Value* exception, | |
| 679 Value* stack_trace) | |
| 680 : node_id_(node_id), | |
| 681 token_index_(token_index), | |
| 682 exception_(exception), | |
| 683 stack_trace_(stack_trace) { | |
| 684 ASSERT(exception_ != NULL); | |
| 685 ASSERT(stack_trace_ != NULL); | |
| 686 } | |
| 687 | |
| 688 DECLARE_COMPUTATION(ReThrow) | |
| 689 | |
| 690 intptr_t node_id() const { return node_id_; } | |
| 691 intptr_t token_index() const { return token_index_; } | |
| 692 Value* exception() const { return exception_; } | |
| 693 Value* stack_trace() const { return stack_trace_; } | |
| 694 | |
| 695 private: | |
| 696 intptr_t node_id_; | |
| 697 intptr_t token_index_; | |
| 698 Value* exception_; | |
| 699 Value* stack_trace_; | |
| 700 | |
| 701 DISALLOW_COPY_AND_ASSIGN(ReThrowComp); | |
| 702 }; | |
| 703 | |
| 704 | |
| 705 class NativeLoadFieldComp : public Computation { | 646 class NativeLoadFieldComp : public Computation { |
| 706 public: | 647 public: |
| 707 NativeLoadFieldComp(Value* value, intptr_t offset_in_bytes) | 648 NativeLoadFieldComp(Value* value, intptr_t offset_in_bytes) |
| 708 : value_(value), offset_in_bytes_(offset_in_bytes) { | 649 : value_(value), offset_in_bytes_(offset_in_bytes) { |
| 709 ASSERT(value != NULL); | 650 ASSERT(value != NULL); |
| 710 } | 651 } |
| 711 | 652 |
| 712 DECLARE_COMPUTATION(NativeLoadField) | 653 DECLARE_COMPUTATION(NativeLoadField) |
| 713 | 654 |
| 714 Value* value() const { return value_; } | 655 Value* value() const { return value_; } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 // type name. The concrete instruction classes are the name with Instr | 764 // type name. The concrete instruction classes are the name with Instr |
| 824 // concatenated. | 765 // concatenated. |
| 825 #define FOR_EACH_INSTRUCTION(M) \ | 766 #define FOR_EACH_INSTRUCTION(M) \ |
| 826 M(JoinEntry) \ | 767 M(JoinEntry) \ |
| 827 M(TargetEntry) \ | 768 M(TargetEntry) \ |
| 828 M(PickTemp) \ | 769 M(PickTemp) \ |
| 829 M(TuckTemp) \ | 770 M(TuckTemp) \ |
| 830 M(Do) \ | 771 M(Do) \ |
| 831 M(Bind) \ | 772 M(Bind) \ |
| 832 M(Return) \ | 773 M(Return) \ |
| 774 M(Throw) \ |
| 775 M(ReThrow) \ |
| 833 M(Branch) \ | 776 M(Branch) \ |
| 834 | 777 |
| 835 | 778 |
| 836 // Forward declarations for Instruction classes. | 779 // Forward declarations for Instruction classes. |
| 837 class BlockEntryInstr; | 780 class BlockEntryInstr; |
| 838 #define FORWARD_DECLARATION(type) class type##Instr; | 781 #define FORWARD_DECLARATION(type) class type##Instr; |
| 839 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 782 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 840 #undef FORWARD_DECLARATION | 783 #undef FORWARD_DECLARATION |
| 841 | 784 |
| 842 | 785 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 Computation* computation_; | 1006 Computation* computation_; |
| 1064 Instruction* successor_; | 1007 Instruction* successor_; |
| 1065 | 1008 |
| 1066 DISALLOW_COPY_AND_ASSIGN(BindInstr); | 1009 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
| 1067 }; | 1010 }; |
| 1068 | 1011 |
| 1069 | 1012 |
| 1070 class ReturnInstr : public Instruction { | 1013 class ReturnInstr : public Instruction { |
| 1071 public: | 1014 public: |
| 1072 ReturnInstr(Value* value, intptr_t token_index) | 1015 ReturnInstr(Value* value, intptr_t token_index) |
| 1073 : Instruction(), value_(value), token_index_(token_index) { } | 1016 : Instruction(), value_(value), token_index_(token_index) { |
| 1017 ASSERT(value_ != NULL); |
| 1018 } |
| 1074 | 1019 |
| 1075 DECLARE_INSTRUCTION(Return) | 1020 DECLARE_INSTRUCTION(Return) |
| 1076 | 1021 |
| 1077 Value* value() const { return value_; } | 1022 Value* value() const { return value_; } |
| 1078 intptr_t token_index() const { return token_index_; } | 1023 intptr_t token_index() const { return token_index_; } |
| 1079 | 1024 |
| 1080 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1025 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1081 | 1026 |
| 1082 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); | 1027 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); |
| 1083 | 1028 |
| 1084 private: | 1029 private: |
| 1085 Value* value_; | 1030 Value* value_; |
| 1086 intptr_t token_index_; | 1031 intptr_t token_index_; |
| 1087 | 1032 |
| 1088 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); | 1033 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); |
| 1089 }; | 1034 }; |
| 1090 | 1035 |
| 1091 | 1036 |
| 1037 class ThrowInstr : public Instruction { |
| 1038 public: |
| 1039 ThrowInstr(intptr_t node_id, intptr_t token_index, Value* exception) |
| 1040 : Instruction(), |
| 1041 node_id_(node_id), |
| 1042 token_index_(token_index), |
| 1043 exception_(exception) { |
| 1044 ASSERT(exception_ != NULL); |
| 1045 } |
| 1046 |
| 1047 DECLARE_INSTRUCTION(Throw) |
| 1048 |
| 1049 intptr_t node_id() const { return node_id_; } |
| 1050 intptr_t token_index() const { return token_index_; } |
| 1051 Value* exception() const { return exception_; } |
| 1052 |
| 1053 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1054 |
| 1055 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); |
| 1056 |
| 1057 private: |
| 1058 intptr_t node_id_; |
| 1059 intptr_t token_index_; |
| 1060 Value* exception_; |
| 1061 |
| 1062 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); |
| 1063 }; |
| 1064 |
| 1065 |
| 1066 class ReThrowInstr : public Instruction { |
| 1067 public: |
| 1068 ReThrowInstr(intptr_t node_id, |
| 1069 intptr_t token_index, |
| 1070 Value* exception, |
| 1071 Value* stack_trace) |
| 1072 : node_id_(node_id), |
| 1073 token_index_(token_index), |
| 1074 exception_(exception), |
| 1075 stack_trace_(stack_trace) { |
| 1076 ASSERT(exception_ != NULL); |
| 1077 ASSERT(stack_trace_ != NULL); |
| 1078 } |
| 1079 |
| 1080 DECLARE_INSTRUCTION(ReThrow) |
| 1081 |
| 1082 intptr_t node_id() const { return node_id_; } |
| 1083 intptr_t token_index() const { return token_index_; } |
| 1084 Value* exception() const { return exception_; } |
| 1085 Value* stack_trace() const { return stack_trace_; } |
| 1086 |
| 1087 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1088 |
| 1089 virtual void Postorder(GrowableArray<BlockEntryInstr*>* block_entries); |
| 1090 |
| 1091 private: |
| 1092 intptr_t node_id_; |
| 1093 intptr_t token_index_; |
| 1094 Value* exception_; |
| 1095 Value* stack_trace_; |
| 1096 |
| 1097 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); |
| 1098 }; |
| 1099 |
| 1100 |
| 1092 class BranchInstr : public Instruction { | 1101 class BranchInstr : public Instruction { |
| 1093 public: | 1102 public: |
| 1094 explicit BranchInstr(Value* value) | 1103 explicit BranchInstr(Value* value) |
| 1095 : Instruction(), | 1104 : Instruction(), |
| 1096 value_(value), | 1105 value_(value), |
| 1097 true_successor_(NULL), | 1106 true_successor_(NULL), |
| 1098 false_successor_(NULL) { } | 1107 false_successor_(NULL) { } |
| 1099 | 1108 |
| 1100 DECLARE_INSTRUCTION(Branch) | 1109 DECLARE_INSTRUCTION(Branch) |
| 1101 | 1110 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 #undef DECLARE_VISIT_INSTRUCTION | 1156 #undef DECLARE_VISIT_INSTRUCTION |
| 1148 | 1157 |
| 1149 private: | 1158 private: |
| 1150 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1159 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1151 }; | 1160 }; |
| 1152 | 1161 |
| 1153 | 1162 |
| 1154 } // namespace dart | 1163 } // namespace dart |
| 1155 | 1164 |
| 1156 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1165 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |