From 8ece310be82a824dd81cd76e03e823cd55126ba9 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Mon, 11 Aug 2014 14:54:15 +0000 Subject: [PATCH] Change the type of the cache so we can check whether it is there BUG= R=yangguo@chromium.org Review URL: https://codereview.chromium.org/457333003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23048 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/contexts.h | 2 +- src/objects.cc | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/contexts.h b/src/contexts.h index 0f8bf77..63c9955 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -160,7 +160,7 @@ enum BindingFlags { V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \ V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \ - V(NORMALIZED_MAP_CACHE_INDEX, NormalizedMapCache, normalized_map_cache) \ + V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache) \ V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \ V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \ diff --git a/src/objects.cc b/src/objects.cc index cf9f65d..aa99840 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4441,8 +4441,6 @@ Handle NormalizedMapCache::New(Isolate* isolate) { MaybeHandle NormalizedMapCache::Get(Handle fast_map, PropertyNormalizationMode mode) { - // Only use the cache once it is initialized. - if (!IsNormalizedMapCache(this)) return MaybeHandle(); DisallowHeapAllocation no_gc; Object* value = FixedArray::get(GetIndex(fast_map)); if (!value->IsMap() || @@ -4455,8 +4453,6 @@ MaybeHandle NormalizedMapCache::Get(Handle fast_map, void NormalizedMapCache::Set(Handle fast_map, Handle normalized_map) { - // Only use the cache once it is initialized. - if (!IsNormalizedMapCache(this)) return; DisallowHeapAllocation no_gc; DCHECK(normalized_map->is_dictionary_map()); FixedArray::set(GetIndex(fast_map), *normalized_map); @@ -6980,11 +6976,14 @@ Handle Map::Normalize(Handle fast_map, DCHECK(!fast_map->is_dictionary_map()); Isolate* isolate = fast_map->GetIsolate(); - Handle cache( - isolate->context()->native_context()->normalized_map_cache()); + Handle maybe_cache(isolate->native_context()->normalized_map_cache(), + isolate); + bool use_cache = !maybe_cache->IsUndefined(); + Handle cache; + if (use_cache) cache = Handle::cast(maybe_cache); Handle new_map; - if (cache->Get(fast_map, mode).ToHandle(&new_map)) { + if (use_cache && cache->Get(fast_map, mode).ToHandle(&new_map)) { #ifdef VERIFY_HEAP if (FLAG_verify_heap) new_map->DictionaryMapVerify(); #endif @@ -7008,8 +7007,10 @@ Handle Map::Normalize(Handle fast_map, #endif } else { new_map = Map::CopyNormalized(fast_map, mode); - cache->Set(fast_map, new_map); - isolate->counters()->normalized_maps()->Increment(); + if (use_cache) { + cache->Set(fast_map, new_map); + isolate->counters()->normalized_maps()->Increment(); + } } fast_map->NotifyLeafMapLayoutChange(); return new_map; -- 2.7.4