1
1
package org .jruby .ir .targets ;
2
2
3
- import com .headius .invoke .binder .Binder ;
4
- import org .jcodings .Encoding ;
5
- import org .jcodings .EncodingDB ;
6
- import org .jcodings .specific .USASCIIEncoding ;
3
+ import com .headius .invokebinder .Binder ;
4
+ import org .jruby .RubyArray ;
7
5
import org .jruby .RubyClass ;
8
6
import org .jruby .RubyEncoding ;
9
7
import org .jruby .RubyFixnum ;
10
- import org .jruby .RubyInstanceConfig ;
11
8
import org .jruby .RubyString ;
12
9
import org .jruby .RubySymbol ;
13
10
import org .jruby .internal .runtime .methods .DynamicMethod ;
14
- import org .jruby .javasupport .util .RuntimeHelpers ;
15
11
import org .jruby .runtime .Block ;
16
12
import org .jruby .runtime .CallType ;
17
13
import org .jruby .runtime .ThreadContext ;
18
14
import org .jruby .runtime .builtin .IRubyObject ;
19
15
import org .jruby .runtime .callsite .CacheEntry ;
20
- import org .jruby .runtime .encoding .EncodingService ;
21
- import org .jruby .runtime .invokedynamic .JRubyCallSite ;
22
16
import org .jruby .util .JavaNameMangler ;
23
17
import org .objectweb .asm .Handle ;
24
18
import org .objectweb .asm .Opcodes ;
29
23
import java .lang .invoke .MethodHandles ;
30
24
import java .lang .invoke .MethodType ;
31
25
import java .lang .invoke .MutableCallSite ;
32
- import java .lang .invoke .SwitchPoint ;
33
- import java .util .Arrays ;
34
26
35
- import static org .jruby .runtime .invokedynamic .InvokeDynamicSupport .*;
36
- import static org .jruby .util .CodegenUtils .*;
37
27
import static java .lang .invoke .MethodHandles .*;
38
- import static java .lang .invoke .MethodType .*;
28
+ import static org .jruby .runtime .invokedynamic .InvokeDynamicSupport .*;
29
+ import static org .jruby .util .CodegenUtils .p ;
30
+ import static org .jruby .util .CodegenUtils .sig ;
39
31
40
32
public class Bootstrap {
41
33
public static CallSite string (Lookup lookup , String name , MethodType type , String value , int encoding ) {
@@ -47,6 +39,15 @@ public static CallSite string(Lookup lookup, String name, MethodType type, Strin
47
39
return site ;
48
40
}
49
41
42
+ public static CallSite array (Lookup lookup , String name , MethodType type ) {
43
+ MethodHandle handle = Binder
44
+ .from (type )
45
+ .collect (1 , IRubyObject [].class )
46
+ .invokeStaticQuiet (MethodHandles .lookup (), Bootstrap .class , "array" );
47
+ CallSite site = new ConstantCallSite (handle );
48
+ return site ;
49
+ }
50
+
50
51
private static class InvokeSite extends MutableCallSite {
51
52
public InvokeSite (MethodType type , String name ) {
52
53
super (type );
@@ -117,6 +118,10 @@ public static Handle string() {
117
118
return new Handle (Opcodes .H_INVOKESTATIC , p (Bootstrap .class ), "string" , sig (CallSite .class , Lookup .class , String .class , MethodType .class , String .class , int .class ));
118
119
}
119
120
121
+ public static Handle array () {
122
+ return new Handle (Opcodes .H_INVOKESTATIC , p (Bootstrap .class ), "array" , sig (CallSite .class , Lookup .class , String .class , MethodType .class ));
123
+ }
124
+
120
125
public static Handle invoke () {
121
126
return new Handle (Opcodes .H_INVOKESTATIC , p (Bootstrap .class ), "invoke" , sig (CallSite .class , Lookup .class , String .class , MethodType .class ));
122
127
}
@@ -138,6 +143,10 @@ public static IRubyObject string(String value, int encoding, ThreadContext conte
138
143
return RubyString .newStringNoCopy (context .runtime , value .getBytes (RubyEncoding .ISO ));
139
144
}
140
145
146
+ public static IRubyObject array (ThreadContext context , IRubyObject [] elts ) {
147
+ return RubyArray .newArrayNoCopy (context .runtime , elts );
148
+ }
149
+
141
150
public static IRubyObject invoke (InvokeSite site , ThreadContext context , IRubyObject self ) throws Throwable {
142
151
RubyClass selfClass = pollAndGetClass (context , self );
143
152
String methodName = site .name ;
0 commit comments