Revision: 12071
Author: [email protected]
Date: Thu Jul 12 09:36:10 2012
Log: Renamed ConvertDescriptorToFieldAndMapTransition to
ConvertTransitionToMapTransition, and let it replace the transition
in-place rather than copy the transition array.
Review URL: https://chromiumcodereview.appspot.com/10694155
http://code.google.com/p/v8/source/detail?r=12071
Modified:
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/property.h
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Thu Jul 12 08:14:54 2012
+++ /branches/bleeding_edge/src/objects-inl.h Thu Jul 12 09:36:10 2012
@@ -3538,6 +3538,10 @@
if (HasTransitionArray()) return transitions()->CopyInsert(key, value);
return TransitionArray::NewWith(key, value);
}
+
+void Map::SetTransition(int transition_index, Object* value) {
+ transitions()->SetValue(transition_index, value);
+}
// If the map is using the empty descriptor array, install a new empty
=======================================
--- /branches/bleeding_edge/src/objects.cc Thu Jul 12 08:14:54 2012
+++ /branches/bleeding_edge/src/objects.cc Thu Jul 12 09:36:10 2012
@@ -1779,12 +1779,12 @@
}
-MaybeObject* JSObject::ConvertDescriptorToFieldAndMapTransition(
+MaybeObject* JSObject::ConvertTransitionToMapTransition(
+ int transition_index,
String* name,
Object* new_value,
PropertyAttributes attributes) {
Map* old_map = map();
- FixedArray* old_properties = properties();
Object* result;
MaybeObject* maybe_result =
@@ -1797,23 +1797,10 @@
// with the map of "new Object()" cannot have transitions in the first
place.
ASSERT(map() != GetIsolate()->empty_object_map());
- TransitionArray* new_transitions;
- MaybeObject* maybe_new_transitions = old_map->AddTransition(name, map());
- if (!maybe_new_transitions->To(&new_transitions)) {
- // Undo changes and return failure.
- set_map(old_map);
- set_properties(old_properties);
- return maybe_new_transitions;
- }
-
- MaybeObject* transition_added =
old_map->set_transitions(new_transitions);
- if (transition_added->IsFailure()) {
- // Undo changes and return failure.
- set_map(old_map);
- set_properties(old_properties);
- return transition_added;
- }
-
+ // TODO(verwaest): From here on we lose existing map transitions, causing
+ // invalid back pointers. This will change once we can store multiple
+ // transitions with the same key.
+ old_map->SetTransition(transition_index, map());
map()->SetBackPointer(old_map);
return result;
}
@@ -2906,9 +2893,8 @@
}
// Otherwise, replace with a map transition to a new map with a
FIELD,
// even if the value is a constant function.
- return self->ConvertDescriptorToFieldAndMapTransition(*name,
- *value,
- attributes);
+ return ConvertTransitionToMapTransition(
+ result->GetTransitionIndex(), *name, *value, attributes);
}
case HANDLER:
case NONEXISTENT:
@@ -3023,7 +3009,8 @@
// Was transition to CONSTANT_FUNCTION. Replace with a map
transition to a
// new map with a FIELD, even if the value is a function.
- return ConvertDescriptorToFieldAndMapTransition(name, value,
attributes);
+ return ConvertTransitionToMapTransition(
+ result.GetTransitionIndex(), name, value, attributes);
}
case HANDLER:
case NONEXISTENT:
=======================================
--- /branches/bleeding_edge/src/objects.h Thu Jul 12 08:14:54 2012
+++ /branches/bleeding_edge/src/objects.h Thu Jul 12 09:36:10 2012
@@ -1938,19 +1938,15 @@
MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind
to_kind);
- // Converts a descriptor of any other type to a real field,
- // backed by the properties array. Descriptors of visible
- // types, such as CONSTANT_FUNCTION, keep their enumeration order.
- // Converts the descriptor on the original object's map to a
- // map transition, and the the new field is on the object's new map.
- MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition(
+ // Replaces an existing transition with a transition to a map with a
FIELD.
+ MUST_USE_RESULT MaybeObject* ConvertTransitionToMapTransition(
+ int transition_index,
String* name,
Object* new_value,
PropertyAttributes attributes);
- // Converts a descriptor of any other type to a real field,
- // backed by the properties array. Descriptors of visible
- // types, such as CONSTANT_FUNCTION, keep their enumeration order.
+ // Converts a descriptor of any other type to a real field, backed by the
+ // properties array.
MUST_USE_RESULT MaybeObject* ConvertDescriptorToField(
String* name,
Object* new_value,
@@ -4819,8 +4815,8 @@
MUST_USE_RESULT inline MaybeObject* set_elements_transition_map(
Map* transitioned_map);
inline TransitionArray* transitions();
- MUST_USE_RESULT inline MaybeObject* AddTransition(String* key,
- Object* value);
+ inline void SetTransition(int index, Object* value);
+ MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, Object*
value);
MUST_USE_RESULT inline MaybeObject* set_transitions(
TransitionArray* transitions);
inline void ClearTransitions(Heap* heap,
=======================================
--- /branches/bleeding_edge/src/property.h Thu Jul 12 08:14:54 2012
+++ /branches/bleeding_edge/src/property.h Thu Jul 12 09:36:10 2012
@@ -329,6 +329,11 @@
ASSERT(IsTransition());
return Map::cast(map->transitions()->GetValue(number_));
}
+
+ int GetTransitionIndex() {
+ ASSERT(IsTransition());
+ return number_;
+ }
int GetFieldIndex() {
ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev