| Index: src/x64/macro-assembler-x64.cc
|
| diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
|
| index 0c31809588befb995187f4fc66431a936e36dfa2..68c4ecabdc349f36dc0b4d75978e0cca16cb1646 100644
|
| --- a/src/x64/macro-assembler-x64.cc
|
| +++ b/src/x64/macro-assembler-x64.cc
|
| @@ -5615,19 +5615,36 @@ void MacroAssembler::TestJSArrayForAllocationMemento(
|
| Register receiver_reg,
|
| Register scratch_reg,
|
| Label* no_memento_found) {
|
| - ExternalReference new_space_start =
|
| - ExternalReference::new_space_start(isolate());
|
| + Label map_check;
|
| ExternalReference new_space_allocation_top =
|
| ExternalReference::new_space_allocation_top_address(isolate());
|
| -
|
| - leap(scratch_reg, Operand(receiver_reg,
|
| - JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag));
|
| - Move(kScratchRegister, new_space_start);
|
| - cmpp(scratch_reg, kScratchRegister);
|
| - j(less, no_memento_found);
|
| + const int kMementoMapOffset = JSArray::kSize - kHeapObjectTag;
|
| + const int kMementoEndOffset = kMementoMapOffset + AllocationMemento::kSize;
|
| +
|
| + // Bail out if the object sits on the page boundary as no memento can follow
|
| + // and we cannot touch the memory following it.
|
| + leap(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
|
| + xorp(scratch_reg, receiver_reg);
|
| + cmpp(scratch_reg, Immediate(Page::kPageSize));
|
| + j(greater, no_memento_found);
|
| + // Bail out if the object is not in new space.
|
| + leap(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
|
| + JumpIfNotInNewSpace(scratch_reg, scratch_reg, no_memento_found);
|
| + // If the object is in new space, we need to check whether it is on the same
|
| + // page as the current top.
|
| + leap(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
|
| + xorp(scratch_reg, ExternalOperand(new_space_allocation_top));
|
| + testp(scratch_reg, Immediate(~Page::kPageAlignmentMask));
|
| + // If top is not on the same page as the current object, we can just continue
|
| + // with the map check.
|
| + j(not_zero, &map_check);
|
| + // Otherwise, we have to check whether we are still below top, to ensure that
|
| + // we are not checking against a stale memento.
|
| + leap(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
|
| cmpp(scratch_reg, ExternalOperand(new_space_allocation_top));
|
| j(greater, no_memento_found);
|
| - CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize),
|
| + bind(&map_check);
|
| + CompareRoot(MemOperand(receiver_reg, kMementoMapOffset),
|
| Heap::kAllocationMementoMapRootIndex);
|
| }
|
|
|
|
|