Revision: 22597
Author:   [email protected]
Date:     Thu Jul 24 12:12:44 2014 UTC
Log:      Use heap iterator in store buffer when page was swept precisely.

BUG=
[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=22592

Review URL: https://codereview.chromium.org/413693002
http://code.google.com/p/v8/source/detail?r=22597

Modified:
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/test/cctest/test-constantpool.cc

=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Thu Jul 24 10:45:37 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h   Thu Jul 24 12:12:44 2014 UTC
@@ -2539,6 +2539,7 @@

 void ConstantPoolArray::set(int index, Object* value) {
   ASSERT(map() == GetHeap()->constant_pool_array_map());
+  ASSERT(!GetHeap()->InNewSpace(value));
   ASSERT(get_type(index) == HEAP_PTR);
   WRITE_FIELD(this, OffsetOfElementAt(index), value);
   WRITE_BARRIER(GetHeap(), this, OffsetOfElementAt(index), value);
@@ -2583,6 +2584,7 @@

 void ConstantPoolArray::set_at_offset(int offset, Object* value) {
   ASSERT(map() == GetHeap()->constant_pool_array_map());
+  ASSERT(!GetHeap()->InNewSpace(value));
   ASSERT(offset_is_type(offset, HEAP_PTR));
   WRITE_FIELD(this, offset, value);
   WRITE_BARRIER(GetHeap(), this, offset, value);
=======================================
--- /branches/bleeding_edge/test/cctest/test-constantpool.cc Tue Jun 3 16:22:10 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-constantpool.cc Thu Jul 24 12:12:44 2014 UTC
@@ -242,3 +242,39 @@
   int expected_int32_indexs[] = { 1, 2, 3, 4 };
   CheckIterator(array, ConstantPoolArray::INT32, expected_int32_indexs, 4);
 }
+
+
+TEST(ConstantPoolPreciseGC) {
+  LocalContext context;
+  Isolate* isolate = CcTest::i_isolate();
+  Heap* heap = isolate->heap();
+  Factory* factory = isolate->factory();
+  v8::HandleScope scope(context->GetIsolate());
+
+  ConstantPoolArray::NumberOfEntries small(1, 0, 0, 1);
+  Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(small);
+
+ // Check that the store buffer knows which entries are pointers and which are
+  // not.  To do this, make non-pointer entries which look like new space
+ // pointers but are actually invalid and ensure the GC doesn't try to move
+  // them.
+  Handle<HeapObject> object = factory->NewHeapNumber(4.0);
+  Object* raw_ptr = *object;
+ // If interpreted as a pointer, this should be right inside the heap number
+  // which will cause a crash when trying to lookup the 'map' pointer.
+ int32_t invalid_ptr_int32 = reinterpret_cast<int32_t>(raw_ptr) + kInt32Size; + int64_t invalid_ptr_int64 = reinterpret_cast<int64_t>(raw_ptr) + kInt32Size;
+  array->set(0, invalid_ptr_int64);
+  array->set(1, invalid_ptr_int32);
+
+  // Ensure we perform a scan on scavenge for the constant pool's page.
+  MemoryChunk::FromAddress(array->address())->set_scan_on_scavenge(true);
+  heap->CollectGarbage(NEW_SPACE);
+
+  // Check the object was moved by GC.
+  CHECK_NE(*object, raw_ptr);
+
+  // Check the non-pointer entries weren't changed.
+  CHECK_EQ(invalid_ptr_int64, array->get_int64_entry(0));
+  CHECK_EQ(invalid_ptr_int32, array->get_int32_entry(1));
+}

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to