Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index d64d4ff28c621a7088b2f9b5ad9cd7bdc0dbf682..bd48a929249fb1f712f17a395cb557d6711a3b46 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -4942,8 +4942,9 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
} else { |
FastCloneShallowArrayStub::Mode mode = |
boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS |
- ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
- : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
+ ? FastCloneShallowArrayStub:: |
+ CLONE_DOUBLE_ELEMENTS_WITH_ALLOCATION_SITE_INFO |
+ : FastCloneShallowArrayStub::CLONE_ELEMENTS_WITH_ALLOCATION_SITE_INFO; |
FastCloneShallowArrayStub stub(mode, length); |
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
} |
@@ -4953,10 +4954,14 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
Register result, |
Register source, |
- int* offset) { |
+ int* offset, |
+ AllocationSiteInfoMode mode) { |
ASSERT(!source.is(rcx)); |
ASSERT(!result.is(rcx)); |
+ bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE_INFO && |
+ object->map()->CanTrackAllocationSite(); |
+ |
// Only elements backing stores for non-COW arrays need to be copied. |
Handle<FixedArrayBase> elements(object->elements()); |
bool has_elements = elements->length() > 0 && |
@@ -4967,8 +4972,14 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
int object_offset = *offset; |
int object_size = object->map()->instance_size(); |
int elements_offset = *offset + object_size; |
+ if (create_allocation_site_info) { |
+ elements_offset += AllocationSiteInfo::kSize; |
+ } |
int elements_size = has_elements ? elements->Size() : 0; |
*offset += object_size + elements_size; |
+ if (create_allocation_site_info) { |
+ *offset += AllocationSiteInfo::kSize; |
+ } |
// Copy object header. |
ASSERT(object->properties()->length() == 0); |
@@ -4992,7 +5003,8 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
__ lea(rcx, Operand(result, *offset)); |
__ movq(FieldOperand(result, total_offset), rcx); |
__ LoadHeapObject(source, value_object); |
- EmitDeepCopy(value_object, result, source, offset); |
+ EmitDeepCopy(value_object, result, source, offset, |
+ DONT_TRACK_ALLOCATION_SITE_INFO); |
} else if (value->IsHeapObject()) { |
__ LoadHeapObject(rcx, Handle<HeapObject>::cast(value)); |
__ movq(FieldOperand(result, total_offset), rcx); |
@@ -5002,6 +5014,13 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
} |
} |
+ // Build Allocation Site Info if desired |
+ if (create_allocation_site_info) { |
+ __ LoadRoot(kScratchRegister, Heap::kAllocationSiteInfoMapRootIndex); |
+ __ movq(FieldOperand(result, object_size), kScratchRegister); |
+ __ movq(FieldOperand(result, object_size + kPointerSize), source); |
+ } |
+ |
if (has_elements) { |
// Copy elements backing store header. |
__ LoadHeapObject(source, elements); |
@@ -5032,7 +5051,8 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
__ lea(rcx, Operand(result, *offset)); |
__ movq(FieldOperand(result, total_offset), rcx); |
__ LoadHeapObject(source, value_object); |
- EmitDeepCopy(value_object, result, source, offset); |
+ EmitDeepCopy(value_object, result, source, offset, |
+ DONT_TRACK_ALLOCATION_SITE_INFO); |
} else if (value->IsHeapObject()) { |
__ LoadHeapObject(rcx, Handle<HeapObject>::cast(value)); |
__ movq(FieldOperand(result, total_offset), rcx); |
@@ -5082,7 +5102,8 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
__ bind(&allocated); |
int offset = 0; |
__ LoadHeapObject(rbx, instr->hydrogen()->boilerplate()); |
- EmitDeepCopy(instr->hydrogen()->boilerplate(), rax, rbx, &offset); |
+ EmitDeepCopy(instr->hydrogen()->boilerplate(), rax, rbx, &offset, |
+ instr->hydrogen()->allocation_site_info_mode()); |
ASSERT_EQ(size, offset); |
} |