|
31 | 31 | import com.headius.invokebinder.SmartBinder; |
32 | 32 | import com.headius.invokebinder.SmartHandle; |
33 | 33 | import org.jcodings.Encoding; |
34 | | -import org.jcodings.EncodingDB; |
35 | 34 | import org.jruby.Ruby; |
36 | 35 | import org.jruby.RubyArray; |
37 | 36 | import org.jruby.RubyBasicObject; |
|
87 | 86 | import org.jruby.util.ByteList; |
88 | 87 | import org.jruby.util.CodegenUtils; |
89 | 88 | import org.jruby.util.JavaNameMangler; |
90 | | -import org.jruby.util.StringSupport; |
91 | 89 | import org.jruby.util.cli.Options; |
92 | 90 | import org.jruby.util.log.Logger; |
93 | 91 | import org.jruby.util.log.LoggerFactory; |
@@ -126,55 +124,8 @@ public class Bootstrap { |
126 | 124 | public final static String BOOTSTRAP_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, int.class); |
127 | 125 | private static final Logger LOG = LoggerFactory.getLogger(Bootstrap.class); |
128 | 126 | static final Lookup LOOKUP = MethodHandles.lookup(); |
129 | | - public static final Handle EMPTY_STRING_BOOTSTRAP = new Handle( |
130 | | - Opcodes.H_INVOKESTATIC, |
131 | | - p(Bootstrap.class), |
132 | | - "emptyString", |
133 | | - sig(CallSite.class, Lookup.class, String.class, MethodType.class, String.class), |
134 | | - false); |
135 | | - public static final Handle BUFFER_STRING_BOOTSTRAP = new Handle( |
136 | | - Opcodes.H_INVOKESTATIC, |
137 | | - p(Bootstrap.class), |
138 | | - "bufferString", |
139 | | - sig(CallSite.class, Lookup.class, String.class, MethodType.class, String.class, int.class), |
140 | | - false); |
141 | 127 | private static final String[] GENERIC_CALL_PERMUTE = {"context", "self", "arg.*"}; |
142 | 128 |
|
143 | | - public static CallSite string(Lookup lookup, String name, MethodType type, String value, String encodingName, int cr) { |
144 | | - return new ConstantCallSite(insertArguments(STRING_HANDLE, 1, bytelist(value, encodingName), cr)); |
145 | | - } |
146 | | - |
147 | | - private static final MethodHandle STRING_HANDLE = |
148 | | - Binder |
149 | | - .from(RubyString.class, ThreadContext.class, ByteList.class, int.class) |
150 | | - .invokeStaticQuiet(LOOKUP, Bootstrap.class, "string"); |
151 | | - |
152 | | - public static CallSite fstring(Lookup lookup, String name, MethodType type, String value, String encodingName, int cr, String file, int line) { |
153 | | - MutableCallSite site = new MutableCallSite(type); |
154 | | - |
155 | | - site.setTarget(insertArguments(FSTRING_HANDLE, 1, site, bytelist(value, encodingName), cr, file, line)); |
156 | | - |
157 | | - return site; |
158 | | - } |
159 | | - |
160 | | - private static final MethodHandle FSTRING_HANDLE = |
161 | | - Binder |
162 | | - .from(RubyString.class, ThreadContext.class, MutableCallSite.class, ByteList.class, int.class, String.class, int.class) |
163 | | - .invokeStaticQuiet(LOOKUP, Bootstrap.class, "frozenString"); |
164 | | - |
165 | | - public static CallSite emptyString(Lookup lookup, String name, MethodType type, String encodingName) { |
166 | | - RubyString.EmptyByteListHolder holder = RubyString.getEmptyByteList(encodingFromName(encodingName)); |
167 | | - return new ConstantCallSite(insertArguments(STRING_HANDLE, 1, holder.bytes, holder.cr)); |
168 | | - } |
169 | | - |
170 | | - public static CallSite bufferString(Lookup lookup, String name, MethodType type, String encodingName, int size) { |
171 | | - return new ConstantCallSite(insertArguments(BUFFERSTRING_HANDLE, 1, encodingFromName(encodingName), size, StringSupport.CR_7BIT)); |
172 | | - } |
173 | | - |
174 | | - private static final MethodHandle BUFFERSTRING_HANDLE = |
175 | | - Binder |
176 | | - .from(RubyString.class, ThreadContext.class, Encoding.class, int.class, int.class) |
177 | | - .invokeStaticQuiet(LOOKUP, Bootstrap.class, "bufferString"); |
178 | 129 |
|
179 | 130 | public static Handle isNilBoot() { |
180 | 131 | return new Handle( |
@@ -266,36 +217,6 @@ public static boolean isTruthy(IRubyObject obj, RubyNil nil, RubyBoolean.False f |
266 | 217 | } |
267 | 218 | } |
268 | 219 |
|
269 | | - public static CallSite bytelist(Lookup lookup, String name, MethodType type, String value, String encodingName) { |
270 | | - return new ConstantCallSite(constant(ByteList.class, bytelist(value, encodingName))); |
271 | | - } |
272 | | - |
273 | | - public static ByteList bytelist(String value, String encodingName) { |
274 | | - Encoding encoding = encodingFromName(encodingName); |
275 | | - |
276 | | - if (value.length() == 0) { |
277 | | - // special case empty string and don't create a new BL |
278 | | - return RubyString.getEmptyByteList(encoding).bytes; |
279 | | - } |
280 | | - |
281 | | - return new ByteList(RubyEncoding.encodeISO(value), encoding, false); |
282 | | - } |
283 | | - |
284 | | - public static ByteList bytelist(int size, String encodingName) { |
285 | | - Encoding encoding = encodingFromName(encodingName); |
286 | | - |
287 | | - return new ByteList(size, encoding); |
288 | | - } |
289 | | - |
290 | | - private static Encoding encodingFromName(String encodingName) { |
291 | | - Encoding encoding; |
292 | | - EncodingDB.Entry entry = EncodingDB.getEncodings().get(encodingName.getBytes()); |
293 | | - if (entry == null) entry = EncodingDB.getAliases().get(encodingName.getBytes()); |
294 | | - if (entry == null) throw new RuntimeException("could not find encoding: " + encodingName); |
295 | | - encoding = entry.getEncoding(); |
296 | | - return encoding; |
297 | | - } |
298 | | - |
299 | 220 | public static final Handle CALLSITE = new Handle( |
300 | 221 | Opcodes.H_INVOKESTATIC, |
301 | 222 | p(Bootstrap.class), |
@@ -456,33 +377,6 @@ public static CallSite kwargsHash(Lookup lookup, String name, MethodType type) { |
456 | 377 | .from(RubyHash.class, ThreadContext.class, RubyHash.class, IRubyObject[].class) |
457 | 378 | .invokeStaticQuiet(LOOKUP, Bootstrap.class, "kwargsHash"); |
458 | 379 |
|
459 | | - public static Handle string() { |
460 | | - return new Handle( |
461 | | - Opcodes.H_INVOKESTATIC, |
462 | | - p(Bootstrap.class), |
463 | | - "string", |
464 | | - sig(CallSite.class, Lookup.class, String.class, MethodType.class, String.class, String.class, int.class), |
465 | | - false); |
466 | | - } |
467 | | - |
468 | | - public static Handle fstring() { |
469 | | - return new Handle( |
470 | | - Opcodes.H_INVOKESTATIC, |
471 | | - p(Bootstrap.class), |
472 | | - "fstring", |
473 | | - sig(CallSite.class, Lookup.class, String.class, MethodType.class, String.class, String.class, int.class, String.class, int.class), |
474 | | - false); |
475 | | - } |
476 | | - |
477 | | - public static Handle bytelist() { |
478 | | - return new Handle( |
479 | | - Opcodes.H_INVOKESTATIC, |
480 | | - p(Bootstrap.class), |
481 | | - "bytelist", |
482 | | - sig(CallSite.class, Lookup.class, String.class, MethodType.class, String.class, String.class), |
483 | | - false); |
484 | | - } |
485 | | - |
486 | 380 | public static Handle array() { |
487 | 381 | return new Handle( |
488 | 382 | Opcodes.H_INVOKESTATIC, |
@@ -523,23 +417,6 @@ public static Handle global() { |
523 | 417 | false); |
524 | 418 | } |
525 | 419 |
|
526 | | - public static RubyString string(ThreadContext context, ByteList value, int cr) { |
527 | | - return RubyString.newStringShared(context.runtime, value, cr); |
528 | | - } |
529 | | - |
530 | | - public static RubyString bufferString(ThreadContext context, Encoding encoding, int size, int cr) { |
531 | | - return RubyString.newString(context.runtime, new ByteList(size, encoding), cr); |
532 | | - } |
533 | | - |
534 | | - public static RubyString frozenString(ThreadContext context, MutableCallSite site, ByteList value, int cr, String file, int line) { |
535 | | - RubyString frozen = IRRuntimeHelpers.newFrozenString(context, value, cr, file, line); |
536 | | - |
537 | | - // Permanently bind to the new frozen string |
538 | | - site.setTarget(dropArguments(constant(RubyString.class, frozen), 0, ThreadContext.class)); |
539 | | - |
540 | | - return frozen; |
541 | | - } |
542 | | - |
543 | 420 | public static RubyArray array(ThreadContext context, IRubyObject[] ary) { |
544 | 421 | assert ary.length > RubyArraySpecialized.MAX_PACKED_SIZE; |
545 | 422 | // Bootstrap.array() only dispatches here if ^^ holds |
|
0 commit comments