Index: src/crankshaft/x87/lithium-codegen-x87.cc |
diff --git a/src/crankshaft/x87/lithium-codegen-x87.cc b/src/crankshaft/x87/lithium-codegen-x87.cc |
index f6c97ff18c66fecb49d03d2be0805eccf2698ea9..f4159a65b0c0c4bc12685e0b82f84236fe72a960 100644 |
--- a/src/crankshaft/x87/lithium-codegen-x87.cc |
+++ b/src/crankshaft/x87/lithium-codegen-x87.cc |
@@ -5419,6 +5419,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); |
@@ -5487,6 +5495,47 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
CallRuntimeFromDeferred( |
Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); |
__ StoreToSafepointRegisterSlot(result, eax); |
+ |
+ 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); |
+ __ sub(eax, Immediate(kHeapObjectTag)); |
+ __ mov(Operand::StaticVariable(allocation_top), eax); |
+ __ add(eax, Immediate(kHeapObjectTag)); |
+ } |
+} |
+ |
+void LCodeGen::DoFastAllocate(LFastAllocate* instr) { |
+ DCHECK(instr->hydrogen()->IsAllocationFolded()); |
+ Register result = ToRegister(instr->result()); |
+ Register temp = ToRegister(instr->temp()); |
+ |
+ 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, temp, flags); |
+ } else { |
+ Register size = ToRegister(instr->size()); |
+ __ FastAllocate(size, result, temp, flags); |
+ } |
+ } |
} |