mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1603330 - Update test to prevent JIT keeps the retval of wr.deref(). r=jonco
Move allocation into a function call can prevent JIT keeps the return value of weakRef.deref(). Differential Revision: https://phabricator.services.mozilla.com/D60662 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2dd304ff1d
commit
b4e01399cf
18
js/src/jit-test/tests/gc/bug-1603330.js
Normal file
18
js/src/jit-test/tests/gc/bug-1603330.js
Normal file
@ -0,0 +1,18 @@
|
||||
// |jit-test| --enable-weak-refs
|
||||
|
||||
// Allocate the object in the function to prevent marked as a singleton so the
|
||||
// object won't be kept alive by IC stub.
|
||||
function allocObj() { return {}; }
|
||||
|
||||
let wr;
|
||||
{
|
||||
let obj = allocObj();
|
||||
wr = new WeakRef(obj);
|
||||
}
|
||||
|
||||
assertEq(wr.deref() !== undefined, true);
|
||||
|
||||
clearKeptObjects();
|
||||
gc();
|
||||
|
||||
assertEq(wr.deref(), undefined);
|
@ -44,17 +44,17 @@ var that = this;
|
||||
gc();
|
||||
|
||||
let wr1;
|
||||
(function() {
|
||||
let obj = {};
|
||||
// Allocate the object in the function to prevent marked as a singleton so the
|
||||
// object won't be kept alive by IC stub.
|
||||
function allocObj() { return {}; }
|
||||
|
||||
(function () {
|
||||
let obj = allocObj();
|
||||
wr1 = new WeakRef(obj);
|
||||
obj = null;
|
||||
})();
|
||||
|
||||
// TODO:
|
||||
// Bug 1603330: WeakRef.deref() makes the target being kept even
|
||||
// ClearKeptObjects() is called.
|
||||
//
|
||||
// don't call wr1.deref() here to prevent the target of wr1 is kept.
|
||||
assertEq(undefined === wr1.deref(), false);
|
||||
|
||||
gc();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user