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

Unified Diff: test/cctest/test-heap.cc

Issue 686783003: Clear old backing store of WeakCollection on updates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « src/runtime/runtime-collections.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index ac121e059fe9a313e921d656918281da96d105eb..e652282a88d93967732a7549539e699893f7a298 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -4608,6 +4608,46 @@ TEST(Regress388880) {
}
+TEST(Regress3631) {
+ i::FLAG_expose_gc = true;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+ IncrementalMarking* marking = CcTest::heap()->incremental_marking();
+ v8::Local<v8::Value> result = CompileRun(
+ "var weak_map = new WeakMap();"
+ "var future_keys = [];"
+ "for (var i = 0; i < 50; i++) {"
+ " var key = {'k' : i + 0.1};"
+ " weak_map.set(key, 1);"
+ " future_keys.push({'x' : i + 0.2});"
+ "}"
+ "weak_map");
+ if (marking->IsStopped()) {
+ marking->Start();
+ }
+ // Incrementally mark the backing store.
+ Handle<JSObject> obj =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result));
+ Handle<JSWeakCollection> weak_map(reinterpret_cast<JSWeakCollection*>(*obj));
+ while (!Marking::IsBlack(
+ Marking::MarkBitFrom(HeapObject::cast(weak_map->table()))) &&
+ !marking->IsStopped()) {
+ marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
+ }
+ // Stash the backing store in a handle.
+ Handle<Object> save(weak_map->table(), isolate);
+ // The following line will update the backing store.
+ CompileRun(
+ "for (var i = 0; i < 50; i++) {"
+ " weak_map.set(future_keys[i], i);"
+ "}");
+ heap->incremental_marking()->set_should_hurry(true);
+ heap->CollectGarbage(OLD_POINTER_SPACE);
+}
+
+
#ifdef DEBUG
TEST(PathTracer) {
CcTest::InitializeVM();
« no previous file with comments | « src/runtime/runtime-collections.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698