[parser] Load outer ScopeInfo from SharedFunctionInfo.

This switches the {ParseInfo} constructor to always determine the outer
scope info from the shared function info instead of a concrete closure.
It is a precursor to deprecate the constructor taking closures entirely
and hence make the fact that we can parse without a closure explicit.

R=jochen@chromium.org
BUG=v8:2206

Review-Url: https://codereview.chromium.org/2397053003
Cr-Commit-Position: refs/heads/master@{#40031}
This commit is contained in:
mstarzinger 2016-10-06 05:01:10 -07:00 committed by Commit bot
parent a03ac68c55
commit 23644ddffd

View File

@ -32,11 +32,7 @@ ParseInfo::ParseInfo(Zone* zone)
literal_(nullptr) {}
ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function)
: ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {
if (!function->context()->IsNativeContext()) {
set_outer_scope_info(handle(function->context()->scope_info()));
}
}
: ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {}
ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
: ParseInfo(zone) {
@ -59,6 +55,12 @@ ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
if (!script.is_null() && script->type() == Script::TYPE_NATIVE) {
set_native();
}
Handle<HeapObject> scope_info(shared->outer_scope_info());
if (!scope_info->IsTheHole(isolate()) &&
Handle<ScopeInfo>::cast(scope_info)->length() > 0) {
set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info));
}
}
ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) {