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

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

Issue 11228022: Cache parsed functions when inlining. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: virtual Created 8 years, 1 month 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/code_descriptors_test.cc ('k') | runtime/vm/flow_graph_inliner.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) 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/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 LongJump jump; 415 LongJump jump;
416 isolate->set_long_jump_base(&jump); 416 isolate->set_long_jump_base(&jump);
417 // Skips parsing if we need to only install unoptimized code. 417 // Skips parsing if we need to only install unoptimized code.
418 if (!optimized && !Code::Handle(function.unoptimized_code()).IsNull()) { 418 if (!optimized && !Code::Handle(function.unoptimized_code()).IsNull()) {
419 InstallUnoptimizedCode(function); 419 InstallUnoptimizedCode(function);
420 isolate->set_long_jump_base(base); 420 isolate->set_long_jump_base(base);
421 return Error::null(); 421 return Error::null();
422 } 422 }
423 if (setjmp(*jump.Set()) == 0) { 423 if (setjmp(*jump.Set()) == 0) {
424 TIMERSCOPE(time_compilation); 424 TIMERSCOPE(time_compilation);
425 ParsedFunction parsed_function(function); 425 ParsedFunction* parsed_function = new ParsedFunction(function);
426 if (FLAG_trace_compiler) { 426 if (FLAG_trace_compiler) {
427 OS::Print("Compiling %sfunction: '%s' @ token %"Pd"\n", 427 OS::Print("Compiling %sfunction: '%s' @ token %"Pd"\n",
428 (optimized ? "optimized " : ""), 428 (optimized ? "optimized " : ""),
429 function.ToFullyQualifiedCString(), 429 function.ToFullyQualifiedCString(),
430 function.token_pos()); 430 function.token_pos());
431 } 431 }
432 Parser::ParseFunction(&parsed_function); 432 Parser::ParseFunction(parsed_function);
433 parsed_function.AllocateVariables(); 433 parsed_function->AllocateVariables();
434 434
435 const bool success = 435 const bool success =
436 CompileParsedFunctionHelper(parsed_function, optimized); 436 CompileParsedFunctionHelper(*parsed_function, optimized);
437 if (optimized && !success) { 437 if (optimized && !success) {
438 // Optimizer bailed out. Disable optimizations and to never try again. 438 // Optimizer bailed out. Disable optimizations and to never try again.
439 if (FLAG_trace_compiler) { 439 if (FLAG_trace_compiler) {
440 OS::Print("--> disabling optimizations for '%s'\n", 440 OS::Print("--> disabling optimizations for '%s'\n",
441 function.ToFullyQualifiedCString()); 441 function.ToFullyQualifiedCString());
442 } 442 }
443 function.set_is_optimizable(false); 443 function.set_is_optimizable(false);
444 isolate->set_long_jump_base(base); 444 isolate->set_long_jump_base(base);
445 return Error::null(); 445 return Error::null();
446 } 446 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 func.set_result_type(Type::Handle(Type::DynamicType())); 559 func.set_result_type(Type::Handle(Type::DynamicType()));
560 func.set_num_fixed_parameters(0); 560 func.set_num_fixed_parameters(0);
561 func.SetNumOptionalParameters(0, true); 561 func.SetNumOptionalParameters(0, true);
562 // Manually generated AST, do not recompile. 562 // Manually generated AST, do not recompile.
563 func.set_is_optimizable(false); 563 func.set_is_optimizable(false);
564 564
565 // We compile the function here, even though InvokeStatic() below 565 // We compile the function here, even though InvokeStatic() below
566 // would compile func automatically. We are checking fewer invariants 566 // would compile func automatically. We are checking fewer invariants
567 // here. 567 // here.
568 ParsedFunction parsed_function(func); 568 ParsedFunction* parsed_function = new ParsedFunction(func);
569 parsed_function.SetNodeSequence(fragment); 569 parsed_function->SetNodeSequence(fragment);
570 parsed_function.set_default_parameter_values(Array::Handle()); 570 parsed_function->set_default_parameter_values(Array::Handle());
571 parsed_function.set_expression_temp_var( 571 parsed_function->set_expression_temp_var(
572 ParsedFunction::CreateExpressionTempVar(0)); 572 ParsedFunction::CreateExpressionTempVar(0));
573 fragment->scope()->AddVariable(parsed_function.expression_temp_var()); 573 fragment->scope()->AddVariable(parsed_function->expression_temp_var());
574 parsed_function.AllocateVariables(); 574 parsed_function->AllocateVariables();
575 575
576 // Non-optimized code generator. 576 // Non-optimized code generator.
577 CompileParsedFunctionHelper(parsed_function, false); 577 CompileParsedFunctionHelper(*parsed_function, false);
578 578
579 GrowableArray<const Object*> arguments; // no arguments. 579 GrowableArray<const Object*> arguments; // no arguments.
580 const Array& kNoArgumentNames = Array::Handle(); 580 const Array& kNoArgumentNames = Array::Handle();
581 Object& result = Object::Handle(); 581 Object& result = Object::Handle();
582 result = DartEntry::InvokeStatic(func, 582 result = DartEntry::InvokeStatic(func,
583 arguments, 583 arguments,
584 kNoArgumentNames); 584 kNoArgumentNames);
585 isolate->set_long_jump_base(base); 585 isolate->set_long_jump_base(base);
586 return result.raw(); 586 return result.raw();
587 } else { 587 } else {
588 Object& result = Object::Handle(); 588 Object& result = Object::Handle();
589 result = isolate->object_store()->sticky_error(); 589 result = isolate->object_store()->sticky_error();
590 isolate->object_store()->clear_sticky_error(); 590 isolate->object_store()->clear_sticky_error();
591 isolate->set_long_jump_base(base); 591 isolate->set_long_jump_base(base);
592 return result.raw(); 592 return result.raw();
593 } 593 }
594 UNREACHABLE(); 594 UNREACHABLE();
595 return Object::null(); 595 return Object::null();
596 } 596 }
597 597
598 } // namespace dart 598 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698