| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 2fa7702db07192dc18e976ead0ee29b441e38bce..d390788d261cd479bec9a1cd4df0d6d22f0fe283 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -3569,6 +3569,58 @@ AllocationResult Heap::Allocate(Map* map, AllocationSpace space,
|
| }
|
|
|
|
|
| +AllocationResult Heap::AllocateArgumentsObject(Object* callee, int length) {
|
| + // To get fast allocation and map sharing for arguments objects we
|
| + // allocate them based on an arguments boilerplate.
|
| +
|
| + JSObject* boilerplate;
|
| + int arguments_object_size;
|
| + bool strict_mode_callee = callee->IsJSFunction() &&
|
| + JSFunction::cast(callee)->shared()->strict_mode() == STRICT;
|
| + if (strict_mode_callee) {
|
| + boilerplate =
|
| + isolate()->context()->native_context()->strict_arguments_boilerplate();
|
| + arguments_object_size = kStrictArgumentsObjectSize;
|
| + } else {
|
| + boilerplate =
|
| + isolate()->context()->native_context()->sloppy_arguments_boilerplate();
|
| + arguments_object_size = kSloppyArgumentsObjectSize;
|
| + }
|
| +
|
| + // Check that the size of the boilerplate matches our
|
| + // expectations. The ArgumentsAccessStub::GenerateNewObject relies
|
| + // on the size being a known constant.
|
| + ASSERT(arguments_object_size == boilerplate->map()->instance_size());
|
| +
|
| + // Do the allocation.
|
| + HeapObject* result;
|
| + { AllocationResult allocation =
|
| + AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE);
|
| + if (!allocation.To(&result)) return allocation;
|
| + }
|
| +
|
| + // Copy the content. The arguments boilerplate doesn't have any
|
| + // fields that point to new space so it's safe to skip the write
|
| + // barrier here.
|
| + CopyBlock(result->address(), boilerplate->address(), JSObject::kHeaderSize);
|
| +
|
| + // Set the length property.
|
| + JSObject* js_obj = JSObject::cast(result);
|
| + js_obj->InObjectPropertyAtPut(
|
| + kArgumentsLengthIndex, Smi::FromInt(length), SKIP_WRITE_BARRIER);
|
| + // Set the callee property for sloppy mode arguments object only.
|
| + if (!strict_mode_callee) {
|
| + js_obj->InObjectPropertyAtPut(kArgumentsCalleeIndex, callee);
|
| + }
|
| +
|
| + // Check the state of the object
|
| + ASSERT(js_obj->HasFastProperties());
|
| + ASSERT(js_obj->HasFastObjectElements());
|
| +
|
| + return js_obj;
|
| +}
|
| +
|
| +
|
| void Heap::InitializeJSObjectFromMap(JSObject* obj,
|
| FixedArray* properties,
|
| Map* map) {
|
|
|