From 146eb9e0ee6a63640159ca543d6fe0450e20cd49 Mon Sep 17 00:00:00 2001 From: "rafaelw@chromium.org" Date: Tue, 22 Oct 2013 17:41:08 +0000 Subject: [PATCH] Handlify Map::CopyForObserved R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/34023002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17327 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects.cc | 48 +++++++++++++++++++++++++----------------------- src/objects.h | 7 ++++++- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 7136c06..4412e76 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2434,6 +2434,16 @@ void JSObject::MigrateToMap(Handle object, Handle new_map) { } +Handle Map::AddTransition(Handle map, + Handle key, + Handle target, + SimpleTransitionFlag flag) { + CALL_HEAP_FUNCTION(map->GetIsolate(), + map->AddTransition(*key, *target, flag), + TransitionArray); +} + + void JSObject::GeneralizeFieldRepresentation(Handle object, int modify_index, Representation new_representation, @@ -6930,41 +6940,33 @@ MaybeObject* Map::CopyAsElementsKind(ElementsKind kind, TransitionFlag flag) { Handle Map::CopyForObserved(Handle map) { - CALL_HEAP_FUNCTION(map->GetIsolate(), - map->CopyForObserved(), - Map); -} + ASSERT(!map->is_observed()); - -MaybeObject* Map::CopyForObserved() { - ASSERT(!is_observed()); + Isolate* isolate = map->GetIsolate(); // In case the map owned its own descriptors, share the descriptors and // transfer ownership to the new map. - Map* new_map; - MaybeObject* maybe_new_map; - if (owns_descriptors()) { - maybe_new_map = CopyDropDescriptors(); + Handle new_map; + if (map->owns_descriptors()) { + new_map = Map::CopyDropDescriptors(map); } else { - maybe_new_map = Copy(); + new_map = Map::Copy(map); } - if (!maybe_new_map->To(&new_map)) return maybe_new_map; - TransitionArray* transitions; - MaybeObject* maybe_transitions = AddTransition(GetHeap()->observed_symbol(), - new_map, - FULL_TRANSITION); - if (!maybe_transitions->To(&transitions)) return maybe_transitions; - set_transitions(transitions); + Handle transitions = + Map::AddTransition(map, isolate->factory()->observed_symbol(), new_map, + FULL_TRANSITION); + + map->set_transitions(*transitions); new_map->set_is_observed(true); - if (owns_descriptors()) { - new_map->InitializeDescriptors(instance_descriptors()); - set_owns_descriptors(false); + if (map->owns_descriptors()) { + new_map->InitializeDescriptors(map->instance_descriptors()); + map->set_owns_descriptors(false); } - new_map->SetBackPointer(this); + new_map->SetBackPointer(*map); return new_map; } diff --git a/src/objects.h b/src/objects.h index 47d8772..299ca2d 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5749,6 +5749,12 @@ class Map: public HeapObject { Map* transitioned_map); inline void SetTransition(int transition_index, Map* target); inline Map* GetTransition(int transition_index); + + static Handle AddTransition(Handle map, + Handle key, + Handle target, + SimpleTransitionFlag flag); + MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, Map* target, SimpleTransitionFlag flag); @@ -5986,7 +5992,6 @@ class Map: public HeapObject { TransitionFlag flag); static Handle CopyForObserved(Handle map); - MUST_USE_RESULT MaybeObject* CopyForObserved(); static Handle CopyNormalized(Handle map, PropertyNormalizationMode mode, -- 2.7.4