Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ java-web targets headless Java: console apps, libraries and javac.
for, less the process's umask. In-memory files get synthetic inode numbers, a
link count of 1 and default modes.
- `-XX:OnOutOfMemoryError` runs no command, and `StackWalker`
has no live locals or operands. `ThreadMXBean.getThreadInfo` and
`dumpThreads` are not implemented, and a virtual thread that yields while it
has no live locals or operands. A virtual thread that yields while it
holds a monitor stays pinned to its carrier.
- `ThreadMXBean` describes threads and finds deadlocks, but has no CPU times
and no blocked or waited times (contention monitoring is off). Thread dumps
find a frame's locked monitors from its synchronized blocks as compilers emit
them, and list a monitor taken any other way with stack depth -1.
- `WatchService` reports files the program itself, or another thread in the
same VM, creates, changes or deletes. It does not see changes made outside
the VM, including by child processes the program starts.
Expand Down
3 changes: 3 additions & 0 deletions src/jvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,13 +902,16 @@ export class JVM {
if (this.tryMonitorEnter(t, o)) {
if (t.blockedOnMonitor) {
t.blockedOnMonitor = false;
t.pendingOn = null;
this.setThreadStatus(t, STATUS_RUNNABLE);
}
return true;
}
// Thread.getState() says BLOCKED while it waits, as on HotSpot
if (!t.blockedOnMonitor) {
t.blockedOnMonitor = true;
t.blockedCount++;
t.pendingOn = o;
this.setThreadStatus(t, STATUS_BLOCKED);
}
t.state = WAITING;
Expand Down
4 changes: 4 additions & 0 deletions src/natives/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function* waitImpl(t: JThread, self: JObject, ms: bigint): NativeGen {
const count = mon.count;
vm.releaseMonitor(mon);
setThreadStatus(t, ms > 0n ? STATUS_TIMED_WAITING : STATUS_WAITING);
t.waitingOn = self;
t.waitedCount++;
let entry: { t: JThread; wake: () => void; count: number } | null = null;
yield t.block(interruptibleWait(t, ms > 0n ? Number(ms) : null, (wake) => {
entry = { t, wake, count };
Expand All @@ -69,6 +71,7 @@ function* waitImpl(t: JThread, self: JObject, ms: bigint): NativeGen {
while (mon.owner !== null) yield t.block(new Promise<void>((r) => mon.entry.push(r)));
mon.owner = t;
mon.count = count;
t.waitingOn = null;
setThreadStatus(t, STATUS_RUNNABLE);
checkInterrupt(t);
}
Expand Down Expand Up @@ -242,6 +245,7 @@ export const natives: Natives = {
"java/lang/Thread.sleepNanos0(J)V": function* (t, [nanos]): NativeGen {
checkInterrupt(t);
setThreadStatus(t, STATUS_SLEEPING);
t.waitedCount++;
// timers can fire a little early by the clock nanoTime reads; sleep at least as asked
const end = performance.now() + Number(nanos) / 1e6;
try {
Expand Down
Loading
Loading