Skip to content

Commit 7eaebf5

Browse files
committed
[jvm] Fix off-by-one in multi cache
1 parent 47db26d commit 7eaebf5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiCacheInstance.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ public void add(CallCaptureInstance capture, SixModelObject result, ThreadContex
9696
if (numArgs >= MD_CACHE_MAX_ARITY)
9797
return;
9898

99+
/* The zero arity case was handled above.
100+
* At index 0 we have the cache for arity 1 */
101+
ArityCache ac = this.arityCaches[numArgs - 1];
102+
99103
/* If the cache is saturated, don't do anything (we could instead do a random
100104
* replacement). */
101-
ArityCache ac = this.arityCaches[numArgs];
102105
if (ac != null && ac.numEntries == MD_CACHE_MAX_ENTRIES)
103106
return;
104107

0 commit comments

Comments
 (0)