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

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

Issue 23589008: Clean up handling of guarded fields in the flow graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « no previous file | runtime/vm/flow_graph.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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool done = false; 263 bool done = false;
264 // volatile because the variable may be clobbered by a longjmp. 264 // volatile because the variable may be clobbered by a longjmp.
265 volatile bool use_far_branches = false; 265 volatile bool use_far_branches = false;
266 while (!done) { 266 while (!done) {
267 const intptr_t prev_deopt_id = isolate->deopt_id(); 267 const intptr_t prev_deopt_id = isolate->deopt_id();
268 isolate->set_deopt_id(0); 268 isolate->set_deopt_id(0);
269 LongJump* old_base = isolate->long_jump_base(); 269 LongJump* old_base = isolate->long_jump_base();
270 LongJump bailout_jump; 270 LongJump bailout_jump;
271 isolate->set_long_jump_base(&bailout_jump); 271 isolate->set_long_jump_base(&bailout_jump);
272 if (setjmp(*bailout_jump.Set()) == 0) { 272 if (setjmp(*bailout_jump.Set()) == 0) {
273 FlowGraphBuilder* builder = NULL;
274 FlowGraph* flow_graph = NULL; 273 FlowGraph* flow_graph = NULL;
275 GrowableArray<const Field*> guarded_fields;
276 // TimerScope needs an isolate to be properly terminated in case of a 274 // TimerScope needs an isolate to be properly terminated in case of a
277 // LongJump. 275 // LongJump.
278 { 276 {
279 TimerScope timer(FLAG_compiler_stats, 277 TimerScope timer(FLAG_compiler_stats,
280 &CompilerStats::graphbuilder_timer, 278 &CompilerStats::graphbuilder_timer,
281 isolate); 279 isolate);
282 Array& ic_data_array = Array::Handle(); 280 Array& ic_data_array = Array::Handle();
283 if (optimized) { 281 if (optimized) {
284 ASSERT(function.HasCode()); 282 ASSERT(function.HasCode());
285 // Extract type feedback before the graph is built, as the graph 283 // Extract type feedback before the graph is built, as the graph
286 // builder uses it to attach it to nodes. 284 // builder uses it to attach it to nodes.
287 ASSERT(function.deoptimization_counter() < 285 ASSERT(function.deoptimization_counter() <
288 FLAG_deoptimization_counter_threshold); 286 FLAG_deoptimization_counter_threshold);
289 const Code& unoptimized_code = 287 const Code& unoptimized_code =
290 Code::Handle(function.unoptimized_code()); 288 Code::Handle(function.unoptimized_code());
291 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray(); 289 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray();
292 } 290 }
293 291
294 // Build the flow graph. 292 // Build the flow graph.
295 builder = new FlowGraphBuilder(parsed_function, 293 FlowGraphBuilder builder(parsed_function,
296 ic_data_array, 294 ic_data_array,
297 NULL, // NULL = not inlining. 295 NULL, // NULL = not inlining.
298 &guarded_fields, 296 osr_id);
299 osr_id); 297 flow_graph = builder.BuildGraph();
300 flow_graph = builder->BuildGraph();
301 } 298 }
302 299
303 if (FLAG_print_flow_graph || 300 if (FLAG_print_flow_graph ||
304 (optimized && FLAG_print_flow_graph_optimized)) { 301 (optimized && FLAG_print_flow_graph_optimized)) {
305 if (osr_id == Isolate::kNoDeoptId) { 302 if (osr_id == Isolate::kNoDeoptId) {
306 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); 303 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph);
307 } else { 304 } else {
308 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); 305 FlowGraphPrinter::PrintGraph("For OSR", flow_graph);
309 } 306 }
310 } 307 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (optimized) { 541 if (optimized) {
545 if (osr_id == Isolate::kNoDeoptId) { 542 if (osr_id == Isolate::kNoDeoptId) {
546 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode())); 543 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode()));
547 if (FLAG_trace_compiler) { 544 if (FLAG_trace_compiler) {
548 OS::Print("--> patching entry %#" Px "\n", 545 OS::Print("--> patching entry %#" Px "\n",
549 Code::Handle(function.unoptimized_code()).EntryPoint()); 546 Code::Handle(function.unoptimized_code()).EntryPoint());
550 } 547 }
551 } 548 }
552 function.SetCode(code); 549 function.SetCode(code);
553 550
554 for (intptr_t i = 0; i < guarded_fields.length(); i++) { 551 for (intptr_t i = 0;
555 const Field& field = *guarded_fields[i]; 552 i < flow_graph->guarded_fields()->length();
556 field.RegisterDependentCode(code); 553 i++) {
554 const Field* field = (*flow_graph->guarded_fields())[i];
555 field->RegisterDependentCode(code);
557 } 556 }
558 } else { 557 } else {
559 function.set_unoptimized_code(code); 558 function.set_unoptimized_code(code);
560 function.SetCode(code); 559 function.SetCode(code);
561 ASSERT(CodePatcher::CodeIsPatchable(code)); 560 ASSERT(CodePatcher::CodeIsPatchable(code));
562 } 561 }
563 } 562 }
564 is_compiled = true; 563 is_compiled = true;
565 done = true; 564 done = true;
566 } else { 565 } else {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 Object::Handle(isolate->object_store()->sticky_error()); 924 Object::Handle(isolate->object_store()->sticky_error());
926 isolate->object_store()->clear_sticky_error(); 925 isolate->object_store()->clear_sticky_error();
927 isolate->set_long_jump_base(base); 926 isolate->set_long_jump_base(base);
928 return result.raw(); 927 return result.raw();
929 } 928 }
930 UNREACHABLE(); 929 UNREACHABLE();
931 return Object::null(); 930 return Object::null();
932 } 931 }
933 932
934 } // namespace dart 933 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698