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/locations.h" |
12 #include "vm/object.h" | 13 #include "vm/object.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 | 16 |
16 // TODO(srdjan): Add _ByteArrayBase, get:length. | 17 // TODO(srdjan): Add _ByteArrayBase, get:length. |
17 | 18 |
18 #define RECOGNIZED_LIST(V) \ | 19 #define RECOGNIZED_LIST(V) \ |
19 V(ObjectArray, get:length, ObjectArrayLength) \ | 20 V(ObjectArray, get:length, ObjectArrayLength) \ |
20 V(ImmutableArray, get:length, ImmutableArrayLength) \ | 21 V(ImmutableArray, get:length, ImmutableArrayLength) \ |
21 V(GrowableObjectArray, get:length, GrowableArrayLength) \ | 22 V(GrowableObjectArray, get:length, GrowableArrayLength) \ |
(...skipping 17 matching lines...) Expand all Loading... |
39 static Kind RecognizeKind(const Function& function); | 40 static Kind RecognizeKind(const Function& function); |
40 static const char* KindToCString(Kind kind); | 41 static const char* KindToCString(Kind kind); |
41 }; | 42 }; |
42 | 43 |
43 | 44 |
44 class BitVector; | 45 class BitVector; |
45 class FlowGraphCompiler; | 46 class FlowGraphCompiler; |
46 class FlowGraphVisitor; | 47 class FlowGraphVisitor; |
47 class Function; | 48 class Function; |
48 class LocalVariable; | 49 class LocalVariable; |
49 class LocationSummary; | |
50 | 50 |
51 // M is a two argument macro. It is applied to each concrete value's | 51 // M is a two argument macro. It is applied to each concrete value's |
52 // typename and classname. | 52 // typename and classname. |
53 #define FOR_EACH_VALUE(M) \ | 53 #define FOR_EACH_VALUE(M) \ |
54 M(Use, UseVal) \ | 54 M(Use, UseVal) \ |
55 M(Constant, ConstantVal) \ | 55 M(Constant, ConstantVal) \ |
56 | 56 |
57 | 57 |
58 // M is a two argument macro. It is applied to each concrete instruction's | 58 // M is a two argument macro. It is applied to each concrete instruction's |
59 // (including the values) typename and classname. | 59 // (including the values) typename and classname. |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 M(GraphEntry) \ | 1699 M(GraphEntry) \ |
1700 M(JoinEntry) \ | 1700 M(JoinEntry) \ |
1701 M(TargetEntry) \ | 1701 M(TargetEntry) \ |
1702 M(Do) \ | 1702 M(Do) \ |
1703 M(Bind) \ | 1703 M(Bind) \ |
1704 M(Phi) \ | 1704 M(Phi) \ |
1705 M(Return) \ | 1705 M(Return) \ |
1706 M(Throw) \ | 1706 M(Throw) \ |
1707 M(ReThrow) \ | 1707 M(ReThrow) \ |
1708 M(Branch) \ | 1708 M(Branch) \ |
| 1709 M(ParallelMove) |
1709 | 1710 |
1710 | 1711 |
1711 // Forward declarations for Instruction classes. | 1712 // Forward declarations for Instruction classes. |
1712 class BlockEntryInstr; | 1713 class BlockEntryInstr; |
1713 class FlowGraphBuilder; | 1714 class FlowGraphBuilder; |
1714 | 1715 |
1715 #define FORWARD_DECLARATION(type) class type##Instr; | 1716 #define FORWARD_DECLARATION(type) class type##Instr; |
1716 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 1717 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
1717 #undef FORWARD_DECLARATION | 1718 #undef FORWARD_DECLARATION |
1718 | 1719 |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 private: | 2357 private: |
2357 Value* value_; | 2358 Value* value_; |
2358 TargetEntryInstr* true_successor_; | 2359 TargetEntryInstr* true_successor_; |
2359 TargetEntryInstr* false_successor_; | 2360 TargetEntryInstr* false_successor_; |
2360 bool is_fused_with_comparison_; | 2361 bool is_fused_with_comparison_; |
2361 bool is_negated_; | 2362 bool is_negated_; |
2362 | 2363 |
2363 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 2364 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
2364 }; | 2365 }; |
2365 | 2366 |
| 2367 |
| 2368 class MoveOperands : public ValueObject { |
| 2369 public: |
| 2370 MoveOperands(Location dest, Location src) : dest_(dest), src_(src) { } |
| 2371 |
| 2372 Location src() const { return src_; } |
| 2373 Location dest() const { return dest_; } |
| 2374 |
| 2375 private: |
| 2376 Location dest_; |
| 2377 Location src_; |
| 2378 }; |
| 2379 |
| 2380 |
| 2381 class ParallelMoveInstr : public Instruction { |
| 2382 public: |
| 2383 ParallelMoveInstr() : moves_(1) { } |
| 2384 |
| 2385 DECLARE_INSTRUCTION(ParallelMove) |
| 2386 |
| 2387 void AddMove(Location dest, Location src) { |
| 2388 moves_.Add(MoveOperands(dest, src)); |
| 2389 } |
| 2390 |
| 2391 const GrowableArray<MoveOperands>& moves() { return moves_; } |
| 2392 |
| 2393 private: |
| 2394 GrowableArray<MoveOperands> moves_; |
| 2395 |
| 2396 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); |
| 2397 }; |
| 2398 |
2366 #undef DECLARE_INSTRUCTION | 2399 #undef DECLARE_INSTRUCTION |
2367 | 2400 |
2368 | 2401 |
2369 // Visitor base class to visit each instruction and computation in a flow | 2402 // Visitor base class to visit each instruction and computation in a flow |
2370 // graph as defined by a reversed list of basic blocks. | 2403 // graph as defined by a reversed list of basic blocks. |
2371 class FlowGraphVisitor : public ValueObject { | 2404 class FlowGraphVisitor : public ValueObject { |
2372 public: | 2405 public: |
2373 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order) | 2406 explicit FlowGraphVisitor(const GrowableArray<BlockEntryInstr*>& block_order) |
2374 : block_order_(block_order) { } | 2407 : block_order_(block_order) { } |
2375 virtual ~FlowGraphVisitor() { } | 2408 virtual ~FlowGraphVisitor() { } |
(...skipping 20 matching lines...) Expand all Loading... |
2396 const GrowableArray<BlockEntryInstr*>& block_order_; | 2429 const GrowableArray<BlockEntryInstr*>& block_order_; |
2397 | 2430 |
2398 private: | 2431 private: |
2399 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2432 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
2400 }; | 2433 }; |
2401 | 2434 |
2402 | 2435 |
2403 } // namespace dart | 2436 } // namespace dart |
2404 | 2437 |
2405 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2438 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |