| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "src/messages.h" | 22 #include "src/messages.h" |
| 23 #include "src/parser.h" | 23 #include "src/parser.h" |
| 24 #include "src/prettyprinter.h" | 24 #include "src/prettyprinter.h" |
| 25 #include "src/rewriter.h" | 25 #include "src/rewriter.h" |
| 26 #include "src/runtime-profiler.h" | 26 #include "src/runtime-profiler.h" |
| 27 #include "src/scanner-character-streams.h" | 27 #include "src/scanner-character-streams.h" |
| 28 #include "src/scopeinfo.h" | 28 #include "src/scopeinfo.h" |
| 29 #include "src/scopes.h" | 29 #include "src/scopes.h" |
| 30 #include "src/snapshot/serialize.h" | 30 #include "src/snapshot/serialize.h" |
| 31 #include "src/typing.h" | 31 #include "src/typing.h" |
| 32 #include "src/typing-asm.h" |
| 32 #include "src/vm-state-inl.h" | 33 #include "src/vm-state-inl.h" |
| 33 | 34 |
| 34 namespace v8 { | 35 namespace v8 { |
| 35 namespace internal { | 36 namespace internal { |
| 36 | 37 |
| 37 std::ostream& operator<<(std::ostream& os, const SourcePosition& p) { | 38 std::ostream& operator<<(std::ostream& os, const SourcePosition& p) { |
| 38 if (p.IsUnknown()) { | 39 if (p.IsUnknown()) { |
| 39 return os << "<?>"; | 40 return os << "<?>"; |
| 40 } else if (FLAG_hydrogen_track_positions) { | 41 } else if (FLAG_hydrogen_track_positions) { |
| 41 return os << "<" << p.inlining_id() << ":" << p.position() << ">"; | 42 return os << "<" << p.inlining_id() << ":" << p.position() << ">"; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 os << "[compiling method " << Brief(*info()->closure()) | 436 os << "[compiling method " << Brief(*info()->closure()) |
| 436 << " using Crankshaft"; | 437 << " using Crankshaft"; |
| 437 if (info()->is_osr()) os << " OSR"; | 438 if (info()->is_osr()) os << " OSR"; |
| 438 os << "]" << std::endl; | 439 os << "]" << std::endl; |
| 439 } | 440 } |
| 440 | 441 |
| 441 if (FLAG_trace_hydrogen) { | 442 if (FLAG_trace_hydrogen) { |
| 442 isolate()->GetHTracer()->TraceCompilation(info()); | 443 isolate()->GetHTracer()->TraceCompilation(info()); |
| 443 } | 444 } |
| 444 | 445 |
| 446 #if 0 |
| 445 // Type-check the function. | 447 // Type-check the function. |
| 446 AstTyper::Run(info()); | 448 switch (scope->asm_mode()) { |
| 449 case ASM_MODULE: |
| 450 if (FLAG_trace_asm) { |
| 451 OFStream os(stdout); |
| 452 os << "[asm: compiling module " |
| 453 << info()->function()->debug_name()->ToCString().get() |
| 454 << "]" << std::endl; |
| 455 } |
| 456 if (AsmTyper::Run(info())) break; |
| 457 // Fall through. |
| 458 { |
| 459 OFStream os(stdout); |
| 460 os << "asm: could not type module " |
| 461 << info()->function()->debug_name()->ToCString().get() |
| 462 <<", falling back to normal typing" << std::endl; |
| 463 } |
| 464 case ASM_NO: |
| 465 AstTyper::Run(info()); |
| 466 break; |
| 467 case ASM_FUNCTION: |
| 468 if (FLAG_trace_asm) { |
| 469 OFStream os(stdout); |
| 470 os << "[asm: compiling function " |
| 471 << info()->function()->debug_name()->ToCString().get() |
| 472 << "]" << std::endl; |
| 473 } |
| 474 #ifdef DEBUG |
| 475 if (FLAG_print_asm_env) scope->Print(); |
| 476 #endif |
| 477 case ASM_END: |
| 478 DCHECK(false); |
| 479 break; |
| 480 } |
| 481 #else |
| 482 AstTyper::Run(info()); |
| 483 #endif |
| 447 | 484 |
| 448 // Optimization could have been disabled by the parser. Note that this check | 485 // Optimization could have been disabled by the parser. Note that this check |
| 449 // is only needed because the Hydrogen graph builder is missing some bailouts. | 486 // is only needed because the Hydrogen graph builder is missing some bailouts. |
| 450 if (info()->shared_info()->optimization_disabled()) { | 487 if (info()->shared_info()->optimization_disabled()) { |
| 451 return AbortOptimization( | 488 return AbortOptimization( |
| 452 info()->shared_info()->disable_optimization_reason()); | 489 info()->shared_info()->disable_optimization_reason()); |
| 453 } | 490 } |
| 454 | 491 |
| 455 graph_builder_ = (info()->is_tracking_positions() || FLAG_trace_ic) | 492 graph_builder_ = (info()->is_tracking_positions() || FLAG_trace_ic) |
| 456 ? new (info()->zone()) | 493 ? new (info()->zone()) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 911 |
| 875 if (function->shared()->is_compiled()) { | 912 if (function->shared()->is_compiled()) { |
| 876 return Handle<Code>(function->shared()->code()); | 913 return Handle<Code>(function->shared()->code()); |
| 877 } | 914 } |
| 878 | 915 |
| 879 CompilationInfoWithZone info(function); | 916 CompilationInfoWithZone info(function); |
| 880 Handle<Code> result; | 917 Handle<Code> result; |
| 881 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCodeCommon(&info), | 918 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCodeCommon(&info), |
| 882 Code); | 919 Code); |
| 883 | 920 |
| 884 if (FLAG_always_opt) { | 921 if (FLAG_always_opt || info.scope()->asm_mode() != ASM_NO) { |
| 885 Handle<Code> opt_code; | 922 Handle<Code> opt_code; |
| 886 if (Compiler::GetOptimizedCode( | 923 if (Compiler::GetOptimizedCode( |
| 887 function, result, | 924 function, result, |
| 888 Compiler::NOT_CONCURRENT).ToHandle(&opt_code)) { | 925 Compiler::NOT_CONCURRENT).ToHandle(&opt_code)) { |
| 889 result = opt_code; | 926 result = opt_code; |
| 890 } | 927 } |
| 891 } | 928 } |
| 892 | 929 |
| 893 return result; | 930 return result; |
| 894 } | 931 } |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 | 1605 |
| 1569 | 1606 |
| 1570 #if DEBUG | 1607 #if DEBUG |
| 1571 void CompilationInfo::PrintAstForTesting() { | 1608 void CompilationInfo::PrintAstForTesting() { |
| 1572 PrintF("--- Source from AST ---\n%s\n", | 1609 PrintF("--- Source from AST ---\n%s\n", |
| 1573 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1610 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
| 1574 } | 1611 } |
| 1575 #endif | 1612 #endif |
| 1576 } // namespace internal | 1613 } // namespace internal |
| 1577 } // namespace v8 | 1614 } // namespace v8 |
| OLD | NEW |