2018-11-05 14:21:02 +00:00
|
|
|
// 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: --harmony-weak-refs --expose-gc --noincremental-marking --allow-natives-syntax
|
|
|
|
|
|
|
|
let o1 = {};
|
|
|
|
let o2 = {};
|
|
|
|
let wr1;
|
|
|
|
let wr2;
|
|
|
|
(function() {
|
2018-12-17 08:15:02 +00:00
|
|
|
wr1 = new WeakRef(o1);
|
|
|
|
wr2 = new WeakRef(o2);
|
2018-11-05 14:21:02 +00:00
|
|
|
})();
|
|
|
|
|
|
|
|
// Since the WeakRefs were created during this turn, they're not cleared by GC.
|
|
|
|
gc();
|
2018-12-17 08:15:02 +00:00
|
|
|
|
2018-11-05 14:21:02 +00:00
|
|
|
(function() {
|
|
|
|
assertNotEquals(undefined, wr1.deref());
|
|
|
|
assertNotEquals(undefined, wr2.deref());
|
|
|
|
})();
|
|
|
|
|
2018-12-04 06:12:49 +00:00
|
|
|
%PerformMicrotaskCheckpoint();
|
2018-11-05 14:21:02 +00:00
|
|
|
// New turn.
|
|
|
|
|
|
|
|
wr1.deref();
|
|
|
|
o1 = null;
|
|
|
|
gc(); // deref makes sure we don't clean up wr1
|
|
|
|
|
2018-12-04 06:12:49 +00:00
|
|
|
%PerformMicrotaskCheckpoint();
|
2018-11-05 14:21:02 +00:00
|
|
|
// New turn.
|
|
|
|
|
|
|
|
wr2.deref();
|
|
|
|
o2 = null;
|
|
|
|
gc(); // deref makes sure we don't clean up wr2
|
|
|
|
|
2018-12-04 06:12:49 +00:00
|
|
|
%PerformMicrotaskCheckpoint();
|
2018-11-05 14:21:02 +00:00
|
|
|
// New turn.
|
|
|
|
|
2018-12-17 08:15:02 +00:00
|
|
|
assertEquals(undefined, wr1.deref());
|
2018-11-05 14:21:02 +00:00
|
|
|
|
|
|
|
gc();
|
|
|
|
|
2018-12-04 06:12:49 +00:00
|
|
|
%PerformMicrotaskCheckpoint();
|
2018-11-05 14:21:02 +00:00
|
|
|
// New turn.
|
|
|
|
|
2018-12-17 08:15:02 +00:00
|
|
|
assertEquals(undefined, wr2.deref());
|