Commit 146eb9e0 authored by rafaelw@chromium.org's avatar rafaelw@chromium.org

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
parent 3ec2f195
...@@ -2434,6 +2434,16 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) { ...@@ -2434,6 +2434,16 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
} }
Handle<TransitionArray> Map::AddTransition(Handle<Map> map,
Handle<Name> key,
Handle<Map> target,
SimpleTransitionFlag flag) {
CALL_HEAP_FUNCTION(map->GetIsolate(),
map->AddTransition(*key, *target, flag),
TransitionArray);
}
void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object,
int modify_index, int modify_index,
Representation new_representation, Representation new_representation,
...@@ -6930,41 +6940,33 @@ MaybeObject* Map::CopyAsElementsKind(ElementsKind kind, TransitionFlag flag) { ...@@ -6930,41 +6940,33 @@ MaybeObject* Map::CopyAsElementsKind(ElementsKind kind, TransitionFlag flag) {
Handle<Map> Map::CopyForObserved(Handle<Map> map) { Handle<Map> Map::CopyForObserved(Handle<Map> map) {
CALL_HEAP_FUNCTION(map->GetIsolate(), ASSERT(!map->is_observed());
map->CopyForObserved(),
Map);
}
Isolate* isolate = map->GetIsolate();
MaybeObject* Map::CopyForObserved() {
ASSERT(!is_observed());
// In case the map owned its own descriptors, share the descriptors and // In case the map owned its own descriptors, share the descriptors and
// transfer ownership to the new map. // transfer ownership to the new map.
Map* new_map; Handle<Map> new_map;
MaybeObject* maybe_new_map; if (map->owns_descriptors()) {
if (owns_descriptors()) { new_map = Map::CopyDropDescriptors(map);
maybe_new_map = CopyDropDescriptors();
} else { } else {
maybe_new_map = Copy(); new_map = Map::Copy(map);
} }
if (!maybe_new_map->To(&new_map)) return maybe_new_map;
TransitionArray* transitions; Handle<TransitionArray> transitions =
MaybeObject* maybe_transitions = AddTransition(GetHeap()->observed_symbol(), Map::AddTransition(map, isolate->factory()->observed_symbol(), new_map,
new_map, FULL_TRANSITION);
FULL_TRANSITION);
if (!maybe_transitions->To(&transitions)) return maybe_transitions; map->set_transitions(*transitions);
set_transitions(transitions);
new_map->set_is_observed(true); new_map->set_is_observed(true);
if (owns_descriptors()) { if (map->owns_descriptors()) {
new_map->InitializeDescriptors(instance_descriptors()); new_map->InitializeDescriptors(map->instance_descriptors());
set_owns_descriptors(false); map->set_owns_descriptors(false);
} }
new_map->SetBackPointer(this); new_map->SetBackPointer(*map);
return new_map; return new_map;
} }
......
...@@ -5749,6 +5749,12 @@ class Map: public HeapObject { ...@@ -5749,6 +5749,12 @@ class Map: public HeapObject {
Map* transitioned_map); Map* transitioned_map);
inline void SetTransition(int transition_index, Map* target); inline void SetTransition(int transition_index, Map* target);
inline Map* GetTransition(int transition_index); inline Map* GetTransition(int transition_index);
static Handle<TransitionArray> AddTransition(Handle<Map> map,
Handle<Name> key,
Handle<Map> target,
SimpleTransitionFlag flag);
MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key,
Map* target, Map* target,
SimpleTransitionFlag flag); SimpleTransitionFlag flag);
...@@ -5986,7 +5992,6 @@ class Map: public HeapObject { ...@@ -5986,7 +5992,6 @@ class Map: public HeapObject {
TransitionFlag flag); TransitionFlag flag);
static Handle<Map> CopyForObserved(Handle<Map> map); static Handle<Map> CopyForObserved(Handle<Map> map);
MUST_USE_RESULT MaybeObject* CopyForObserved();
static Handle<Map> CopyNormalized(Handle<Map> map, static Handle<Map> CopyNormalized(Handle<Map> map,
PropertyNormalizationMode mode, PropertyNormalizationMode mode,
......
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