Skip to content

Commit

Permalink
Use FrameSlotKind.Static for marker, ip, and sp
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jul 25, 2022
1 parent 48328c2 commit 23e54fb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameDescriptor.Builder;
import com.oracle.truffle.api.frame.FrameSlotKind;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.source.Source;
Expand All @@ -46,6 +44,7 @@
import de.hpi.swa.trufflesqueak.nodes.primitives.PrimitiveNodeFactory.ArgumentsLocation;
import de.hpi.swa.trufflesqueak.shared.SqueakLanguageConfig;
import de.hpi.swa.trufflesqueak.util.ArrayUtils;
import de.hpi.swa.trufflesqueak.util.FrameAccess;
import de.hpi.swa.trufflesqueak.util.MiscUtils;
import de.hpi.swa.trufflesqueak.util.ObjectGraphUtils.ObjectTracer;
import de.hpi.swa.trufflesqueak.util.UnsafeUtils;
Expand Down Expand Up @@ -270,13 +269,7 @@ public RootCallTarget getResumptionCallTarget(final ContextObject context) {
public FrameDescriptor getFrameDescriptor() {
if (frameDescriptor == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
final Builder builder = FrameDescriptor.newBuilder();
builder.addSlot(FrameSlotKind.Object, null, null); // SLOT_IDENTIFIER.THIS_MARKER
builder.addSlot(FrameSlotKind.Illegal, null, null); // SLOT_IDENTIFIER.THIS_CONTEXT
builder.addSlot(FrameSlotKind.Int, null, null); // SLOT_IDENTIFIER.INSTRUCTION_POINTER
builder.addSlot(FrameSlotKind.Int, null, null); // SLOT_IDENTIFIER.STACK_POINTER
builder.addSlots(getSqueakContextSize(), FrameSlotKind.Illegal);
frameDescriptor = builder.build();
frameDescriptor = FrameAccess.newFrameDescriptor(getSqueakContextSize());
}
return frameDescriptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameDescriptor.Builder;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameSlotKind;
import com.oracle.truffle.api.frame.MaterializedFrame;
Expand Down Expand Up @@ -97,6 +98,17 @@ private enum SlotIndicies {
private FrameAccess() {
}

/** Creates a new {@link FrameDescriptor} according to {@link SlotIndicies}. */
public static FrameDescriptor newFrameDescriptor(final int squeakContextSize) {
final Builder builder = FrameDescriptor.newBuilder();
builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.THIS_MARKER
builder.addSlot(FrameSlotKind.Illegal, null, null); // SlotIndicies.THIS_CONTEXT
builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.INSTRUCTION_POINTER
builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.STACK_POINTER
builder.addSlots(squeakContextSize, FrameSlotKind.Illegal);
return builder.build();
}

public static CompiledCodeObject getCodeObject(final Frame frame) {
return (CompiledCodeObject) frame.getArguments()[ArgumentIndicies.CODE_OBJECT.ordinal()];
}
Expand Down Expand Up @@ -169,11 +181,11 @@ public static Object[] getReceiverAndArguments(final Frame frame) {
}

public static FrameMarker getMarker(final Frame frame) {
return (FrameMarker) frame.getObject(SlotIndicies.THIS_MARKER.ordinal());
return (FrameMarker) frame.getObjectStatic(SlotIndicies.THIS_MARKER.ordinal());
}

public static void setMarker(final Frame frame, final FrameMarker marker) {
frame.setObject(SlotIndicies.THIS_MARKER.ordinal(), marker);
frame.setObjectStatic(SlotIndicies.THIS_MARKER.ordinal(), marker);
}

public static void initializeMarker(final Frame frame) {
Expand Down Expand Up @@ -206,19 +218,19 @@ public static void setContext(final Frame frame, final ContextObject context) {
}

public static int getInstructionPointer(final Frame frame) {
return frame.getInt(SlotIndicies.INSTRUCTION_POINTER.ordinal());
return frame.getIntStatic(SlotIndicies.INSTRUCTION_POINTER.ordinal());
}

public static void setInstructionPointer(final Frame frame, final int value) {
frame.setInt(SlotIndicies.INSTRUCTION_POINTER.ordinal(), value);
frame.setIntStatic(SlotIndicies.INSTRUCTION_POINTER.ordinal(), value);
}

public static int getStackPointer(final Frame frame) {
return frame.getInt(SlotIndicies.STACK_POINTER.ordinal());
return frame.getIntStatic(SlotIndicies.STACK_POINTER.ordinal());
}

public static void setStackPointer(final Frame frame, final int value) {
frame.setInt(SlotIndicies.STACK_POINTER.ordinal(), value);
frame.setIntStatic(SlotIndicies.STACK_POINTER.ordinal(), value);
}

public static int toStackSlotIndex(final Frame frame, final int index) {
Expand Down

4 comments on commit 23e54fb

@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 (23e54fb)

Benchmarks ran on graalvm-ce-java17-22.2.0.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 179 187 179.96 179 179.95 35991 0.6
DeltaBlue 253 406 360.77 368 359.67 72154 1.2
Havlak 1531 1621 1558.23 1557.5 1558.16 311646 5.19
Json 735 744 739.59 740 739.59 147918 2.47
List 890 1036 895.88 892 895.65 179175 2.99
Mandelbrot 144 150 145.15 145 145.14 29029 0.48
NBody 273 283 275.31 274 275.3 55061 0.92
Permute 226 232 227.5 227 227.49 45499 0.76
Queens 251 257 253.03 253 253.03 50606 0.84
Richards 1088 1103 1093.09 1093 1093.08 218617 3.64
Sieve 208 217 209.48 209 209.48 41896 0.7
Storage 275 292 277.76 278 277.75 55551 0.93
Towers 348 357 351.75 352 351.74 70350 1.17
6401 6885 6567.46 6567.5 6566.03 1313493 21.89

23e54fb-2-steady.svg

Warmup (first 50 iterations)

23e54fb-3-warmup.svg

@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 (23e54fb)

Benchmarks ran on graalvm-ce-java11-22.2.0.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 453 711 457.88 456 457.62 91576 1.53
DeltaBlue 348 863 510.88 515 508.42 102175 1.7
Havlak 3996 4548 4194.25 4084 4190.06 838850 13.98
Json 836 1107 846.33 844 846 169266 2.82
List 947 1317 956.2 951 955.9 191239 3.19
Mandelbrot 143 148 145.18 145 145.17 29035 0.48
NBody 310 757 317.49 315 316.65 63498 1.06
Permute 269 277 272.88 273 272.88 54576 0.91
Queens 278 285 280.88 281 280.88 56176 0.94
Richards 1048 1374 1061.07 1057 1060.73 212213 3.54
Sieve 262 267 263.75 263 263.74 52749 0.88
Storage 327 570 331.94 330 331.63 66387 1.11
Towers 361 366 363.03 363 363.02 72605 1.21
9578 12590 10001.73 9877 9992.69 2000345 33.34

23e54fb-2-steady.svg

Warmup (first 50 iterations)

23e54fb-3-warmup.svg

@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 (23e54fb)

Benchmarks ran on graalvm-ce-java11-22.2.0.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 179 272 183.92 179 183.27 36783 0.61
DeltaBlue 279 415 377.73 378 377.5 75546 1.26
Havlak 1464 1607 1542.12 1553 1541.9 308424 5.14
Json 905 950 911.76 907 911.72 182352 3.04
List 893 957 900.2 894 900.09 180039 3
Mandelbrot 144 176 145.88 145 145.82 29176 0.49
NBody 274 343 280.29 276 280.14 56058 0.93
Permute 231 303 233.42 231 233.3 46683 0.78
Queens 263 304 268.85 265 268.66 53770 0.9
Richards 1084 1114 1088.18 1085.5 1088.16 217635 3.63
Sieve 209 274 215.3 210 214.88 43060 0.72
Storage 286 334 290.88 287 290.75 58176 0.97
Towers 371 417 374.36 372 374.3 74871 1.25
6582 7466 6812.87 6782.5 6810.49 1362573 22.71

23e54fb-2-steady.svg

Warmup (first 50 iterations)

23e54fb-3-warmup.svg

@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 (23e54fb)

Benchmarks ran on graalvm-ce-java11-22.2.0.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 179 272 182.92 181 182.71 36583 0.61
DeltaBlue 281 416 387.21 389 386.9 77441 1.29
Havlak 1487 1605 1554.28 1569 1554.02 310855 5.18
Json 891 936 897.61 892 897.55 179521 2.99
List 895 953 900.14 897 900.1 180027 3
Mandelbrot 144 175 147.35 145 147.19 29470 0.49
NBody 274 313 278.95 275 278.84 55789 0.93
Permute 229 274 231.41 230 231.33 46281 0.77
Queens 263 317 268.73 264 268.51 53745 0.9
Richards 1108 1156 1113.62 1111 1113.59 222723 3.71
Sieve 209 272 213.98 210 213.65 42795 0.71
Storage 285 317 289.02 286 288.96 57805 0.96
Towers 361 388 363.15 362 363.12 72629 1.21
6606 7394 6828.32 6811 6826.48 1365664 22.76

23e54fb-2-steady.svg

Warmup (first 100 iterations)

23e54fb-3-warmup.svg

Please sign in to comment.