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_ia32.h

Issue 10559035: Implement a simple register allocator that tries to keep instruction results in registers. (Closed) Base URL: https://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
OLDNEW
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_FLOW_GRAPH_COMPILER_IA32_H_ 5 #ifndef VM_FLOW_GRAPH_COMPILER_IA32_H_
6 #define VM_FLOW_GRAPH_COMPILER_IA32_H_ 6 #define VM_FLOW_GRAPH_COMPILER_IA32_H_
7 7
8 #ifndef VM_FLOW_GRAPH_COMPILER_H_ 8 #ifndef VM_FLOW_GRAPH_COMPILER_H_
9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_ia32.h. 9 #error Include flow_graph_compiler.h instead of flow_graph_compiler_ia32.h.
10 #endif 10 #endif
11 11
12 #include "vm/assembler.h"
13 #include "vm/assembler_macros.h"
14 #include "vm/code_descriptors.h"
15 #include "vm/code_generator.h"
16 #include "vm/intermediate_language.h"
17
18 namespace dart { 12 namespace dart {
19 13
20 class AbstractType; 14 class AbstractType;
21 class Assembler; 15 class Assembler;
22 class Code; 16 class Code;
23 class DeoptimizationStub; 17 class DeoptimizationStub;
18 class FlowGraphCompiler;
24 template <typename T> class GrowableArray; 19 template <typename T> class GrowableArray;
25 class ParsedFunction; 20 class ParsedFunction;
26 class StackMapBuilder; 21 class StackMapBuilder;
27 22
23
28 // Stubbed out implementation of graph compiler, bails out immediately if 24 // Stubbed out implementation of graph compiler, bails out immediately if
29 // CompileGraph is called. The rest of the public API is UNIMPLEMENTED. 25 // CompileGraph is called. The rest of the public API is UNIMPLEMENTED.
30 class FlowGraphCompiler : public ValueObject { 26 class FlowGraphCompiler : public ValueObject {
31 private: 27 private:
32 struct BlockInfo : public ZoneAllocated { 28 struct BlockInfo : public ZoneAllocated {
33 public: 29 public:
34 BlockInfo() : label() { } 30 BlockInfo() : label() { }
35 Label label; 31 Label label;
36 }; 32 };
37 33
38 public: 34 public:
39 FlowGraphCompiler(Assembler* assembler, 35 FlowGraphCompiler(Assembler* assembler,
40 const ParsedFunction& parsed_function, 36 const ParsedFunction& parsed_function,
41 const GrowableArray<BlockEntryInstr*>& block_order, 37 const GrowableArray<BlockEntryInstr*>& block_order,
42 bool is_optimizing); 38 bool is_optimizing);
43 39
44 virtual ~FlowGraphCompiler(); 40 ~FlowGraphCompiler();
45 41
46 // Accessors. 42 // Accessors.
47 Assembler* assembler() const { return assembler_; } 43 Assembler* assembler() const { return assembler_; }
48 const ParsedFunction& parsed_function() const { return parsed_function_; } 44 const ParsedFunction& parsed_function() const { return parsed_function_; }
49 const GrowableArray<BlockEntryInstr*>& block_order() const { 45 const GrowableArray<BlockEntryInstr*>& block_order() const {
50 return block_order_; 46 return block_order_;
51 } 47 }
52 DescriptorList* pc_descriptors_list() const { 48 DescriptorList* pc_descriptors_list() const {
53 return pc_descriptors_list_; 49 return pc_descriptors_list_;
54 } 50 }
(...skipping 17 matching lines...) Expand all
72 68
73 void LoadDoubleOrSmiToXmm(XmmRegister result, 69 void LoadDoubleOrSmiToXmm(XmmRegister result,
74 Register reg, 70 Register reg,
75 Register temp, 71 Register temp,
76 Label* not_double_or_smi); 72 Label* not_double_or_smi);
77 73
78 // Returns 'true' if code generation for this function is complete, i.e., 74 // Returns 'true' if code generation for this function is complete, i.e.,
79 // no fall-through to regular code is needed. 75 // no fall-through to regular code is needed.
80 bool TryIntrinsify(); 76 bool TryIntrinsify();
81 77
82 virtual void GenerateCallRuntime(intptr_t cid, 78 void GenerateCallRuntime(intptr_t cid,
83 intptr_t token_index, 79 intptr_t token_index,
84 intptr_t try_index, 80 intptr_t try_index,
85 const RuntimeEntry& entry); 81 const RuntimeEntry& entry);
86 82
87 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit 83 // Returns pc-offset (in bytes) of the pc after the call, can be used to emit
88 // pc-descriptor information. 84 // pc-descriptor information.
89 virtual intptr_t EmitStaticCall(const Function& function, 85 intptr_t EmitStaticCall(const Function& function,
90 const Array& arguments_descriptor, 86 const Array& arguments_descriptor,
91 intptr_t argument_count); 87 intptr_t argument_count);
92 88
93 virtual void GenerateCall(intptr_t token_index, 89 void GenerateCall(intptr_t token_index,
94 intptr_t try_index, 90 intptr_t try_index,
95 const ExternalLabel* label, 91 const ExternalLabel* label,
96 PcDescriptors::Kind kind); 92 PcDescriptors::Kind kind);
97 virtual void GenerateInstanceOf(intptr_t cid, 93 void GenerateInstanceOf(intptr_t cid,
98 intptr_t token_index, 94 intptr_t token_index,
99 intptr_t try_index, 95 intptr_t try_index,
100 const AbstractType& type, 96 const AbstractType& type,
101 bool negate_result); 97 bool negate_result);
102 virtual void GenerateAssertAssignable(intptr_t cid, 98 void GenerateAssertAssignable(intptr_t cid,
103 intptr_t token_index, 99 intptr_t token_index,
104 intptr_t try_index, 100 intptr_t try_index,
105 const AbstractType& dst_type, 101 const AbstractType& dst_type,
106 const String& dst_name); 102 const String& dst_name);
107 103
108 void GenerateInstanceCall(intptr_t cid, 104 void GenerateInstanceCall(intptr_t cid,
109 intptr_t token_index, 105 intptr_t token_index,
110 intptr_t try_index, 106 intptr_t try_index,
111 const String& function_name, 107 const String& function_name,
112 intptr_t argument_count, 108 intptr_t argument_count,
113 const Array& argument_names, 109 const Array& argument_names,
114 intptr_t checked_argument_count); 110 intptr_t checked_argument_count);
115 111
116 void GenerateStaticCall(intptr_t cid, 112 void GenerateStaticCall(intptr_t cid,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 Register reg1 = kNoRegister, 165 Register reg1 = kNoRegister,
170 Register reg2 = kNoRegister, 166 Register reg2 = kNoRegister,
171 Register reg3 = kNoRegister); 167 Register reg3 = kNoRegister);
172 168
173 void FinalizeExceptionHandlers(const Code& code); 169 void FinalizeExceptionHandlers(const Code& code);
174 void FinalizePcDescriptors(const Code& code); 170 void FinalizePcDescriptors(const Code& code);
175 void FinalizeStackmaps(const Code& code); 171 void FinalizeStackmaps(const Code& code);
176 void FinalizeVarDescriptors(const Code& code); 172 void FinalizeVarDescriptors(const Code& code);
177 void FinalizeComments(const Code& code); 173 void FinalizeComments(const Code& code);
178 174
175 FrameRegisterAllocator* frame_register_allocator() {
176 return &frame_register_allocator_;
177 }
178
179 static const int kLocalsOffsetFromFP = (-1 * kWordSize); 179 static const int kLocalsOffsetFromFP = (-1 * kWordSize);
180 180
181 const Bool& bool_true() const { return bool_true_; } 181 const Bool& bool_true() const { return bool_true_; }
182 const Bool& bool_false() const { return bool_false_; } 182 const Bool& bool_false() const { return bool_false_; }
183 const Class& double_class() const { return double_class_; } 183 const Class& double_class() const { return double_class_; }
184 184
185 private: 185 private:
186 friend class DeoptimizationStub; 186 friend class DeoptimizationStub;
187 187
188 void GenerateDeferredCode(); 188 void GenerateDeferredCode();
189 189
190 void CopyParameters(); 190 void CopyParameters();
191 virtual void EmitInstructionPrologue(Instruction* instr); 191 void EmitInstructionPrologue(Instruction* instr);
192 192
193 virtual void GenerateInlinedGetter(intptr_t offset); 193 void GenerateInlinedGetter(intptr_t offset);
194 virtual void GenerateInlinedSetter(intptr_t offset); 194 void GenerateInlinedSetter(intptr_t offset);
195 195
196 RawSubtypeTestCache* GenerateInlineInstanceof(intptr_t cid, 196 RawSubtypeTestCache* GenerateInlineInstanceof(intptr_t cid,
197 intptr_t token_index, 197 intptr_t token_index,
198 const AbstractType& type, 198 const AbstractType& type,
199 Label* is_instance_lbl, 199 Label* is_instance_lbl,
200 Label* is_not_instance_lbl); 200 Label* is_not_instance_lbl);
201 201
202 RawSubtypeTestCache* GenerateInstantiatedTypeWithArgumentsTest( 202 RawSubtypeTestCache* GenerateInstantiatedTypeWithArgumentsTest(
203 intptr_t cid, 203 intptr_t cid,
204 intptr_t token_index, 204 intptr_t token_index,
(...skipping 29 matching lines...) Expand all
234 234
235 RawSubtypeTestCache* GenerateCallSubtypeTestStub(TypeTestStubKind test_kind, 235 RawSubtypeTestCache* GenerateCallSubtypeTestStub(TypeTestStubKind test_kind,
236 Register instance_reg, 236 Register instance_reg,
237 Register type_arguments_reg, 237 Register type_arguments_reg,
238 Register temp_reg, 238 Register temp_reg,
239 Label* is_instance_lbl, 239 Label* is_instance_lbl,
240 Label* is_not_instance_lbl); 240 Label* is_not_instance_lbl);
241 241
242 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false); 242 void GenerateBoolToJump(Register bool_reg, Label* is_true, Label* is_false);
243 243
244 virtual void CheckClassIds(Register class_id_reg, 244 void CheckClassIds(Register class_id_reg,
245 const GrowableArray<intptr_t>& class_ids, 245 const GrowableArray<intptr_t>& class_ids,
246 Label* is_equal_lbl, 246 Label* is_equal_lbl,
247 Label* is_not_equal_lbl); 247 Label* is_not_equal_lbl);
248 248
249 249
250 // Map a block number in a forward iteration into the block number in the 250 // Map a block number in a forward iteration into the block number in the
251 // corresponding reverse iteration. Used to obtain an index into 251 // corresponding reverse iteration. Used to obtain an index into
252 // block_order for reverse iterations. 252 // block_order for reverse iterations.
253 intptr_t reverse_index(intptr_t index) const { 253 intptr_t reverse_index(intptr_t index) const {
254 return block_order_.length() - index - 1; 254 return block_order_.length() - index - 1;
255 } 255 }
256 256
257 class Assembler* assembler_; 257 class Assembler* assembler_;
258 const ParsedFunction& parsed_function_; 258 const ParsedFunction& parsed_function_;
259 const GrowableArray<BlockEntryInstr*>& block_order_; 259 const GrowableArray<BlockEntryInstr*>& block_order_;
260 260
261 // Compiler specific per-block state. Indexed by postorder block number 261 // Compiler specific per-block state. Indexed by postorder block number
262 // for convenience. This is not the block's index in the block order, 262 // for convenience. This is not the block's index in the block order,
263 // which is reverse postorder. 263 // which is reverse postorder.
264 BlockEntryInstr* current_block_; 264 BlockEntryInstr* current_block_;
265 ExceptionHandlerList* exception_handlers_list_; 265 ExceptionHandlerList* exception_handlers_list_;
266 DescriptorList* pc_descriptors_list_; 266 DescriptorList* pc_descriptors_list_;
267 StackmapBuilder* stackmap_builder_; 267 StackmapBuilder* stackmap_builder_;
268 GrowableArray<BlockInfo*> block_info_; 268 GrowableArray<BlockInfo*> block_info_;
269 GrowableArray<DeoptimizationStub*> deopt_stubs_; 269 GrowableArray<DeoptimizationStub*> deopt_stubs_;
270 const bool is_optimizing_; 270 const bool is_optimizing_;
271 271
272 const Bool& bool_true_; 272 const Bool& bool_true_;
273 const Bool& bool_false_; 273 const Bool& bool_false_;
274 const Class& double_class_; 274 const Class& double_class_;
275 275
276 FrameRegisterAllocator frame_register_allocator_;
277
276 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); 278 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler);
277 }; 279 };
278 280
279 281
280 class DeoptimizationStub : public ZoneAllocated { 282 class DeoptimizationStub : public ZoneAllocated {
281 public: 283 public:
282 DeoptimizationStub(intptr_t deopt_id, 284 DeoptimizationStub(intptr_t deopt_id,
283 intptr_t deopt_token_index, 285 intptr_t deopt_token_index,
284 intptr_t try_index, 286 intptr_t try_index,
285 DeoptReasonId reason) 287 DeoptReasonId reason)
(...skipping 18 matching lines...) Expand all
304 GrowableArray<Register> registers_; 306 GrowableArray<Register> registers_;
305 Label entry_label_; 307 Label entry_label_;
306 308
307 DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub); 309 DISALLOW_COPY_AND_ASSIGN(DeoptimizationStub);
308 }; 310 };
309 311
310 312
311 } // namespace dart 313 } // namespace dart
312 314
313 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_ 315 #endif // VM_FLOW_GRAPH_COMPILER_IA32_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698