Example #1
0
  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;
  }
Example #2
0
  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);
  }
Example #3
0
 @JIT
 private static RubyString newStringShared(ThreadContext context, ByteList byteList) {
   return RubyString.newStringShared(context.runtime, byteList);
 }