02df9f3ef1
31 out of the 36 JS tests in test/mjsunit/harmony/weakrefs/ rely on
precise GC with the following general pattern: they allocate some
objects, clear all references to them, invoke a GC, then perform
some test that assumes that the GC has reclaimed the objects.
When conservative stack scanning is used, this may fail.
This CL fixes the tests, ensuring that a precise GC will be invoked
when necessary, without scanning the stack. To achieve this, the GC
has to be invoked in asynchronous execution mode, which ensures that
it will be invoked from the event loop without a stack. In some
cases, this change requires a non-trivial change in the tests.
In 5 tests, part of the test's objective was to verify that a weak
reference is not cleared before the end of the turn. In those, it
was not possible to invoke GC asynchronously, as this would
immediately start a new turn. These tests still use synchronous GC
and they have been modified, if necessary, to allow for CSS (i.e.,
to not test that all possible garbage is reclaimed after a
sequential GC). Because of CSS, these tests may not always test
everything that they were intended to.
Some tests are unsuitable for testing in "GC stress" mode, because
this interferes with the execution of FinalizationRegistry cleanup
tasks or with the clearing of WeakRefs, when asynchronous GC is used.
Tests with trivial fix:
- cleanup-from-different-realm
- cleanup
- cleanup-proxy-from-different-realm
- cleanupsome-2
- cleanupsome-after-unregister
- cleanupsome
- finalizationregistry-keeps-holdings-alive
- multiple-dirty-finalization-groups
- stress-finalizationregistry-dirty-enqueue
- undefined-holdings
- unregister-after-cleanup
- unregister-before-cleanup
- unregister-called-twice
- unregister-inside-cleanup2
- unregister-inside-cleanup3
- unregister-inside-cleanup
- unregister-many
- unregister-when-cleanup-already-scheduled
- weak-cell-basics
Tests with non-trivial fixes; same logic but very restructured:
- cleanup-is-not-a-microtask:
- cleanup-on-detached-realm
- finalizationregistry-scheduled-for-cleanup-multiple-times
- finalizationregistry-independent-lifetime
- finalizationregistry-independent-lifetime-multiple
- reentrant-gc-from-cleanup
- symbol-in-finalizationregistry
(was 2nd part of former symbol-as-weakref-target-gc)
- weak-unregistertoken
Tests with non-trivial fixes; same logic, restructured, using
synchronous GC:
- finalizationregistry-and-weakref
- symbol-as-weakref-target-gc
(was 1st part of former symbol-as-weakref-target-gc)
- two-weakrefs
- weakref-creation-keeps-alive
- weakref-deref-keeps-alive
This is a reland of commit
|
||
---|---|---|
.. | ||
basics-cleanupsome.js | ||
basics.js | ||
cleanup-from-different-realm.js | ||
cleanup-is-not-a-microtask.js | ||
cleanup-on-detached-realm.js | ||
cleanup-proxy-from-different-realm.js | ||
cleanup.js | ||
cleanupsome-2.js | ||
cleanupsome-after-unregister.js | ||
cleanupsome-optional.js | ||
cleanupsome.js | ||
clearkeptobjects-on-quit.js | ||
finalizationregistry-and-weakref.js | ||
finalizationregistry-independent-lifetime-multiple.js | ||
finalizationregistry-independent-lifetime.js | ||
finalizationregistry-keeps-holdings-alive.js | ||
finalizationregistry-scheduled-for-cleanup-multiple-times.js | ||
multiple-dirty-finalization-groups.js | ||
reentrant-gc-from-cleanup.js | ||
stress-finalizationregistry-dirty-enqueue.js | ||
symbol-as-weakref-target-gc.js | ||
symbol-as-weakref-target.js | ||
symbol-in-finalizationregistry.js | ||
two-weakrefs.js | ||
undefined-holdings.js | ||
unregister-after-cleanup.js | ||
unregister-before-cleanup.js | ||
unregister-called-twice.js | ||
unregister-inside-cleanup2.js | ||
unregister-inside-cleanup3.js | ||
unregister-inside-cleanup.js | ||
unregister-many.js | ||
unregister-when-cleanup-already-scheduled.js | ||
weak-cell-basics.js | ||
weak-unregistertoken.js | ||
weakref-creation-keeps-alive.js | ||
weakref-deref-keeps-alive.js |