Skip to content

Commit

Permalink
Various refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Dec 16, 2023
1 parent 8efac83 commit 6177be7
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static PointersObject instantiate(final ClassObject dummyClass) {
}

private static void writeAndValidate(final AbstractPointersObject obj, final int index, final Object value) {
AbstractPointersObjectWriteNode.getUncached().execute(null, obj, index, value);
assertEquals("Write failed", AbstractPointersObjectReadNode.getUncached().execute(null, obj, index), value);
AbstractPointersObjectWriteNode.executeUncached(obj, index, value);
assertEquals("Write failed", AbstractPointersObjectReadNode.executeUncached(obj, index), value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ private void run(final ContextObject thisContext) {
final PointersObject activeProcess = image.getActiveProcessSlow();
try {
/* Mark thisContext as suspended during tracing and writing. */
AbstractPointersObjectWriteNode.getUncached().execute(null, activeProcess, PROCESS.SUSPENDED_CONTEXT, thisContext);
AbstractPointersObjectWriteNode.executeUncached(activeProcess, PROCESS.SUSPENDED_CONTEXT, thisContext);
traceObjects();
writeImageHeader();
writeBody();
} finally {
/* Unmark thisContext as suspended. */
AbstractPointersObjectWriteNode.getUncached().executeNil(null, activeProcess, PROCESS.SUSPENDED_CONTEXT);
AbstractPointersObjectWriteNode.executeUncached(activeProcess, PROCESS.SUSPENDED_CONTEXT, NilObject.SINGLETON);
closeStream();
finalizeImageHeader();
}
Expand Down Expand Up @@ -242,7 +242,7 @@ public long toWord(final Object object) {
return toTaggedSmallInteger((long) object);
} else if (object instanceof Double) {
return toTaggedSmallFloat((double) object);
} else if (object instanceof AbstractSqueakObject aso) {
} else if (object instanceof AbstractSqueakObjectWithClassAndHash aso) {
final Long oop = oopMap.get(aso);
if (oop != null) {
return oop;
Expand All @@ -252,6 +252,7 @@ public long toWord(final Object object) {
}
} else {
/* Nil out any foreign objects. */
assert !(object instanceof AbstractSqueakObject);
return nilOop;
}
}
Expand Down Expand Up @@ -384,7 +385,7 @@ public void writeObjects(final Object[] objects) {
}

public void writeObjectIfTracedElseNil(final Object object) {
writeLong(toWord(object instanceof AbstractSqueakObject aso && oopMap.containsKey(aso) ? object : NilObject.SINGLETON));
writeLong(toWord(object instanceof AbstractSqueakObjectWithClassAndHash aso && oopMap.containsKey(aso) ? object : NilObject.SINGLETON));
}

private static long toTaggedCharacter(final long value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void setSqueakDisplay(final PointersObject squeakDisplay) {

@TruffleBoundary
public void showDisplayRect(final int left, final int right, final int top, final int bottom) {
assert left < right && top < bottom;
assert left <= right && top <= bottom;
canvas.paintImmediately(left, top, right, bottom);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ public final int instsize() {

public final Object instVarAt0Slow(final long index) {
CompilerAsserts.neverPartOfCompilation();
return AbstractPointersObjectReadNode.getUncached().execute(null, this, index);
return AbstractPointersObjectReadNode.executeUncached(this, index);
}

public final void instVarAtPut0Slow(final long index, final Object value) {
CompilerAsserts.neverPartOfCompilation();
AbstractPointersObjectWriteNode.getUncached().execute(null, this, index, value);
AbstractPointersObjectWriteNode.executeUncached(this, index, value);
}

protected final boolean layoutValuesPointTo(final SqueakObjectIdentityNode identityNode, final Node inlineTarget, final Object thang) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ObjectLayout evolveLocation(final long longIndex, final Object value) {
throw SqueakException.create("Only the latest layout should be evolved");
}
final SlotLocation oldLocation = locations[index];
assert index < locations.length && !oldLocation.isGeneric();
assert !oldLocation.isGeneric();
invalidate();
final SlotLocation[] newLocations = locations.clone();
newLocations[index] = SlotLocation.UNINITIALIZED_LOCATION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static AbstractPointersObjectReadNode getUncached() {

public abstract Object execute(Node node, AbstractPointersObject obj, long index);

public static final Object executeUncached(final AbstractPointersObject obj, final long index) {
return getUncached().execute(null, obj, index);
}

public abstract long executeLong(Node node, AbstractPointersObject obj, long index);

public abstract ArrayObject executeArray(Node node, AbstractPointersObject obj, long index);
Expand Down Expand Up @@ -95,6 +99,10 @@ public static AbstractPointersObjectWriteNode getUncached() {

public abstract void execute(Node node, AbstractPointersObject obj, long index, Object value);

public static final void executeUncached(final AbstractPointersObject obj, final long index, final Object value) {
getUncached().execute(null, obj, index, value);
}

public final void executeNil(final Node node, final AbstractPointersObject obj, final long index) {
execute(node, obj, index, NilObject.SINGLETON);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ protected static final void doArrayOfChars(final ArrayObject obj, final long ind
@Specialization(guards = {"obj.isCharType()", "isCharNilTag(value)"})
protected static final void doArrayOfCharsNilTagClash(final Node node, final ArrayObject obj, final long index, final char value,
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
/** `value` happens to be char nil tag, need to despecialize to be able store it. */
/** `value` happens to be char nil tag, need to despecialize to be able to store it. */
obj.transitionFromCharsToObjects(isNilTagProfile, node);
doArrayOfObjects(obj, index, value);
}
Expand All @@ -517,7 +517,7 @@ protected static final void doArrayOfLongs(final ArrayObject obj, final long ind
@Specialization(guards = {"obj.isLongType()", "isLongNilTag(value)"})
protected static final void doArrayOfLongsNilTagClash(final Node node, final ArrayObject obj, final long index, final long value,
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
/** `value` happens to be long nil tag, need to despecialize to be able store it. */
/** `value` happens to be long nil tag, need to despecialize to be able to store it. */
obj.transitionFromLongsToObjects(isNilTagProfile, node);
doArrayOfObjects(obj, index, value);
}
Expand All @@ -542,7 +542,7 @@ protected static final void doArrayOfDoubles(final ArrayObject obj, final long i
@Specialization(guards = {"obj.isDoubleType()", "isDoubleNilTag(value)"})
protected static final void doArrayOfDoublesNilTagClash(final Node node, final ArrayObject obj, final long index, final double value,
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
// `value` happens to be double nil tag, need to despecialize to be able store it.
// `value` happens to be double nil tag, need to despecialize to be able to store it.
obj.transitionFromDoublesToObjects(isNilTagProfile, node);
doArrayOfObjects(obj, index, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected static final CompiledCodeObject doObjectAsMethod(final Node node, fina
return method;
} else {
assert runWithInMethod == null : "runWithInMethod should not be another Object";
return doDoesNotUnderstand(image, targetObjectClass, runWithInMethod);
return doDoesNotUnderstand(image, targetObjectClass, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1304,11 +1304,7 @@ private void computeFinalWideBezierValueswidth(final int bezier, final int lineW
rightX = temp;
}
edgeXValueOfput(bezier, leftX);
if (rightX - leftX > lineWidth) {
wideBezierWidthOfput(bezier, rightX - leftX);
} else {
wideBezierWidthOfput(bezier, lineWidth);
}
wideBezierWidthOfput(bezier, Math.max(rightX - leftX, lineWidth));
}

/* BalloonEngineBase>>#computeSqrt: */
Expand Down Expand Up @@ -2497,16 +2493,8 @@ private boolean fillSpanfromto(final int fill, final int leftX, final int rightX
}
int x0;
int x1;
if (leftX < spanEndAAGet()) {
x0 = spanEndAAGet();
} else {
x0 = leftX;
}
if (rightX > shl(spanSizeGet(), aaShiftGet())) {
x1 = shl(spanSizeGet(), aaShiftGet());
} else {
x1 = rightX;
}
x0 = Math.max(leftX, spanEndAAGet());
x1 = Math.min(rightX, shl(spanSizeGet(), aaShiftGet()));
if (x0 < fillMinXGet()) {
x0 = fillMinXGet();
}
Expand Down Expand Up @@ -5695,7 +5683,7 @@ private void quickSortGlobalEdgeTablefromto(final int[] array, final int i, fina
di = dj;
dj = tt;
}
if (n <= 2) {
if (n == 2) {
return;
}
/* ij is the midpoint of i and j. */
Expand All @@ -5721,7 +5709,7 @@ private void quickSortGlobalEdgeTablefromto(final int[] array, final int i, fina
array[ij] = tmp;
dij = di;
}
if (n <= 3) {
if (n == 3) {
return;
}
int k = i;
Expand Down
Loading

1 comment on commit 6177be7

@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 (6177be7)

Benchmarks ran on graalvm-jdk-21+35.1.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 550 560 552.38 551 552.37 110476 1.84
CD 470 484 473.87 472 473.86 94774 1.58
DeltaBlue 270 454 401.82 400 400.44 80363 1.34
Havlak 1130 1184 1158.17 1163 1158.09 231633 3.86
Json 362 371 364.37 363 364.36 72874 1.21
List 291 314 294.05 293 294.02 58810 0.98
Mandelbrot 125 136 126.23 126 126.21 25245 0.42
NBody 249 280 252.81 250 252.77 50561 0.84
Permute 150 166 151.84 151 151.82 30368 0.51
Queens 231 242 231.87 232 231.86 46374 0.77
Richards 1234 1291 1239.2 1239 1239.19 247839 4.13
Sieve 163 176 164.1 164 164.08 32819 0.55
Storage 139 147 141.24 140 141.22 28247 0.47
Towers 197 210 198.47 198 198.46 39694 0.66
5561 6015 5750.39 5742 5748.75 1150077 19.17

6177be7-2-steady.svg

Warmup (first 100 iterations)

6177be7-3-warmup.svg

Please sign in to comment.