| 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" |
| 11 #include "vm/handles_impl.h" | 11 #include "vm/handles_impl.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 class FlowGraphVisitor; | 16 class FlowGraphVisitor; |
| 17 class LocalVariable; | 17 class LocalVariable; |
| 18 | 18 |
| 19 // M is a two argument macro. It is applied to each concrete value's | 19 // M is a two argument macro. It is applied to each concrete value's |
| 20 // typename and classname. | 20 // typename and classname. |
| 21 #define FOR_EACH_VALUE(M) \ | 21 #define FOR_EACH_VALUE(M) \ |
| 22 M(Temp, TempVal) \ | |
| 23 M(Use, UseVal) \ | 22 M(Use, UseVal) \ |
| 24 M(Constant, ConstantVal) \ | 23 M(Constant, ConstantVal) \ |
| 25 | 24 |
| 26 | 25 |
| 27 // 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 |
| 28 // (including the values) typename and classname. | 27 // (including the values) typename and classname. |
| 29 #define FOR_EACH_COMPUTATION(M) \ | 28 #define FOR_EACH_COMPUTATION(M) \ |
| 30 FOR_EACH_VALUE(M) \ | 29 FOR_EACH_VALUE(M) \ |
| 31 M(AssertAssignable, AssertAssignableComp) \ | 30 M(AssertAssignable, AssertAssignableComp) \ |
| 32 M(AssertBoolean, AssertBooleanComp) \ | 31 M(AssertBoolean, AssertBooleanComp) \ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Functions defined in all concrete computation classes. | 156 // Functions defined in all concrete computation classes. |
| 158 #define DECLARE_COMPUTATION(ShortName) \ | 157 #define DECLARE_COMPUTATION(ShortName) \ |
| 159 virtual void Accept(FlowGraphVisitor* visitor); \ | 158 virtual void Accept(FlowGraphVisitor* visitor); \ |
| 160 | 159 |
| 161 // Functions defined in all concrete value classes. | 160 // Functions defined in all concrete value classes. |
| 162 #define DECLARE_VALUE(ShortName) \ | 161 #define DECLARE_VALUE(ShortName) \ |
| 163 DECLARE_COMPUTATION(ShortName) \ | 162 DECLARE_COMPUTATION(ShortName) \ |
| 164 virtual ShortName##Val* As##ShortName() { return this; } | 163 virtual ShortName##Val* As##ShortName() { return this; } |
| 165 | 164 |
| 166 | 165 |
| 167 class TempVal : public Value { | |
| 168 public: | |
| 169 explicit TempVal(intptr_t index) : index_(index) { } | |
| 170 | |
| 171 DECLARE_VALUE(Temp) | |
| 172 | |
| 173 intptr_t index() const { return index_; } | |
| 174 | |
| 175 private: | |
| 176 const intptr_t index_; | |
| 177 | |
| 178 DISALLOW_COPY_AND_ASSIGN(TempVal); | |
| 179 }; | |
| 180 | |
| 181 | |
| 182 // Definitions and uses are mutually recursive. | 166 // Definitions and uses are mutually recursive. |
| 183 class Definition; | 167 class Definition; |
| 184 | 168 |
| 185 class UseVal : public Value { | 169 class UseVal : public Value { |
| 186 public: | 170 public: |
| 187 explicit UseVal(Definition* definition) : definition_(definition) { } | 171 explicit UseVal(Definition* definition) : definition_(definition) { } |
| 188 | 172 |
| 189 DECLARE_VALUE(Use) | 173 DECLARE_VALUE(Use) |
| 190 | 174 |
| 191 Definition* definition() const { return definition_; } | 175 Definition* definition() const { return definition_; } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 class ClosureCallComp : public Computation { | 301 class ClosureCallComp : public Computation { |
| 318 public: | 302 public: |
| 319 ClosureCallComp(ClosureCallNode* node, | 303 ClosureCallComp(ClosureCallNode* node, |
| 320 intptr_t try_index, | 304 intptr_t try_index, |
| 321 Value* context, | 305 Value* context, |
| 322 ZoneGrowableArray<Value*>* arguments) | 306 ZoneGrowableArray<Value*>* arguments) |
| 323 : ast_node_(*node), | 307 : ast_node_(*node), |
| 324 try_index_(try_index), | 308 try_index_(try_index), |
| 325 context_(context), | 309 context_(context), |
| 326 arguments_(arguments) { | 310 arguments_(arguments) { |
| 327 ASSERT(context->IsTemp() || context->IsUse()); | 311 ASSERT(context->IsUse()); |
| 328 } | 312 } |
| 329 | 313 |
| 330 DECLARE_COMPUTATION(ClosureCall) | 314 DECLARE_COMPUTATION(ClosureCall) |
| 331 | 315 |
| 332 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 316 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 333 intptr_t token_index() const { return ast_node_.token_index(); } | 317 intptr_t token_index() const { return ast_node_.token_index(); } |
| 334 intptr_t try_index() const { return try_index_; } | 318 intptr_t try_index() const { return try_index_; } |
| 335 | 319 |
| 336 Value* context() const { return context_; } | 320 Value* context() const { return context_; } |
| 337 intptr_t ArgumentCount() const { return arguments_->length(); } | 321 intptr_t ArgumentCount() const { return arguments_->length(); } |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 const GrowableArray<BlockEntryInstr*>& block_order_; | 1635 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1652 | 1636 |
| 1653 private: | 1637 private: |
| 1654 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1638 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1655 }; | 1639 }; |
| 1656 | 1640 |
| 1657 | 1641 |
| 1658 } // namespace dart | 1642 } // namespace dart |
| 1659 | 1643 |
| 1660 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1644 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |