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

Side by Side Diff: runtime/vm/flow_graph_compiler.cc

Issue 10823131: Add deopt info to code object and print it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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.h ('k') | runtime/vm/flow_graph_compiler_ia32.h » ('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) 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 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
11 #include "vm/deopt_instructions.h"
11 #include "vm/il_printer.h" 12 #include "vm/il_printer.h"
12 #include "vm/intrinsifier.h" 13 #include "vm/intrinsifier.h"
13 #include "vm/locations.h" 14 #include "vm/locations.h"
14 #include "vm/longjump.h" 15 #include "vm/longjump.h"
15 #include "vm/object_store.h" 16 #include "vm/object_store.h"
16 #include "vm/parser.h" 17 #include "vm/parser.h"
17 #include "vm/stub_code.h" 18 #include "vm/stub_code.h"
18 #include "vm/symbols.h" 19 #include "vm/symbols.h"
19 20
20 namespace dart { 21 namespace dart {
21 22
22 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); 23 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
23 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); 24 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function.");
24 DECLARE_FLAG(bool, code_comments); 25 DECLARE_FLAG(bool, code_comments);
25 DECLARE_FLAG(bool, enable_type_checks); 26 DECLARE_FLAG(bool, enable_type_checks);
26 DECLARE_FLAG(bool, intrinsify); 27 DECLARE_FLAG(bool, intrinsify);
27 DECLARE_FLAG(bool, report_usage_count); 28 DECLARE_FLAG(bool, report_usage_count);
28 DECLARE_FLAG(bool, trace_functions); 29 DECLARE_FLAG(bool, trace_functions);
29 DECLARE_FLAG(int, optimization_counter_threshold); 30 DECLARE_FLAG(int, optimization_counter_threshold);
30 31
32 RawDeoptInfo* DeoptimizationStub::CreateDeoptInfo(FlowGraphCompiler* compiler) {
33 if (deoptimization_env_ == NULL) return DeoptInfo::null();
34 const intptr_t fixed_parameter_count =
35 deoptimization_env_->fixed_parameter_count();
36 DeoptInfoBuilder builder(compiler->object_table(), fixed_parameter_count);
37
38 const Function& function = compiler->parsed_function().function();
39 intptr_t slot_ix = 0;
40 builder.AddReturnAddress(function, deopt_id_, slot_ix++);
41
42 // All locals between TOS and PC-marker.
43 const GrowableArray<Value*>& values = deoptimization_env_->values();
44 // const intptr_t local_slot_count = values.length() - fixed_parameter_count;
45 for (intptr_t i = values.length() - 1; i >= fixed_parameter_count; i--) {
46 builder.AddCopy(deoptimization_env_->LocationAt(i), *values[i], slot_ix++);
47 }
48
49 // PC marker, caller-fp, caller-pc.
50 builder.AddPcMarker(function, slot_ix++);
51 builder.AddCallerFp(slot_ix++);
52 builder.AddCallerPc(slot_ix++);
53 // Incoming arguments.
54 for (intptr_t i = fixed_parameter_count - 1; i >= 0; i--) {
55 builder.AddCopy(deoptimization_env_->LocationAt(i), *values[i], slot_ix++);
56 }
57
58 const DeoptInfo& deopt_info = DeoptInfo::Handle(builder.CreateDeoptInfo());
59 return deopt_info.raw();
60 }
61
31 62
32 FlowGraphCompiler::FlowGraphCompiler( 63 FlowGraphCompiler::FlowGraphCompiler(
33 Assembler* assembler, 64 Assembler* assembler,
34 const ParsedFunction& parsed_function, 65 const ParsedFunction& parsed_function,
35 const GrowableArray<BlockEntryInstr*>& block_order, 66 const GrowableArray<BlockEntryInstr*>& block_order,
36 bool is_optimizing, 67 bool is_optimizing,
37 bool is_ssa, 68 bool is_ssa,
38 bool is_leaf) 69 bool is_leaf)
39 : assembler_(assembler), 70 : assembler_(assembler),
40 parsed_function_(parsed_function), 71 parsed_function_(parsed_function),
41 block_order_(block_order), 72 block_order_(block_order),
42 current_block_(NULL), 73 current_block_(NULL),
43 exception_handlers_list_(NULL), 74 exception_handlers_list_(NULL),
44 pc_descriptors_list_(NULL), 75 pc_descriptors_list_(NULL),
45 stackmap_table_builder_(NULL), 76 stackmap_table_builder_(NULL),
46 block_info_(block_order.length()), 77 block_info_(block_order.length()),
47 deopt_stubs_(), 78 deopt_stubs_(),
79 object_table_(GrowableObjectArray::Handle(GrowableObjectArray::New())),
48 is_optimizing_(is_optimizing), 80 is_optimizing_(is_optimizing),
49 is_ssa_(is_ssa), 81 is_ssa_(is_ssa),
50 is_dart_leaf_(is_leaf), 82 is_dart_leaf_(is_leaf),
51 bool_true_(Bool::ZoneHandle(Bool::True())), 83 bool_true_(Bool::ZoneHandle(Bool::True())),
52 bool_false_(Bool::ZoneHandle(Bool::False())), 84 bool_false_(Bool::ZoneHandle(Bool::False())),
53 double_class_(Class::ZoneHandle( 85 double_class_(Class::ZoneHandle(
54 Isolate::Current()->object_store()->double_class())), 86 Isolate::Current()->object_store()->double_class())),
55 frame_register_allocator_(this, is_optimizing, is_ssa), 87 frame_register_allocator_(this, is_optimizing, is_ssa),
56 parallel_move_resolver_(this) { 88 parallel_move_resolver_(this) {
57 ASSERT(assembler != NULL); 89 ASSERT(assembler != NULL);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 190
159 bool FlowGraphCompiler::IsNextBlock(BlockEntryInstr* block_entry) const { 191 bool FlowGraphCompiler::IsNextBlock(BlockEntryInstr* block_entry) const {
160 intptr_t current_index = reverse_index(current_block()->postorder_number()); 192 intptr_t current_index = reverse_index(current_block()->postorder_number());
161 return (current_index < (block_order().length() - 1)) && 193 return (current_index < (block_order().length() - 1)) &&
162 (block_order()[current_index + 1] == block_entry); 194 (block_order()[current_index + 1] == block_entry);
163 } 195 }
164 196
165 197
166 void FlowGraphCompiler::GenerateDeferredCode() { 198 void FlowGraphCompiler::GenerateDeferredCode() {
167 for (intptr_t i = 0; i < deopt_stubs_.length(); i++) { 199 for (intptr_t i = 0; i < deopt_stubs_.length(); i++) {
168 deopt_stubs_[i]->GenerateCode(this); 200 deopt_stubs_[i]->GenerateCode(this, i);
169 } 201 }
170 } 202 }
171 203
172 204
173 void FlowGraphCompiler::AddExceptionHandler(intptr_t try_index, 205 void FlowGraphCompiler::AddExceptionHandler(intptr_t try_index,
174 intptr_t pc_offset) { 206 intptr_t pc_offset) {
175 exception_handlers_list_->AddHandler(try_index, pc_offset); 207 exception_handlers_list_->AddHandler(try_index, pc_offset);
176 } 208 }
177 209
178 210
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 257
226 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) { 258 void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) {
227 ASSERT(pc_descriptors_list_ != NULL); 259 ASSERT(pc_descriptors_list_ != NULL);
228 const PcDescriptors& descriptors = PcDescriptors::Handle( 260 const PcDescriptors& descriptors = PcDescriptors::Handle(
229 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); 261 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint()));
230 descriptors.Verify(parsed_function_.function().is_optimizable()); 262 descriptors.Verify(parsed_function_.function().is_optimizable());
231 code.set_pc_descriptors(descriptors); 263 code.set_pc_descriptors(descriptors);
232 } 264 }
233 265
234 266
267 void FlowGraphCompiler::FinalizeDeoptInfo(const Code& code) {
268 const Array& array =
269 Array::Handle(Array::New(deopt_stubs_.length(), Heap::kOld));
270 DeoptInfo& info = DeoptInfo::Handle();
271 for (intptr_t i = 0; i < deopt_stubs_.length(); i++) {
272 info = deopt_stubs_[i]->CreateDeoptInfo(this);
273 array.SetAt(i, info);
274 }
275 code.set_deopt_info_array(array);
276 const Array& object_array = Array::Handle(Array::MakeArray(object_table_));
277 code.set_object_table(object_array);
278 }
279
280
235 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) { 281 void FlowGraphCompiler::FinalizeStackmaps(const Code& code) {
236 if (stackmap_table_builder_ == NULL) { 282 if (stackmap_table_builder_ == NULL) {
237 // The unoptimizing compiler has no stack maps. 283 // The unoptimizing compiler has no stack maps.
238 code.set_stackmaps(Array::Handle()); 284 code.set_stackmaps(Array::Handle());
239 } else { 285 } else {
240 // Finalize the stack map array and add it to the code object. 286 // Finalize the stack map array and add it to the code object.
241 code.set_stackmaps( 287 code.set_stackmaps(
242 Array::Handle(stackmap_table_builder_->FinalizeStackmaps(code))); 288 Array::Handle(stackmap_table_builder_->FinalizeStackmaps(code)));
243 } 289 }
244 } 290 }
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 return; 847 return;
802 } 848 }
803 } 849 }
804 850
805 // This move is not blocked. 851 // This move is not blocked.
806 EmitMove(index); 852 EmitMove(index);
807 } 853 }
808 854
809 855
810 } // namespace dart 856 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698