Index: src/contexts.cc |
diff --git a/src/contexts.cc b/src/contexts.cc |
index 0c27681a7dca42554f6d835e626d84d058708c79..b29405b505b2316236fad7168366207d54bfbd92 100644 |
--- a/src/contexts.cc |
+++ b/src/contexts.cc |
@@ -40,10 +40,10 @@ bool ScriptContextTable::Lookup(Handle<ScriptContextTable> table, |
DCHECK(context->IsScriptContext()); |
Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
int slot_index = ScopeInfo::ContextSlotIndex( |
- scope_info, name, &result->mode, &result->init_flag, |
+ scope_info, name, &result->mode, &result->location, &result->init_flag, |
&result->maybe_assigned_flag); |
- if (slot_index >= 0) { |
+ if (slot_index >= 0 && result->location == VariableLocation::CONTEXT) { |
result->context_index = i; |
result->slot_index = slot_index; |
return true; |
@@ -287,14 +287,15 @@ Handle<Object> Context::Lookup(Handle<String> name, |
ScopeInfo::cast(context->extension()), isolate); |
} |
VariableMode mode; |
+ VariableLocation location; |
InitializationFlag init_flag; |
// TODO(sigurds) Figure out whether maybe_assigned_flag should |
// be used to compute binding_flags. |
MaybeAssignedFlag maybe_assigned_flag; |
int slot_index = ScopeInfo::ContextSlotIndex( |
- scope_info, name, &mode, &init_flag, &maybe_assigned_flag); |
+ scope_info, name, &mode, &location, &init_flag, &maybe_assigned_flag); |
DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); |
- if (slot_index >= 0) { |
+ if (slot_index >= 0 && location == VariableLocation::CONTEXT) { |
if (FLAG_trace_contexts) { |
PrintF("=> found local in context slot %d (mode = %d)\n", |
slot_index, mode); |
@@ -352,6 +353,27 @@ Handle<Object> Context::Lookup(Handle<String> name, |
} |
+void Context::InitializeGlobalSlots() { |
+ DCHECK(IsScriptContext()); |
+ DisallowHeapAllocation no_gc; |
+ |
+ ScopeInfo* scope_info = ScopeInfo::cast(extension()); |
+ |
+ int context_globals = scope_info->ContextGlobalCount(); |
+ if (context_globals > 0) { |
+ PropertyCell* empty_cell = GetHeap()->empty_property_cell(); |
+ |
+ int context_locals = scope_info->ContextLocalCount(); |
+ int index = Context::MIN_CONTEXT_SLOTS + context_locals; |
+ for (int i = 0; i < context_globals; i++) { |
+ // Clear both read and write slots. |
+ set(index++, empty_cell); |
+ set(index++, empty_cell); |
+ } |
+ } |
+} |
+ |
+ |
void Context::AddOptimizedFunction(JSFunction* function) { |
DCHECK(IsNativeContext()); |
#ifdef ENABLE_SLOW_DCHECKS |