| 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 15 matching lines...) Expand all Loading... |
| 26 // | LoadLocal <LocalVariable> | 26 // | LoadLocal <LocalVariable> |
| 27 // | StoreLocal <LocalVariable> <Value> | 27 // | StoreLocal <LocalVariable> <Value> |
| 28 // | StrictCompare <Token::kind> <Value> <Value> | 28 // | StrictCompare <Token::kind> <Value> <Value> |
| 29 // | NativeCall <NativeBodyNode> | 29 // | NativeCall <NativeBodyNode> |
| 30 // | StoreIndexed <StoreIndexedNode> <Value> <Value> <Value> | 30 // | StoreIndexed <StoreIndexedNode> <Value> <Value> <Value> |
| 31 // | InstanceSetter <InstanceSetterNode> <Value> <Value> | 31 // | InstanceSetter <InstanceSetterNode> <Value> <Value> |
| 32 // | LoadInstanceField <LoadInstanceFieldNode> <Value> | 32 // | LoadInstanceField <LoadInstanceFieldNode> <Value> |
| 33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> | 33 // | StoreInstanceField <StoreInstanceFieldNode> <Value> <Value> |
| 34 // | LoadStaticField <Field> | 34 // | LoadStaticField <Field> |
| 35 // | StoreStaticField <StoreStaticFieldNode> <Value> | 35 // | StoreStaticField <StoreStaticFieldNode> <Value> |
| 36 // | BooleanNegate <Value> |
| 37 // | InstanceOf <Value> <Type> |
| 36 // | 38 // |
| 37 // <Value> ::= | 39 // <Value> ::= |
| 38 // Temp <int> | 40 // Temp <int> |
| 39 // | Constant <Instance> | 41 // | Constant <Instance> |
| 40 | 42 |
| 41 // M is a two argument macro. It is applied to each concrete value's | 43 // M is a two argument macro. It is applied to each concrete value's |
| 42 // typename and classname. | 44 // typename and classname. |
| 43 #define FOR_EACH_VALUE(M) \ | 45 #define FOR_EACH_VALUE(M) \ |
| 44 M(Temp, TempVal) \ | 46 M(Temp, TempVal) \ |
| 45 M(Constant, ConstantVal) \ | 47 M(Constant, ConstantVal) \ |
| 46 | 48 |
| 47 | 49 |
| 48 // M is a two argument macro. It is applied to each concrete instruction's | 50 // M is a two argument macro. It is applied to each concrete instruction's |
| 49 // (including the values) typename and classname. | 51 // (including the values) typename and classname. |
| 50 #define FOR_EACH_COMPUTATION(M) \ | 52 #define FOR_EACH_COMPUTATION(M) \ |
| 51 FOR_EACH_VALUE(M) \ | 53 FOR_EACH_VALUE(M) \ |
| 52 M(AssertAssignable, AssertAssignableComp) \ | 54 M(AssertAssignable, AssertAssignableComp) \ |
| 53 M(InstanceCall, InstanceCallComp) \ | 55 M(InstanceCall, InstanceCallComp) \ |
| 54 M(StaticCall, StaticCallComp) \ | 56 M(StaticCall, StaticCallComp) \ |
| 55 M(LoadLocal, LoadLocalComp) \ | 57 M(LoadLocal, LoadLocalComp) \ |
| 56 M(StoreLocal, StoreLocalComp) \ | 58 M(StoreLocal, StoreLocalComp) \ |
| 57 M(StrictCompare, StrictCompareComp) \ | 59 M(StrictCompare, StrictCompareComp) \ |
| 58 M(NativeCall, NativeCallComp) \ | 60 M(NativeCall, NativeCallComp) \ |
| 59 M(StoreIndexed, StoreIndexedComp) \ | 61 M(StoreIndexed, StoreIndexedComp) \ |
| 60 M(InstanceSetter, InstanceSetterComp) \ | 62 M(InstanceSetter, InstanceSetterComp) \ |
| 61 M(LoadInstanceField, LoadInstanceFieldComp) \ | 63 M(LoadInstanceField, LoadInstanceFieldComp) \ |
| 62 M(StoreInstanceField, StoreInstanceFieldComp) \ | 64 M(StoreInstanceField, StoreInstanceFieldComp) \ |
| 63 M(LoadStaticField, LoadStaticFieldComp) \ | 65 M(LoadStaticField, LoadStaticFieldComp) \ |
| 64 M(StoreStaticField, StoreStaticFieldComp) | 66 M(StoreStaticField, StoreStaticFieldComp) \ |
| 67 M(BooleanNegate, BooleanNegateComp) \ |
| 68 M(InstanceOf, InstanceOfComp) |
| 65 | 69 |
| 66 | 70 |
| 67 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 71 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 68 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 72 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 69 #undef FORWARD_DECLARATION | 73 #undef FORWARD_DECLARATION |
| 70 | 74 |
| 71 class Computation : public ZoneAllocated { | 75 class Computation : public ZoneAllocated { |
| 72 public: | 76 public: |
| 73 Computation() { } | 77 Computation() { } |
| 74 | 78 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 440 |
| 437 private: | 441 private: |
| 438 const InstanceSetterNode& ast_node_; | 442 const InstanceSetterNode& ast_node_; |
| 439 Value* receiver_; | 443 Value* receiver_; |
| 440 Value* value_; | 444 Value* value_; |
| 441 | 445 |
| 442 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); | 446 DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp); |
| 443 }; | 447 }; |
| 444 | 448 |
| 445 | 449 |
| 450 // Note overrideable, built-in: value? false : true. |
| 451 class BooleanNegateComp : public Computation { |
| 452 public: |
| 453 explicit BooleanNegateComp(Value* value) : value_(value) {} |
| 454 |
| 455 DECLARE_COMPUTATION(BooleanNegateComp) |
| 456 |
| 457 Value* value() const { return value_; } |
| 458 |
| 459 private: |
| 460 Value* value_; |
| 461 |
| 462 DISALLOW_COPY_AND_ASSIGN(BooleanNegateComp); |
| 463 }; |
| 464 |
| 465 |
| 466 class InstanceOfComp : public Computation { |
| 467 public: |
| 468 InstanceOfComp(intptr_t node_id, |
| 469 intptr_t token_index, |
| 470 Value* value, |
| 471 const AbstractType& type, |
| 472 bool negate_result) |
| 473 : node_id_(node_id), |
| 474 token_index_(token_index), |
| 475 value_(value), |
| 476 type_(type), |
| 477 negate_result_(negate_result) {} |
| 478 |
| 479 DECLARE_COMPUTATION(InstanceOfComp) |
| 480 |
| 481 Value* value() const { return value_; } |
| 482 bool negate_result() const { return negate_result_; } |
| 483 const AbstractType& type() const { return type_; } |
| 484 |
| 485 private: |
| 486 const intptr_t node_id_; |
| 487 const intptr_t token_index_; |
| 488 Value* value_; |
| 489 const AbstractType& type_; |
| 490 const bool negate_result_; |
| 491 |
| 492 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); |
| 493 }; |
| 494 |
| 495 |
| 446 #undef DECLARE_COMPUTATION | 496 #undef DECLARE_COMPUTATION |
| 447 | 497 |
| 448 | 498 |
| 449 // Instructions. | 499 // Instructions. |
| 450 // | 500 // |
| 451 // <Instruction> ::= JoinEntry <Instruction> | 501 // <Instruction> ::= JoinEntry <Instruction> |
| 452 // | TargetEntry <Instruction> | 502 // | TargetEntry <Instruction> |
| 453 // | PickTemp <int> <int> <Instruction> | 503 // | PickTemp <int> <int> <Instruction> |
| 454 // | TuckTemp <int> <int> <Instruction> | 504 // | TuckTemp <int> <int> <Instruction> |
| 455 // | Do <Computation> <Instruction> | 505 // | Do <Computation> <Instruction> |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 #undef DECLARE_VISIT_INSTRUCTION | 837 #undef DECLARE_VISIT_INSTRUCTION |
| 788 | 838 |
| 789 private: | 839 private: |
| 790 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 840 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 791 }; | 841 }; |
| 792 | 842 |
| 793 | 843 |
| 794 } // namespace dart | 844 } // namespace dart |
| 795 | 845 |
| 796 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 846 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |