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

Unified Diff: src/compiler.cc

Issue 2645403002: [Compiler] Enable use of seperate zones for parsing and compiling. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index ea6fefd9668b593e67cd72df5087f6898b166bc1..cd0f6e78500755de175c22fca419c20d4f4ef5b1 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -375,6 +375,12 @@ bool ShouldUseIgnition(CompilationInfo* info) {
return shared->PassesFilter(FLAG_ignition_filter);
}
+bool UseAsmWasm(DeclarationScope* scope, Handle<SharedFunctionInfo> shared_info,
+ bool is_debug) {
+ return FLAG_validate_asm && scope->asm_module() &&
+ !shared_info->is_asm_wasm_broken() && !is_debug;
+}
+
CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) {
// Function should have been parsed and analyzed before creating a compilation
// job.
@@ -462,8 +468,7 @@ bool Renumber(ParseInfo* parse_info,
}
bool GenerateUnoptimizedCode(CompilationInfo* info) {
- if (FLAG_validate_asm && info->scope()->asm_module() &&
- !info->shared_info()->is_asm_wasm_broken() && !info->is_debug()) {
+ if (UseAsmWasm(info->scope(), info->shared_info(), info->is_debug())) {
EnsureFeedbackMetadata(info);
MaybeHandle<FixedArray> wasm_data;
wasm_data = AsmJs::CompileAsmViaWasm(info);
@@ -512,7 +517,9 @@ bool CompileUnoptimizedInnerFunctions(
outer_info->parse_info()->ast_value_factory());
parse_info.set_ast_value_factory_owned(false);
- CompilationInfo info(&parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info,
+ Handle<JSFunction>::null());
if (outer_info->will_serialize()) info.PrepareForSerializing();
if (outer_info->is_debug()) info.MarkAsDebug();
@@ -530,13 +537,36 @@ bool CompileUnoptimizedInnerFunctions(
return true;
}
+bool InnerFunctionIsAsmModule(
+ ThreadedList<ThreadedListZoneEntry<FunctionLiteral*>>* literals) {
+ for (auto it : *literals) {
+ FunctionLiteral* literal = it->value();
+ if (literal->scope()->IsAsmModule()) return true;
+ }
+ return false;
+}
+
bool CompileUnoptimizedCode(CompilationInfo* info) {
Isolate* isolate = info->isolate();
DCHECK(AllowCompilation::IsAllowed(isolate));
Compiler::EagerInnerFunctionLiterals inner_literals;
- if (!Compiler::Analyze(info->parse_info(), &inner_literals) ||
- !CompileUnoptimizedInnerFunctions(&inner_literals, info) ||
+ if (!Compiler::Analyze(info->parse_info(), &inner_literals)) {
+ if (!isolate->has_pending_exception()) isolate->StackOverflow();
+ return false;
+ }
+
+ // TODO(rmcilroy,bradnelson): Remove this UseAsmWasm check once the asm-wasm
+ // builder doesn't do parsing when visiting function declarations.
+ if (!info->scope()->IsAsmModule() &&
+ !InnerFunctionIsAsmModule(&inner_literals)) {
rmcilroy 2017/01/23 15:54:35 I'm going to send out a separate mail to figure ou
+ // Seal the parse zone so that it can be shared by parallel inner function
+ // compilation jobs.
+ DCHECK_NE(info->parse_info()->zone(), info->zone());
+ info->parse_info()->zone()->Seal();
+ }
+
+ if (!CompileUnoptimizedInnerFunctions(&inner_literals, info) ||
!GenerateUnoptimizedCode(info)) {
if (!isolate->has_pending_exception()) isolate->StackOverflow();
return false;
@@ -888,7 +918,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
VMState<COMPILER> state(isolate);
PostponeInterruptsScope postpone(isolate);
ParseInfo parse_info(handle(function->shared()));
- CompilationInfo info(&parse_info, function);
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info, function);
DCHECK(function->shared()->is_compiled());
@@ -1021,7 +1052,8 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
}
ParseInfo parse_info(handle(function->shared()));
- CompilationInfo info(&parse_info, function);
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info, function);
Handle<Code> result;
ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
@@ -1200,7 +1232,8 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
function->shared()->ReplaceCode(*code);
} else {
ParseInfo parse_info(handle(function->shared()));
- CompilationInfo info(&parse_info, function);
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info, function);
if (!GetUnoptimizedCode(&info).ToHandle(&code)) {
return false;
}
@@ -1224,7 +1257,8 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
// Start a compilation.
ParseInfo parse_info(shared);
- CompilationInfo info(&parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info, Handle<JSFunction>::null());
info.MarkAsDebug();
if (GetUnoptimizedCode(&info).is_null()) {
isolate->clear_pending_exception();
@@ -1251,7 +1285,8 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) {
// Start a compilation.
ParseInfo parse_info(script);
- CompilationInfo info(&parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info, Handle<JSFunction>::null());
info.MarkAsDebug();
// TODO(635): support extensions.
@@ -1291,8 +1326,9 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
DCHECK_NOT_NULL(info->scope());
Handle<SharedFunctionInfo> shared = info->shared_info();
if (!shared->has_deoptimization_support()) {
- Zone zone(info->isolate()->allocator(), ZONE_NAME);
- CompilationInfo unoptimized(info->parse_info(), info->closure());
+ Zone compile_zone(info->isolate()->allocator(), ZONE_NAME);
+ CompilationInfo unoptimized(&compile_zone, info->parse_info(),
+ info->closure());
unoptimized.EnableDeoptimizationSupport();
// Don't generate full-codegen code for functions it can't support.
@@ -1386,7 +1422,9 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
Script::SetEvalOrigin(script, outer_info, eval_position);
ParseInfo parse_info(script);
- CompilationInfo info(&parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info,
+ Handle<JSFunction>::null());
parse_info.set_eval();
parse_info.set_language_mode(language_mode);
parse_info.set_parse_restriction(restriction);
@@ -1564,7 +1602,9 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
// Compile the function and add it to the cache.
ParseInfo parse_info(script);
- CompilationInfo info(&parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo info(&compile_zone, &parse_info,
+ Handle<JSFunction>::null());
if (resource_options.IsModule()) parse_info.set_module();
if (compile_options != ScriptCompiler::kNoCompileOptions) {
parse_info.set_cached_data(cached_data);
@@ -1625,7 +1665,9 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript(
parse_info->set_language_mode(
static_cast<LanguageMode>(parse_info->language_mode() | language_mode));
- CompilationInfo compile_info(parse_info, Handle<JSFunction>::null());
+ Zone compile_zone(isolate->allocator(), ZONE_NAME);
+ CompilationInfo compile_info(&compile_zone, parse_info,
+ Handle<JSFunction>::null());
// The source was parsed lazily, so compiling for debugging is not possible.
DCHECK(!compile_info.is_debug());

Powered by Google App Engine
This is Rietveld 408576698