Commit a7ecf7d4 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Inline relevant parts of MigrateToMap into AllocateStorageForMap

This speeds up the json parser by 10-20%

Bug: chromium:771227
Change-Id: Ib2392471bdd9ff9041237708cb272229b5ece410
Reviewed-on: https://chromium-review.googlesource.com/700494
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48287}
parent cbd03a83
......@@ -5826,7 +5826,55 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
}
map = Map::ReconfigureElementsKind(map, to_kind);
}
JSObject::MigrateToMap(object, map);
int number_of_fields = map->NumberOfFields();
int inobject = map->GetInObjectProperties();
int unused = map->unused_property_fields();
int total_size = number_of_fields + unused;
int external = total_size - inobject;
// Allocate mutable double boxes if necessary. It is always necessary if we
// have external properties, but is also necessary if we only have inobject
// properties but don't unbox double fields.
if (!FLAG_unbox_double_fields || external > 0) {
Isolate* isolate = object->GetIsolate();
Handle<DescriptorArray> descriptors(map->instance_descriptors());
Handle<FixedArray> storage;
if (!FLAG_unbox_double_fields) {
storage = isolate->factory()->NewFixedArray(inobject);
}
Handle<PropertyArray> array;
if (external > 0) {
array = isolate->factory()->NewPropertyArray(external);
}
for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
PropertyDetails details = descriptors->GetDetails(i);
Representation representation = details.representation();
if (!representation.IsDouble()) continue;
FieldIndex index = FieldIndex::ForDescriptor(*map, i);
if (map->IsUnboxedDoubleField(index)) continue;
Handle<HeapNumber> box = isolate->factory()->NewMutableHeapNumber();
if (index.is_inobject()) {
storage->set(index.property_index(), *box);
} else {
array->set(index.outobject_array_index(), *box);
}
}
if (external > 0) {
object->SetProperties(*array);
}
if (!FLAG_unbox_double_fields) {
for (int i = 0; i < inobject; i++) {
FieldIndex index = FieldIndex::ForPropertyIndex(*map, i);
Object* value = storage->get(i);
object->RawFastPropertyAtPut(index, value);
}
}
}
object->synchronized_set_map(*map);
}
......
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