diff --git a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java index 937f5c3b70a0..2e0ce619a512 100644 --- a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java +++ b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java @@ -75,7 +75,7 @@ public final class DebuggerController implements ContextsListener { private final Map suspendLocks = Collections.synchronizedMap(new HashMap<>()); private final Map suspendedInfos = Collections.synchronizedMap(new HashMap<>()); private final Map commandRequestIds = new HashMap<>(); - private final Map> threadJobs = new HashMap<>(); + private final Map> invokeJobs = new HashMap<>(); private final Map fieldBreakpointExpected = new HashMap<>(); private final Map methodBreakpointExpected = new HashMap<>(); private final Map breakpointInfos = new HashMap<>(); @@ -698,9 +698,9 @@ private void lockThread(Object thread, boolean forceSuspend, List // we have the actual suspension status and suspended information threadSuspension.removeHardSuspendedThread(thread); fine(() -> "lock.wait() for thread: " + getThreadName(thread)); - // Having the thread lock, we can check if a thread job was posted outside of + // Having the thread lock, we can check if an invoke job was posted outside of // locking, and if so, we postpone blocking the thread until next time around. - if (!threadJobs.containsKey(thread)) { + if (!invokeJobs.containsKey(thread)) { lock.wait(); } } @@ -709,22 +709,22 @@ private void lockThread(Object thread, boolean forceSuspend, List // make sure the interrupted flag is set though Thread.currentThread().interrupt(); } - checkThreadJobsAndRun(thread); + checkInvokeJobsAndRun(thread); } fine(() -> "lock wakeup for thread: " + getThreadName(thread)); } - private void checkThreadJobsAndRun(Object thread) { - if (threadJobs.containsKey(thread)) { - ThreadJob job = threadJobs.remove(thread); + private void checkInvokeJobsAndRun(Object thread) { + if (invokeJobs.containsKey(thread)) { + InvokeJob job = invokeJobs.remove(thread); job.runJob(this); } } - public void postJobForThread(ThreadJob job) { + public void postInvokeJobForThread(InvokeJob job) { SimpleLock lock = getSuspendLock(job.getThread()); synchronized (lock) { - threadJobs.put(job.getThread(), job); + invokeJobs.put(job.getThread(), job); lock.notifyAll(); } } diff --git a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/ThreadJob.java b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/InvokeJob.java similarity index 96% rename from espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/ThreadJob.java rename to espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/InvokeJob.java index 9fe7d47f90f8..e657ef303403 100644 --- a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/ThreadJob.java +++ b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/InvokeJob.java @@ -24,7 +24,7 @@ import java.util.concurrent.Callable; -public final class ThreadJob { +public final class InvokeJob { private final Object jobLock = new Object(); private final Object thread; @@ -33,11 +33,11 @@ public final class ThreadJob { private boolean resultAvailable; private JobResult result; - public ThreadJob(Object guestThread, Callable task) { + public InvokeJob(Object guestThread, Callable task) { this(guestThread, task, SuspendStrategy.EVENT_THREAD); } - public ThreadJob(Object guestThread, Callable task, byte suspensionStrategy) { + public InvokeJob(Object guestThread, Callable task, byte suspensionStrategy) { this.thread = guestThread; this.callable = task; this.suspensionStrategy = suspensionStrategy; diff --git a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java index ed5b5f0a7ae9..c7e027eeb19d 100644 --- a/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java +++ b/espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java @@ -1163,8 +1163,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D try { // we have to call the method in the correct thread, so post a // Callable to the controller and wait for the result to appear - ThreadJob job = new ThreadJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy); - controller.postJobForThread(job); + InvokeJob job = new InvokeJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy); + controller.postInvokeJobForThread(job); // invocation of a method can cause events with possible thread suspension // to happen, e.g. class prepare events for newly loaded classes @@ -1175,8 +1175,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D public void run() { CommandResult commandResult = new CommandResult(reply); try { - ThreadJob.JobResult result = job.getResult(); - writeMethodResult(reply, context, result, thread, controller); + InvokeJob.JobResult result = job.getResult(); + writeMethodResult(reply, context, result); } catch (Throwable t) { reply.errorCode(ErrorCodes.INTERNAL); controller.severe(INVOKE_METHOD.class.getName() + ".createReply", t); @@ -1246,15 +1246,15 @@ static CommandResult createReply(Packet packet, DebuggerController controller) { try { // we have to call the constructor in the correct thread, so post a // Callable to the controller and wait for the result to appear - ThreadJob job = new ThreadJob<>(thread, () -> { + InvokeJob job = new InvokeJob<>(thread, () -> { args[0] = context.allocateInstance(klass); method.invokeMethodSpecial(args); return args[0]; }, suspensionStrategy); - controller.postJobForThread(job); - ThreadJob.JobResult result = job.getResult(); + controller.postInvokeJobForThread(job); + InvokeJob.JobResult result = job.getResult(); - writeMethodResult(reply, context, result, thread, controller); + writeMethodResult(reply, context, result); } catch (Throwable t) { throw new RuntimeException("not able to invoke static method through jdwp", t); } @@ -1350,8 +1350,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D try { // we have to call the method in the correct thread, so post a // Callable to the controller and wait for the result to appear - ThreadJob job = new ThreadJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy); - controller.postJobForThread(job); + InvokeJob job = new InvokeJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy); + controller.postInvokeJobForThread(job); // invocation of a method can cause events with possible thread suspension // to happen, e.g. class prepare events for newly loaded classes // to avoid blocking here, we fire up a new thread that will post @@ -1361,8 +1361,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D public void run() { CommandResult commandResult = new CommandResult(reply); try { - ThreadJob.JobResult result = job.getResult(); - writeMethodResult(reply, context, result, thread, controller); + InvokeJob.JobResult result = job.getResult(); + writeMethodResult(reply, context, result); } catch (Throwable t) { reply.errorCode(ErrorCodes.INTERNAL); controller.severe(INVOKE_METHOD.class.getName() + "." + "createReply", t); @@ -1807,7 +1807,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D try { // we have to call the method in the correct thread, so post a // Callable to the controller and wait for the result to appear - ThreadJob job = new ThreadJob<>(thread, () -> { + InvokeJob job = new InvokeJob<>(thread, () -> { if (invokeNonvirtual) { return method.invokeMethodNonVirtual(args); } else if (Modifier.isPrivate(method.getModifiers())) { @@ -1818,7 +1818,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D return method.invokeMethodVirtual(args); } }, suspensionStrategy); - controller.postJobForThread(job); + controller.postInvokeJobForThread(job); // invocation of a method can cause events with possible thread suspension // to happen, e.g. class prepare events for newly loaded classes // to avoid blocking here, we fire up a new thread that will post @@ -1828,8 +1828,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D public void run() { CommandResult commandResult = new CommandResult(reply); try { - ThreadJob.JobResult result = job.getResult(); - writeMethodResult(reply, context, result, thread, controller); + InvokeJob.JobResult result = job.getResult(); + writeMethodResult(reply, context, result); } catch (Throwable t) { reply.errorCode(ErrorCodes.INTERNAL); controller.severe(INVOKE_METHOD.class.getName() + "." + "createReply", t); @@ -2393,11 +2393,11 @@ static CommandResult createReply(Packet packet, DebuggerController controller) { } // make sure owned monitors taken in frame are exited - ThreadJob job = new ThreadJob<>(thread, () -> { + InvokeJob job = new InvokeJob<>(thread, () -> { controller.getContext().clearFrameMonitors(topFrame); return null; }); - controller.postJobForThread(job); + controller.postInvokeJobForThread(job); // don't return here before job completed job.getResult(); @@ -3042,7 +3042,7 @@ public static void writeValue(byte tag, Object value, PacketStream reply, boolea } } - private static void writeMethodResult(PacketStream reply, JDWPContext context, ThreadJob.JobResult result, Object thread, DebuggerController controller) { + private static void writeMethodResult(PacketStream reply, JDWPContext context, InvokeJob.JobResult result) { if (result.getException() != null) { reply.writeByte(TagConstants.OBJECT); reply.writeLong(0);