Skip to content

Commit

Permalink
Remove interrupt-related semaphore fields
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 17, 2023
1 parent 4c7f9f2 commit efc4fce
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public void execute(final VirtualFrame frame) {
if (istate.interruptPending()) {
LogUtils.INTERRUPTS.fine("User interrupt");
istate.interruptPending = false; // reset interrupt flag
signalSemaporeNode.executeSignal(frame, this, istate.getInterruptSemaphore());
signalSemaporeNode.executeSignal(frame, this, specialObjects[SPECIAL_OBJECT.THE_INTERRUPT_SEMAPHORE]);
}
if (istate.nextWakeUpTickTrigger()) {
LogUtils.INTERRUPTS.fine("Timer interrupt");
istate.nextWakeupTick = 0; // reset timer interrupt
signalSemaporeNode.executeSignal(frame, this, istate.getTimerSemaphore());
signalSemaporeNode.executeSignal(frame, this, specialObjects[SPECIAL_OBJECT.THE_TIMER_SEMAPHORE]);
}
if (istate.pendingFinalizationSignals()) { // signal any pending finalizations
LogUtils.INTERRUPTS.fine("Finalization interrupt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void execute(final VirtualFrame frame) {
if (istate.interruptPending()) {
LogUtils.INTERRUPTS.fine("User interrupt");
istate.interruptPending = false; // reset interrupt flag
signalSemaporeNode.executeSignal(frame, this, istate.getInterruptSemaphore());
signalSemaporeNode.executeSignal(frame, this, specialObjects[SPECIAL_OBJECT.THE_INTERRUPT_SEMAPHORE]);
}
// Timer interrupts skipped
if (istate.pendingFinalizationSignals()) { // signal any pending finalizations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
import java.util.concurrent.TimeUnit;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;

import de.hpi.swa.trufflesqueak.image.SqueakImageContext;
import de.hpi.swa.trufflesqueak.model.NilObject;
import de.hpi.swa.trufflesqueak.model.PointersObject;
import de.hpi.swa.trufflesqueak.model.layout.ObjectLayouts.SPECIAL_OBJECT;
import de.hpi.swa.trufflesqueak.util.LogUtils;
import de.hpi.swa.trufflesqueak.util.MiscUtils;

Expand All @@ -46,8 +42,6 @@ public final class CheckForInterruptsState {
private boolean shouldTrigger;
private boolean shouldTriggerNoTimer;

@CompilationFinal private PointersObject interruptSemaphore;
private PointersObject timerSemaphore;
private ScheduledFuture<?> interruptChecks;

public CheckForInterruptsState(final SqueakImageContext image) {
Expand All @@ -62,18 +56,6 @@ public void start() {
if (image.options.disableInterruptHandler) {
return;
}
final Object interruptSema = image.getSpecialObject(SPECIAL_OBJECT.THE_INTERRUPT_SEMAPHORE);
if (interruptSema instanceof final PointersObject o) {
setInterruptSemaphore(o);
} else {
assert interruptSema == NilObject.SINGLETON;
}
final Object timerSema = image.getSpecialObject(SPECIAL_OBJECT.THE_TIMER_SEMAPHORE);
if (timerSema instanceof final PointersObject o) {
setTimerSemaphore(o);
} else {
assert timerSema == NilObject.SINGLETON;
}
executor = Executors.newSingleThreadScheduledExecutor(r -> {
final Thread t = new Thread(r, CHECK_FOR_INTERRUPTS_THREAD_NAME);
t.setDaemon(true);
Expand Down Expand Up @@ -181,22 +163,6 @@ private void resetTriggers() {
shouldTriggerNoTimer = false;
}

public PointersObject getInterruptSemaphore() {
return interruptSemaphore;
}

public void setInterruptSemaphore(final PointersObject interruptSemaphore) {
this.interruptSemaphore = interruptSemaphore;
}

public PointersObject getTimerSemaphore() {
return timerSemaphore;
}

public void setTimerSemaphore(final PointersObject timerSemaphore) {
this.timerSemaphore = timerSemaphore;
}

/*
* TESTING
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@ private abstract static class AbstractSignalAtPrimitiveNode extends AbstractPrim
protected final void signalAtMilliseconds(final PointersObject semaphore, final long msTime) {
final SqueakImageContext image = getContext();
image.setSemaphore(SPECIAL_OBJECT.THE_TIMER_SEMAPHORE, semaphore);
image.interrupt.setTimerSemaphore(semaphore);
image.interrupt.setNextWakeupTick(msTime);
}

protected final void resetTimerSemaphore() {
final SqueakImageContext image = getContext();
image.setSemaphore(SPECIAL_OBJECT.THE_TIMER_SEMAPHORE, NilObject.SINGLETON);
image.interrupt.setTimerSemaphore(null);
image.interrupt.setNextWakeupTick(0);
}
}
Expand Down Expand Up @@ -499,18 +497,16 @@ protected static final boolean doWeakPointers(final WeakVariablePointersObject r
protected abstract static class PrimInterruptSemaphoreNode extends AbstractPrimitiveNode implements BinaryPrimitiveFallback {

@Specialization
protected final Object get(final Object receiver, final PointersObject semaphore) {
protected final Object set(final Object receiver, final PointersObject semaphore) {
final SqueakImageContext image = getContext();
image.setSemaphore(SPECIAL_OBJECT.THE_INTERRUPT_SEMAPHORE, semaphore);
image.interrupt.setInterruptSemaphore(semaphore);
return receiver;
}

@Specialization
protected final Object get(final Object receiver, final NilObject semaphore) {
protected final Object set(final Object receiver, final NilObject semaphore) {
final SqueakImageContext image = getContext();
image.setSemaphore(SPECIAL_OBJECT.THE_INTERRUPT_SEMAPHORE, semaphore);
image.interrupt.setInterruptSemaphore(null);
return receiver;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,4 @@ protected static final void doSignal(final VirtualFrame frame, final Node node,
protected static final void doNothing(@SuppressWarnings("unused") final NilObject nil) {
// nothing to do
}

@SuppressWarnings("unused")
@Specialization(guards = "object == null")
protected static final void doNothing(final Object object) {
// nothing to do
}
}

1 comment on commit efc4fce

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance Report (efc4fce)

Benchmarks ran on graalvm-jdk-21+35.1.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 533 542 536.07 534 536.06 107213 1.79
CD 476 486 479.34 477 479.33 95868 1.6
DeltaBlue 274 450 405.79 398 404.76 81157 1.35
Havlak 1107 1159 1137.95 1144 1137.86 227590 3.79
Json 361 370 363.53 362 363.51 72705 1.21
List 321 333 321.57 321 321.57 64314 1.07
Mandelbrot 126 136 127.29 127 127.28 25458 0.42
NBody 248 264 251.67 250 251.65 50334 0.84
Permute 150 161 151.28 151 151.27 30256 0.5
Queens 231 243 232.05 232 232.04 46410 0.77
Richards 1226 1238 1229.66 1229.5 1229.65 245931 4.1
Sieve 157 179 158.26 158 158.24 31652 0.53
Storage 139 146 140.84 140 140.82 28167 0.47
Towers 195 204 196.03 196 196.03 39206 0.65
5544 5911 5731.31 5719.5 5730.07 1146261 19.1

efc4fce-2-steady.svg

Warmup (first 100 iterations)

efc4fce-3-warmup.svg

Please sign in to comment.