Skip to content

Commit

Permalink
Cache one class hash
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 22, 2022
1 parent 5079502 commit 28a2ce9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,16 @@ protected static final Object doSlotAtPut(@SuppressWarnings("unused") final Obje
@SqueakPrimitive(indices = 175)
protected abstract static class PrimBehaviorHashNode extends AbstractPrimitiveNode implements UnaryPrimitiveFallback {

@Specialization
/* Cache one class hash (helps String>>#hash). */
@SuppressWarnings("unused")
@Specialization(guards = "receiver == cachedClass", limit = "1")
protected static final long doClassCached(final ClassObject receiver,
@Cached("receiver") final ClassObject cachedClass,
@Cached("doClassUncached(receiver)") final long cachedHash) {
return cachedHash;
}

@Specialization(replaces = "doClassCached")
protected static final long doClassUncached(final ClassObject receiver) {
receiver.ensureBehaviorHash();
return receiver.getSqueakHash();
Expand Down

0 comments on commit 28a2ce9

Please sign in to comment.