Skip to content

Commit

Permalink
Only ever match valid layouts in PIC guard
Browse files Browse the repository at this point in the history
This avoids blowing inline cache limits unnecessarily.
  • Loading branch information
fniephaus committed Feb 17, 2025
1 parent e179ddc commit 57fb986
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ public final ObjectLayout getLayout() {
return layout;
}

public final boolean matchesLayout(final ObjectLayout expectedLayout) {
if (!getLayout().isValid()) {
CompilerDirectives.transferToInterpreterAndInvalidate();
updateLayout();
}
assert layout.isValid() : "Should only ever match valid layout (invalid expectedLayout will be replaced in PIC)";
return layout == expectedLayout;
}

public final void changeClassTo(final ClassObject newClass) {
setSqueakClass(newClass);
migrateToLayout(newClass.getLayout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Idempotent;

Expand Down Expand Up @@ -207,7 +206,6 @@ public void invalidate() {
isValidAssumption.invalidate("Layout no longer valid");
}

@TruffleBoundary
public boolean isValid() {
return isValidAssumption.isValid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private AbstractPointersObjectGuard(final AbstractPointersObject receiver) {

@Override
public boolean check(final Object receiver) {
return receiver instanceof final AbstractPointersObject o && o.getLayout() == expectedLayout;
return receiver instanceof final AbstractPointersObject o && o.matchesLayout(expectedLayout);
}

@Override
Expand Down

1 comment on commit 57fb986

@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 (57fb986)

Benchmarks ran on 23.0.2-graal.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 548 563 552.54 549 552.52 110508 1.84
CD 802 822 808.34 804 808.31 161668 2.69
DeltaBlue 338 513 465.16 476.5 463.51 93032 1.55
Havlak 1311 1387 1342.17 1342 1342.13 268433 4.47
Json 420 440 424.57 422 424.54 84914 1.42
List 503 646 533.13 505 531.77 106626 1.78
Mandelbrot 129 153 130.76 130 130.72 26152 0.44
NBody 458 483 465.72 464 465.69 93144 1.55
Permute 185 201 187.51 187 187.49 37502 0.63
Queens 225 249 227.75 226 227.69 45549 0.76
Richards 1243 1263 1247.81 1245 1247.79 249561 4.16
Sieve 170 191 171.27 170 171.24 34254 0.57
Storage 153 167 155.95 154 155.89 31189 0.52
Towers 308 338 313.25 311.5 313.19 62649 1.04
6793 7416 7025.91 6986 7022.48 1405181 23.42

57fb986-2-steady.svg

Warmup (first 100 iterations)

57fb986-3-warmup.svg

Please sign in to comment.