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