You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
919 B

/*---
{
"custom": true
}
---*/
/* XXX: the ordering of print statements is not deterministic, it changes
* when using the torture build: finalizer runs before 'nulled'.
*/
/*===
nulling
nulled
finalizer, foo -> 123
===*/
var a;
var b;
/* Note: values are created inside function to ensure that no references
* to them may remain in temporary registers of the global function.
* There is currently no guarantee that temporary values do not keep a
* value reachable during function execution.
*/
function init() {
a = { foo: 123 };
b = {}
__duk__.setFinalizer(a, function (x) {
print('finalizer, foo ->', x.foo);
});
// circular reference prevents refcount collection
a.bar = b;
b.bar = a;
}
init();
// refcount does not finalize here
print('nulling')
a = null;
b = null;
print('nulled')
// mark-and-sweep finalizing happens here if refcount disabled
__duk__.gc();