Index: src/crankshaft/s390/lithium-codegen-s390.cc |
diff --git a/src/crankshaft/s390/lithium-codegen-s390.cc b/src/crankshaft/s390/lithium-codegen-s390.cc |
index a8cbc167dd4eb9ec219571a5a5fd2cec87bd1d0a..76db44ad4a80b423e2a2295e51dca842c3da5266 100644 |
--- a/src/crankshaft/s390/lithium-codegen-s390.cc |
+++ b/src/crankshaft/s390/lithium-codegen-s390.cc |
@@ -5260,6 +5260,12 @@ void LCodeGen::DoAllocate(LAllocate* instr) { |
flags = static_cast<AllocationFlags>(flags | PRETENURE); |
} |
+ if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
+ flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDING_DOMINATOR); |
+ } |
+ |
+ DCHECK(!instr->hydrogen()->IsAllocationFolded()); |
+ |
if (instr->size()->IsConstantOperand()) { |
int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
CHECK(size <= Page::kMaxRegularHeapObjectSize); |
@@ -5338,6 +5344,49 @@ void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
CallRuntimeFromDeferred(Runtime::kAllocateInTargetSpace, 2, instr, |
instr->context()); |
__ StoreToSafepointRegisterSlot(r2, 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(); |
+ __ SubP(r2, r2, Operand(kHeapObjectTag)); |
+ __ mov(top_address, Operand(allocation_top)); |
+ __ StoreP(r2, MemOperand(top_address)); |
+ __ AddP(r2, r2, Operand(kHeapObjectTag)); |
+ } |
+} |
+ |
+void LCodeGen::DoFastAllocate(LFastAllocate* instr) { |
+ DCHECK(instr->hydrogen()->IsAllocationFolded()); |
+ DCHECK(!instr->hydrogen()->IsAllocationFoldingDominator()); |
+ Register result = ToRegister(instr->result()); |
+ Register scratch1 = ToRegister(instr->temp1()); |
+ Register scratch2 = ToRegister(instr->temp2()); |
+ |
+ AllocationFlags flags = ALLOCATION_FOLDED; |
+ 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->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); |
+ } |
} |
void LCodeGen::DoTypeof(LTypeof* instr) { |