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

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: rebased 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
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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 return true; 690 return true;
691 } 691 }
692 692
693 693
694 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon( 694 MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
695 CompilationInfo* info) { 695 CompilationInfo* info) {
696 VMState<COMPILER> state(info->isolate()); 696 VMState<COMPILER> state(info->isolate());
697 PostponeInterruptsScope postpone(info->isolate()); 697 PostponeInterruptsScope postpone(info->isolate());
698 698
699 // Parse and update CompilationInfo with the results. 699 // Parse and update CompilationInfo with the results.
700 if (!Parser::Parse(info)) return MaybeHandle<Code>(); 700 if (!Parser::ParseStatic(info)) return MaybeHandle<Code>();
701 Handle<SharedFunctionInfo> shared = info->shared_info(); 701 Handle<SharedFunctionInfo> shared = info->shared_info();
702 FunctionLiteral* lit = info->function(); 702 FunctionLiteral* lit = info->function();
703 shared->set_language_mode(lit->language_mode()); 703 shared->set_language_mode(lit->language_mode());
704 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 704 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
705 MaybeDisableOptimization(shared, lit->dont_optimize_reason()); 705 MaybeDisableOptimization(shared, lit->dont_optimize_reason());
706 706
707 // Compile unoptimized code. 707 // Compile unoptimized code.
708 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 708 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
709 709
710 CHECK_EQ(Code::FUNCTION, info->code()->kind()); 710 CHECK_EQ(Code::FUNCTION, info->code()->kind());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 if (!Rewriter::Rewrite(info)) return false; 862 if (!Rewriter::Rewrite(info)) return false;
863 if (!Scope::Analyze(info)) return false; 863 if (!Scope::Analyze(info)) return false;
864 if (!Renumber(info)) return false; 864 if (!Renumber(info)) return false;
865 DCHECK(info->scope() != NULL); 865 DCHECK(info->scope() != NULL);
866 if (!CheckSuperConstructorCall(info)) return false; 866 if (!CheckSuperConstructorCall(info)) return false;
867 return true; 867 return true;
868 } 868 }
869 869
870 870
871 bool Compiler::ParseAndAnalyze(CompilationInfo* info) { 871 bool Compiler::ParseAndAnalyze(CompilationInfo* info) {
872 if (!Parser::Parse(info)) return false; 872 if (!Parser::ParseStatic(info)) return false;
873 return Compiler::Analyze(info); 873 return Compiler::Analyze(info);
874 } 874 }
875 875
876 876
877 static bool GetOptimizedCodeNow(CompilationInfo* info) { 877 static bool GetOptimizedCodeNow(CompilationInfo* info) {
878 if (!Compiler::ParseAndAnalyze(info)) return false; 878 if (!Compiler::ParseAndAnalyze(info)) return false;
879 879
880 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); 880 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
881 881
882 OptimizedCompileJob job(info); 882 OptimizedCompileJob job(info);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 } 1103 }
1104 1104
1105 1105
1106 void Compiler::CompileForLiveEdit(Handle<Script> script) { 1106 void Compiler::CompileForLiveEdit(Handle<Script> script) {
1107 // TODO(635): support extensions. 1107 // TODO(635): support extensions.
1108 CompilationInfoWithZone info(script); 1108 CompilationInfoWithZone info(script);
1109 PostponeInterruptsScope postpone(info.isolate()); 1109 PostponeInterruptsScope postpone(info.isolate());
1110 VMState<COMPILER> state(info.isolate()); 1110 VMState<COMPILER> state(info.isolate());
1111 1111
1112 info.MarkAsGlobal(); 1112 info.MarkAsGlobal();
1113 if (!Parser::Parse(&info)) return; 1113 if (!Parser::ParseStatic(&info)) return;
1114 1114
1115 LiveEditFunctionTracker tracker(info.isolate(), info.function()); 1115 LiveEditFunctionTracker tracker(info.isolate(), info.function());
1116 if (!CompileUnoptimizedCode(&info)) return; 1116 if (!CompileUnoptimizedCode(&info)) return;
1117 if (!info.shared_info().is_null()) { 1117 if (!info.shared_info().is_null()) {
1118 Handle<ScopeInfo> scope_info = 1118 Handle<ScopeInfo> scope_info =
1119 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1119 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1120 info.shared_info()->set_scope_info(*scope_info); 1120 info.shared_info()->set_scope_info(*scope_info);
1121 } 1121 }
1122 tracker.RecordRootFunctionInfo(info.code()); 1122 tracker.RecordRootFunctionInfo(info.code());
1123 } 1123 }
(...skipping 29 matching lines...) Expand all
1153 1153
1154 if (!parse_allow_lazy && 1154 if (!parse_allow_lazy &&
1155 (info->compile_options() == ScriptCompiler::kProduceParserCache || 1155 (info->compile_options() == ScriptCompiler::kProduceParserCache ||
1156 info->compile_options() == ScriptCompiler::kConsumeParserCache)) { 1156 info->compile_options() == ScriptCompiler::kConsumeParserCache)) {
1157 // We are going to parse eagerly, but we either 1) have cached data 1157 // We are going to parse eagerly, but we either 1) have cached data
1158 // produced by lazy parsing or 2) are asked to generate cached data. 1158 // produced by lazy parsing or 2) are asked to generate cached data.
1159 // Eager parsing cannot benefit from cached data, and producing cached 1159 // Eager parsing cannot benefit from cached data, and producing cached
1160 // data while parsing eagerly is not implemented. 1160 // data while parsing eagerly is not implemented.
1161 info->SetCachedData(NULL, ScriptCompiler::kNoCompileOptions); 1161 info->SetCachedData(NULL, ScriptCompiler::kNoCompileOptions);
1162 } 1162 }
1163 if (!Parser::Parse(info, parse_allow_lazy)) { 1163 if (!Parser::ParseStatic(info, parse_allow_lazy)) {
1164 return Handle<SharedFunctionInfo>::null(); 1164 return Handle<SharedFunctionInfo>::null();
1165 } 1165 }
1166 } 1166 }
1167 1167
1168 FunctionLiteral* lit = info->function(); 1168 FunctionLiteral* lit = info->function();
1169 LiveEditFunctionTracker live_edit_tracker(isolate, lit); 1169 LiveEditFunctionTracker live_edit_tracker(isolate, lit);
1170 1170
1171 // Measure how long it takes to do the compilation; only take the 1171 // Measure how long it takes to do the compilation; only take the
1172 // rest of the function into account to avoid overlap with the 1172 // rest of the function into account to avoid overlap with the
1173 // parsing statistics. 1173 // parsing statistics.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 } 1616 }
1617 1617
1618 1618
1619 #if DEBUG 1619 #if DEBUG
1620 void CompilationInfo::PrintAstForTesting() { 1620 void CompilationInfo::PrintAstForTesting() {
1621 PrintF("--- Source from AST ---\n%s\n", 1621 PrintF("--- Source from AST ---\n%s\n",
1622 PrettyPrinter(isolate(), zone()).PrintProgram(function())); 1622 PrettyPrinter(isolate(), zone()).PrintProgram(function()));
1623 } 1623 }
1624 #endif 1624 #endif
1625 } } // namespace v8::internal 1625 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/parser.h » ('j') | src/parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698