Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: runtime/vm/flow_graph_allocator.h

Issue 12827027: Revert "Compute local variable liveness before translation to SSA." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_allocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_FLOW_GRAPH_ALLOCATOR_H_ 5 #ifndef VM_FLOW_GRAPH_ALLOCATOR_H_
6 #define VM_FLOW_GRAPH_ALLOCATOR_H_ 6 #define VM_FLOW_GRAPH_ALLOCATOR_H_
7 7
8 #include "vm/flow_graph.h"
9 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
10 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
11 10
12 namespace dart { 11 namespace dart {
13 12
14 class AllocationFinger; 13 class AllocationFinger;
15 class BlockInfo; 14 class BlockInfo;
16 class FlowGraph; 15 class FlowGraph;
17 class LiveRange; 16 class LiveRange;
18 class UseInterval; 17 class UseInterval;
(...skipping 10 matching lines...) Expand all
29 28
30 private: 29 private:
31 void AddPhi(PhiInstr* phi); 30 void AddPhi(PhiInstr* phi);
32 void Compute(); 31 void Compute();
33 32
34 const FlowGraph& flow_graph_; 33 const FlowGraph& flow_graph_;
35 GrowableArray<PhiInstr*> phis_; 34 GrowableArray<PhiInstr*> phis_;
36 }; 35 };
37 36
38 37
39 class SSALivenessAnalysis : public LivenessAnalysis {
40 public:
41 explicit SSALivenessAnalysis(const FlowGraph& flow_graph)
42 : LivenessAnalysis(flow_graph.max_virtual_register_number(),
43 flow_graph.postorder()),
44 graph_entry_(flow_graph.graph_entry()) { }
45
46 private:
47 // Compute initial values for live-out, kill and live-in sets.
48 virtual void ComputeInitialSets();
49
50 GraphEntryInstr* graph_entry_;
51 };
52
53
54 class FlowGraphAllocator : public ValueObject { 38 class FlowGraphAllocator : public ValueObject {
55 public: 39 public:
56 // Number of stack slots needed for a double spill slot. 40 // Number of stack slots needed for a double spill slot.
57 static const intptr_t kDoubleSpillSlotFactor = kDoubleSize / kWordSize; 41 static const intptr_t kDoubleSpillSlotFactor = kDoubleSize / kWordSize;
58 42
59 explicit FlowGraphAllocator(const FlowGraph& flow_graph); 43 explicit FlowGraphAllocator(const FlowGraph& flow_graph);
60 44
61 void AllocateRegisters(); 45 void AllocateRegisters();
62 46
47 // Build live-in and live-out sets for each block.
48 void AnalyzeLiveness();
49
63 // Map a virtual register number to its live range. 50 // Map a virtual register number to its live range.
64 LiveRange* GetLiveRange(intptr_t vreg); 51 LiveRange* GetLiveRange(intptr_t vreg);
65 52
66 private: 53 private:
67 void CollectRepresentations(); 54 void CollectRepresentations();
68 55
69 // Eliminate unnecessary environments from the IL. 56 // Eliminate unnecessary environments from the IL.
70 void EliminateEnvironments(); 57 void EliminateEnvironments();
71 58
59 // Compute initial values for live-out, kill and live-in sets.
60 void ComputeInitialSets();
61
62 // Update live-out set for the given block: live-out should contain
63 // all values that are live-in for block's successors.
64 // Returns true if live-out set was changed.
65 bool UpdateLiveOut(const BlockEntryInstr& instr);
66
67 // Update live-in set for the given block: live-in should contain
68 // all values that are live-out from the block and are not defined
69 // by this block.
70 // Returns true if live-in set was changed.
71 bool UpdateLiveIn(const BlockEntryInstr& instr);
72
73 // Perform fix-point iteration updating live-out and live-in sets
74 // for blocks until they stop changing.
75 void ComputeLiveInAndLiveOutSets();
76
77 // Print results of liveness analysis.
78 void DumpLiveness();
79
72 // Visit blocks in the code generation order (reverse post order) and 80 // Visit blocks in the code generation order (reverse post order) and
73 // linearly assign consequent lifetime positions to every instruction. 81 // linearly assign consequent lifetime positions to every instruction.
74 // We assign position as follows: 82 // We assign position as follows:
75 // 83 //
76 // 2 * n - even position corresponding to instruction's start; 84 // 2 * n - even position corresponding to instruction's start;
77 // 85 //
78 // 2 * n + 1 - odd position corresponding to instruction's end; 86 // 2 * n + 1 - odd position corresponding to instruction's end;
79 // 87 //
80 // Having two positions per instruction allows us to capture non-trivial 88 // Having two positions per instruction allows us to capture non-trivial
81 // shapes of use intervals: e.g. by placing a use at the start or the 89 // shapes of use intervals: e.g. by placing a use at the start or the
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 242
235 const GrowableArray<BlockEntryInstr*>& block_order_; 243 const GrowableArray<BlockEntryInstr*>& block_order_;
236 const GrowableArray<BlockEntryInstr*>& postorder_; 244 const GrowableArray<BlockEntryInstr*>& postorder_;
237 245
238 // Mapping between lifetime positions and instructions. 246 // Mapping between lifetime positions and instructions.
239 GrowableArray<Instruction*> instructions_; 247 GrowableArray<Instruction*> instructions_;
240 248
241 // Mapping between lifetime positions and blocks containing them. 249 // Mapping between lifetime positions and blocks containing them.
242 GrowableArray<BlockInfo*> block_info_; 250 GrowableArray<BlockInfo*> block_info_;
243 251
244 SSALivenessAnalysis liveness_; 252 // Live-out sets for each block. They contain indices of SSA values
253 // that are live out from this block: that is values that were either
254 // defined in this block or live into it and that are used in some
255 // successor block.
256 GrowableArray<BitVector*> live_out_;
257
258 // Kill sets for each block. They contain indices of SSA values that
259 // are defined by this block.
260 GrowableArray<BitVector*> kill_;
261
262 // Live-in sets for each block. They contain indices of SSA values
263 // that are used by this block or its successors.
264 GrowableArray<BitVector*> live_in_;
245 265
246 // Number of virtual registers. Currently equal to the number of 266 // Number of virtual registers. Currently equal to the number of
247 // SSA values. 267 // SSA values.
248 const intptr_t vreg_count_; 268 const intptr_t vreg_count_;
249 269
250 // LiveRanges corresponding to SSA values. 270 // LiveRanges corresponding to SSA values.
251 GrowableArray<LiveRange*> live_ranges_; 271 GrowableArray<LiveRange*> live_ranges_;
252 272
253 GrowableArray<LiveRange*> unallocated_cpu_; 273 GrowableArray<LiveRange*> unallocated_cpu_;
254 GrowableArray<LiveRange*> unallocated_xmm_; 274 GrowableArray<LiveRange*> unallocated_xmm_;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 656
637 AllocationFinger finger_; 657 AllocationFinger finger_;
638 658
639 DISALLOW_COPY_AND_ASSIGN(LiveRange); 659 DISALLOW_COPY_AND_ASSIGN(LiveRange);
640 }; 660 };
641 661
642 662
643 } // namespace dart 663 } // namespace dart
644 664
645 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_ 665 #endif // VM_FLOW_GRAPH_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698