@Override public DynamicMethod dup() { return new CompiledIRMethod(method, name, file, line, scope, visibility, implementationClass); }
public static IRubyObject invokeModuleBody(ThreadContext context, CompiledIRMethod method) { RubyModule implClass = method.getImplementationClass(); return method.call(context, implClass, implClass, ""); }
public CompiledIRMethod(MethodHandle method, String name, String file, int line, StaticScope scope, Visibility visibility, RubyModule implementationClass) { super(implementationClass, visibility, CallConfiguration.FrameNoneScopeNone); this.method = method; this.name = name; this.file = file; this.line = line; this.scope = scope; this.arity = calculateArity(); setHandle(method); }
if (method.getImplementationClass().getMethodLocation().isSingleton()) { IRubyObject possibleRealClass = ((MetaClass) method.getImplementationClass()).getAttached(); if (possibleRealClass instanceof RubyModule) { excludeModuleName = "Meta:" + ((RubyModule) possibleRealClass).getName(); || jitCompiler.config.getExcludedMethods().contains(excludeModuleName + '#' + methodName) || jitCompiler.config.getExcludedMethods().contains(methodName))) { method.setCallCount(-1); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "skipping method: " + excludeModuleName + '#' + methodName); String key = SexpMaker.sha1(method.getIRScope()); Ruby runtime = jitCompiler.runtime; JVMVisitor visitor = new JVMVisitor(runtime); Class sourceClass = visitor.defineFromBytecode(method.getIRScope(), generator.bytecode(), new OneShotClassLoader(runtime.getJRubyClassLoader())); return; } else { generator.updateCounters(jitCompiler.counts, method.ensureInstrsReady()); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "live compiled methods: " + methodCount); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), className + '.' + methodName, "done jitting"); method.setVariable(variable); if (signatures.size() != 0) { for (IntHashMap.Entry<MethodType> entry : signatures.entrySet()) { method.setSpecific(JITCompiler.PUBLIC_LOOKUP.findStatic(sourceClass, context.getSpecificName(), entry.getValue()));
mh = (MethodHandle)compiledIRMethod.getHandle(); } else if (site.arity == 0) { MethodHandle specific; if ((specific = compiledIRMethod.getHandleFor(site.arity)) != null) { mh = specific; } else { mh = (MethodHandle)compiledIRMethod.getHandle(); binder = binder.insert(2, "args", IRubyObject.NULL_ARRAY); if ((specific = compiledIRMethod.getHandleFor(site.arity)) != null) { mh = specific; } else { mh = (MethodHandle) compiledIRMethod.getHandle(); binder = binder.collect("args", "arg.*"); .insert(1, "scope", StaticScope.class, compiledIRMethod.getStaticScope()) .append("class", RubyModule.class, compiledIRMethod.getImplementationClass()) .append("frameName", String.class, site.name());
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { if (IRRuntimeHelpers.isDebug()) { // FIXME: name should probably not be "" ever. String realName = name == null || "".equals(name) ? this.name : name; LOG.info("Executing '" + realName + "'"); } try { // update call stacks (push: frame, class, scope, etc.) RubyModule implementationClass = getImplementationClass(); context.preMethodFrameAndScope(implementationClass, name, self, block, scope); context.setCurrentVisibility(getVisibility()); return (IRubyObject)this.method.invokeWithArguments(context, scope, self, args, block); } catch (Throwable t) { Helpers.throwException(t); // not reached return null; } finally { // update call stacks (pop: ..) context.popFrame(); context.postMethodScopeOnly(); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0) { if (specificArity != 1) return call(context, self, clazz, name, new IRubyObject[]{arg0}, Block.NULL_BLOCK); try { return (IRubyObject) this.specific.invokeExact(context, staticScope, self, arg0, Block.NULL_BLOCK, implementationClass.getMethodLocation(), name); } catch (Throwable t) { Helpers.throwException(t); return null; // not reached } }
mh = (MethodHandle)((CompiledIRMethod)method).getHandle(); mh = MethodHandles.insertArguments(mh, 1, ((CompiledIRMethod)method).getStaticScope());
public CompiledIRMethod(MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, Visibility visibility, RubyModule implementationClass) { super(method, visibility, implementationClass); this.variable = variable; this.specific = specific; // deopt unboxing if we have to process kwargs hash (although this really has nothing to do with arg // unboxing -- it was a simple path to hacking this in). this.specificArity = method.receivesKeywordArgs() ? -1 : specificArity; this.method.getStaticScope().determineModule(); assert method.hasExplicitCallProtocol(); setHandle(variable); method.compilable = this; }
if (method.getImplementationClass().getMethodLocation().isSingleton()) { IRubyObject possibleRealClass = ((MetaClass) method.getImplementationClass()).getAttached(); if (possibleRealClass instanceof RubyModule) { excludeModuleName = "Meta:" + ((RubyModule) possibleRealClass).getName(); || jitCompiler.config.getExcludedMethods().contains(excludeModuleName + '#' + methodName) || jitCompiler.config.getExcludedMethods().contains(methodName))) { method.setCallCount(-1); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "skipping method: " + excludeModuleName + '#' + methodName); String key = SexpMaker.sha1(method.getIRScope()); Ruby runtime = jitCompiler.runtime; JVMVisitor visitor = new JVMVisitor(runtime); Class sourceClass = visitor.defineFromBytecode(method.getIRScope(), generator.bytecode(), new OneShotClassLoader(runtime.getJRubyClassLoader())); return; } else { generator.updateCounters(jitCompiler.counts, method.ensureInstrsReady()); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "live compiled methods: " + methodCount); JITCompiler.log(method.getImplementationClass(), method.getFile(), method.getLine(), className + '.' + methodName, "done jitting"); method.setVariable(variable); if (signatures.size() != 0) { for (IntHashMap.Entry<MethodType> entry : signatures.entrySet()) { method.setSpecific(JITCompiler.PUBLIC_LOOKUP.findStatic(sourceClass, context.getSpecificName(), entry.getValue()));
mh = (MethodHandle)compiledIRMethod.getHandle(); } else if (site.arity == 0) { MethodHandle specific; if ((specific = compiledIRMethod.getHandleFor(site.arity)) != null) { mh = specific; } else { mh = (MethodHandle)compiledIRMethod.getHandle(); binder = binder.insert(2, "args", IRubyObject.NULL_ARRAY); if ((specific = compiledIRMethod.getHandleFor(site.arity)) != null) { mh = specific; } else { mh = (MethodHandle) compiledIRMethod.getHandle(); binder = binder.collect("args", "arg.*"); .insert(1, "scope", StaticScope.class, compiledIRMethod.getStaticScope()) .append("class", RubyModule.class, compiledIRMethod.getImplementationClass()) .append("frameName", String.class, site.name());
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { if (IRRuntimeHelpers.isDebug()) { // FIXME: name should probably not be "" ever. String realName = name == null || "".equals(name) ? this.name : name; LOG.info("Executing '" + realName + "'"); } try { // update call stacks (push: frame, class, scope, etc.) RubyModule implementationClass = getImplementationClass(); context.preMethodFrameAndScope(implementationClass, name, self, block, scope); context.setCurrentVisibility(getVisibility()); return (IRubyObject)this.method.invokeWithArguments(context, scope, self, arg0, arg1, arg2, block); } catch (Throwable t) { Helpers.throwException(t); // not reached return null; } finally { // update call stacks (pop: ..) context.popFrame(); context.postMethodScopeOnly(); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (specificArity != 2) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}, Block.NULL_BLOCK); try { return (IRubyObject) this.specific.invokeExact(context, staticScope, self, arg0, arg1, Block.NULL_BLOCK, implementationClass.getMethodLocation(), name); } catch (Throwable t) { Helpers.throwException(t); return null; // not reached } }
mh = (MethodHandle)((CompiledIRMethod)method).getHandle(); mh = MethodHandles.insertArguments(mh, 1, ((CompiledIRMethod)method).getStaticScope());
public CompiledIRMethod(MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, Visibility visibility, RubyModule implementationClass) { super(method, visibility, implementationClass); this.variable = variable; this.specific = specific; // deopt unboxing if we have to process kwargs hash (although this really has nothing to do with arg // unboxing -- it was a simple path to hacking this in). this.specificArity = method.receivesKeywordArgs() ? -1 : specificArity; this.method.getStaticScope().determineModule(); assert method.hasExplicitCallProtocol(); setHandle(variable); method.compilable = this; }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { if (IRRuntimeHelpers.isDebug()) { // FIXME: name should probably not be "" ever. String realName = name == null || "".equals(name) ? this.name : name; LOG.info("Executing '" + realName + "'"); } try { // update call stacks (push: frame, class, scope, etc.) RubyModule implementationClass = getImplementationClass(); context.preMethodFrameAndScope(implementationClass, name, self, block, scope); context.setCurrentVisibility(getVisibility()); return (IRubyObject)this.method.invokeWithArguments(context, scope, self, block); } catch (Throwable t) { Helpers.throwException(t); // not reached return null; } finally { // update call stacks (pop: ..) context.popFrame(); context.postMethodScopeOnly(); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1) { if (specificArity != 2) return call(context, self, clazz, name, new IRubyObject[] {arg0, arg1}, Block.NULL_BLOCK); try { return (IRubyObject) this.specific.invokeExact(context, staticScope, self, arg0, arg1, Block.NULL_BLOCK, implementationClass.getMethodLocation(), name); } catch (Throwable t) { Helpers.throwException(t); return null; // not reached } }
@Override public DynamicMethod dup() { return new CompiledIRMethod(method, name, file, line, scope, visibility, implementationClass); }
public static IRubyObject invokeModuleBody(ThreadContext context, CompiledIRMethod method) { RubyModule implClass = method.getImplementationClass(); return method.call(context, implClass, implClass, ""); }
public CompiledIRMethod(MethodHandle method, String name, String file, int line, StaticScope scope, Visibility visibility, RubyModule implementationClass) { super(implementationClass, visibility, CallConfiguration.FrameNoneScopeNone); this.method = method; this.name = name; this.file = file; this.line = line; this.scope = scope; this.arity = calculateArity(); setHandle(method); }