Index: src/crankshaft/arm/lithium-codegen-arm.cc |
diff --git a/src/crankshaft/arm/lithium-codegen-arm.cc b/src/crankshaft/arm/lithium-codegen-arm.cc |
index 69da090137012266638ad7cd715e63050d2d8e21..f17fc0c7ba5edec526d5f626e32344b57ee4eaa9 100644 |
--- a/src/crankshaft/arm/lithium-codegen-arm.cc |
+++ b/src/crankshaft/arm/lithium-codegen-arm.cc |
@@ -5109,6 +5109,14 @@ void LCodeGen::DoAllocate(LAllocate* instr) { |
flags = static_cast<AllocationFlags>(flags | PRETENURE); |
} |
+ if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
+ flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDING_DOMINATOR); |
+ } |
+ |
+ if (instr->hydrogen()->IsAllocationFolded()) { |
+ flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDED); |
+ } |
+ |
if (instr->size()->IsConstantOperand()) { |
int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
CHECK(size <= Page::kMaxRegularHeapObjectSize); |
@@ -5176,6 +5184,50 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
CallRuntimeFromDeferred( |
Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); |
__ StoreToSafepointRegisterSlot(r0, result); |
+ |
+ if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
+ AllocationFlags allocation_flags = NO_ALLOCATION_FLAGS; |
+ if (instr->hydrogen()->IsOldSpaceAllocation()) { |
+ DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
+ allocation_flags = static_cast<AllocationFlags>(flags | PRETENURE); |
+ } |
+ // If the allocation folding dominator allocate triggered a GC, allocation |
+ // happend in the runtime. We have to reset the top pointer to virtually |
+ // undo the allocation. |
+ ExternalReference allocation_top = |
+ AllocationUtils::GetAllocationTopReference(isolate(), allocation_flags); |
+ Register top_address = scratch0(); |
+ __ sub(r0, r0, Operand(kHeapObjectTag)); |
+ __ mov(top_address, Operand(allocation_top)); |
+ __ str(r0, MemOperand(top_address)); |
+ __ add(r0, r0, Operand(kHeapObjectTag)); |
+ } |
+} |
+ |
+void LCodeGen::DoFastAllocate(LFastAllocate* instr) { |
+ DCHECK(instr->hydrogen()->IsAllocationFolded()); |
+ Register result = ToRegister(instr->result()); |
+ Register scratch1 = ToRegister(instr->temp1()); |
+ Register scratch2 = ToRegister(instr->temp2()); |
+ |
+ AllocationFlags flags = NO_ALLOCATION_FLAGS; |
+ if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
+ flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
+ } |
+ if (instr->hydrogen()->IsOldSpaceAllocation()) { |
+ DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
+ flags = static_cast<AllocationFlags>(flags | PRETENURE); |
+ } |
+ if (!instr->hydrogen()->IsAllocationFoldingDominator()) { |
+ if (instr->size()->IsConstantOperand()) { |
+ int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
+ CHECK(size <= Page::kMaxRegularHeapObjectSize); |
+ __ FastAllocate(size, result, scratch1, scratch2, flags); |
+ } else { |
+ Register size = ToRegister(instr->size()); |
+ __ FastAllocate(size, result, scratch1, scratch2, flags); |
+ } |
+ } |
} |