Commit e58bc018 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Reland "Skip Execution::Call in CompileFunctionInContext."

This is a reland of ce8f5141

Original change's description:
> Skip Execution::Call in CompileFunctionInContext.
> 
> We execute the top-level function only to get to the wrapped function.
> We could do the same by simply instantiating it.
> 
> Other approaches would change the parser so that the top-level function
> is the wrapped function. However, that change violates existing scoping
> invariants and fixing it would add a lot more complexity to the parser.
> 
> R=adamk@chromium.org, marja@chromium.org
> 
> Bug: v8:7172
> Change-Id: I7272b8b58fc739d47a44da3a9d4a914af3e8cf3d
> Reviewed-on: https://chromium-review.googlesource.com/836367
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50333}

Bug: v8:7172
Change-Id: Ie0e4b3db46f84a30cff8613c89eb11534ce3c1ac
Reviewed-on: https://chromium-review.googlesource.com/956146Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51866}
parent 923a7ad3
......@@ -1332,24 +1332,24 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
ASSIGN_RETURN_ON_EXCEPTION(isolate, top_level,
CompileToplevel(&parse_info, isolate), JSFunction);
Handle<JSFunction> top_level_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(top_level, context,
NOT_TENURED);
// TODO(yangguo): consider not having to call the top-level function, and
// instead instantiate the wrapper function directly.
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, result,
Execution::Call(isolate, top_level_fun, isolate->global_proxy(), 0,
nullptr),
JSFunction);
Handle<SharedFunctionInfo> wrapped;
SharedFunctionInfo::ScriptIterator infos(script);
while (SharedFunctionInfo* info = infos.Next()) {
if (info->is_wrapped()) {
wrapped = Handle<SharedFunctionInfo>(info);
break;
}
}
DCHECK(!wrapped.is_null());
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(wrapped, context,
NOT_TENURED);
// OnAfterCompile has to be called after we create the JSFunction, which we
// may require to recompile the eval for debugging, if we find a function
// that contains break points in the eval script.
isolate->debug()->OnAfterCompile(script);
return Handle<JSFunction>::cast(result);
return function;
}
bool Compiler::CodeGenerationFromStringsAllowed(Isolate* isolate,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment