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

Side by Side Diff: src/compiler.cc

Issue 908173003: Parsing: Make Parser not know about Isolate during background parsing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: main thread check Created 5 years, 10 months 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
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/parser.h » ('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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 return true; 653 return true;
654 } 654 }
655 655
656 656
657 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( 657 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
658 CompilationInfo* info) { 658 CompilationInfo* info) {
659 VMState<COMPILER> state(info->isolate()); 659 VMState<COMPILER> state(info->isolate());
660 PostponeInterruptsScope postpone(info->isolate()); 660 PostponeInterruptsScope postpone(info->isolate());
661 661
662 // Parse and update CompilationInfo with the results. 662 // Parse and update CompilationInfo with the results.
663 if (!Parser::Parse(info)) return MaybeHandle<Code>(); 663 if (!Parser::ParseStatic(info)) return MaybeHandle<Code>();
664 Handle<SharedFunctionInfo> shared = info->shared_info(); 664 Handle<SharedFunctionInfo> shared = info->shared_info();
665 FunctionLiteral* lit = info->function(); 665 FunctionLiteral* lit = info->function();
666 shared->set_language_mode(lit->language_mode()); 666 shared->set_language_mode(lit->language_mode());
667 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 667 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
668 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 668 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
669 669
670 // Compile unoptimized code. 670 // Compile unoptimized code.
671 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 671 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
672 672
673 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 673 CHECK_EQ(Code::FUNCTION, info->code()->kind());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 if (!Rewriter::Rewrite(info)) return false; 825 if (!Rewriter::Rewrite(info)) return false;
826 if (!Scope::Analyze(info)) return false; 826 if (!Scope::Analyze(info)) return false;
827 if (!Renumber(info)) return false; 827 if (!Renumber(info)) return false;
828 DCHECK(info->scope() != NULL); 828 DCHECK(info->scope() != NULL);
829 if (!CheckSuperConstructorCall(info)) return false; 829 if (!CheckSuperConstructorCall(info)) return false;
830 return true; 830 return true;
831 } 831 }
832 832
833 833
834 bool Compiler::ParseAndAnalyze(CompilationInfo* info) { 834 bool Compiler::ParseAndAnalyze(CompilationInfo* info) {
835 if (!Parser::Parse(info)) return false; 835 if (!Parser::ParseStatic(info)) return false;
836 return Compiler::Analyze(info); 836 return Compiler::Analyze(info);
837 } 837 }
838 838
839 839
840 static bool GetOptimizedCodeNow(CompilationInfo* info) { 840 static bool GetOptimizedCodeNow(CompilationInfo* info) {
841 if (!Compiler::ParseAndAnalyze(info)) return false; 841 if (!Compiler::ParseAndAnalyze(info)) return false;
842 842
843 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); 843 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
844 844
845 OptimizedCompileJob job(info); 845 OptimizedCompileJob job(info);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 } 1066 }
1067 1067
1068 1068
1069 void Compiler::CompileForLiveEdit(Handle<Script> script) { 1069 void Compiler::CompileForLiveEdit(Handle<Script> script) {
1070 // TODO(635): support extensions. 1070 // TODO(635): support extensions.
1071 CompilationInfoWithZone info(script); 1071 CompilationInfoWithZone info(script);
1072 PostponeInterruptsScope postpone(info.isolate()); 1072 PostponeInterruptsScope postpone(info.isolate());
1073 VMState<COMPILER> state(info.isolate()); 1073 VMState<COMPILER> state(info.isolate());
1074 1074
1075 info.MarkAsGlobal(); 1075 info.MarkAsGlobal();
1076 if (!Parser::Parse(&info)) return; 1076 if (!Parser::ParseStatic(&info)) return;
1077 1077
1078 LiveEditFunctionTracker tracker(info.isolate(), info.function()); 1078 LiveEditFunctionTracker tracker(info.isolate(), info.function());
1079 if (!CompileUnoptimizedCode(&info)) return; 1079 if (!CompileUnoptimizedCode(&info)) return;
1080 if (!info.shared_info().is_null()) { 1080 if (!info.shared_info().is_null()) {
1081 Handle<ScopeInfo> scope_info = 1081 Handle<ScopeInfo> scope_info =
1082 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1082 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1083 info.shared_info()->set_scope_info(*scope_info); 1083 info.shared_info()->set_scope_info(*scope_info);
1084 } 1084 }
1085 tracker.RecordRootFunctionInfo(info.code()); 1085 tracker.RecordRootFunctionInfo(info.code());
1086 } 1086 }
(...skipping 29 matching lines...) Expand all
1116 1116
1117 if (!parse_allow_lazy && 1117 if (!parse_allow_lazy &&
1118 (info->compile_options() == ScriptCompiler::kProduceParserCache || 1118 (info->compile_options() == ScriptCompiler::kProduceParserCache ||
1119 info->compile_options() == ScriptCompiler::kConsumeParserCache)) { 1119 info->compile_options() == ScriptCompiler::kConsumeParserCache)) {
1120 // We are going to parse eagerly, but we either 1) have cached data 1120 // We are going to parse eagerly, but we either 1) have cached data
1121 // produced by lazy parsing or 2) are asked to generate cached data. 1121 // produced by lazy parsing or 2) are asked to generate cached data.
1122 // Eager parsing cannot benefit from cached data, and producing cached 1122 // Eager parsing cannot benefit from cached data, and producing cached
1123 // data while parsing eagerly is not implemented. 1123 // data while parsing eagerly is not implemented.
1124 info->SetCachedData(NULL, ScriptCompiler::kNoCompileOptions); 1124 info->SetCachedData(NULL, ScriptCompiler::kNoCompileOptions);
1125 } 1125 }
1126 if (!Parser::Parse(info, parse_allow_lazy)) { 1126 if (!Parser::ParseStatic(info, parse_allow_lazy)) {
1127 return Handle<SharedFunctionInfo>::null(); 1127 return Handle<SharedFunctionInfo>::null();
1128 } 1128 }
1129 } 1129 }
1130 1130
1131 FunctionLiteral* lit = info->function(); 1131 FunctionLiteral* lit = info->function();
1132 LiveEditFunctionTracker live_edit_tracker(isolate, lit); 1132 LiveEditFunctionTracker live_edit_tracker(isolate, lit);
1133 1133
1134 // Measure how long it takes to do the compilation; only take the 1134 // Measure how long it takes to do the compilation; only take the
1135 // rest of the function into account to avoid overlap with the 1135 // rest of the function into account to avoid overlap with the
1136 // parsing statistics. 1136 // parsing statistics.
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 } 1585 }
1586 1586
1587 1587
1588 #if DEBUG 1588 #if DEBUG
1589 void CompilationInfo::PrintAstForTesting() { 1589 void CompilationInfo::PrintAstForTesting() {
1590 PrintF("--- Source from AST ---\n%s\n", 1590 PrintF("--- Source from AST ---\n%s\n",
1591 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1591 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1592 } 1592 }
1593 #endif 1593 #endif
1594 } } // namespace v8::internal 1594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698