Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index a30d62f96551e8d16edf21a3e3f8f8afdaa9c8c5..b8f820d7f5581e9727731f61fa8481a751258aa0 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -354,6 +354,49 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
} |
+void FastCloneShallowObjectStub::Generate(MacroAssembler* masm) { |
+ // Stack layout on entry: |
+ // |
+ // [rsp + kPointerSize]: object literal flags. |
+ // [rsp + (2 * kPointerSize)]: constant properties. |
+ // [rsp + (3 * kPointerSize)]: literal index. |
+ // [rsp + (4 * kPointerSize)]: literals array. |
+ |
+ // Load boilerplate object into ecx and check if we need to create a |
+ // boilerplate. |
+ Label slow_case; |
+ __ movq(rcx, Operand(rsp, 4 * kPointerSize)); |
+ __ movq(rax, Operand(rsp, 3 * kPointerSize)); |
+ SmiIndex index = masm->SmiToIndex(rax, rax, kPointerSizeLog2); |
+ __ movq(rcx, |
+ FieldOperand(rcx, index.reg, index.scale, FixedArray::kHeaderSize)); |
+ __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); |
+ __ 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; |
+ __ movq(rax, FieldOperand(rcx, HeapObject::kMapOffset)); |
+ __ movzxbq(rax, FieldOperand(rax, Map::kInstanceSizeOffset)); |
+ __ cmpq(rax, 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, rax, rbx, rdx, &slow_case, TAG_OBJECT); |
+ for (int i = 0; i < size; i += kPointerSize) { |
+ __ movq(rbx, FieldOperand(rcx, i)); |
+ __ movq(FieldOperand(rax, i), rbx); |
+ } |
+ |
+ // 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) { |