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" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/compilation-cache.h" | 12 #include "src/compilation-cache.h" |
13 #include "src/compiler/pipeline.h" | 13 #include "src/compiler/pipeline.h" |
14 #include "src/cpu-profiler.h" | 14 #include "src/cpu-profiler.h" |
15 #include "src/debug/debug.h" | 15 #include "src/debug/debug.h" |
16 #include "src/debug/liveedit.h" | 16 #include "src/debug/liveedit.h" |
17 #include "src/deoptimizer.h" | 17 #include "src/deoptimizer.h" |
18 #include "src/full-codegen/full-codegen.h" | 18 #include "src/full-codegen/full-codegen.h" |
19 #include "src/gdb-jit.h" | 19 #include "src/gdb-jit.h" |
20 #include "src/hydrogen.h" | 20 #include "src/hydrogen.h" |
| 21 #include "src/interpreter/interpreter.h" |
21 #include "src/lithium.h" | 22 #include "src/lithium.h" |
22 #include "src/log-inl.h" | 23 #include "src/log-inl.h" |
23 #include "src/messages.h" | 24 #include "src/messages.h" |
24 #include "src/parser.h" | 25 #include "src/parser.h" |
25 #include "src/prettyprinter.h" | 26 #include "src/prettyprinter.h" |
26 #include "src/rewriter.h" | 27 #include "src/rewriter.h" |
27 #include "src/runtime-profiler.h" | 28 #include "src/runtime-profiler.h" |
28 #include "src/scanner-character-streams.h" | 29 #include "src/scanner-character-streams.h" |
29 #include "src/scopeinfo.h" | 30 #include "src/scopeinfo.h" |
30 #include "src/scopes.h" | 31 #include "src/scopes.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 if (!Compiler::Analyze(info->parse_info()) || | 655 if (!Compiler::Analyze(info->parse_info()) || |
655 !FullCodeGenerator::MakeCode(info)) { | 656 !FullCodeGenerator::MakeCode(info)) { |
656 Isolate* isolate = info->isolate(); | 657 Isolate* isolate = info->isolate(); |
657 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 658 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
658 return false; | 659 return false; |
659 } | 660 } |
660 return true; | 661 return true; |
661 } | 662 } |
662 | 663 |
663 | 664 |
| 665 static bool GenerateBytecode(CompilationInfo* info) { |
| 666 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
| 667 if (!Compiler::Analyze(info->parse_info()) || |
| 668 !interpreter::Interpreter::MakeBytecode(info)) { |
| 669 Isolate* isolate = info->isolate(); |
| 670 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
| 671 return false; |
| 672 } |
| 673 return true; |
| 674 } |
| 675 |
| 676 |
664 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( | 677 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( |
665 CompilationInfo* info) { | 678 CompilationInfo* info) { |
666 VMState<COMPILER> state(info->isolate()); | 679 VMState<COMPILER> state(info->isolate()); |
667 PostponeInterruptsScope postpone(info->isolate()); | 680 PostponeInterruptsScope postpone(info->isolate()); |
668 | 681 |
669 // Parse and update CompilationInfo with the results. | 682 // Parse and update CompilationInfo with the results. |
670 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 683 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
671 Handle<SharedFunctionInfo> shared = info->shared_info(); | 684 Handle<SharedFunctionInfo> shared = info->shared_info(); |
672 FunctionLiteral* lit = info->function(); | 685 FunctionLiteral* lit = info->function(); |
673 shared->set_language_mode(lit->language_mode()); | 686 shared->set_language_mode(lit->language_mode()); |
674 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 687 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
675 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); | 688 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); |
676 | 689 |
677 // Compile unoptimized code. | 690 if (FLAG_ignition && info->closure()->PassesFilter(FLAG_ignition_filter)) { |
678 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); | 691 // Compile bytecode for the interpreter. |
| 692 if (!GenerateBytecode(info)) return MaybeHandle<Code>(); |
| 693 } else { |
| 694 // Compile unoptimized code. |
| 695 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
679 | 696 |
680 CHECK_EQ(Code::FUNCTION, info->code()->kind()); | 697 CHECK_EQ(Code::FUNCTION, info->code()->kind()); |
681 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 698 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
| 699 } |
682 | 700 |
683 // Update the shared function info with the scope info. Allocating the | 701 // Update the shared function info with the scope info. Allocating the |
684 // ScopeInfo object may cause a GC. | 702 // ScopeInfo object may cause a GC. |
685 Handle<ScopeInfo> scope_info = | 703 Handle<ScopeInfo> scope_info = |
686 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); | 704 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); |
687 shared->set_scope_info(*scope_info); | 705 shared->set_scope_info(*scope_info); |
688 | 706 |
689 // Update the code and feedback vector for the shared function info. | 707 // Update the code and feedback vector for the shared function info. |
690 shared->ReplaceCode(*info->code()); | 708 shared->ReplaceCode(*info->code()); |
691 shared->set_feedback_vector(*info->feedback_vector()); | 709 shared->set_feedback_vector(*info->feedback_vector()); |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 | 1702 |
1685 | 1703 |
1686 #if DEBUG | 1704 #if DEBUG |
1687 void CompilationInfo::PrintAstForTesting() { | 1705 void CompilationInfo::PrintAstForTesting() { |
1688 PrintF("--- Source from AST ---\n%s\n", | 1706 PrintF("--- Source from AST ---\n%s\n", |
1689 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1707 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1690 } | 1708 } |
1691 #endif | 1709 #endif |
1692 } // namespace internal | 1710 } // namespace internal |
1693 } // namespace v8 | 1711 } // namespace v8 |
OLD | NEW |