Reviewers: Jakob,

Description:
Fix adding to WeakFixedArray after compaction.

WeakFixedArray::Add expects space for at least one element.

[email protected]

Please review this at https://codereview.chromium.org/1101993002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+13, -0 lines):
  M src/objects.cc
  M test/cctest/test-heap.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f3733295c4dc1baf9d27330aa5a4200a3a3b999b..babcf671672c88ad226345caebfefdf9fd6a7225 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8310,6 +8310,7 @@ void WeakFixedArray::Compact() {
     if (WeakCell::cast(element)->cleared()) continue;
     array->set(new_length++, element);
   }
+  if (new_length == kFirstIndex) new_length++;
   array->Shrink(new_length);
   set_last_used_index(0);
 }
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 8858a82d9adf7f838a0add8538918278d1ba7748..9cada2f0e57fc22c03062a8e703eb9c645f41359 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -5369,3 +5369,15 @@ TEST(Regress472513) {
   TestRightTrimFixedTypedArray(i::kExternalUint16Array, 8 - 1, 3);
   TestRightTrimFixedTypedArray(i::kExternalUint32Array, 4, 3);
 }
+
+
+TEST(WeakFixedArray) {
+  CcTest::InitializeVM();
+  v8::HandleScope scope(CcTest::isolate());
+
+ Handle<HeapNumber> number = CcTest::i_isolate()->factory()->NewHeapNumber(1); + Handle<WeakFixedArray> array = WeakFixedArray::Add(Handle<Object>(), number);
+  array->Remove(number);
+  array->Compact();
+  WeakFixedArray::Add(array, number);
+}


--
--
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