Index: src/arm64/macro-assembler-arm64.cc |
diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc |
index 0bd28aa8b38d739ce8aa2323dca4af3f1bfa381a..845565d9deb3fd156af6e821345d89084448d341 100644 |
--- a/src/arm64/macro-assembler-arm64.cc |
+++ b/src/arm64/macro-assembler-arm64.cc |
@@ -3073,23 +3073,24 @@ void MacroAssembler::Allocate(int object_size, |
intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); |
DCHECK((limit - top) == kPointerSize); |
- // Set up allocation top address and object size registers. |
+ // Set up allocation top address and allocation limit registers. |
Register top_address = scratch1; |
- Register allocation_limit = scratch2; |
+ Register alloc_limit = scratch2; |
+ Register result_end = scratch3; |
Mov(top_address, Operand(heap_allocation_top)); |
if ((flags & RESULT_CONTAINS_TOP) == 0) { |
- // Load allocation top into result and the allocation limit. |
- Ldp(result, allocation_limit, MemOperand(top_address)); |
+ // Load allocation top into result and allocation limit into alloc_limit. |
+ Ldp(result, alloc_limit, MemOperand(top_address)); |
} else { |
if (emit_debug_code()) { |
// Assert that result actually contains top on entry. |
- Ldr(scratch3, MemOperand(top_address)); |
- Cmp(result, scratch3); |
+ Ldr(alloc_limit, MemOperand(top_address)); |
+ Cmp(result, alloc_limit); |
Check(eq, kUnexpectedAllocationTop); |
} |
- // Load the allocation limit. 'result' already contains the allocation top. |
- Ldr(allocation_limit, MemOperand(top_address, limit - top)); |
+ // Load allocation limit. Result already contains allocation top. |
+ Ldr(alloc_limit, MemOperand(top_address, limit - top)); |
} |
// We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
@@ -3097,10 +3098,10 @@ void MacroAssembler::Allocate(int object_size, |
STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
// Calculate new top and bail out if new space is exhausted. |
- Adds(scratch3, result, object_size); |
- Ccmp(scratch3, allocation_limit, CFlag, cc); |
+ Adds(result_end, result, object_size); |
+ Ccmp(result_end, alloc_limit, CFlag, cc); |
B(hi, gc_required); |
- Str(scratch3, MemOperand(top_address)); |
+ Str(result_end, MemOperand(top_address)); |
// Tag the object if requested. |
if ((flags & TAG_OBJECT) != 0) { |
@@ -3127,7 +3128,9 @@ void MacroAssembler::Allocate(Register object_size, Register result, |
UseScratchRegisterScope temps(this); |
Register scratch2 = temps.AcquireX(); |
- DCHECK(!AreAliased(object_size, result, scratch, scratch2, result_end)); |
+ // |object_size| and |result_end| may overlap, other registers must not. |
+ DCHECK(!AreAliased(object_size, result, scratch, scratch2)); |
+ DCHECK(!AreAliased(result_end, result, scratch, scratch2)); |
DCHECK(object_size.Is64Bits() && result.Is64Bits() && scratch.Is64Bits() && |
result_end.Is64Bits()); |
@@ -3141,23 +3144,23 @@ void MacroAssembler::Allocate(Register object_size, Register result, |
intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); |
DCHECK((limit - top) == kPointerSize); |
- // Set up allocation top address and object size registers. |
+ // Set up allocation top address and allocation limit registers. |
Register top_address = scratch; |
- Register allocation_limit = scratch2; |
+ Register alloc_limit = scratch2; |
Mov(top_address, heap_allocation_top); |
if ((flags & RESULT_CONTAINS_TOP) == 0) { |
- // Load allocation top into result and the allocation limit. |
- Ldp(result, allocation_limit, MemOperand(top_address)); |
+ // Load allocation top into result and allocation limit into alloc_limit. |
+ Ldp(result, alloc_limit, MemOperand(top_address)); |
} else { |
if (emit_debug_code()) { |
// Assert that result actually contains top on entry. |
- Ldr(result_end, MemOperand(top_address)); |
- Cmp(result, result_end); |
+ Ldr(alloc_limit, MemOperand(top_address)); |
+ Cmp(result, alloc_limit); |
Check(eq, kUnexpectedAllocationTop); |
} |
- // Load the allocation limit. 'result' already contains the allocation top. |
- Ldr(allocation_limit, MemOperand(top_address, limit - top)); |
+ // Load allocation limit. Result already contains allocation top. |
+ Ldr(alloc_limit, MemOperand(top_address, limit - top)); |
} |
// We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
@@ -3176,7 +3179,7 @@ void MacroAssembler::Allocate(Register object_size, Register result, |
Check(eq, kUnalignedAllocationInNewSpace); |
} |
- Ccmp(result_end, allocation_limit, CFlag, cc); |
+ Ccmp(result_end, alloc_limit, CFlag, cc); |
B(hi, gc_required); |
Str(result_end, MemOperand(top_address)); |