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.
287 lines
3.7 KiB
287 lines
3.7 KiB
/*
|
|
* Test heap destruction finalizer sanity limit for "runaway finalizers".
|
|
* Here, test a finalizer which spawns two new finalizable objects which
|
|
* do the same.
|
|
*
|
|
* This testcase is fragile: the number of finalizations depends on internal
|
|
* parameters which may be changed without breaking compatibility promises.
|
|
* The important thing is that the process terminates in a reasonable time.
|
|
*/
|
|
|
|
/*---
|
|
{
|
|
"custom": true
|
|
}
|
|
---*/
|
|
|
|
/*===
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
object true
|
|
===*/
|
|
|
|
function mkObj() {
|
|
var obj = {};
|
|
Duktape.fin(obj, function myFinalizer(o, heapDestruct) {
|
|
print(typeof o, heapDestruct);
|
|
var dummy1 = mkObj();
|
|
var dummy2 = mkObj();
|
|
});
|
|
return obj;
|
|
}
|
|
|
|
var ref = mkObj();
|
|
|
|
// Let heap destruction handle the finalizable objects.
|
|
|