Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index dd4d733f15c793396e1825d0c56f74e793dcffc1..577c6918bb9a7e0ea75ff6db42fef81c14633e1e 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -2898,22 +2898,32 @@ MaybeObject* 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; |
| + |
| + if (callee->IsJSFunction() && |
| + JSFunction::cast(callee)->shared()->strict_mode()) { |
| + boilerplate = |
| + Top::context()->global_context()->arguments_boilerplate_strict(); |
| + arguments_object_size = kArgumentsObjectSizeStrict; |
| + } else { |
| + boilerplate = Top::context()->global_context()->arguments_boilerplate(); |
| + arguments_object_size = kArgumentsObjectSize; |
| + } |
| + |
| // This calls Copy directly rather than using Heap::AllocateRaw so we |
| // duplicate the check here. |
| ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
| - JSObject* boilerplate = |
| - Top::context()->global_context()->arguments_boilerplate(); |
| - |
| // Check that the size of the boilerplate matches our |
| // expectations. The ArgumentsAccessStub::GenerateNewObject relies |
| // on the size being a known constant. |
| - ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); |
| + ASSERT(arguments_object_size == boilerplate->map()->instance_size()); |
| // Do the allocation. |
| Object* result; |
| { MaybeObject* maybe_result = |
| - AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); |
| + AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE); |
| if (!maybe_result->ToObject(&result)) return maybe_result; |
| } |
| @@ -2922,14 +2932,17 @@ MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { |
| // barrier here. |
| CopyBlock(HeapObject::cast(result)->address(), |
| boilerplate->address(), |
| - kArgumentsObjectSize); |
| + JSObject::kHeaderSize); |
| - // Set the two properties. |
| - JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, |
| - callee); |
| + // Set the length property. |
| JSObject::cast(result)->InObjectPropertyAtPut(arguments_length_index, |
| Smi::FromInt(length), |
| SKIP_WRITE_BARRIER); |
| + // Set the callee property for non-strict mode arguments object. |
| + if (arguments_object_size == kArgumentsObjectSize) { |
|
Lasse Reichstein
2011/03/15 09:58:40
Save the is_strict_callee boolean as a variable, a
Martin Maly
2011/03/16 01:21:24
Done.
|
| + JSObject::cast(result)->InObjectPropertyAtPut(arguments_callee_index, |
| + callee); |
| + } |
| // Check the state of the object |
| ASSERT(JSObject::cast(result)->HasFastProperties()); |