Reviewers: mvstanton,

Description:
Use a wrapper for copying object.

[email protected]

Please review this at https://codereview.chromium.org/238113003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -27 lines):
  M src/heap.h
  M src/heap.cc
  M src/objects.h
  M src/objects.cc


Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 03f68a7958e66defc2df178a02a5a7ae7b1e11f9..b4e6dde1d56ee5ef8cd1876d5dc58f8edb55109a 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4790,21 +4790,6 @@ MaybeObject* Heap::AllocateUninitializedFixedArray(int length) {
 }


-MaybeObject* Heap::AllocateEmptyFixedDoubleArray() {
-  int size = FixedDoubleArray::SizeFor(0);
-  Object* result;
-  { MaybeObject* maybe_result =
-        AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
-    if (!maybe_result->ToObject(&result)) return maybe_result;
-  }
-  // Initialize the object.
-  reinterpret_cast<FixedDoubleArray*>(result)->set_map_no_write_barrier(
-      fixed_double_array_map());
-  reinterpret_cast<FixedDoubleArray*>(result)->set_length(0);
-  return result;
-}
-
-
 MaybeObject* Heap::AllocateUninitializedFixedDoubleArray(
     int length,
     PretenureFlag pretenure) {
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index e463287cb5a4615ecb1384bea3c77a3273e81231..adf420b333237500a4421db23307736eba89047d 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -2110,9 +2110,6 @@ class Heap {
   MUST_USE_RESULT MaybeObject* AllocateEmptyFixedTypedArray(
       ExternalArrayType array_type);

-  // Allocate empty fixed double array.
-  MUST_USE_RESULT MaybeObject* AllocateEmptyFixedDoubleArray();
-
   // Allocate empty constant pool array.
   MUST_USE_RESULT MaybeObject* AllocateEmptyConstantPoolArray();

Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 5a1daa2fc201301b311fc25f3ae28bcbf5784075..f43f76d9225f7b535401a013492a1bb32d9b7364 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5824,10 +5824,22 @@ void JSObject::SetObserved(Handle<JSObject> object) {
 }


+Handle<JSObject> JSObject::Copy(Handle<JSObject> object,
+                                Handle<AllocationSite> site) {
+  Isolate* isolate = object->GetIsolate();
+  CALL_HEAP_FUNCTION(isolate,
+                     isolate->heap()->CopyJSObject(
+                         *object,
+                         site.is_null() ? NULL : *site),
+                     JSObject);
+}
+
+
 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
   Isolate* isolate = object->GetIsolate();
   CALL_HEAP_FUNCTION(isolate,
-                     isolate->heap()->CopyJSObject(*object), JSObject);
+                     isolate->heap()->CopyJSObject(*object, NULL),
+                     JSObject);
 }


@@ -5898,14 +5910,7 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
     if (site_context()->ShouldCreateMemento(object)) {
       site_to_pass = site_context()->current();
     }
-    CALL_AND_RETRY_OR_DIE(isolate,
-                          isolate->heap()->CopyJSObject(*object,
- site_to_pass.is_null() ? NULL : *site_to_pass), - { copy = Handle<JSObject>(JSObject::cast(__object__),
-                                                    isolate);
-                            break;
-                          },
-                          return Handle<JSObject>());
+    copy = JSObject::Copy(object, site_to_pass);
   } else {
     copy = object;
   }
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index ae3ba6db3ea581bd2cb1cec74fa37d60532904ac..5558e6738359a70e2ef9b716b09b65b6100f8d9c 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2147,6 +2147,10 @@ class JSReceiver: public HeapObject {
 // Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable.
 class ObjectHashTable;

+// Forward declaration for JSObject::Copy.
+class AllocationSite;
+
+
 // The JSObject describes real heap allocated JavaScript objects with
 // properties.
 // Note that the map of JSObject changes during execution to enable inline
@@ -2655,6 +2659,8 @@ class JSObject: public JSReceiver {
     kObjectIsShallowArray = 1
   };

+  static Handle<JSObject> Copy(Handle<JSObject> object,
+                               Handle<AllocationSite> site);
   static Handle<JSObject> Copy(Handle<JSObject> object);
   static Handle<JSObject> DeepCopy(Handle<JSObject> object,
AllocationSiteUsageContext* site_context,


--
--
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/d/optout.

Reply via email to