Skip to content

Commit c9738ae

Browse files
committed
Multi cache should decontainerize before taking the type for JVM/Parrot consistency. Still a little dodgy because it assumes hashCode values are unique.
1 parent ca52770 commit c9738ae

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,7 @@ QAST::OperationsJAST.map_classlib_core_op('rename', $TYPE_OPS, 'rename', [$RT_ST
18961896
QAST::OperationsJAST.map_classlib_core_op('copy', $TYPE_OPS, 'copy', [$RT_STR, $RT_STR], $RT_INT);
18971897
QAST::OperationsJAST.map_classlib_core_op('link', $TYPE_OPS, 'link', [$RT_STR, $RT_STR], $RT_INT);
18981898
QAST::OperationsJAST.map_classlib_core_op('symlink', $TYPE_OPS, 'symlink', [$RT_STR, $RT_STR], $RT_INT);
1899+
QAST::OperationsJAST.map_classlib_core_op('debugnoop', $TYPE_OPS, 'debugnoop', [$RT_OBJ], $RT_OBJ, :tc);
18991900

19001901
# terms
19011902
QAST::OperationsJAST.map_classlib_core_op('time_i', $TYPE_OPS, 'time_i', [], $RT_INT);

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,12 +1511,12 @@ public static SixModelObject lexotic(long target) {
15111511
public static SixModelObject multicacheadd(SixModelObject cache, SixModelObject capture, SixModelObject result, ThreadContext tc) {
15121512
if (!(cache instanceof MultiCacheInstance))
15131513
cache = tc.gc.MultiCache.st.REPR.allocate(tc, tc.gc.MultiCache.st);
1514-
((MultiCacheInstance)cache).add((CallCaptureInstance)capture, result);
1514+
((MultiCacheInstance)cache).add((CallCaptureInstance)capture, result, tc);
15151515
return cache;
15161516
}
15171517
public static SixModelObject multicachefind(SixModelObject cache, SixModelObject capture, ThreadContext tc) {
15181518
if (cache instanceof MultiCacheInstance)
1519-
return ((MultiCacheInstance)cache).lookup((CallCaptureInstance)capture);
1519+
return ((MultiCacheInstance)cache).lookup((CallCaptureInstance)capture, tc);
15201520
else
15211521
return null;
15221522
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.perl6.nqp.sixmodel.reprs;
22

33
import org.perl6.nqp.runtime.CallSiteDescriptor;
4+
import org.perl6.nqp.runtime.Ops;
5+
import org.perl6.nqp.runtime.ThreadContext;
46
import org.perl6.nqp.sixmodel.SixModelObject;
57
import org.perl6.nqp.sixmodel.TypeObject;
68

@@ -34,7 +36,7 @@ private class ArityCache
3436
public SixModelObject[] results;
3537
}
3638

37-
public void add(CallCaptureInstance capture, SixModelObject result) {
39+
public void add(CallCaptureInstance capture, SixModelObject result, ThreadContext tc) {
3840
/* If there's flattenings, we can't cache. */
3941
if (capture.descriptor.hasFlattening)
4042
return;
@@ -71,7 +73,7 @@ public void add(CallCaptureInstance capture, SixModelObject result) {
7173
case CallSiteDescriptor.ARG_OBJ:
7274
if (numArgs >= MD_CACHE_MAX_ARITY)
7375
return;
74-
long flag = ((long)((SixModelObject)args[i]).st.hashCode()) << 1;
76+
long flag = ((long)Ops.decont((SixModelObject)args[i], tc).st.hashCode()) << 1;
7577
if (!(args[i] instanceof TypeObject))
7678
flag |= 1;
7779
argTup[numArgs++] = flag;
@@ -107,7 +109,7 @@ public void add(CallCaptureInstance capture, SixModelObject result) {
107109
ac.numEntries++;
108110
}
109111

110-
public SixModelObject lookup(CallCaptureInstance capture) {
112+
public SixModelObject lookup(CallCaptureInstance capture, ThreadContext tc) {
111113
/* If there's flattenings, we can't use the cache. */
112114
if (capture.descriptor.hasFlattening)
113115
return null;
@@ -138,7 +140,7 @@ public SixModelObject lookup(CallCaptureInstance capture) {
138140
case CallSiteDescriptor.ARG_OBJ:
139141
if (numArgs >= MD_CACHE_MAX_ARITY)
140142
return null;
141-
long flag = ((long)((SixModelObject)args[i]).st.hashCode()) << 1;
143+
long flag = ((long)Ops.decont((SixModelObject)args[i], tc).st.hashCode()) << 1;
142144
if (!(args[i] instanceof TypeObject))
143145
flag |= 1;
144146
argTup[numArgs++] = flag;

0 commit comments

Comments
 (0)