Commit 13b64dfe authored by ishell@chromium.org's avatar ishell@chromium.org

ContextSlotCache::Update() handlified.

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/263613003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21099 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 016a0419
......@@ -307,15 +307,14 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
*mode = scope_info->ContextLocalMode(var);
*init_flag = scope_info->ContextLocalInitFlag(var);
result = Context::MIN_CONTEXT_SLOTS + var;
context_slot_cache->Update(
*scope_info, *name, *mode, *init_flag, result);
context_slot_cache->Update(scope_info, name, *mode, *init_flag, result);
ASSERT(result < scope_info->ContextLength());
return result;
}
}
// Cache as not found. Mode and init flag don't matter.
context_slot_cache->Update(
*scope_info, *name, INTERNAL, kNeedsInitialization, -1);
scope_info, name, INTERNAL, kNeedsInitialization, -1);
}
return -1;
}
......@@ -432,18 +431,19 @@ int ContextSlotCache::Lookup(Object* data,
}
void ContextSlotCache::Update(Object* data,
String* name,
void ContextSlotCache::Update(Handle<Object> data,
Handle<String> name,
VariableMode mode,
InitializationFlag init_flag,
int slot_index) {
DisallowHeapAllocation no_gc;
String* internalized_name;
ASSERT(slot_index > kNotFound);
if (name->GetIsolate()->heap()->InternalizeStringIfExists(
name, &internalized_name)) {
int index = Hash(data, internalized_name);
*name, &internalized_name)) {
int index = Hash(*data, internalized_name);
Key& key = keys_[index];
key.data = data;
key.data = *data;
key.name = internalized_name;
// Please note value only takes a uint as index.
values_[index] = Value(mode, init_flag, slot_index - kNotFound).raw();
......@@ -461,18 +461,19 @@ void ContextSlotCache::Clear() {
#ifdef DEBUG
void ContextSlotCache::ValidateEntry(Object* data,
String* name,
void ContextSlotCache::ValidateEntry(Handle<Object> data,
Handle<String> name,
VariableMode mode,
InitializationFlag init_flag,
int slot_index) {
DisallowHeapAllocation no_gc;
String* internalized_name;
if (name->GetIsolate()->heap()->InternalizeStringIfExists(
name, &internalized_name)) {
int index = Hash(data, name);
*name, &internalized_name)) {
int index = Hash(*data, *name);
Key& key = keys_[index];
ASSERT(key.data == data);
ASSERT(key.name->Equals(name));
ASSERT(key.data == *data);
ASSERT(key.name->Equals(*name));
Value result(values_[index]);
ASSERT(result.mode() == mode);
ASSERT(result.initialization_flag() == init_flag);
......
......@@ -26,8 +26,8 @@ class ContextSlotCache {
InitializationFlag* init_flag);
// Update an element in the cache.
void Update(Object* data,
String* name,
void Update(Handle<Object> data,
Handle<String> name,
VariableMode mode,
InitializationFlag init_flag,
int slot_index);
......@@ -49,8 +49,8 @@ class ContextSlotCache {
inline static int Hash(Object* data, String* name);
#ifdef DEBUG
void ValidateEntry(Object* data,
String* name,
void ValidateEntry(Handle<Object> data,
Handle<String> name,
VariableMode mode,
InitializationFlag init_flag,
int slot_index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment