public static RubyString frozenString(MutableCallSite site, ByteList value, int cr, String file, int line, ThreadContext context) throws Throwable { RubyString frozen = IRRuntimeHelpers.newFrozenString(context, value, cr, file, line); MethodHandle handle = Binder.from(RubyString.class, ThreadContext.class) .dropAll() .constant(frozen); site.setTarget(handle); return frozen; }
public static RubyString frozenString(MutableCallSite site, ByteList value, int cr, String file, int line, ThreadContext context) throws Throwable { RubyString frozen = IRRuntimeHelpers.newFrozenString(context, value, cr, file, line); MethodHandle handle = Binder.from(RubyString.class, ThreadContext.class) .dropAll() .constant(frozen); site.setTarget(handle); return frozen; }
public IRubyObject cache(IRubyObject t) { MethodHandle constant = null; if (t instanceof Constantizable) { constant = (MethodHandle) ((Constantizable) t).constant(); } if (constant == null) { constant = Binder.from(type()) .dropAll() .constant(t); } setTarget(constant); return t; }
public IRubyObject cache(IRubyObject t) { MethodHandle constant = null; if (t instanceof Constantizable) { constant = (MethodHandle) ((Constantizable) t).constant(); } if (constant == null) { constant = Binder.from(type()) .dropAll() .constant(t); } setTarget(constant); return t; }
public RubyRegexp construct(ThreadContext context, RubyString[] pieces) throws Throwable { RubyString pattern = RubyRegexp.preprocessDRegexp(context.runtime, pieces, options); RubyRegexp re = RubyRegexp.newDRegexp(context.runtime, pattern, options); re.setLiteral(); if (options.isOnce()) { if (cache != null) { // we cached a value, so re-call this site's target handle to get it return cache; } // we don't care if this succeeds, just that it only gets set once UPDATER.compareAndSet(this, null, cache); setTarget(Binder.from(type()).dropAll().constant(cache)); } return re; } }
public RubyRegexp construct(ThreadContext context, RubyString[] pieces) throws Throwable { RubyString pattern = RubyRegexp.preprocessDRegexp(context.runtime, pieces, options); RubyRegexp re = RubyRegexp.newDRegexp(context.runtime, pattern, options); re.setLiteral(); if (options.isOnce()) { if (cache != null) { // we cached a value, so re-call this site's target handle to get it return cache; } // we don't care if this succeeds, just that it only gets set once UPDATER.compareAndSet(this, null, cache); setTarget(Binder.from(type()).dropAll().constant(cache)); } return re; } }