From 91fa96bf6b1e3f23fc57bb76d88a2fa47b6705a4 Mon Sep 17 00:00:00 2001 From: "rafaelw@chromium.org" Date: Wed, 23 Oct 2013 19:47:38 +0000 Subject: [PATCH] Handlify Map::CopyNormalized R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/32483006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17349 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects.cc | 66 +++++++++++++++++++++++++++------------------------------- src/objects.h | 3 +-- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 2889014..71c3285 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4473,14 +4473,14 @@ PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor( Handle NormalizedMapCache::Get(Handle cache, Handle obj, PropertyNormalizationMode mode) { - Map* fast = obj->map(); - int index = fast->Hash() % kEntries; - Object* result = cache->get(index); + int index = obj->map()->Hash() % kEntries; + Handle result = handle(cache->get(index), cache->GetIsolate()); if (result->IsMap() && - Map::cast(result)->EquivalentToForNormalization(fast, mode)) { + Handle::cast(result)->EquivalentToForNormalization(obj->map(), + mode)) { #ifdef VERIFY_HEAP if (FLAG_verify_heap) { - Map::cast(result)->SharedMapVerify(); + Handle::cast(result)->SharedMapVerify(); } #endif #ifdef DEBUG @@ -4488,27 +4488,25 @@ Handle NormalizedMapCache::Get(Handle cache, // The cached map should match newly created normalized map bit-by-bit, // except for the code cache, which can contain some ics which can be // applied to the shared map. - Object* fresh; - MaybeObject* maybe_fresh = - fast->CopyNormalized(mode, SHARED_NORMALIZED_MAP); - if (maybe_fresh->ToObject(&fresh)) { - ASSERT(memcmp(Map::cast(fresh)->address(), - Map::cast(result)->address(), - Map::kCodeCacheOffset) == 0); - STATIC_ASSERT(Map::kDependentCodeOffset == - Map::kCodeCacheOffset + kPointerSize); - int offset = Map::kDependentCodeOffset + kPointerSize; - ASSERT(memcmp(Map::cast(fresh)->address() + offset, - Map::cast(result)->address() + offset, - Map::kSize - offset) == 0); - } + Handle fresh = Map::CopyNormalized(handle(obj->map()), mode, + SHARED_NORMALIZED_MAP); + + ASSERT(memcmp(fresh->address(), + Handle::cast(result)->address(), + Map::kCodeCacheOffset) == 0); + STATIC_ASSERT(Map::kDependentCodeOffset == + Map::kCodeCacheOffset + kPointerSize); + int offset = Map::kDependentCodeOffset + kPointerSize; + ASSERT(memcmp(fresh->address() + offset, + Handle::cast(result)->address() + offset, + Map::kSize - offset) == 0); } #endif - return handle(Map::cast(result)); + return Handle::cast(result); } Isolate* isolate = cache->GetIsolate(); - Handle map = Map::CopyNormalized(handle(fast), mode, + Handle map = Map::CopyNormalized(handle(obj->map()), mode, SHARED_NORMALIZED_MAP); ASSERT(map->is_dictionary_map()); cache->set(index, *map); @@ -6649,6 +6647,14 @@ Object* JSObject::SlowReverseLookup(Object* value) { } +Handle Map::RawCopy(Handle map, + int instance_size) { + CALL_HEAP_FUNCTION(map->GetIsolate(), + map->RawCopy(instance_size), + Map); +} + + MaybeObject* Map::RawCopy(int instance_size) { Map* result; MaybeObject* maybe_result = @@ -6673,25 +6679,15 @@ MaybeObject* Map::RawCopy(int instance_size) { Handle Map::CopyNormalized(Handle map, PropertyNormalizationMode mode, NormalizedMapSharingMode sharing) { - CALL_HEAP_FUNCTION(map->GetIsolate(), - map->CopyNormalized(mode, sharing), - Map); -} - - -MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, - NormalizedMapSharingMode sharing) { - int new_instance_size = instance_size(); + int new_instance_size = map->instance_size(); if (mode == CLEAR_INOBJECT_PROPERTIES) { - new_instance_size -= inobject_properties() * kPointerSize; + new_instance_size -= map->inobject_properties() * kPointerSize; } - Map* result; - MaybeObject* maybe_result = RawCopy(new_instance_size); - if (!maybe_result->To(&result)) return maybe_result; + Handle result = Map::RawCopy(map, new_instance_size); if (mode != CLEAR_INOBJECT_PROPERTIES) { - result->set_inobject_properties(inobject_properties()); + result->set_inobject_properties(map->inobject_properties()); } result->set_is_shared(sharing == SHARED_NORMALIZED_MAP); diff --git a/src/objects.h b/src/objects.h index 1dfa737..200097a 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5965,6 +5965,7 @@ class Map: public HeapObject { // descriptor array of the map. Returns NULL if no updated map is found. Map* CurrentMapForDeprecated(); + static Handle RawCopy(Handle map, int instance_size); MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); static Handle CopyDropDescriptors(Handle map); @@ -6006,8 +6007,6 @@ class Map: public HeapObject { static Handle CopyNormalized(Handle map, PropertyNormalizationMode mode, NormalizedMapSharingMode sharing); - MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, - NormalizedMapSharingMode sharing); inline void AppendDescriptor(Descriptor* desc, const DescriptorArray::WhitenessWitness&); -- 2.7.4