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

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/836367Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50333}
parent 781fa726
...@@ -1206,24 +1206,24 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( ...@@ -1206,24 +1206,24 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
ASSIGN_RETURN_ON_EXCEPTION(isolate, top_level, ASSIGN_RETURN_ON_EXCEPTION(isolate, top_level,
CompileToplevel(&parse_info, isolate), JSFunction); CompileToplevel(&parse_info, isolate), JSFunction);
Handle<JSFunction> top_level_fun = Handle<SharedFunctionInfo> wrapped;
isolate->factory()->NewFunctionFromSharedFunctionInfo(top_level, context, SharedFunctionInfo::ScriptIterator infos(script);
NOT_TENURED); while (SharedFunctionInfo* info = infos.Next()) {
if (info->is_wrapped()) {
// TODO(yangguo): consider not having to call the top-level function, and wrapped = Handle<SharedFunctionInfo>(info);
// instead instantiate the wrapper function directly. break;
Handle<Object> result; }
ASSIGN_RETURN_ON_EXCEPTION( }
isolate, result, DCHECK(!wrapped.is_null());
Execution::Call(isolate, top_level_fun, isolate->global_proxy(), 0,
nullptr),
JSFunction);
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(wrapped, context,
NOT_TENURED);
// OnAfterCompile has to be called after we create the JSFunction, which we // 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 // may require to recompile the eval for debugging, if we find a function
// that contains break points in the eval script. // that contains break points in the eval script.
isolate->debug()->OnAfterCompile(script); isolate->debug()->OnAfterCompile(script);
return Handle<JSFunction>::cast(result); return function;
} }
namespace { namespace {
......
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