Avoid holding locks when calling ObjectFree callback

We were calling into agent code (through the ObjectFree event) while
holding the ObjectTagTable's allow_disallow_lock_ and other locks.
Depending on the GC being used, this could prevent other threads from
accessing tag-data while the ObjectFree is ongoing. Combined with the
ObjectFree event making use of jrawMonitorID locks (something they are
explicitly allowed to do) this could easily lead to deadlocks.

To fix this we made the ObjectTagTable delay sending the events until
locks are released after calling either the Allow or Broadcast
functions which notify the table that the sweep is finished. We did
need to modify the SemiSpace collector to call the Broadcast function
as well.

This has the unfortunate effect that previously all ObjectFree events
would occur before the end of the Runtime.gc function which is no
longer the case. This is all allowed by the spec however.

We needed to modify test 905 to check for gc having occurred using
phantom references since this change means that ObjectFree events
might happen after a Runtime.gc call returns.

Test: ./test/testrunner/run_build_test_target.py art-gss-gc
Test: ./test.py --host
Test: ./art/tools/run-libjdwp-tests.sh --mode=host

Bug: 76205593

Change-Id: I4565e9828d134899a1623c2f490ac183e7be5ab6
4 files changed