use of com.oracle.truffle.espresso.blocking.GuestInterruptedException in project graal by oracle.
the class VM method JVM_MonitorWait.
@VmImpl(isJni = true)
@TruffleBoundary
@SuppressFBWarnings(value = { "IMSE" }, justification = "Not dubious, .wait is just forwarded from the guest.")
@SuppressWarnings("try")
public void JVM_MonitorWait(@JavaType(Object.class) StaticObject self, long timeout, @Inject Meta meta, @Inject SubstitutionProfiler profiler) {
EspressoContext context = getContext();
StaticObject currentThread = context.getCurrentThread();
State state = timeout > 0 ? State.TIMED_WAITING : State.WAITING;
try (Transition transition = Transition.transition(context, state)) {
if (context.EnableManagement) {
// Locks bookkeeping.
meta.HIDDEN_THREAD_BLOCKED_OBJECT.setHiddenObject(currentThread, self);
Target_java_lang_Thread.incrementThreadCounter(currentThread, meta.HIDDEN_THREAD_WAITED_COUNT);
}
final boolean report = context.shouldReportVMEvents();
if (report) {
context.reportMonitorWait(self, timeout);
}
boolean timedOut = !InterpreterToVM.monitorWait(self.getLock(getContext()), timeout);
if (report) {
context.reportMonitorWaited(self, timedOut);
}
} catch (GuestInterruptedException e) {
profiler.profile(0);
if (getThreadAccess().isInterrupted(currentThread, true)) {
throw meta.throwExceptionWithMessage(meta.java_lang_InterruptedException, e.getMessage());
}
getThreadAccess().fullSafePoint(currentThread);
} catch (IllegalMonitorStateException e) {
profiler.profile(1);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalMonitorStateException, e.getMessage());
} catch (IllegalArgumentException e) {
profiler.profile(2);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, e.getMessage());
} finally {
if (context.EnableManagement) {
meta.HIDDEN_THREAD_BLOCKED_OBJECT.setHiddenObject(currentThread, null);
}
}
}
use of com.oracle.truffle.espresso.blocking.GuestInterruptedException in project graal by oracle.
the class EspressoReferenceDrainer method doWaitForReferencePendingList.
@TruffleBoundary
private void doWaitForReferencePendingList() {
try {
EspressoLock pLock = getLock();
pLock.lock();
try {
// Wait until the reference drain updates the list.
while (!hasReferencePendingList()) {
pLock.await(0L);
}
} finally {
pLock.unlock();
}
} catch (GuestInterruptedException e) {
/*
* The guest handler thread will attempt emptying the reference list by re-obtaining it.
* If the list is not null, then everything will proceed as normal. In the case it is
* empty, the guest handler will simply loop back into waiting. This looping back into
* waiting done in guest code gives us a chance to reach an espresso safe point (a back
* edge), thus giving us the possibility to stop this thread when tearing down the VM.
*/
}
}
Aggregations