@Override public MethodHandle guardMethodHandle(MethodType inputType) throws Exception { Binder binder = Binder.from(inputType); return binder.drop(0, inputType.parameterCount()) .constant(false); } }
@Override public MethodHandle guardMethodHandle(MethodType inputType) throws Exception { Binder binder = Binder.from(inputType); return binder.drop(0, inputType.parameterCount()) .constant(true); } }
public static Ruby loadRuntime(MutableCallSite site, ThreadContext context) throws Throwable { site.setTarget(Binder.from(Ruby.class, ThreadContext.class).drop(0).constant(context.runtime)); return context.runtime; }
public static IRubyObject loadNil(MutableCallSite site, ThreadContext context) throws Throwable { site.setTarget(Binder.from(IRubyObject.class, ThreadContext.class).drop(0).constant(context.nil)); return context.nil; }
public static IRubyObject loadNil(MutableCallSite site, ThreadContext context) throws Throwable { site.setTarget(Binder.from(IRubyObject.class, ThreadContext.class).drop(0).constant(context.nil)); return context.nil; }
public static Ruby loadRuntime(MutableCallSite site, ThreadContext context) throws Throwable { site.setTarget(Binder.from(Ruby.class, ThreadContext.class).drop(0).constant(context.runtime)); return context.runtime; }
public static IRubyObject fixnum(MutableCallSite site, long value, ThreadContext context) { RubyFixnum fixnum = RubyFixnum.newFixnum(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(fixnum) ); return fixnum; }
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 IRubyObject fixnum(MutableCallSite site, long value, ThreadContext context) { RubyFixnum fixnum = RubyFixnum.newFixnum(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(fixnum) ); return fixnum; }
public static IRubyObject flote(MutableCallSite site, double value, ThreadContext context) { RubyFloat flote = RubyFloat.newFloat(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(flote) ); return flote; } }
public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) { RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(symbol) ); return symbol; }
public static IRubyObject flote(MutableCallSite site, double value, ThreadContext context) { RubyFloat flote = RubyFloat.newFloat(context.runtime, value); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(flote) ); return flote; } }
public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) { RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(symbol) ); return symbol; }
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; } }
private void bind(Ruby runtime, RubyModule module, IRubyObject constant, MethodHandle cachingFallback) { MethodHandle target = Binder.from(type()) .drop(0, 2) .constant(constant); // Get appropriate fallback given state of site MethodHandle fallback = getFallback(module, cachingFallback); // Test that module is same as before target = guardWithTest(module.getIdTest(), target, fallback); // Global invalidation SwitchPoint switchPoint = (SwitchPoint) runtime.getConstantInvalidator(name).getData(); target = switchPoint.guardWithTest(target, fallback); setTarget(target); }
private void bind(Ruby runtime, RubyModule module, IRubyObject constant, MethodHandle cachingFallback) { MethodHandle target = Binder.from(type()) .drop(0, 2) .constant(constant); // Get appropriate fallback given state of site MethodHandle fallback = getFallback(module, cachingFallback); // Test that module is same as before target = guardWithTest(module.getIdTest(), target, fallback); // Global invalidation SwitchPoint switchPoint = (SwitchPoint) runtime.getConstantInvalidator(name).getData(); target = switchPoint.guardWithTest(target, fallback); setTarget(target); }
/** * Apply all transforms to an endpoint that does absolutely nothing. Useful for * creating exception handlers in void methods that simply ignore the exception. * * @return a handle that has all transforms applied and does nothing at its endpoint */ public MethodHandle nop() { if (type().returnType() != void.class) { throw new InvalidTransformException("must have void return type to nop: " + type()); } return invoke(Binder .from(type()) .drop(0, type().parameterCount()) .cast(Object.class) .constant(null)); }