Handlify JSObject::AddFastPropertyUsingMap method.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16801 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 83cb6a63
......@@ -1850,46 +1850,39 @@ String* JSReceiver::constructor_name() {
}
Handle<Object> JSObject::AddFastPropertyUsingMap(
Handle<JSObject> object,
Handle<Map> new_map,
Handle<Name> name,
Handle<Object> value,
int field_index,
Representation representation) {
CALL_HEAP_FUNCTION(object->GetIsolate(),
object->AddFastPropertyUsingMap(
*new_map, *name, *value, field_index, representation),
// TODO(mstarzinger): Temporary wrapper until handlified.
static Handle<Object> NewStorageFor(Isolate* isolate,
Handle<Object> object,
Representation representation) {
Heap* heap = isolate->heap();
CALL_HEAP_FUNCTION(isolate,
object->AllocateNewStorageFor(heap, representation),
Object);
}
MaybeObject* JSObject::AddFastPropertyUsingMap(Map* new_map,
Name* name,
Object* value,
int field_index,
Representation representation) {
void JSObject::AddFastPropertyUsingMap(Handle<JSObject> object,
Handle<Map> new_map,
Handle<Name> name,
Handle<Object> value,
int field_index,
Representation representation) {
Isolate* isolate = object->GetIsolate();
// This method is used to transition to a field. If we are transitioning to a
// double field, allocate new storage.
Object* storage;
MaybeObject* maybe_storage =
value->AllocateNewStorageFor(GetHeap(), representation);
if (!maybe_storage->To(&storage)) return maybe_storage;
Handle<Object> storage = NewStorageFor(isolate, value, representation);
if (map()->unused_property_fields() == 0) {
if (object->map()->unused_property_fields() == 0) {
int new_unused = new_map->unused_property_fields();
FixedArray* values;
MaybeObject* maybe_values =
properties()->CopySize(properties()->length() + new_unused + 1);
if (!maybe_values->To(&values)) return maybe_values;
set_properties(values);
Handle<FixedArray> properties(object->properties());
Handle<FixedArray> values = isolate->factory()->CopySizeFixedArray(
properties, properties->length() + new_unused + 1);
object->set_properties(*values);
}
set_map(new_map);
FastPropertyAtPut(field_index, storage);
return value;
object->set_map(*new_map);
object->FastPropertyAtPut(field_index, *storage);
}
......@@ -3791,8 +3784,9 @@ Handle<Object> JSObject::SetPropertyUsingTransition(
}
int field_index = descriptors->GetFieldIndex(descriptor);
return AddFastPropertyUsingMap(
AddFastPropertyUsingMap(
object, transition_map, name, value, field_index, representation);
return value;
}
......@@ -5570,17 +5564,6 @@ MUST_USE_RESULT MaybeObject* JSObject::SetObserved(Isolate* isolate) {
}
// TODO(mstarzinger): Temporary wrapper until handlified.
static Handle<Object> NewStorageFor(Isolate* isolate,
Handle<Object> object,
Representation representation) {
Heap* heap = isolate->heap();
CALL_HEAP_FUNCTION(isolate,
object->AllocateNewStorageFor(heap, representation),
Object);
}
Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
Isolate* isolate = object->GetIsolate();
CALL_HEAP_FUNCTION(isolate,
......
......@@ -2761,18 +2761,12 @@ class JSObject: public JSReceiver {
// Add a property to a fast-case object using a map transition to
// new_map.
static Handle<Object> AddFastPropertyUsingMap(Handle<JSObject> object,
Handle<Map> new_map,
Handle<Name> name,
Handle<Object> value,
int field_index,
Representation representation);
MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(
Map* new_map,
Name* name,
Object* value,
int field_index,
Representation representation);
static void AddFastPropertyUsingMap(Handle<JSObject> object,
Handle<Map> new_map,
Handle<Name> name,
Handle<Object> value,
int field_index,
Representation representation);
// Add a property to a slow-case object.
static void AddSlowProperty(Handle<JSObject> object,
......
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