Reviewers: Yang,
Description:
Handlify JSObject::AddFastPropertyUsingMap method.
[email protected]
Please review this at https://codereview.chromium.org/24195003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+31, -54 lines):
M src/objects.h
M src/objects.cc
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
b213e9743653b41fe0e02a6d2b2d152486fc8aa2..d68cc1aa2c118e5895a9269c5b3a4077398ebfd9
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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;
}
@@ -5571,17 +5565,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,
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
5d004297e0b62c7851605f35766983a9e7421ae1..41a513c36b643ac7442a455337b359d99a2974b3
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -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,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.