mirror of https://github.com/svaarala/duktape.git
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
49 lines
919 B
12 years ago
|
/*---
|
||
|
{
|
||
|
"custom": true
|
||
|
}
|
||
|
---*/
|
||
12 years ago
|
|
||
12 years ago
|
/* XXX: the ordering of print statements is not deterministic, it changes
|
||
|
* when using the torture build: finalizer runs before 'nulled'.
|
||
|
*/
|
||
|
|
||
12 years ago
|
/*===
|
||
|
nulling
|
||
|
nulled
|
||
|
finalizer, foo -> 123
|
||
|
===*/
|
||
|
|
||
12 years ago
|
var a;
|
||
|
var b;
|
||
12 years ago
|
|
||
12 years ago
|
/* 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 = {}
|
||
12 years ago
|
|
||
12 years ago
|
__duk__.setFinalizer(a, function (x) {
|
||
|
print('finalizer, foo ->', x.foo);
|
||
|
});
|
||
|
|
||
|
// circular reference prevents refcount collection
|
||
|
a.bar = b;
|
||
|
b.bar = a;
|
||
|
}
|
||
|
|
||
|
init();
|
||
12 years ago
|
|
||
|
// refcount does not finalize here
|
||
|
print('nulling')
|
||
|
a = null;
|
||
|
b = null;
|
||
|
print('nulled')
|
||
|
|
||
|
// mark-and-sweep finalizing happens here if refcount disabled
|
||
|
__duk__.gc();
|
||
|
|