From 13b64dfe3f72899029a281c718c58d92bc46f4a8 Mon Sep 17 00:00:00 2001 From: "ishell@chromium.org" Date: Wed, 30 Apr 2014 17:12:52 +0000 Subject: [PATCH] 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 --- src/scopeinfo.cc | 29 +++++++++++++++-------------- src/scopeinfo.h | 8 ++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc index a44ac61..daa60c9 100644 --- a/src/scopeinfo.cc +++ b/src/scopeinfo.cc @@ -307,15 +307,14 @@ int ScopeInfo::ContextSlotIndex(Handle 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 data, + Handle 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 data, + Handle 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); diff --git a/src/scopeinfo.h b/src/scopeinfo.h index 9a13b82..755b6a3 100644 --- a/src/scopeinfo.h +++ b/src/scopeinfo.h @@ -26,8 +26,8 @@ class ContextSlotCache { InitializationFlag* init_flag); // Update an element in the cache. - void Update(Object* data, - String* name, + void Update(Handle data, + Handle 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 data, + Handle name, VariableMode mode, InitializationFlag init_flag, int slot_index); -- 2.7.4