| 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 11 matching lines...) Expand all Loading... |
| 22 M(Temp, TempVal) \ | 22 M(Temp, TempVal) \ |
| 23 M(Constant, ConstantVal) \ | 23 M(Constant, ConstantVal) \ |
| 24 | 24 |
| 25 | 25 |
| 26 // M is a two argument macro. It is applied to each concrete instruction's | 26 // M is a two argument macro. It is applied to each concrete instruction's |
| 27 // (including the values) typename and classname. | 27 // (including the values) typename and classname. |
| 28 #define FOR_EACH_COMPUTATION(M) \ | 28 #define FOR_EACH_COMPUTATION(M) \ |
| 29 FOR_EACH_VALUE(M) \ | 29 FOR_EACH_VALUE(M) \ |
| 30 M(AssertAssignable, AssertAssignableComp) \ | 30 M(AssertAssignable, AssertAssignableComp) \ |
| 31 M(CurrentContext, CurrentContextComp) \ | 31 M(CurrentContext, CurrentContextComp) \ |
| 32 M(StoreContext, StoreContextComp) \ |
| 32 M(ClosureCall, ClosureCallComp) \ | 33 M(ClosureCall, ClosureCallComp) \ |
| 33 M(InstanceCall, InstanceCallComp) \ | 34 M(InstanceCall, InstanceCallComp) \ |
| 34 M(StaticCall, StaticCallComp) \ | 35 M(StaticCall, StaticCallComp) \ |
| 35 M(LoadLocal, LoadLocalComp) \ | 36 M(LoadLocal, LoadLocalComp) \ |
| 36 M(StoreLocal, StoreLocalComp) \ | 37 M(StoreLocal, StoreLocalComp) \ |
| 37 M(StrictCompare, StrictCompareComp) \ | 38 M(StrictCompare, StrictCompareComp) \ |
| 38 M(NativeCall, NativeCallComp) \ | 39 M(NativeCall, NativeCallComp) \ |
| 39 M(StoreIndexed, StoreIndexedComp) \ | 40 M(StoreIndexed, StoreIndexedComp) \ |
| 40 M(InstanceSetter, InstanceSetterComp) \ | 41 M(InstanceSetter, InstanceSetterComp) \ |
| 41 M(StaticSetter, StaticSetterComp) \ | 42 M(StaticSetter, StaticSetterComp) \ |
| 42 M(LoadInstanceField, LoadInstanceFieldComp) \ | 43 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 43 M(StoreInstanceField, StoreInstanceFieldComp) \ | 44 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 44 M(LoadStaticField, LoadStaticFieldComp) \ | 45 M(LoadStaticField, LoadStaticFieldComp) \ |
| 45 M(StoreStaticField, StoreStaticFieldComp) \ | 46 M(StoreStaticField, StoreStaticFieldComp) \ |
| 46 M(BooleanNegate, BooleanNegateComp) \ | 47 M(BooleanNegate, BooleanNegateComp) \ |
| 47 M(InstanceOf, InstanceOfComp) \ | 48 M(InstanceOf, InstanceOfComp) \ |
| 48 M(CreateArray, CreateArrayComp) \ | 49 M(CreateArray, CreateArrayComp) \ |
| 49 M(CreateClosure, CreateClosureComp) \ | 50 M(CreateClosure, CreateClosureComp) \ |
| 50 M(AllocateObject, AllocateObjectComp) \ | 51 M(AllocateObject, AllocateObjectComp) \ |
| 51 M(NativeLoadField, NativeLoadFieldComp) \ | 52 M(NativeLoadField, NativeLoadFieldComp) \ |
| 52 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \ | 53 M(ExtractFactoryTypeArguments, ExtractFactoryTypeArgumentsComp) \ |
| 53 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ | 54 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ |
| 54 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ | 55 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ |
| 56 M(AllocateContext, AllocateContextComp) \ |
| 57 M(ChainContext, ChainContextComp) \ |
| 55 | 58 |
| 56 | 59 |
| 57 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 60 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 58 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 61 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 59 #undef FORWARD_DECLARATION | 62 #undef FORWARD_DECLARATION |
| 60 | 63 |
| 61 class Computation : public ZoneAllocated { | 64 class Computation : public ZoneAllocated { |
| 62 public: | 65 public: |
| 63 Computation() { } | 66 Computation() { } |
| 64 | 67 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 public: | 157 public: |
| 155 CurrentContextComp() { } | 158 CurrentContextComp() { } |
| 156 | 159 |
| 157 DECLARE_COMPUTATION(CurrentContext) | 160 DECLARE_COMPUTATION(CurrentContext) |
| 158 | 161 |
| 159 private: | 162 private: |
| 160 DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); | 163 DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); |
| 161 }; | 164 }; |
| 162 | 165 |
| 163 | 166 |
| 167 class StoreContextComp : public Computation { |
| 168 public: |
| 169 explicit StoreContextComp(Value* value) : value_(value) { |
| 170 ASSERT(value_ != NULL); |
| 171 } |
| 172 |
| 173 DECLARE_COMPUTATION(StoreContext); |
| 174 |
| 175 Value* value() const { return value_; } |
| 176 |
| 177 private: |
| 178 Value* value_; |
| 179 |
| 180 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); |
| 181 }; |
| 182 |
| 183 |
| 164 class ClosureCallComp : public Computation { | 184 class ClosureCallComp : public Computation { |
| 165 public: | 185 public: |
| 166 ClosureCallComp(ClosureCallNode* node, | 186 ClosureCallComp(ClosureCallNode* node, |
| 167 Value* context, | 187 Value* context, |
| 168 ZoneGrowableArray<Value*>* arguments) | 188 ZoneGrowableArray<Value*>* arguments) |
| 169 : ast_node_(*node), | 189 : ast_node_(*node), |
| 170 context_(context), | 190 context_(context), |
| 171 arguments_(arguments) { | 191 arguments_(arguments) { |
| 172 ASSERT(context->IsTemp()); | 192 ASSERT(context->IsTemp()); |
| 173 } | 193 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const Function& function_; | 302 const Function& function_; |
| 283 const Array& argument_names_; | 303 const Array& argument_names_; |
| 284 ZoneGrowableArray<Value*>* arguments_; | 304 ZoneGrowableArray<Value*>* arguments_; |
| 285 | 305 |
| 286 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); | 306 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
| 287 }; | 307 }; |
| 288 | 308 |
| 289 | 309 |
| 290 class LoadLocalComp : public Computation { | 310 class LoadLocalComp : public Computation { |
| 291 public: | 311 public: |
| 292 explicit LoadLocalComp(const LocalVariable& local) : local_(local) { } | 312 LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
| 313 : local_(local), context_level_(context_level) { } |
| 293 | 314 |
| 294 DECLARE_COMPUTATION(LoadLocal) | 315 DECLARE_COMPUTATION(LoadLocal) |
| 295 | 316 |
| 296 const LocalVariable& local() const { return local_; } | 317 const LocalVariable& local() const { return local_; } |
| 318 intptr_t context_level() const { return context_level_; } |
| 297 | 319 |
| 298 private: | 320 private: |
| 299 const LocalVariable& local_; | 321 const LocalVariable& local_; |
| 322 const intptr_t context_level_; |
| 300 | 323 |
| 301 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); | 324 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
| 302 }; | 325 }; |
| 303 | 326 |
| 304 | 327 |
| 305 class StoreLocalComp : public Computation { | 328 class StoreLocalComp : public Computation { |
| 306 public: | 329 public: |
| 307 StoreLocalComp(const LocalVariable& local, Value* value) | 330 StoreLocalComp(const LocalVariable& local, |
| 308 : local_(local), value_(value) { } | 331 Value* value, |
| 332 intptr_t context_level) |
| 333 : local_(local), value_(value), context_level_(context_level) { } |
| 309 | 334 |
| 310 DECLARE_COMPUTATION(StoreLocal) | 335 DECLARE_COMPUTATION(StoreLocal) |
| 311 | 336 |
| 312 const LocalVariable& local() const { return local_; } | 337 const LocalVariable& local() const { return local_; } |
| 313 Value* value() const { return value_; } | 338 Value* value() const { return value_; } |
| 339 intptr_t context_level() const { return context_level_; } |
| 314 | 340 |
| 315 private: | 341 private: |
| 316 const LocalVariable& local_; | 342 const LocalVariable& local_; |
| 317 Value* value_; | 343 Value* value_; |
| 344 const intptr_t context_level_; |
| 318 | 345 |
| 319 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 346 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 320 }; | 347 }; |
| 321 | 348 |
| 322 | 349 |
| 323 class NativeCallComp : public Computation { | 350 class NativeCallComp : public Computation { |
| 324 public: | 351 public: |
| 325 explicit NativeCallComp(NativeBodyNode* node) : ast_node_(*node) {} | 352 explicit NativeCallComp(NativeBodyNode* node) : ast_node_(*node) {} |
| 326 | 353 |
| 327 DECLARE_COMPUTATION(NativeCall) | 354 DECLARE_COMPUTATION(NativeCall) |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 760 |
| 734 private: | 761 private: |
| 735 const ConstructorCallNode& ast_node_; | 762 const ConstructorCallNode& ast_node_; |
| 736 Value* instantiator_; | 763 Value* instantiator_; |
| 737 Value* discard_value_; | 764 Value* discard_value_; |
| 738 | 765 |
| 739 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); | 766 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorInstantiatorComp); |
| 740 }; | 767 }; |
| 741 | 768 |
| 742 | 769 |
| 770 class AllocateContextComp : public Computation { |
| 771 public: |
| 772 AllocateContextComp(intptr_t token_index, intptr_t num_context_variables) |
| 773 : token_index_(token_index), |
| 774 num_context_variables_(num_context_variables) {} |
| 775 |
| 776 DECLARE_COMPUTATION(AllocateContext); |
| 777 |
| 778 intptr_t token_index() const { return token_index_; } |
| 779 intptr_t num_context_variables() const { return num_context_variables_; } |
| 780 |
| 781 private: |
| 782 const intptr_t token_index_; |
| 783 const intptr_t num_context_variables_; |
| 784 |
| 785 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); |
| 786 }; |
| 787 |
| 788 |
| 789 class ChainContextComp : public Computation { |
| 790 public: |
| 791 explicit ChainContextComp(Value* context_value) |
| 792 : context_value_(context_value) { |
| 793 ASSERT(context_value_ != NULL); |
| 794 } |
| 795 |
| 796 DECLARE_COMPUTATION(ChainContext) |
| 797 |
| 798 Value* context_value() const { return context_value_; } |
| 799 |
| 800 private: |
| 801 Value* context_value_; |
| 802 |
| 803 DISALLOW_COPY_AND_ASSIGN(ChainContextComp); |
| 804 }; |
| 805 |
| 806 |
| 743 #undef DECLARE_COMPUTATION | 807 #undef DECLARE_COMPUTATION |
| 744 | 808 |
| 745 | 809 |
| 746 // Instructions. | 810 // Instructions. |
| 747 // | 811 // |
| 748 // <Instruction> ::= JoinEntry <Instruction> | 812 // <Instruction> ::= JoinEntry <Instruction> |
| 749 // | TargetEntry <Instruction> | 813 // | TargetEntry <Instruction> |
| 750 // | PickTemp <int> <int> <Instruction> | 814 // | PickTemp <int> <int> <Instruction> |
| 751 // | TuckTemp <int> <int> <Instruction> | 815 // | TuckTemp <int> <int> <Instruction> |
| 752 // | Do <Computation> <Instruction> | 816 // | Do <Computation> <Instruction> |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 const GrowableArray<BlockEntryInstr*>& block_order_; | 1284 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1221 | 1285 |
| 1222 private: | 1286 private: |
| 1223 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1287 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1224 }; | 1288 }; |
| 1225 | 1289 |
| 1226 | 1290 |
| 1227 } // namespace dart | 1291 } // namespace dart |
| 1228 | 1292 |
| 1229 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1293 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |