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

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

Issue 10447133: FlowGraphCompiler is not a visitor any longer. Start consolidating shared code between the x64 and … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_shared.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_FLOW_GRAPH_COMPILER_SHARED_H_
6 #define VM_FLOW_GRAPH_COMPILER_SHARED_H_
7
8 #include "vm/allocation.h"
9 #include "vm/assembler.h"
10 #include "vm/code_descriptors.h"
11 #include "vm/code_generator.h"
12 #include "vm/growable_array.h"
13
14 namespace dart {
15
16 class BlockEntryInstr;
17 class ExceptionHandlerList;
18 class FlowGraphCompilerShared;
19 class ParsedFunction;
20 class TargetEntryInstr;
21
22 class DeoptimizationStub : public ZoneAllocated {
23 public:
24 DeoptimizationStub(intptr_t deopt_id,
25 intptr_t deopt_token_index,
26 intptr_t try_index,
27 DeoptReasonId reason)
28 : deopt_id_(deopt_id),
29 deopt_token_index_(deopt_token_index),
30 try_index_(try_index),
31 reason_(reason),
32 registers_(2),
33 entry_label_() {}
34
35 void Push(Register reg) { registers_.Add(reg); }
36 Label* entry_label() { return &entry_label_; }
37
38 // Implementation is in architecture specific file.
39 void GenerateCode(FlowGraphCompilerShared* compiler);
40
41 private:
42 const intptr_t deopt_id_;
43 const intptr_t deopt_token_index_;
44 const intptr_t try_index_;
45 const DeoptReasonId reason_;
46 GrowableArray<Register> registers_;
47 Label entry_label_;
48
49 DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub);
50 };
51
52
53 class FlowGraphCompilerShared : public ValueObject {
54 public:
55 FlowGraphCompilerShared(Assembler* assembler,
56 const ParsedFunction& parsed_function,
57 const GrowableArray<BlockEntryInstr*>& block_order,
58 bool is_optimizing);
59
60 virtual ~FlowGraphCompilerShared();
61
62 // Constructor is lighweight, major initialization work should occur here.
63 // This makes it easier to measure time spent in the compiler.
64 void InitCompiler();
65
66 Assembler* assembler() const { return assembler_; }
67 const ParsedFunction& parsed_function() const { return parsed_function_; }
68 const GrowableArray<BlockEntryInstr*>& block_order() const {
69 return block_order_;
70 }
71 DescriptorList* pc_descriptors_list() const {
72 return pc_descriptors_list_;
73 }
74 BlockEntryInstr* current_block() const { return current_block_; }
75 void set_current_block(BlockEntryInstr* value) {
76 current_block_ = value;
77 }
78 bool is_optimizing() const { return is_optimizing_; }
79
80 intptr_t StackSize() const;
81
82 // Returns assembler label associated with the given block entry.
83 Label* GetBlockLabel(BlockEntryInstr* block_entry) const;
84
85 // Returns true if the next block after current in the current block order
86 // is the given block.
87 bool IsNextBlock(TargetEntryInstr* block_entry) const;
88
89 void AddExceptionHandler(intptr_t try_index, intptr_t pc_offset);
90 void AddCurrentDescriptor(PcDescriptors::Kind kind,
91 intptr_t cid,
92 intptr_t token_index,
93 intptr_t try_index);
94 Label* AddDeoptStub(intptr_t deopt_id,
95 intptr_t deopt_token_index,
96 intptr_t try_index_,
97 DeoptReasonId reason,
98 Register reg1,
99 Register reg2);
100
101 void FinalizeExceptionHandlers(const Code& code);
102 void FinalizePcDescriptors(const Code& code);
103 void FinalizeStackmaps(const Code& code);
104 void FinalizeVarDescriptors(const Code& code);
105
106 void GenerateDeferredCode();
107
108 struct BlockInfo : public ZoneAllocated {
109 public:
110 BlockInfo() : label() { }
111
112 Label label;
113 };
114
115 const GrowableArray<BlockInfo*>& block_info() const { return block_info_; }
116
117 private:
118 // Map a block number in a forward iteration into the block number in the
119 // corresponding reverse iteration. Used to obtain an index into
120 // block_order for reverse iterations.
121 intptr_t reverse_index(intptr_t index) const {
122 return block_order_.length() - index - 1;
123 }
124
125 class Assembler* assembler_;
126 const ParsedFunction& parsed_function_;
127 const GrowableArray<BlockEntryInstr*>& block_order_;
128
129 // Compiler specific per-block state. Indexed by postorder block number
130 // for convenience. This is not the block's index in the block order,
131 // which is reverse postorder.
132 BlockEntryInstr* current_block_;
133 ExceptionHandlerList* exception_handlers_list_;
134 DescriptorList* pc_descriptors_list_;
135 StackmapBuilder* stackmap_builder_;
136 GrowableArray<BlockInfo*> block_info_;
137 GrowableArray<DeoptimizationStub*> deopt_stubs_;
138 const bool is_optimizing_;
139
140 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompilerShared);
141 };
142
143
144 } // namespace dart
145
146
147 #endif // VM_FLOW_GRAPH_COMPILER_SHARED_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698