d59db06bf5
Bug: v8:8179 Change-Id: I7f699073807d1874d0c10a4f1641de6bfb0efe6f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2741582 Commit-Queue: Shu-yu Guo <syg@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#73871}
48 lines
999 B
JavaScript
48 lines
999 B
JavaScript
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --expose-gc --noincremental-marking
|
|
|
|
let o1 = {};
|
|
let o2 = {};
|
|
let wr1;
|
|
let wr2;
|
|
(function() {
|
|
wr1 = new WeakRef(o1);
|
|
wr2 = new WeakRef(o2);
|
|
})();
|
|
|
|
// Since the WeakRefs were created during this turn, they're not cleared by GC.
|
|
gc();
|
|
|
|
(function() {
|
|
assertNotEquals(undefined, wr1.deref());
|
|
assertNotEquals(undefined, wr2.deref());
|
|
})();
|
|
|
|
// New task
|
|
setTimeout(function() {
|
|
wr1.deref();
|
|
o1 = null;
|
|
gc(); // deref makes sure we don't clean up wr1
|
|
|
|
// New task
|
|
setTimeout(function() {
|
|
wr2.deref();
|
|
o2 = null;
|
|
gc(); // deref makes sure we don't clean up wr2
|
|
|
|
// New task
|
|
setTimeout(function() {
|
|
assertEquals(undefined, wr1.deref());
|
|
gc();
|
|
|
|
// New task
|
|
setTimeout(function() {
|
|
assertEquals(undefined, wr2.deref());
|
|
}, 0);
|
|
}, 0);
|
|
}, 0);
|
|
}, 0);
|