Skip to content

Commit

Permalink
Showing 4 changed files with 10 additions and 47 deletions.
8 changes: 0 additions & 8 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -478,14 +478,6 @@ public static IRubyObject yieldSpecific(ThreadContext context, Block b) {
return b.yieldSpecific(context);
}

public static IRubyObject yieldValues(ThreadContext context, Block b, IRubyObject arg0, IRubyObject arg1) {
return b.yieldValues(context, new IRubyObject[] {arg0, arg1});
}

public static IRubyObject yieldSpecific(ThreadContext context, Block b, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
return b.yieldValues(context, new IRubyObject[]{arg0, arg1, arg2});
}

public static IRubyObject[] convertValueIntoArgArray(ThreadContext context, IRubyObject value, int blockArity, boolean argIsArray) {
// SSS FIXME: This should not really happen -- so, some places in the runtime library are breaking this contract.
if (argIsArray && !(value instanceof RubyArray)) argIsArray = false;
Original file line number Diff line number Diff line change
@@ -818,18 +818,17 @@ public void setGlobalVariable(String name) {

@Override
public void yield(boolean unwrap) {
adapter.ldc(unwrap);
invokeIRHelper("yield", sig(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class, boolean.class));
adapter.invokedynamic("yield", sig(JVM.OBJECT, params(ThreadContext.class, Block.class, JVM.OBJECT)), YieldSite.BOOTSTRAP, unwrap ? 1 : 0);
}

@Override
public void yieldSpecific() {
invokeIRHelper("yieldSpecific", sig(IRubyObject.class, ThreadContext.class, Block.class));
adapter.invokedynamic("yieldSpecific", sig(JVM.OBJECT, params(ThreadContext.class, Block.class)), YieldSite.BOOTSTRAP, 0);
}

@Override
public void yieldValues(int arity) {
invokeIRHelper("yieldValues", sig(IRubyObject.class, params(ThreadContext.class, Block.class, IRubyObject.class, arity)));
adapter.invokedynamic("yieldValues", sig(JVM.OBJECT, params(ThreadContext.class, Block.class, JVM.OBJECT, arity)), YieldSite.BOOTSTRAP, 0);
}

@Override
15 changes: 0 additions & 15 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter7.java
Original file line number Diff line number Diff line change
@@ -303,21 +303,6 @@ public void checkpoint() {
Bootstrap.checkpointHandle());
}

@Override
public void yield(boolean unwrap) {
adapter.invokedynamic("yield", sig(JVM.OBJECT, params(ThreadContext.class, Block.class, JVM.OBJECT)), YieldSite.BOOTSTRAP, unwrap ? 1 : 0);
}

@Override
public void yieldSpecific() {
adapter.invokedynamic("yieldSpecific", sig(JVM.OBJECT, params(ThreadContext.class, Block.class)), YieldSite.BOOTSTRAP, 0);
}

@Override
public void yieldValues(int arity) {
adapter.invokedynamic("yieldValues", sig(JVM.OBJECT, params(ThreadContext.class, Block.class, JVM.OBJECT, arity)), YieldSite.BOOTSTRAP, 0);
}

@Override
public void prepareBlock(Handle handle, org.jruby.runtime.Signature signature, String className) {
Handle scopeHandle = new Handle(Opcodes.H_GETSTATIC, getClassData().clsName, handle.getName() + "_IRScope", ci(IRScope.class));
27 changes: 7 additions & 20 deletions core/src/main/java/org/jruby/ir/targets/YieldSite.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.CompiledIRBlockBody;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.objectweb.asm.Handle;
@@ -45,16 +46,10 @@ public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, Metho
.invokeVirtual(lookup, name);
break;
case "yieldValues":
if (type.parameterCount() > 5) {
handle = Binder.from(type)
.collect(2, IRubyObject[].class)
.prepend(YieldSite.class, site)
.invokeVirtual(lookup, name);
} else {
handle = Binder.from(type)
.prepend(YieldSite.class, site)
.invokeVirtual(lookup, name);
}
handle = Binder.from(type)
.collect(2, IRubyObject[].class)
.prepend(YieldSite.class, site)
.invokeVirtual(lookup, name);
break;
default:
throw new RuntimeException("invalid yield type: " + name);
@@ -89,7 +84,7 @@ public IRubyObject yield(ThreadContext context, Block block, IRubyObject arg) th
// return (IRubyObject)target.invokeExact(context, block, arg);

// Fully MH-based dispatch for these still seems slower than megamorphic path
return block.yield(context, arg);
return IRRuntimeHelpers.yield(context, block, arg, unwrap);
}

public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Throwable {
@@ -116,15 +111,7 @@ public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Thro
// return (IRubyObject)target.invokeExact(context, block);

// Fully MH-based dispatch for these still seems slower than megamorphic path
return block.yieldSpecific(context);
}

public IRubyObject yieldValues(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1) {
return block.yieldSpecific(context, arg0, arg1);
}

public IRubyObject yieldValues(ThreadContext context, Block block, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
return block.yieldSpecific(context, arg0, arg1, arg2);
return IRRuntimeHelpers.yieldSpecific(context, block);
}

public IRubyObject yieldValues(ThreadContext context, Block block, IRubyObject[] args) {

0 comments on commit 35d7e5b

Please sign in to comment.