Index: src/scopeinfo.cc |
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc |
index 5492922c455843acc2b3b2097bbe76526a2b6c01..75938c355987087b69179a3875014fc62fcc7797 100644 |
--- a/src/scopeinfo.cc |
+++ b/src/scopeinfo.cc |
@@ -524,57 +524,73 @@ int ScopeInfo::StackSlotIndex(String* name) { |
int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info, |
Handle<String> name, VariableMode* mode, |
- VariableLocation* location, |
InitializationFlag* init_flag, |
MaybeAssignedFlag* maybe_assigned_flag) { |
DCHECK(name->IsInternalizedString()); |
DCHECK(mode != NULL); |
- DCHECK(location != NULL); |
DCHECK(init_flag != NULL); |
if (scope_info->length() > 0) { |
ContextSlotCache* context_slot_cache = |
scope_info->GetIsolate()->context_slot_cache(); |
- int result = context_slot_cache->Lookup(*scope_info, *name, mode, location, |
- init_flag, maybe_assigned_flag); |
+ int result = context_slot_cache->Lookup(*scope_info, *name, mode, init_flag, |
+ maybe_assigned_flag); |
if (result != ContextSlotCache::kNotFound) { |
DCHECK(result < scope_info->ContextLength()); |
return result; |
} |
+ int start = scope_info->ContextLocalNameEntriesIndex(); |
+ int end = scope_info->ContextLocalNameEntriesIndex() + |
+ scope_info->ContextLocalCount(); |
+ for (int i = start; i < end; ++i) { |
+ if (*name == scope_info->get(i)) { |
+ int var = i - start; |
+ *mode = scope_info->ContextLocalMode(var); |
+ *init_flag = scope_info->ContextLocalInitFlag(var); |
+ *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var); |
+ result = Context::MIN_CONTEXT_SLOTS + var; |
+ |
+ context_slot_cache->Update(scope_info, name, *mode, *init_flag, |
+ *maybe_assigned_flag, result); |
+ DCHECK(result < scope_info->ContextLength()); |
+ return result; |
+ } |
+ } |
+ // Cache as not found. Mode, init flag and maybe assigned flag don't matter. |
+ context_slot_cache->Update(scope_info, name, TEMPORARY, |
+ kNeedsInitialization, kNotAssigned, -1); |
+ } |
+ return -1; |
+} |
+ |
+ |
+int ScopeInfo::ContextGlobalSlotIndex(Handle<ScopeInfo> scope_info, |
+ Handle<String> name, VariableMode* mode, |
+ InitializationFlag* init_flag, |
+ MaybeAssignedFlag* maybe_assigned_flag) { |
+ DCHECK(name->IsInternalizedString()); |
+ DCHECK(mode != NULL); |
+ DCHECK(init_flag != NULL); |
+ if (scope_info->length() > 0) { |
+ // This is to ensure that ContextLocalMode() and co. queries would work. |
DCHECK_EQ(scope_info->ContextGlobalNameEntriesIndex(), |
scope_info->ContextLocalNameEntriesIndex() + |
scope_info->ContextLocalCount()); |
- int start = scope_info->ContextLocalNameEntriesIndex(); |
+ int base = scope_info->ContextLocalNameEntriesIndex(); |
+ int start = scope_info->ContextGlobalNameEntriesIndex(); |
int end = scope_info->ContextGlobalNameEntriesIndex() + |
scope_info->ContextGlobalCount(); |
for (int i = start; i < end; ++i) { |
if (*name == scope_info->get(i)) { |
- int var = i - start; |
+ int var = i - base; |
*mode = scope_info->ContextLocalMode(var); |
*init_flag = scope_info->ContextLocalInitFlag(var); |
*maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var); |
- |
- if (var < scope_info->ContextLocalCount()) { |
- *location = VariableLocation::CONTEXT; |
- result = Context::MIN_CONTEXT_SLOTS + var; |
- } else { |
- var -= scope_info->ContextLocalCount(); |
- *location = VariableLocation::GLOBAL; |
- result = Context::MIN_CONTEXT_SLOTS + |
- scope_info->ContextLocalCount() + var; |
- } |
- |
- context_slot_cache->Update(scope_info, name, *mode, *location, |
- *init_flag, *maybe_assigned_flag, result); |
+ int result = Context::MIN_CONTEXT_SLOTS + var; |
DCHECK(result < scope_info->ContextLength()); |
return result; |
} |
} |
- // Cache as not found. Mode, location, init flag and maybe assigned flag |
- // don't matter. |
- context_slot_cache->Update(scope_info, name, TEMPORARY, |
- VariableLocation::CONTEXT, kNeedsInitialization, |
- kNotAssigned, -1); |
} |
return -1; |
} |
@@ -701,7 +717,6 @@ int ContextSlotCache::Hash(Object* data, String* name) { |
int ContextSlotCache::Lookup(Object* data, String* name, VariableMode* mode, |
- VariableLocation* location, |
InitializationFlag* init_flag, |
MaybeAssignedFlag* maybe_assigned_flag) { |
int index = Hash(data, name); |
@@ -709,7 +724,6 @@ int ContextSlotCache::Lookup(Object* data, String* name, VariableMode* mode, |
if ((key.data == data) && key.name->Equals(name)) { |
Value result(values_[index]); |
if (mode != NULL) *mode = result.mode(); |
- if (location != NULL) *location = result.location(); |
if (init_flag != NULL) *init_flag = result.initialization_flag(); |
if (maybe_assigned_flag != NULL) |
*maybe_assigned_flag = result.maybe_assigned_flag(); |
@@ -720,8 +734,7 @@ int ContextSlotCache::Lookup(Object* data, String* name, VariableMode* mode, |
void ContextSlotCache::Update(Handle<Object> data, Handle<String> name, |
- VariableMode mode, VariableLocation location, |
- InitializationFlag init_flag, |
+ VariableMode mode, InitializationFlag init_flag, |
MaybeAssignedFlag maybe_assigned_flag, |
int slot_index) { |
DisallowHeapAllocation no_gc; |
@@ -734,11 +747,10 @@ void ContextSlotCache::Update(Handle<Object> data, Handle<String> name, |
key.data = *data; |
key.name = *internalized_name; |
// Please note value only takes a uint as index. |
- values_[index] = Value(mode, location, init_flag, maybe_assigned_flag, |
+ values_[index] = Value(mode, init_flag, maybe_assigned_flag, |
slot_index - kNotFound).raw(); |
#ifdef DEBUG |
- ValidateEntry(data, name, mode, location, init_flag, maybe_assigned_flag, |
- slot_index); |
+ ValidateEntry(data, name, mode, init_flag, maybe_assigned_flag, slot_index); |
#endif |
} |
} |
@@ -753,7 +765,6 @@ void ContextSlotCache::Clear() { |
void ContextSlotCache::ValidateEntry(Handle<Object> data, Handle<String> name, |
VariableMode mode, |
- VariableLocation location, |
InitializationFlag init_flag, |
MaybeAssignedFlag maybe_assigned_flag, |
int slot_index) { |
@@ -767,7 +778,6 @@ void ContextSlotCache::ValidateEntry(Handle<Object> data, Handle<String> name, |
DCHECK(key.name->Equals(*name)); |
Value result(values_[index]); |
DCHECK(result.mode() == mode); |
- DCHECK(result.location() == location); |
DCHECK(result.initialization_flag() == init_flag); |
DCHECK(result.maybe_assigned_flag() == maybe_assigned_flag); |
DCHECK(result.index() + kNotFound == slot_index); |