Allow threads to be marked as unsuspendable by kForUserCode

There was a possible deadlock between jit-threads being suspended and
another thread waiting for the jit-thread to finish their work. If the
jit-thread hit a suspend-point the process would deadlock. This fixes
this by allowing threads to be marked as unsuspendable by user-code.
This prevents the issue by marking jit and gc threads as unsuspendable
by user code. Agents attempting to suspend them using JVMTI will
succeed (and see the thread as suspended) but internal runtime methods
will not see the thread as suspended and the thread will not be
prevented from moving into the kRunnable state. A thread that is
unsuspendable trying to suspend itself using JVMTI will get
ERR(INTERNAL) and a log message.

Doing this requires that we rewrite the JVMTI thread suspension code
somewhat so it will now perform an unconditional kInternal suspension
prior to trying to suspend the thread kForUserCode. The kInternal
suspension is then lifted. This ensures that everything is done
atomically even if the kForUserCode won't stop the thread.

Test: ./test.py --host
Test: ./art/tools/run-libjdwp-tests.sh --mode=host
Test: ./art/tools/run-libjdwp-tests.sh \
        --mode=host                    \
        --variant=x64                  \
        --test org.apache.harmony.jpda.tests.jdwp.EventModifiers.InstanceOnlyModifierTest

Bug: 70838465
Bug: 111348762

Change-Id: I91211641b82416664bf5abd8546efebf4f672f12
6 files changed