Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: src/ia32/macro-assembler-ia32.cc

Issue 1845463003: Remove usages of Heap::NewSpaceStart and its external reference (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do not access mementos when the array is allocated on a page boundary Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ia32/macro-assembler-ia32.cc
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc
index 556e71076b2ce54919416e547f8e349a365277b1..9fcf263e0fefaf86b56a6d93f0f82e927c83e25b 100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -3327,19 +3327,37 @@ 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());
-
- lea(scratch_reg, Operand(receiver_reg,
- JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag));
- cmp(scratch_reg, Immediate(new_space_start));
- 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.
+ lea(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
+ xor_(scratch_reg, receiver_reg);
+ cmp(scratch_reg, Immediate(Page::kPageSize));
+ j(greater, no_memento_found);
+ // Bail out if the object is not in new space.
+ lea(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.
+ lea(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
+ xor_(scratch_reg, Operand::StaticVariable(new_space_allocation_top));
+ test(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.
+ lea(scratch_reg, Operand(receiver_reg, kMementoEndOffset));
cmp(scratch_reg, Operand::StaticVariable(new_space_allocation_top));
j(greater, no_memento_found);
- cmp(MemOperand(scratch_reg, -AllocationMemento::kSize),
- Immediate(isolate()->factory()->allocation_memento_map()));
+ bind(&map_check);
+ mov(scratch_reg, Operand(receiver_reg, kMementoMapOffset));
+ cmp(scratch_reg, Immediate(isolate()->factory()->allocation_memento_map()));
}

Powered by Google App Engine
This is Rietveld 408576698