Index: src/s390/macro-assembler-s390.cc |
diff --git a/src/s390/macro-assembler-s390.cc b/src/s390/macro-assembler-s390.cc |
index 8ca4674d069cbd965f6737cef4bc5ef240a67a9a..559f7d030a75f74448fbb05ffd32d86f8f16983f 100644 |
--- a/src/s390/macro-assembler-s390.cc |
+++ b/src/s390/macro-assembler-s390.cc |
@@ -3704,20 +3704,46 @@ void MacroAssembler::StoreRepresentation(Register src, const MemOperand& mem, |
void MacroAssembler::TestJSArrayForAllocationMemento(Register receiver_reg, |
Register scratch_reg, |
+ Register scratch2_reg, |
Label* no_memento_found) { |
- ExternalReference new_space_start = |
- ExternalReference::new_space_start(isolate()); |
+ Label map_check; |
+ Label top_check; |
ExternalReference new_space_allocation_top = |
ExternalReference::new_space_allocation_top_address(isolate()); |
- AddP(scratch_reg, receiver_reg, |
- Operand(JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag)); |
- CmpP(scratch_reg, Operand(new_space_start)); |
- blt(no_memento_found); |
- mov(ip, Operand(new_space_allocation_top)); |
- LoadP(ip, MemOperand(ip)); |
- CmpP(scratch_reg, ip); |
+ const int kMementoMapOffset = JSArray::kSize - kHeapObjectTag; |
+ const int kMementoEndOffset = kMementoMapOffset + AllocationMemento::kSize; |
+ Register mask = scratch2_reg; |
+ |
+ DCHECK(!AreAliased(receiver_reg, scratch_reg, mask)); |
+ |
+ // Bail out if the object is not in new space. |
+ JumpIfNotInNewSpace(receiver_reg, scratch_reg, no_memento_found); |
+ |
+ DCHECK((~Page::kPageAlignmentMask & 0xffff) == 0); |
+ LoadImmP(mask, Operand((~Page::kPageAlignmentMask >> 16))); |
+ AddP(scratch_reg, receiver_reg, Operand(kMementoEndOffset)); |
+ |
+ // If the object is in new space, we need to check whether it is on the same |
+ // page as the current top. |
+ XorP(r0, scratch_reg, Operand(new_space_allocation_top)); |
+ AndP(r0, r0, mask); |
+ beq(&top_check, Label::kNear); |
+ // The object is on a different page than allocation top. Bail out if the |
+ // object sits on the page boundary as no memento can follow and we cannot |
+ // touch the memory following it. |
+ XorP(r0, scratch_reg, receiver_reg); |
+ AndP(r0, r0, mask); |
+ bne(no_memento_found); |
+ // Continue with the actual map check. |
+ b(&map_check, Label::kNear); |
+ // If top is on the same page as the current object, we need to check whether |
+ // we are below top. |
+ bind(&top_check); |
+ CmpP(scratch_reg, Operand(new_space_allocation_top)); |
bgt(no_memento_found); |
- LoadP(scratch_reg, MemOperand(scratch_reg, -AllocationMemento::kSize)); |
+ // Memento map check. |
+ bind(&map_check); |
+ LoadP(scratch_reg, MemOperand(receiver_reg, kMementoMapOffset)); |
CmpP(scratch_reg, Operand(isolate()->factory()->allocation_memento_map())); |
} |