| OLD | NEW |
| 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 isolate->set_long_jump_base(base); | 469 isolate->set_long_jump_base(base); |
| 470 return Error::null(); | 470 return Error::null(); |
| 471 } | 471 } |
| 472 if (setjmp(*jump.Set()) == 0) { | 472 if (setjmp(*jump.Set()) == 0) { |
| 473 TIMERSCOPE(time_compilation); | 473 TIMERSCOPE(time_compilation); |
| 474 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 474 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
| 475 per_compile_timer.Start(); | 475 per_compile_timer.Start(); |
| 476 ParsedFunction* parsed_function = new ParsedFunction( | 476 ParsedFunction* parsed_function = new ParsedFunction( |
| 477 Function::ZoneHandle(function.raw())); | 477 Function::ZoneHandle(function.raw())); |
| 478 if (FLAG_trace_compiler) { | 478 if (FLAG_trace_compiler) { |
| 479 OS::Print("Compiling %sfunction: '%s' @ token %"Pd"\n", | 479 OS::Print("Compiling %sfunction: '%s' @ token %"Pd", size %"Pd"\n", |
| 480 (optimized ? "optimized " : ""), | 480 (optimized ? "optimized " : ""), |
| 481 function.ToFullyQualifiedCString(), | 481 function.ToFullyQualifiedCString(), |
| 482 function.token_pos()); | 482 function.token_pos(), |
| 483 (function.end_token_pos() - function.token_pos())); |
| 483 } | 484 } |
| 484 { | 485 { |
| 485 HANDLESCOPE(isolate); | 486 HANDLESCOPE(isolate); |
| 486 Parser::ParseFunction(parsed_function); | 487 Parser::ParseFunction(parsed_function); |
| 487 parsed_function->AllocateVariables(); | 488 parsed_function->AllocateVariables(); |
| 488 } | 489 } |
| 489 | 490 |
| 490 const bool success = | 491 const bool success = |
| 491 CompileParsedFunctionHelper(*parsed_function, optimized); | 492 CompileParsedFunctionHelper(*parsed_function, optimized); |
| 492 if (optimized && !success) { | 493 if (optimized && !success) { |
| 493 // Optimizer bailed out. Disable optimizations and to never try again. | 494 // Optimizer bailed out. Disable optimizations and to never try again. |
| 494 if (FLAG_trace_compiler) { | 495 if (FLAG_trace_compiler) { |
| 495 OS::Print("--> disabling optimizations for '%s'\n", | 496 OS::Print("--> disabling optimizations for '%s'\n", |
| 496 function.ToFullyQualifiedCString()); | 497 function.ToFullyQualifiedCString()); |
| 497 } else if (FLAG_trace_failed_optimization_attempts) { | 498 } else if (FLAG_trace_failed_optimization_attempts) { |
| 498 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); | 499 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); |
| 499 } | 500 } |
| 500 function.set_is_optimizable(false); | 501 function.set_is_optimizable(false); |
| 501 isolate->set_long_jump_base(base); | 502 isolate->set_long_jump_base(base); |
| 502 return Error::null(); | 503 return Error::null(); |
| 503 } | 504 } |
| 504 | 505 |
| 505 ASSERT(success); | 506 ASSERT(success); |
| 506 per_compile_timer.Stop(); | 507 per_compile_timer.Stop(); |
| 507 | 508 |
| 508 if (FLAG_trace_compiler) { | 509 if (FLAG_trace_compiler) { |
| 509 OS::Print("--> '%s' entry: %#"Px" time: %"Pd64" us\n", | 510 OS::Print("--> '%s' entry: %#"Px" size: %"Pd" time: %"Pd64" us\n", |
| 510 function.ToFullyQualifiedCString(), | 511 function.ToFullyQualifiedCString(), |
| 511 Code::Handle(function.CurrentCode()).EntryPoint(), | 512 Code::Handle(function.CurrentCode()).EntryPoint(), |
| 513 Code::Handle(function.CurrentCode()).Size(), |
| 512 per_compile_timer.TotalElapsedTime()); | 514 per_compile_timer.TotalElapsedTime()); |
| 513 } | 515 } |
| 514 | 516 |
| 515 isolate->debugger()->NotifyCompilation(function); | 517 isolate->debugger()->NotifyCompilation(function); |
| 516 | 518 |
| 517 if (FLAG_disassemble) { | 519 if (FLAG_disassemble) { |
| 518 DisassembleCode(function, optimized); | 520 DisassembleCode(function, optimized); |
| 519 } else if (FLAG_disassemble_optimized && optimized) { | 521 } else if (FLAG_disassemble_optimized && optimized) { |
| 520 // TODO(fschneider): Print unoptimized code along with the optimized code. | 522 // TODO(fschneider): Print unoptimized code along with the optimized code. |
| 521 DisassembleCode(function, true); | 523 DisassembleCode(function, true); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 Object::Handle(isolate->object_store()->sticky_error()); | 655 Object::Handle(isolate->object_store()->sticky_error()); |
| 654 isolate->object_store()->clear_sticky_error(); | 656 isolate->object_store()->clear_sticky_error(); |
| 655 isolate->set_long_jump_base(base); | 657 isolate->set_long_jump_base(base); |
| 656 return result.raw(); | 658 return result.raw(); |
| 657 } | 659 } |
| 658 UNREACHABLE(); | 660 UNREACHABLE(); |
| 659 return Object::null(); | 661 return Object::null(); |
| 660 } | 662 } |
| 661 | 663 |
| 662 } // namespace dart | 664 } // namespace dart |
| OLD | NEW |