@@ -41,6 +41,42 @@ public static SixModelObject wvalResolve(MutableCallSite cs, String sc, long idx
41
41
return res ;
42
42
}
43
43
44
+ public static CallSite wval (Lookup caller , String name , MethodType type ,
45
+ String sc , long idx ) {
46
+ try {
47
+ /* Look up wval resolver method. */
48
+ MethodType resType = MethodType .methodType (SixModelObject .class ,
49
+ String .class , long .class , MutableCallSite .class , ThreadContext .class );
50
+ MethodHandle res = caller .findStatic (IndyBootstrap .class , "wvalResolve" , resType );
51
+
52
+ /* Create a mutable callsite, and curry the resolver with it. */
53
+ MutableCallSite cs = new MutableCallSite (type );
54
+ cs .setTarget (MethodHandles .insertArguments (res , 0 , sc , idx , cs ));
55
+
56
+ /* Produce callsite; it'll be updated with the resolved WVal upon the
57
+ * first invocation. */
58
+ return cs ;
59
+ }
60
+ catch (Exception e ) {
61
+ throw new RuntimeException (e );
62
+ }
63
+ }
64
+
65
+ public static SixModelObject wvalResolve (String sc , long idx , MutableCallSite cs , ThreadContext tc ) {
66
+ /* Look up the WVal. */
67
+ SixModelObject res = tc .gc .scs .get (sc ).root_objects .get ((int )idx );
68
+
69
+ /* Update this callsite, so that we never run the lookup again and instead
70
+ * just always use the resolved object. Discards incoming arguments, as
71
+ * they are no longer needed. */
72
+ cs .setTarget (MethodHandles .dropArguments (
73
+ MethodHandles .constant (SixModelObject .class , res ),
74
+ 0 , ThreadContext .class ));
75
+
76
+ /* Hand back the resulting object, for this first call. */
77
+ return res ;
78
+ }
79
+
44
80
public static CallSite subcall (Lookup caller , String _, MethodType type , String name , int csIdx ) {
45
81
try {
46
82
/* Look up subcall resolver method. */
0 commit comments