Skip to content

Commit a64fee0

Browse files
committed
Use cache size and reorder a bit to avoid redundant accesses
Signed-off-by: Stefan Marr <[email protected]>
1 parent 0b3c038 commit a64fee0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/trufflesom/interpreter/nodes/MessageSendNode.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,20 @@ public NodeCost getCost() {
201201
private PreevaluatedExpression specialize(final Object[] arguments) {
202202
int cacheSize = numCacheNodes;
203203
if (cacheSize < 0) {
204-
cacheSize = numCacheNodes = 0;
205204
PreevaluatedExpression eager = attemptEagerSpecialization(arguments);
206205
if (eager != null) {
207206
return eager;
208207
}
209-
}
210208

211-
final GuardedDispatchNode first = dispatchCache;
209+
cacheSize = numCacheNodes = 0;
210+
}
212211

213212
Object rcvr = arguments[0];
214213
assert rcvr != null;
215214

216215
if (rcvr instanceof SObject) {
217216
SObject r = (SObject) rcvr;
218-
if (r.updateLayoutToMatchClass() && first != null) {
217+
if (r.updateLayoutToMatchClass() && cacheSize > 0) {
219218
// if the dispatchCache is null, we end up here, so continue directly below instead
220219
// otherwise, let's retry the cache!
221220
return this;
@@ -247,8 +246,9 @@ private PreevaluatedExpression specialize(final Object[] arguments) {
247246
node = new CachedDnuNode(rcvrClass, guard, selector);
248247
}
249248

250-
if (first != null) {
249+
if (cacheSize > 0) {
251250
reportPolymorphicSpecialize();
251+
final AbstractDispatchNode first = dispatchCache;
252252
node.next = node.insertHere(first);
253253
}
254254
dispatchCache = insert(node);

0 commit comments

Comments
 (0)