Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 27b127d904b362a198fc6573fce2ddd96274735d..c6c1009c8cf7d28e2d8bf6ea12259783b5424a64 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -368,6 +368,52 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
} |
+void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { |
+ // Stack layout on entry: |
+ // |
+ // [esp + kPointerSize]: object literal flags. |
+ // [esp + (2 * kPointerSize)]: constant properties. |
+ // [esp + (3 * kPointerSize)]: literal index. |
+ // [esp + (4 * kPointerSize)]: literals array. |
+ |
+ // Load boilerplate object into ecx and check if we need to create a |
+ // boilerplate. |
+ Label slow_case; |
+ __ mov(ecx, Operand(esp, 4 * kPointerSize)); |
+ __ mov(eax, Operand(esp, 3 * kPointerSize)); |
+ STATIC_ASSERT(kPointerSize == 4); |
+ STATIC_ASSERT(kSmiTagSize == 1); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ __ mov(ecx, FieldOperand(ecx, eax, times_half_pointer_size, |
+ FixedArray::kHeaderSize)); |
+ Factory* factory = masm->isolate()->factory(); |
+ __ cmp(ecx, factory->undefined_value()); |
+ __ j(equal, &slow_case); |
+ |
+ // Check that the boilerplate contains only fast properties and we can |
+ // statically determine the instance size. |
+ int size = JSObject::kHeaderSize + length_ * kPointerSize; |
+ __ mov(eax, FieldOperand(ecx, HeapObject::kMapOffset)); |
+ __ movzx_b(eax, FieldOperand(eax, Map::kInstanceSizeOffset)); |
+ __ cmp(eax, Immediate(size >> kPointerSizeLog2)); |
+ __ j(not_equal, &slow_case); |
+ |
+ // Allocate the JS object and copy header together with all in-object |
+ // properties from the boilerplate. |
+ __ AllocateInNewSpace(size, eax, ebx, edx, &slow_case, TAG_OBJECT); |
+ for (int i = 0; i < size; i += kPointerSize) { |
+ __ mov(ebx, FieldOperand(ecx, i)); |
+ __ mov(FieldOperand(eax, i), ebx); |
+ } |
+ |
+ // Return and remove the on-stack parameters. |
+ __ ret(4 * kPointerSize); |
+ |
+ __ bind(&slow_case); |
+ __ TailCallRuntime(Runtime::kCreateObjectLiteralShallow, 4, 1); |
+} |
+ |
+ |
// The stub expects its argument on the stack and returns its result in tos_: |
// zero for false, and a non-zero value for true. |
void ToBooleanStub::Generate(MacroAssembler* masm) { |