| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 796439a8d394887ad15ed9432cb6ba6b02290407..d61d0d7a22848f008274ff0b95bbfe48511d2544 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -4475,7 +4475,8 @@ void Heap::InitializeJSObjectFromMap(JSObject* obj,
|
| }
|
|
|
|
|
| -MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
|
| +MaybeObject* Heap::AllocateJSObjectFromMap(
|
| + Map* map, PretenureFlag pretenure, bool allocate_properties) {
|
| // JSFunctions should be allocated using AllocateFunction to be
|
| // properly initialized.
|
| ASSERT(map->instance_type() != JS_FUNCTION_TYPE);
|
| @@ -4486,11 +4487,15 @@ MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
|
| ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE);
|
|
|
| // Allocate the backing storage for the properties.
|
| - int prop_size = map->InitialPropertiesLength();
|
| - ASSERT(prop_size >= 0);
|
| - Object* properties;
|
| - { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, pretenure);
|
| - if (!maybe_properties->ToObject(&properties)) return maybe_properties;
|
| + FixedArray* properties;
|
| + if (allocate_properties) {
|
| + int prop_size = map->InitialPropertiesLength();
|
| + ASSERT(prop_size >= 0);
|
| + { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, pretenure);
|
| + if (!maybe_properties->To(&properties)) return maybe_properties;
|
| + }
|
| + } else {
|
| + properties = empty_fixed_array();
|
| }
|
|
|
| // Allocate the JSObject.
|
| @@ -4502,17 +4507,15 @@ MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
|
| if (!maybe_obj->To(&obj)) return maybe_obj;
|
|
|
| // Initialize the JSObject.
|
| - InitializeJSObjectFromMap(JSObject::cast(obj),
|
| - FixedArray::cast(properties),
|
| - map);
|
| + InitializeJSObjectFromMap(JSObject::cast(obj), properties, map);
|
| ASSERT(JSObject::cast(obj)->HasFastElements() ||
|
| JSObject::cast(obj)->HasExternalArrayElements());
|
| return obj;
|
| }
|
|
|
|
|
| -MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
|
| - Handle<AllocationSite> allocation_site) {
|
| +MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(
|
| + Map* map, Handle<AllocationSite> allocation_site) {
|
| // JSFunctions should be allocated using AllocateFunction to be
|
| // properly initialized.
|
| ASSERT(map->instance_type() != JS_FUNCTION_TYPE);
|
| @@ -4525,9 +4528,9 @@ MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
|
| // Allocate the backing storage for the properties.
|
| int prop_size = map->InitialPropertiesLength();
|
| ASSERT(prop_size >= 0);
|
| - Object* properties;
|
| + FixedArray* properties;
|
| { MaybeObject* maybe_properties = AllocateFixedArray(prop_size);
|
| - if (!maybe_properties->ToObject(&properties)) return maybe_properties;
|
| + if (!maybe_properties->To(&properties)) return maybe_properties;
|
| }
|
|
|
| // Allocate the JSObject.
|
| @@ -4539,9 +4542,7 @@ MaybeObject* Heap::AllocateJSObjectFromMapWithAllocationSite(Map* map,
|
| if (!maybe_obj->To(&obj)) return maybe_obj;
|
|
|
| // Initialize the JSObject.
|
| - InitializeJSObjectFromMap(JSObject::cast(obj),
|
| - FixedArray::cast(properties),
|
| - map);
|
| + InitializeJSObjectFromMap(JSObject::cast(obj), properties, map);
|
| ASSERT(JSObject::cast(obj)->HasFastElements());
|
| return obj;
|
| }
|
|
|