Commit ae1aaf7c authored by ishell@chromium.org's avatar ishell@chromium.org

Making MigrateToMap() a single bottleneck for all migrations except slow-to-fast case.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/346743005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21984 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 220fa8ea
...@@ -2104,7 +2104,26 @@ Handle<TransitionArray> Map::SetElementsTransitionMap( ...@@ -2104,7 +2104,26 @@ Handle<TransitionArray> Map::SetElementsTransitionMap(
} }
// To migrate an instance to a map: void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
if (object->map() == *new_map) return;
if (object->HasFastProperties()) {
if (!new_map->is_dictionary_map()) {
MigrateFastToFast(object, new_map);
} else {
MigrateFastToSlow(object, new_map, 0);
}
} else {
// For slow-to-fast migrations JSObject::TransformToFastProperties()
// must be used instead.
CHECK(new_map->is_dictionary_map());
// Slow-to-slow migration is trivial.
object->set_map(*new_map);
}
}
// To migrate an fast instance to a fast map:
// - First check whether the instance needs to be rewritten. If not, simply // - First check whether the instance needs to be rewritten. If not, simply
// change the map. // change the map.
// - Otherwise, allocate a fixed array large enough to hold all fields, in // - Otherwise, allocate a fixed array large enough to hold all fields, in
...@@ -2119,7 +2138,7 @@ Handle<TransitionArray> Map::SetElementsTransitionMap( ...@@ -2119,7 +2138,7 @@ Handle<TransitionArray> Map::SetElementsTransitionMap(
// to temporarily store the inobject properties. // to temporarily store the inobject properties.
// * If there are properties left in the backing store, install the backing // * If there are properties left in the backing store, install the backing
// store. // store.
void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) { void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
Handle<Map> old_map(object->map()); Handle<Map> old_map(object->map());
int number_of_fields = new_map->NumberOfFields(); int number_of_fields = new_map->NumberOfFields();
...@@ -2261,8 +2280,7 @@ void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, ...@@ -2261,8 +2280,7 @@ void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object,
Handle<Map> new_map = Map::GeneralizeRepresentation( Handle<Map> new_map = Map::GeneralizeRepresentation(
handle(object->map()), modify_index, new_representation, handle(object->map()), modify_index, new_representation,
new_field_type, store_mode); new_field_type, store_mode);
if (object->map() == *new_map) return; MigrateToMap(object, new_map);
return MigrateToMap(object, new_map);
} }
...@@ -4555,6 +4573,16 @@ void JSObject::NormalizeProperties(Handle<JSObject> object, ...@@ -4555,6 +4573,16 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
int expected_additional_properties) { int expected_additional_properties) {
if (!object->HasFastProperties()) return; if (!object->HasFastProperties()) return;
Handle<Map> map(object->map());
Handle<Map> new_map = Map::Normalize(map, mode);
MigrateFastToSlow(object, new_map, expected_additional_properties);
}
void JSObject::MigrateFastToSlow(Handle<JSObject> object,
Handle<Map> new_map,
int expected_additional_properties) {
// The global object is always normalized. // The global object is always normalized.
ASSERT(!object->IsGlobalObject()); ASSERT(!object->IsGlobalObject());
// JSGlobalProxy must never be normalized // JSGlobalProxy must never be normalized
...@@ -4563,7 +4591,6 @@ void JSObject::NormalizeProperties(Handle<JSObject> object, ...@@ -4563,7 +4591,6 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Map> map(object->map()); Handle<Map> map(object->map());
Handle<Map> new_map = Map::Normalize(map, mode);
// Allocate new content. // Allocate new content.
int real_size = map->NumberOfOwnDescriptors(); int real_size = map->NumberOfOwnDescriptors();
......
...@@ -2633,6 +2633,11 @@ class JSObject: public JSReceiver { ...@@ -2633,6 +2633,11 @@ class JSObject: public JSReceiver {
friend class JSReceiver; friend class JSReceiver;
friend class Object; friend class Object;
static void MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map);
static void MigrateFastToSlow(Handle<JSObject> object,
Handle<Map> new_map,
int expected_additional_properties);
static void UpdateAllocationSite(Handle<JSObject> object, static void UpdateAllocationSite(Handle<JSObject> object,
ElementsKind to_kind); ElementsKind to_kind);
......
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