Commit 9d0b1590 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Reuse AddFastPropertyUsingMap in AddFastProperty

R=bmeurer@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23465008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16397 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 652b174c
......@@ -1958,46 +1958,17 @@ MaybeObject* JSObject::AddFastProperty(Name* name,
FieldDescriptor new_field(name, index, attributes, representation);
ASSERT(index < map()->inobject_properties() ||
(index - map()->inobject_properties()) < properties()->length() ||
map()->unused_property_fields() == 0);
FixedArray* values = NULL;
// TODO(verwaest): Merge with AddFastPropertyUsingMap.
if (map()->unused_property_fields() == 0) {
// Make room for the new value
MaybeObject* maybe_values =
properties()->CopySize(properties()->length() + kFieldsAdded);
if (!maybe_values->To(&values)) return maybe_values;
}
Heap* heap = isolate->heap();
Object* storage;
MaybeObject* maybe_storage =
value->AllocateNewStorageFor(heap, representation);
if (!maybe_storage->To(&storage)) return maybe_storage;
// Note that Map::CopyAddDescriptor has side-effects, the new map is already
// inserted in the transition tree. No more allocations that might fail are
// allowed after this point.
Map* new_map;
MaybeObject* maybe_new_map = map()->CopyAddDescriptor(&new_field, flag);
if (!maybe_new_map->To(&new_map)) return maybe_new_map;
if (map()->unused_property_fields() == 0) {
ASSERT(values != NULL);
set_properties(values);
new_map->set_unused_property_fields(kFieldsAdded - 1);
} else {
new_map->set_unused_property_fields(map()->unused_property_fields() - 1);
int unused_property_fields = map()->unused_property_fields() - 1;
if (unused_property_fields < 0) {
unused_property_fields += kFieldsAdded;
}
new_map->set_unused_property_fields(unused_property_fields);
set_map(new_map);
FastPropertyAtPut(index, storage);
return value;
return AddFastPropertyUsingMap(new_map, name, value, index, representation);
}
......
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