Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Unified Diff: src/scopeinfo.cc

Issue 8423005: Remove some unnecessary binding initialization checks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopeinfo.h ('k') | src/scopes.h » ('j') | src/scopes.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index 59e707dc5258b2e8953d358686957ca5e010bfaa..25491f59e8165fa00220e5b51e6da7ecd6d620b2 100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -148,10 +148,13 @@ Handle<ScopeInfo> ScopeInfo::Create(Scope* scope) {
scope_info->set(index++, *context_locals[i]->name());
}
- // Add context locals' modes.
- ASSERT(index == scope_info->ContextLocalModeEntriesIndex());
+ // Add context locals' info.
+ ASSERT(index == scope_info->ContextLocalInfoEntriesIndex());
for (int i = 0; i < num_context_locals; ++i) {
- scope_info->set(index++, Smi::FromInt(context_locals[i]->mode()));
+ Variable* var = context_locals[i];
+ uint32_t value = ContextLocalMode::encode(var->mode()) |
+ ContextLocalInitFlag::encode(var->initialization_flag());
+ scope_info->set(index++, Smi::FromInt(value));
}
// If present, add the function variable name and its index.
@@ -305,8 +308,17 @@ Handle<String> ScopeInfo::context_local_name(int var) {
VariableMode ScopeInfo::context_local_mode(int var) {
ASSERT(0 <= var && var < num_context_locals());
- int info_index = ContextLocalModeEntriesIndex() + var;
- return static_cast<VariableMode>(Smi::cast(get(info_index))->value());
+ int info_index = ContextLocalInfoEntriesIndex() + var;
+ int value = Smi::cast(get(info_index))->value();
+ return ContextLocalMode::decode(value);
+}
+
+
+InitializationFlag ScopeInfo::context_local_init_flag(int var) {
+ ASSERT(0 <= var && var < num_context_locals());
+ int info_index = ContextLocalInfoEntriesIndex() + var;
+ int value = Smi::cast(get(info_index))->value();
+ return ContextLocalInitFlag::decode(value);
}
@@ -325,11 +337,13 @@ int ScopeInfo::StackSlotIndex(String* name) {
}
-int ScopeInfo::ContextSlotIndex(String* name, VariableMode* mode) {
+int ScopeInfo::ContextSlotIndex(String* name,
+ VariableMode* mode,
+ InitializationFlag* init_flag) {
ASSERT(name->IsSymbol());
if (length() > 0) {
ContextSlotCache* context_slot_cache = GetIsolate()->context_slot_cache();
- int result = context_slot_cache->Lookup(this, name, mode);
+ int result = context_slot_cache->Lookup(this, name, mode, init_flag);
if (result != ContextSlotCache::kNotFound) {
ASSERT(result < NumberOfContextSlots());
return result;
@@ -341,14 +355,17 @@ int ScopeInfo::ContextSlotIndex(String* name, VariableMode* mode) {
if (name == get(i)) {
int var = i - start;
VariableMode mode_value = context_local_mode(var);
+ InitializationFlag init_flag_value = context_local_init_flag(var);
if (mode != NULL) *mode = mode_value;
+ if (init_flag != NULL) *init_flag = init_flag_value;
result = Context::MIN_CONTEXT_SLOTS + var;
- context_slot_cache->Update(this, name, mode_value, result);
+ context_slot_cache->Update(
+ this, name, mode_value, init_flag_value, result);
ASSERT(result < NumberOfContextSlots());
return result;
}
}
- context_slot_cache->Update(this, name, INTERNAL, -1);
+ context_slot_cache->Update(this, name, INTERNAL, NEEDS_INITIALIZATION, -1);
}
return -1;
}
@@ -403,13 +420,13 @@ int ScopeInfo::ContextLocalNameEntriesIndex() {
}
-int ScopeInfo::ContextLocalModeEntriesIndex() {
+int ScopeInfo::ContextLocalInfoEntriesIndex() {
return ContextLocalNameEntriesIndex() + num_context_locals();
}
int ScopeInfo::FunctionNameEntryIndex() {
- return ContextLocalModeEntriesIndex() + num_context_locals();
+ return ContextLocalInfoEntriesIndex() + num_context_locals();
}
@@ -423,12 +440,14 @@ int ContextSlotCache::Hash(Object* data, String* name) {
int ContextSlotCache::Lookup(Object* data,
String* name,
- VariableMode* mode) {
+ VariableMode* mode,
+ InitializationFlag* init_flag) {
int index = Hash(data, name);
Key& key = keys_[index];
if ((key.data == data) && key.name->Equals(name)) {
Value result(values_[index]);
if (mode != NULL) *mode = result.mode();
+ if (init_flag != NULL) *init_flag = result.initialization_flag();
return result.index() + kNotFound;
}
return kNotFound;
@@ -438,6 +457,7 @@ int ContextSlotCache::Lookup(Object* data,
void ContextSlotCache::Update(Object* data,
String* name,
VariableMode mode,
+ InitializationFlag init_flag,
int slot_index) {
String* symbol;
ASSERT(slot_index > kNotFound);
@@ -447,9 +467,9 @@ void ContextSlotCache::Update(Object* data,
key.data = data;
key.name = symbol;
// Please note value only takes a uint as index.
- values_[index] = Value(mode, slot_index - kNotFound).raw();
+ values_[index] = Value(mode, init_flag, slot_index - kNotFound).raw();
#ifdef DEBUG
- ValidateEntry(data, name, mode, slot_index);
+ ValidateEntry(data, name, mode, init_flag, slot_index);
#endif
}
}
@@ -465,6 +485,7 @@ void ContextSlotCache::Clear() {
void ContextSlotCache::ValidateEntry(Object* data,
String* name,
VariableMode mode,
+ InitializationFlag init_flag,
int slot_index) {
String* symbol;
if (HEAP->LookupSymbolIfExists(name, &symbol)) {
@@ -474,6 +495,7 @@ void ContextSlotCache::ValidateEntry(Object* data,
ASSERT(key.name->Equals(name));
Value result(values_[index]);
ASSERT(result.mode() == mode);
+ ASSERT(result.initialization_flag() == init_flag);
ASSERT(result.index() + kNotFound == slot_index);
}
}
« no previous file with comments | « src/scopeinfo.h ('k') | src/scopes.h » ('j') | src/scopes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698