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 05a4f83
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() && expectedLayout.isValid() : "Should only ever match valid layouts";
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

2 comments on commit 05a4f83

@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 (05a4f83)

Benchmarks ran on 23.0.2-graal.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 557 571 561.23 558 561.21 112245 1.87
CD 796 815 801.77 797 801.74 160353 2.67
DeltaBlue 335 512 466.11 476 464.98 93221 1.55
Havlak 1320 1373 1346.99 1346 1346.95 269397 4.49
Json 447 462 450.59 448 450.55 90117 1.5
List 494 534 496.93 495 496.89 99385 1.66
Mandelbrot 129 152 130.79 130 130.75 26159 0.44
NBody 457 504 463.98 462 463.93 92796 1.55
Permute 187 216 188.12 187 188.09 37623 0.63
Queens 226 251 230.3 228 230.24 46060 0.77
Richards 1225 1262 1232.28 1231 1232.26 246455 4.11
Sieve 170 192 171.33 170 171.3 34266 0.57
Storage 154 169 157.14 155 157.08 31427 0.52
Towers 309 341 315.75 313 315.69 63150 1.05
6806 7354 7013.27 6996 7011.66 1402654 23.38

05a4f83-2-steady.svg

Warmup (first 100 iterations)

05a4f83-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 (05a4f83)

Benchmarks ran on 23.0.2-graal.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 512 527 516.69 514 516.67 103338 1.72
CD 479 497 483.76 480 483.72 96752 1.61
DeltaBlue 173 291 258.05 258 257.8 51609 0.86
Havlak 1212 1272 1243.99 1243 1243.94 248799 4.15
Json 335 350 338.77 336 338.73 67754 1.13
List 319 341 320.73 319 320.69 64145 1.07
Mandelbrot 129 153 130.57 130 130.53 26113 0.44
NBody 245 263 249.57 247 249.51 49913 0.83
Permute 155 170 159.26 159 159.24 31853 0.53
Queens 214 240 218.6 217 218.54 43719 0.73
Richards 800 819 804.71 801 804.69 160942 2.68
Sieve 170 192 171.22 171 171.2 34244 0.57
Storage 136 151 139.22 137 139.15 27844 0.46
Towers 174 201 178.38 177 178.32 35676 0.59
5053 5467 5213.51 5189 5212.74 1042701 17.38

05a4f83-2-steady.svg

Warmup (first 100 iterations)

05a4f83-3-warmup.svg

Please sign in to comment.