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

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

Issue 2584613002: PATCH (not to be comitted): Support for printing instruction statistics
Patch Set: Fixed polymorphic call inside try, added more tags for remaining unknown code Created 4 years 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
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_compiler_arm.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 #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/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/cha.h" 10 #include "vm/cha.h"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
13 #include "vm/debugger.h" 13 #include "vm/debugger.h"
14 #include "vm/deopt_instructions.h" 14 #include "vm/deopt_instructions.h"
15 #include "vm/exceptions.h" 15 #include "vm/exceptions.h"
16 #include "vm/flags.h" 16 #include "vm/flags.h"
17 #include "vm/flow_graph_allocator.h" 17 #include "vm/flow_graph_allocator.h"
18 #include "vm/il_printer.h" 18 #include "vm/il_printer.h"
19 #include "vm/intrinsifier.h" 19 #include "vm/intrinsifier.h"
20 #include "vm/locations.h" 20 #include "vm/locations.h"
21 #include "vm/log.h" 21 #include "vm/log.h"
22 #include "vm/longjump.h" 22 #include "vm/longjump.h"
23 #include "vm/object_store.h" 23 #include "vm/object_store.h"
24 #include "vm/parser.h" 24 #include "vm/parser.h"
25 #include "vm/raw_object.h" 25 #include "vm/raw_object.h"
26 #include "vm/stack_frame.h" 26 #include "vm/stack_frame.h"
27 #include "vm/stub_code.h" 27 #include "vm/stub_code.h"
28 #include "vm/symbols.h" 28 #include "vm/symbols.h"
29 #include "vm/timeline.h" 29 #include "vm/timeline.h"
30 #include "vm/code_statistics.h"
30 31
31 namespace dart { 32 namespace dart {
32 33
33 DEFINE_FLAG(bool, 34 DEFINE_FLAG(bool,
34 enable_simd_inline, 35 enable_simd_inline,
35 true, 36 true,
36 "Enable inlining of SIMD related method calls."); 37 "Enable inlining of SIMD related method calls.");
37 DEFINE_FLAG( 38 DEFINE_FLAG(
38 bool, 39 bool,
39 inline_smi_string_hashcode, 40 inline_smi_string_hashcode,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 201 }
201 202
202 203
203 FlowGraphCompiler::FlowGraphCompiler( 204 FlowGraphCompiler::FlowGraphCompiler(
204 Assembler* assembler, 205 Assembler* assembler,
205 FlowGraph* flow_graph, 206 FlowGraph* flow_graph,
206 const ParsedFunction& parsed_function, 207 const ParsedFunction& parsed_function,
207 bool is_optimizing, 208 bool is_optimizing,
208 const GrowableArray<const Function*>& inline_id_to_function, 209 const GrowableArray<const Function*>& inline_id_to_function,
209 const GrowableArray<TokenPosition>& inline_id_to_token_pos, 210 const GrowableArray<TokenPosition>& inline_id_to_token_pos,
210 const GrowableArray<intptr_t>& caller_inline_id) 211 const GrowableArray<intptr_t>& caller_inline_id,
212 CodeStatistics* stats)
211 : thread_(Thread::Current()), 213 : thread_(Thread::Current()),
212 zone_(Thread::Current()->zone()), 214 zone_(Thread::Current()->zone()),
213 assembler_(assembler), 215 assembler_(assembler),
214 parsed_function_(parsed_function), 216 parsed_function_(parsed_function),
215 flow_graph_(*flow_graph), 217 flow_graph_(*flow_graph),
216 block_order_(*flow_graph->CodegenBlockOrder(is_optimizing)), 218 block_order_(*flow_graph->CodegenBlockOrder(is_optimizing)),
217 current_block_(NULL), 219 current_block_(NULL),
218 exception_handlers_list_(NULL), 220 exception_handlers_list_(NULL),
219 pc_descriptors_list_(NULL), 221 pc_descriptors_list_(NULL),
220 stackmap_table_builder_(NULL), 222 stackmap_table_builder_(NULL),
(...skipping 16 matching lines...) Expand all
237 Class::ZoneHandle(isolate()->object_store()->int32x4_class())), 239 Class::ZoneHandle(isolate()->object_store()->int32x4_class())),
238 list_class_(Class::ZoneHandle(Library::Handle(Library::CoreLibrary()) 240 list_class_(Class::ZoneHandle(Library::Handle(Library::CoreLibrary())
239 .LookupClass(Symbols::List()))), 241 .LookupClass(Symbols::List()))),
240 parallel_move_resolver_(this), 242 parallel_move_resolver_(this),
241 pending_deoptimization_env_(NULL), 243 pending_deoptimization_env_(NULL),
242 deopt_id_to_ic_data_(NULL), 244 deopt_id_to_ic_data_(NULL),
243 edge_counters_array_(Array::ZoneHandle()), 245 edge_counters_array_(Array::ZoneHandle()),
244 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())), 246 inlined_code_intervals_(Array::ZoneHandle(Object::empty_array().raw())),
245 inline_id_to_function_(inline_id_to_function), 247 inline_id_to_function_(inline_id_to_function),
246 inline_id_to_token_pos_(inline_id_to_token_pos), 248 inline_id_to_token_pos_(inline_id_to_token_pos),
247 caller_inline_id_(caller_inline_id) { 249 caller_inline_id_(caller_inline_id),
250 stats_(stats) {
248 ASSERT(flow_graph->parsed_function().function().raw() == 251 ASSERT(flow_graph->parsed_function().function().raw() ==
249 parsed_function.function().raw()); 252 parsed_function.function().raw());
250 if (!is_optimizing) { 253 if (!is_optimizing) {
251 const intptr_t len = thread()->deopt_id(); 254 const intptr_t len = thread()->deopt_id();
252 deopt_id_to_ic_data_ = new (zone()) ZoneGrowableArray<const ICData*>(len); 255 deopt_id_to_ic_data_ = new (zone()) ZoneGrowableArray<const ICData*>(len);
253 deopt_id_to_ic_data_->SetLength(len); 256 deopt_id_to_ic_data_->SetLength(len);
254 for (intptr_t i = 0; i < len; i++) { 257 for (intptr_t i = 0; i < len; i++) {
255 (*deopt_id_to_ic_data_)[i] = NULL; 258 (*deopt_id_to_ic_data_)[i] = NULL;
256 } 259 }
257 // TODO(fschneider): Abstract iteration into ICDataArrayIterator. 260 // TODO(fschneider): Abstract iteration into ICDataArrayIterator.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Instructions that can be deoptimization targets need to record kDeopt 444 // Instructions that can be deoptimization targets need to record kDeopt
442 // PcDescriptor corresponding to their deopt id. GotoInstr records its 445 // PcDescriptor corresponding to their deopt id. GotoInstr records its
443 // own so that it can control the placement. 446 // own so that it can control the placement.
444 AddCurrentDescriptor(RawPcDescriptors::kDeopt, instr->deopt_id(), 447 AddCurrentDescriptor(RawPcDescriptors::kDeopt, instr->deopt_id(),
445 instr->token_pos()); 448 instr->token_pos());
446 } 449 }
447 AllocateRegistersLocally(instr); 450 AllocateRegistersLocally(instr);
448 } else if (instr->MayThrow() && 451 } else if (instr->MayThrow() &&
449 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { 452 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) {
450 // Optimized try-block: Sync locals to fixed stack locations. 453 // Optimized try-block: Sync locals to fixed stack locations.
454 SpecialStatsBegin(CombinedCodeStatistics::kTagTrySyncSpilling);
451 EmitTrySync(instr, CurrentTryIndex()); 455 EmitTrySync(instr, CurrentTryIndex());
456 SpecialStatsEnd(CombinedCodeStatistics::kTagTrySyncSpilling);
452 } 457 }
453 } 458 }
454 459
455 460
456 void FlowGraphCompiler::EmitSourceLine(Instruction* instr) { 461 void FlowGraphCompiler::EmitSourceLine(Instruction* instr) {
457 if (!instr->token_pos().IsReal() || (instr->env() == NULL)) { 462 if (!instr->token_pos().IsReal() || (instr->env() == NULL)) {
458 return; 463 return;
459 } 464 }
460 const Script& script = 465 const Script& script =
461 Script::Handle(zone(), instr->env()->function().script()); 466 Script::Handle(zone(), instr->env()->function().script());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 FrameStateClear(); 537 FrameStateClear();
533 } 538 }
534 #endif 539 #endif
535 540
536 LoopInfoComment(assembler(), *entry, *loop_headers); 541 LoopInfoComment(assembler(), *entry, *loop_headers);
537 542
538 entry->set_offset(assembler()->CodeSize()); 543 entry->set_offset(assembler()->CodeSize());
539 BeginCodeSourceRange(); 544 BeginCodeSourceRange();
540 ASSERT(pending_deoptimization_env_ == NULL); 545 ASSERT(pending_deoptimization_env_ == NULL);
541 pending_deoptimization_env_ = entry->env(); 546 pending_deoptimization_env_ = entry->env();
547 StatsBegin(entry);
542 entry->EmitNativeCode(this); 548 entry->EmitNativeCode(this);
549 StatsEnd(entry);
543 pending_deoptimization_env_ = NULL; 550 pending_deoptimization_env_ = NULL;
544 EndCodeSourceRange(entry->token_pos()); 551 EndCodeSourceRange(entry->token_pos());
545 // Compile all successors until an exit, branch, or a block entry. 552 // Compile all successors until an exit, branch, or a block entry.
546 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 553 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
547 Instruction* instr = it.Current(); 554 Instruction* instr = it.Current();
555
556 StatsBegin(instr);
557
548 // Compose intervals. 558 // Compose intervals.
549 if (instr->has_inlining_id() && is_optimizing()) { 559 if (instr->has_inlining_id() && is_optimizing()) {
550 if (prev_inlining_id != instr->inlining_id()) { 560 if (prev_inlining_id != instr->inlining_id()) {
551 intervals.Add( 561 intervals.Add(
552 IntervalStruct(prev_offset, prev_inlining_pos, prev_inlining_id)); 562 IntervalStruct(prev_offset, prev_inlining_pos, prev_inlining_id));
553 prev_offset = assembler()->CodeSize(); 563 prev_offset = assembler()->CodeSize();
554 prev_inlining_id = instr->inlining_id(); 564 prev_inlining_id = instr->inlining_id();
555 if (prev_inlining_id < inline_id_to_token_pos_.length()) { 565 if (prev_inlining_id < inline_id_to_token_pos_.length()) {
556 prev_inlining_pos = inline_id_to_token_pos_[prev_inlining_id]; 566 prev_inlining_pos = inline_id_to_token_pos_[prev_inlining_id];
557 } else { 567 } else {
(...skipping 24 matching lines...) Expand all
582 pending_deoptimization_env_ = NULL; 592 pending_deoptimization_env_ = NULL;
583 EmitInstructionEpilogue(instr); 593 EmitInstructionEpilogue(instr);
584 EndCodeSourceRange(instr->token_pos()); 594 EndCodeSourceRange(instr->token_pos());
585 } 595 }
586 596
587 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC) 597 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC)
588 if (!is_optimizing()) { 598 if (!is_optimizing()) {
589 FrameStateUpdateWith(instr); 599 FrameStateUpdateWith(instr);
590 } 600 }
591 #endif 601 #endif
602 StatsEnd(instr);
592 } 603 }
593 604
594 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC) 605 #if defined(DEBUG) && !defined(TARGET_ARCH_DBC)
595 ASSERT(is_optimizing() || FrameStateIsSafeToCall()); 606 ASSERT(is_optimizing() || FrameStateIsSafeToCall());
596 #endif 607 #endif
597 } 608 }
598 609
599 if (is_optimizing()) { 610 if (is_optimizing()) {
600 LogBlock lb; 611 LogBlock lb;
601 intervals.Add( 612 intervals.Add(
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) { 1156 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) {
1146 // TODO(27590) Store Field object inside RawFunction::data_ if possible. 1157 // TODO(27590) Store Field object inside RawFunction::data_ if possible.
1147 name = Field::NameFromGetter(name); 1158 name = Field::NameFromGetter(name);
1148 const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name)); 1159 const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name));
1149 ASSERT(!field.IsNull()); 1160 ASSERT(!field.IsNull());
1150 1161
1151 // Only intrinsify getter if the field cannot contain a mutable double. 1162 // Only intrinsify getter if the field cannot contain a mutable double.
1152 // Reading from a mutable double box requires allocating a fresh double. 1163 // Reading from a mutable double box requires allocating a fresh double.
1153 if (field.is_instance() && 1164 if (field.is_instance() &&
1154 (FLAG_precompiled_mode || !IsPotentialUnboxedField(field))) { 1165 (FLAG_precompiled_mode || !IsPotentialUnboxedField(field))) {
1166 SpecialStatsBegin(CombinedCodeStatistics::kTagIntrinsics);
1155 GenerateInlinedGetter(field.Offset()); 1167 GenerateInlinedGetter(field.Offset());
1168 SpecialStatsEnd(CombinedCodeStatistics::kTagIntrinsics);
1156 return !FLAG_use_field_guards; 1169 return !FLAG_use_field_guards;
1157 } 1170 }
1158 return false; 1171 return false;
1159 } 1172 }
1160 if (parsed_function().function().kind() == RawFunction::kImplicitSetter) { 1173 if (parsed_function().function().kind() == RawFunction::kImplicitSetter) {
1161 // TODO(27590) Store Field object inside RawFunction::data_ if possible. 1174 // TODO(27590) Store Field object inside RawFunction::data_ if possible.
1162 name = Field::NameFromSetter(name); 1175 name = Field::NameFromSetter(name);
1163 const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name)); 1176 const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name));
1164 ASSERT(!field.IsNull()); 1177 ASSERT(!field.IsNull());
1165 1178
1166 if (field.is_instance() && 1179 if (field.is_instance() &&
1167 (FLAG_precompiled_mode || field.guarded_cid() == kDynamicCid)) { 1180 (FLAG_precompiled_mode || field.guarded_cid() == kDynamicCid)) {
1181 SpecialStatsBegin(CombinedCodeStatistics::kTagIntrinsics);
1168 GenerateInlinedSetter(field.Offset()); 1182 GenerateInlinedSetter(field.Offset());
1183 SpecialStatsEnd(CombinedCodeStatistics::kTagIntrinsics);
1169 return !FLAG_use_field_guards; 1184 return !FLAG_use_field_guards;
1170 } 1185 }
1171 return false; 1186 return false;
1172 } 1187 }
1173 } 1188 }
1174 1189
1175 EnterIntrinsicMode(); 1190 EnterIntrinsicMode();
1176 1191
1192 SpecialStatsBegin(CombinedCodeStatistics::kTagIntrinsics);
1177 bool complete = Intrinsifier::Intrinsify(parsed_function(), this); 1193 bool complete = Intrinsifier::Intrinsify(parsed_function(), this);
1194 SpecialStatsEnd(CombinedCodeStatistics::kTagIntrinsics);
1178 1195
1179 ExitIntrinsicMode(); 1196 ExitIntrinsicMode();
1180 1197
1181 // "Deoptimization" from intrinsic continues here. All deoptimization 1198 // "Deoptimization" from intrinsic continues here. All deoptimization
1182 // branches from intrinsic code redirect to here where the slow-path 1199 // branches from intrinsic code redirect to here where the slow-path
1183 // (normal function body) starts. 1200 // (normal function body) starts.
1184 // This means that there must not be any side-effects in intrinsic code 1201 // This means that there must not be any side-effects in intrinsic code
1185 // before any deoptimization point. 1202 // before any deoptimization point.
1186 ASSERT(!intrinsic_slow_path_label_.IsBound()); 1203 ASSERT(!intrinsic_slow_path_label_.IsBound());
1187 assembler()->Bind(&intrinsic_slow_path_label_); 1204 assembler()->Bind(&intrinsic_slow_path_label_);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 1998
1982 1999
1983 void FlowGraphCompiler::FrameStateClear() { 2000 void FlowGraphCompiler::FrameStateClear() {
1984 ASSERT(!is_optimizing()); 2001 ASSERT(!is_optimizing());
1985 frame_state_.TruncateTo(0); 2002 frame_state_.TruncateTo(0);
1986 } 2003 }
1987 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) 2004 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC)
1988 2005
1989 2006
1990 } // namespace dart 2007 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698