diff --git a/src/compile.cpp b/src/compile.cpp index 8e40cb32b5..08444e2644 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2736,6 +2736,26 @@ void releaseMonitorForObject(MyThread* t, object o) } } +void acquireMonitorForClassOnEntrance(MyThread* t, GcClass* o) +{ + if (LIKELY(o)) { + t->methodLockIsClean = false; + acquire(t, getJClass(t, o)); + t->methodLockIsClean = true; + } else { + throwNew(t, GcNullPointerException::Type); + } +} + +void releaseMonitorForClass(MyThread* t, GcClass* o) +{ + if (LIKELY(o)) { + release(t, getJClass(t, o)); + } else { + throwNew(t, GcNullPointerException::Type); + } +} + object makeMultidimensionalArray2(MyThread* t, GcClass* class_, uintptr_t* countStack, @@ -3377,7 +3397,7 @@ void handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function) if (method->flags() & ACC_STATIC) { PROTECT(t, method); - lock = frame->append(getJClass(t, method->class_())); + lock = frame->append(method->class_()); } else { lock = loadLocal( frame->context, 1, ir::Type::object(), savedTargetIndex(t, method)); @@ -3406,13 +3426,22 @@ void handleEntrance(MyThread* t, Frame* frame) frame->set(index, ir::Type::object()); } - handleMonitorEvent( - t, frame, getThunk(t, acquireMonitorForObjectOnEntranceThunk)); + handleMonitorEvent(t, + frame, + getThunk(t, + method->flags() & ACC_STATIC + ? acquireMonitorForClassOnEntranceThunk + : acquireMonitorForObjectOnEntranceThunk)); } void handleExit(MyThread* t, Frame* frame) { - handleMonitorEvent(t, frame, getThunk(t, releaseMonitorForObjectThunk)); + handleMonitorEvent(t, + frame, + getThunk(t, + frame->context->method->flags() & ACC_STATIC + ? releaseMonitorForClassThunk + : releaseMonitorForObjectThunk)); } bool inTryBlock(MyThread* t UNUSED, GcCode* code, unsigned ip) diff --git a/src/thunks.cpp b/src/thunks.cpp index e97e21aa12..43a2a0c45d 100644 --- a/src/thunks.cpp +++ b/src/thunks.cpp @@ -48,6 +48,8 @@ THUNK(setMaybeNull) THUNK(acquireMonitorForObject) THUNK(acquireMonitorForObjectOnEntrance) THUNK(releaseMonitorForObject) +THUNK(acquireMonitorForClassOnEntrance) +THUNK(releaseMonitorForClass) THUNK(makeMultidimensionalArray) THUNK(makeMultidimensionalArrayFromReference) THUNK(throw_)