diff options
Diffstat (limited to 'deps/v8/src/objects/contexts.cc')
-rw-r--r-- | deps/v8/src/objects/contexts.cc | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/deps/v8/src/objects/contexts.cc b/deps/v8/src/objects/contexts.cc index 74fb4477b1..9dbba06a4d 100644 --- a/deps/v8/src/objects/contexts.cc +++ b/deps/v8/src/objects/contexts.cc @@ -39,12 +39,14 @@ Handle<ScriptContextTable> ScriptContextTable::Extend( bool ScriptContextTable::Lookup(Isolate* isolate, ScriptContextTable table, String name, LookupResult* result) { DisallowHeapAllocation no_gc; + // Static variables cannot be in script contexts. + IsStaticFlag is_static_flag; for (int i = 0; i < table.used(); i++) { Context context = table.get_context(i); DCHECK(context.IsScriptContext()); int slot_index = ScopeInfo::ContextSlotIndex( context.scope_info(), name, &result->mode, &result->init_flag, - &result->maybe_assigned_flag); + &result->maybe_assigned_flag, &is_static_flag); if (slot_index >= 0) { result->context_index = i; @@ -129,10 +131,6 @@ JSGlobalProxy Context::global_proxy() { return native_context().global_proxy_object(); } -void Context::set_global_proxy(JSGlobalProxy object) { - native_context().set_global_proxy_object(object); -} - /** * Lookups a property in an object environment, taking the unscopables into * account. This is used For HasBinding spec algorithms for ObjectEnvironment. @@ -175,7 +173,6 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, Isolate* isolate = context->GetIsolate(); bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; - bool failed_whitelist = false; *index = kNotFound; *attributes = ABSENT; *init_flag = kCreatedInitialized; @@ -287,8 +284,10 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, VariableMode mode; InitializationFlag flag; MaybeAssignedFlag maybe_assigned_flag; - int slot_index = ScopeInfo::ContextSlotIndex(scope_info, *name, &mode, - &flag, &maybe_assigned_flag); + IsStaticFlag is_static_flag; + int slot_index = + ScopeInfo::ContextSlotIndex(scope_info, *name, &mode, &flag, + &maybe_assigned_flag, &is_static_flag); DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); if (slot_index >= 0) { if (FLAG_trace_contexts) { @@ -357,6 +356,17 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, return extension; } } + + // Check blacklist. Names that are listed, cannot be resolved further. + Object blacklist = context->get(BLACK_LIST_INDEX); + if (blacklist.IsStringSet() && + StringSet::cast(blacklist).Has(isolate, name)) { + if (FLAG_trace_contexts) { + PrintF(" - name is blacklisted. Aborting.\n"); + } + break; + } + // Check the original context, but do not follow its context chain. Object obj = context->get(WRAPPED_CONTEXT_INDEX); if (obj.IsContext()) { @@ -366,26 +376,12 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name, attributes, init_flag, variable_mode); if (!result.is_null()) return result; } - // Check whitelist. Names that do not pass whitelist shall only resolve - // to with, script or native contexts up the context chain. - obj = context->get(WHITE_LIST_INDEX); - if (obj.IsStringSet()) { - failed_whitelist = - failed_whitelist || !StringSet::cast(obj).Has(isolate, name); - } } // 3. Prepare to continue with the previous (next outermost) context. if (context->IsNativeContext()) break; - do { - context = Handle<Context>(context->previous(), isolate); - // If we come across a whitelist context, and the name is not - // whitelisted, then only consider with, script, module or native - // contexts. - } while (failed_whitelist && !context->IsScriptContext() && - !context->IsNativeContext() && !context->IsWithContext() && - !context->IsModuleContext()); + context = Handle<Context>(context->previous(), isolate); } while (follow_context_chain); if (FLAG_trace_contexts) { |