delay incrementing Thread::criticalLevel until after entering ActiveState

If we increment the value while we're still in IdleState, another
thread may try to GC before we are able to enter ActiveState, which
will lead to an assertion failure when the footprint function is
called.
This commit is contained in:
Joel Dice 2013-02-12 08:15:39 -07:00
parent 07e3294937
commit dc943c250a

View File

@ -160,10 +160,12 @@ GetStringRegion(Thread* t, jstring s, jsize start, jsize length, jchar* dst)
const jchar* JNICALL
GetStringCritical(Thread* t, jstring s, jboolean* isCopy)
{
if ((t->criticalLevel ++) == 0) {
if (t->criticalLevel == 0) {
enter(t, Thread::ActiveState);
}
++ t->criticalLevel;
if (isCopy) {
*isCopy = true;
}
@ -3141,9 +3143,11 @@ SetDoubleArrayRegion(Thread* t, jdoubleArray array, jint offset, jint length,
void* JNICALL
GetPrimitiveArrayCritical(Thread* t, jarray array, jboolean* isCopy)
{
if ((t->criticalLevel ++) == 0) {
if (t->criticalLevel == 0) {
enter(t, Thread::ActiveState);
}
++ t->criticalLevel;
if (isCopy) {
*isCopy = true;