Index: src/mips/lithium-codegen-mips.cc |
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc |
index 02ca14534a7512d21e5c3e2db9b5a241e5a45a99..8d062e81dcd46a327e56644f3f24f931b64a9c48 100644 |
--- a/src/mips/lithium-codegen-mips.cc |
+++ b/src/mips/lithium-codegen-mips.cc |
@@ -5118,6 +5118,8 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
ElementsKind boilerplate_elements_kind = |
instr->hydrogen()->boilerplate_elements_kind(); |
+ AllocationSiteMode allocation_site_mode = |
+ instr->hydrogen()->allocation_site_mode(); |
// Deopt if the array literal boilerplate ElementsKind is of a type different |
// than the expected one. The check isn't necessary if the boilerplate has |
@@ -5151,7 +5153,7 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
ASSERT(instr->hydrogen()->depth() == 1); |
FastCloneShallowArrayStub::Mode mode = |
FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
- FastCloneShallowArrayStub stub(mode, length); |
+ FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length); |
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
} else if (instr->hydrogen()->depth() > 1) { |
CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); |
@@ -5160,9 +5162,9 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
} else { |
FastCloneShallowArrayStub::Mode mode = |
boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS |
- ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
- : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
- FastCloneShallowArrayStub stub(mode, length); |
+ ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
+ : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
+ FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
} |
} |
@@ -5171,10 +5173,14 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
Register result, |
Register source, |
- int* offset) { |
+ int* offset, |
+ AllocationSiteMode mode) { |
ASSERT(!source.is(a2)); |
ASSERT(!result.is(a2)); |
+ bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && |
+ 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 && |
@@ -5184,8 +5190,13 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
// this object and its backing store. |
int object_offset = *offset; |
int object_size = object->map()->instance_size(); |
- int elements_offset = *offset + object_size; |
int elements_size = has_elements ? elements->Size() : 0; |
+ int elements_offset = *offset + object_size; |
+ if (create_allocation_site_info) { |
+ elements_offset += AllocationSiteInfo::kSize; |
+ *offset += AllocationSiteInfo::kSize; |
+ } |
+ |
*offset += object_size + elements_size; |
// Copy object header. |
@@ -5210,7 +5221,8 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
__ Addu(a2, result, Operand(*offset)); |
__ sw(a2, FieldMemOperand(result, total_offset)); |
__ LoadHeapObject(source, value_object); |
- EmitDeepCopy(value_object, result, source, offset); |
+ EmitDeepCopy(value_object, result, source, offset, |
+ DONT_TRACK_ALLOCATION_SITE); |
} else if (value->IsHeapObject()) { |
__ LoadHeapObject(a2, Handle<HeapObject>::cast(value)); |
__ sw(a2, FieldMemOperand(result, total_offset)); |
@@ -5220,6 +5232,13 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
} |
} |
+ // Build Allocation Site Info if desired |
+ if (create_allocation_site_info) { |
+ __ li(a2, Operand(Handle<Map>(isolate()->heap()-> |
+ allocation_site_info_map()))); |
+ __ sw(a2, FieldMemOperand(result, object_size)); |
+ __ sw(source, FieldMemOperand(result, object_size + kPointerSize)); |
+ } |
if (has_elements) { |
// Copy elements backing store header. |
@@ -5256,7 +5275,8 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
__ Addu(a2, result, Operand(*offset)); |
__ sw(a2, FieldMemOperand(result, total_offset)); |
__ LoadHeapObject(source, value_object); |
- EmitDeepCopy(value_object, result, source, offset); |
+ EmitDeepCopy(value_object, result, source, offset, |
+ DONT_TRACK_ALLOCATION_SITE); |
} else if (value->IsHeapObject()) { |
__ LoadHeapObject(a2, Handle<HeapObject>::cast(value)); |
__ sw(a2, FieldMemOperand(result, total_offset)); |
@@ -5307,7 +5327,8 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
__ bind(&allocated); |
int offset = 0; |
__ LoadHeapObject(a1, instr->hydrogen()->boilerplate()); |
- EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset); |
+ EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset, |
+ instr->hydrogen()->allocation_site_mode()); |
ASSERT_EQ(size, offset); |
} |