public static RubyString frozenString(MutableCallSite site, ByteList value, ThreadContext context) throws Throwable { RubyString frozen = context.runtime.freezeAndDedupString(RubyString.newStringShared(context.runtime, value)); MethodHandle handle = Binder.from(RubyString.class, ThreadContext.class).dropAll().constant(frozen); site.setTarget(handle); return frozen; }
public static RubyString string(MutableCallSite site, ByteList value, ThreadContext context) throws Throwable { MethodHandle handle = SmartBinder.from(STRING_SIGNATURE) .invoke(NEW_STRING_SHARED_HANDLE.apply("byteList", value)) .handle(); site.setTarget(handle); return RubyString.newStringShared(context.runtime, value); }
@JIT private static RubyString newStringShared(ThreadContext context, ByteList byteList) { return RubyString.newStringShared(context.runtime, byteList); }