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