Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a480e8abf3af
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 73a35b7fba4e
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 2, 2018

  1. Remove dead code.

    headius committed Mar 2, 2018
    Copy the full SHA
    66a34b4 View commit details
  2. Retrieve operands once.

    headius committed Mar 2, 2018
    Copy the full SHA
    c48a581 View commit details
  3. Copy the full SHA
    73a35b7 View commit details
Original file line number Diff line number Diff line change
@@ -146,15 +146,6 @@ public void inject() {
*/
@Override
public void remove() {
final ThreadContext context = getCurrentContext();
try {
DynamicScope currentScope = context.getCurrentScope();
ManyVarsDynamicScope scope = (ManyVarsDynamicScope) context.getCurrentScope();
scope = new ManyVarsDynamicScope(context.runtime.getStaticScopeFactory().newEvalScope(currentScope.getStaticScope()), currentScope);
}
catch (ArrayIndexOutOfBoundsException e) {
//no context is left.
//no operation is needed.
}
// FIXME: Code originally here did not appear to actually do anything, so it was removed.
}
}
Original file line number Diff line number Diff line change
@@ -89,14 +89,13 @@ public String[] toStringNonOperandArgs() {
}

public IRubyObject callHelper(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block.Type blockType) {
StaticScope scope = currDynScope.getStaticScope();
Operand[] operands = getOperands();

if (helperMethod == Methods.IS_DEFINED_BACKREF) {
return IRRuntimeHelpers.isDefinedBackref(
context,
(IRubyObject) getOperands()[0].retrieve(context, self, currScope, currDynScope, temp));
(IRubyObject) operands[0].retrieve(context, self, currScope, currDynScope, temp));
}
Operand[] operands = getOperands();

switch (helperMethod) {
case IS_DEFINED_NTH_REF:
216 changes: 108 additions & 108 deletions core/src/main/java/org/jruby/runtime/CompiledIRBlockBody.java
Original file line number Diff line number Diff line change
@@ -20,33 +20,33 @@ public CompiledIRBlockBody(MethodHandle handle, IRScope closure, long encodedSig
closure.getStaticScope().determineModule();
}

private static final MethodHandle FOLD_METHOD1 = Binder.from(String.class, ThreadContext.class, Block.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldMethod");
private static String foldMethod(ThreadContext context, Block block) {
return block.getBinding().getMethod();
}

private static final MethodHandle FOLD_TYPE1 = Binder.from(Block.Type.class, String.class, ThreadContext.class, Block.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldType");
private static Block.Type foldType(String name, ThreadContext context, Block block) {
return block.type;
}

private static final MethodHandle FOLD_METHOD2 = Binder.from(String.class, ThreadContext.class, Block.class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldMethod");
private static String foldMethod(ThreadContext context, Block block, IRubyObject arg) {
return block.getBinding().getMethod();
}

private static final MethodHandle FOLD_TYPE2 = Binder.from(Block.Type.class, String.class, ThreadContext.class, Block.class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldType");
private static Block.Type foldType(String name, ThreadContext context, Block block, IRubyObject arg) {
return block.type;
}

private static final MethodHandle SET_NORMAL = Binder.from(void.class, ThreadContext.class, Block.class).drop(1).append(Block.Type.NORMAL).invokeVirtualQuiet(MethodHandles.lookup(), "setCurrentBlockType");

private static final MethodHandle VALUE_TO_ARRAY = Binder.from(IRubyObject[].class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), IRRuntimeHelpers.class, "singleBlockArgToArray");

private static final MethodHandle WRAP_VALUE = Binder.from(IRubyObject[].class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "wrapValue");

private static IRubyObject[] wrapValue(IRubyObject value) { return new IRubyObject[] {value}; }
// private static final MethodHandle FOLD_METHOD1 = Binder.from(String.class, ThreadContext.class, Block.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldMethod");
// private static String foldMethod(ThreadContext context, Block block) {
// return block.getBinding().getMethod();
// }
//
// private static final MethodHandle FOLD_TYPE1 = Binder.from(Block.Type.class, String.class, ThreadContext.class, Block.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldType");
// private static Block.Type foldType(String name, ThreadContext context, Block block) {
// return block.type;
// }
//
// private static final MethodHandle FOLD_METHOD2 = Binder.from(String.class, ThreadContext.class, Block.class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldMethod");
// private static String foldMethod(ThreadContext context, Block block, IRubyObject arg) {
// return block.getBinding().getMethod();
// }
//
// private static final MethodHandle FOLD_TYPE2 = Binder.from(Block.Type.class, String.class, ThreadContext.class, Block.class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "foldType");
// private static Block.Type foldType(String name, ThreadContext context, Block block, IRubyObject arg) {
// return block.type;
// }
//
// private static final MethodHandle SET_NORMAL = Binder.from(void.class, ThreadContext.class, Block.class).drop(1).append(Block.Type.NORMAL).invokeVirtualQuiet(MethodHandles.lookup(), "setCurrentBlockType");
//
// private static final MethodHandle VALUE_TO_ARRAY = Binder.from(IRubyObject[].class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), IRRuntimeHelpers.class, "singleBlockArgToArray");
//
// private static final MethodHandle WRAP_VALUE = Binder.from(IRubyObject[].class, IRubyObject.class).invokeStaticQuiet(MethodHandles.lookup(), CompiledIRBlockBody.class, "wrapValue");
//
// private static IRubyObject[] wrapValue(IRubyObject value) { return new IRubyObject[] {value}; }

@Override
public ArgumentDescriptor[] getArgumentDescriptors() {
@@ -62,87 +62,87 @@ public MethodHandle getHandle() {
return handle;
}

protected volatile MethodHandle normalYieldSpecificHandle;
protected volatile MethodHandle normalYieldHandle;
protected volatile MethodHandle normalYieldUnwrapHandle;
protected volatile MethodHandle yieldTwoValuesHandle;
protected volatile MethodHandle yieldThreeValuesHandle;

public MethodHandle getNormalYieldSpecificHandle() {
MethodHandle normalYieldSpecificHandle = this.normalYieldSpecificHandle;
if (normalYieldSpecificHandle != null) return normalYieldSpecificHandle;

return this.normalYieldSpecificHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class)
.foldVoid(SET_NORMAL)
.fold(FOLD_METHOD1)
.fold(FOLD_TYPE1)
.append(new Class[] {StaticScope.class, IRubyObject.class, IRubyObject[].class, Block.class},
getStaticScope(), null, null, Block.NULL_BLOCK)
.permute(2, 3, 4, 5, 6, 7, 1, 0)
.invoke(handle);
}

public MethodHandle getNormalYieldHandle() {
MethodHandle normalYieldHandle = this.normalYieldHandle;
if (normalYieldHandle != null) return normalYieldHandle;

return this.normalYieldHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class)
.foldVoid(SET_NORMAL)
.fold(FOLD_METHOD2)
.fold(FOLD_TYPE2)
.filter(4, WRAP_VALUE)
.insert(4, new Class[]{StaticScope.class, IRubyObject.class}, getStaticScope(), null)
.append(Block.class, Block.NULL_BLOCK)
.permute(2, 3, 4, 5, 6, 7, 1, 0)
.invoke(handle);
}

public MethodHandle getNormalYieldUnwrapHandle() {
MethodHandle normalYieldUnwrapHandle = this.normalYieldUnwrapHandle;
if (normalYieldUnwrapHandle != null) return normalYieldUnwrapHandle;

return this.normalYieldUnwrapHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class)
.foldVoid(SET_NORMAL)
.fold(FOLD_METHOD2)
.fold(FOLD_TYPE2)
.filter(4, VALUE_TO_ARRAY)
.insert(4, new Class[] {StaticScope.class, IRubyObject.class}, getStaticScope(), null)
.append(Block.class, Block.NULL_BLOCK)
.permute(2, 3, 4, 5, 6, 7, 1, 0)
.invoke(handle);
}

public MethodHandle getYieldTwoValuesHandle() {
MethodHandle yieldTwoValuesHandle = this.yieldTwoValuesHandle;
if (yieldTwoValuesHandle != null) return yieldTwoValuesHandle;

return this.yieldTwoValuesHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class, IRubyObject.class)
.foldVoid(SET_NORMAL)
.fold(FOLD_METHOD1)
.fold(FOLD_TYPE1)
.collect(5, IRubyObject[].class)
.insert(5, new Class[] {StaticScope.class, IRubyObject.class},
getStaticScope(), null)
.append(new Class[] {Block.class}, Block.NULL_BLOCK)
.permute(2, 3, 4, 5, 6, 7, 1, 0)
.invoke(handle);
}

public MethodHandle getYieldThreeValuesHandle() {
MethodHandle yieldThreeValuesHandle = this.yieldThreeValuesHandle;
if (yieldThreeValuesHandle != null) return yieldThreeValuesHandle;

return this.yieldThreeValuesHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class, IRubyObject.class, IRubyObject.class)
.foldVoid(SET_NORMAL)
.fold(FOLD_METHOD1)
.fold(FOLD_TYPE1)
.collect(5, IRubyObject[].class)
.insert(5, new Class[] {StaticScope.class, IRubyObject.class},
getStaticScope(), null)
.append(new Class[] {Block.class}, Block.NULL_BLOCK)
.permute(2, 3, 4, 5, 6, 7, 1, 0)
.invoke(handle);
}
// protected volatile MethodHandle normalYieldSpecificHandle;
// protected volatile MethodHandle normalYieldHandle;
// protected volatile MethodHandle normalYieldUnwrapHandle;
// protected volatile MethodHandle yieldTwoValuesHandle;
// protected volatile MethodHandle yieldThreeValuesHandle;
//
// public MethodHandle getNormalYieldSpecificHandle() {
// MethodHandle normalYieldSpecificHandle = this.normalYieldSpecificHandle;
// if (normalYieldSpecificHandle != null) return normalYieldSpecificHandle;
//
// return this.normalYieldSpecificHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class)
// .foldVoid(SET_NORMAL)
// .fold(FOLD_METHOD1)
// .fold(FOLD_TYPE1)
// .append(new Class[] {StaticScope.class, IRubyObject.class, IRubyObject[].class, Block.class},
// getStaticScope(), null, null, Block.NULL_BLOCK)
// .permute(2, 3, 4, 5, 6, 7, 1, 0)
// .invoke(handle);
// }
//
// public MethodHandle getNormalYieldHandle() {
// MethodHandle normalYieldHandle = this.normalYieldHandle;
// if (normalYieldHandle != null) return normalYieldHandle;
//
// return this.normalYieldHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class)
// .foldVoid(SET_NORMAL)
// .fold(FOLD_METHOD2)
// .fold(FOLD_TYPE2)
// .filter(4, WRAP_VALUE)
// .insert(4, new Class[]{StaticScope.class, IRubyObject.class}, getStaticScope(), null)
// .append(Block.class, Block.NULL_BLOCK)
// .permute(2, 3, 4, 5, 6, 7, 1, 0)
// .invoke(handle);
// }
//
// public MethodHandle getNormalYieldUnwrapHandle() {
// MethodHandle normalYieldUnwrapHandle = this.normalYieldUnwrapHandle;
// if (normalYieldUnwrapHandle != null) return normalYieldUnwrapHandle;
//
// return this.normalYieldUnwrapHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class)
// .foldVoid(SET_NORMAL)
// .fold(FOLD_METHOD2)
// .fold(FOLD_TYPE2)
// .filter(4, VALUE_TO_ARRAY)
// .insert(4, new Class[] {StaticScope.class, IRubyObject.class}, getStaticScope(), null)
// .append(Block.class, Block.NULL_BLOCK)
// .permute(2, 3, 4, 5, 6, 7, 1, 0)
// .invoke(handle);
// }
//
// public MethodHandle getYieldTwoValuesHandle() {
// MethodHandle yieldTwoValuesHandle = this.yieldTwoValuesHandle;
// if (yieldTwoValuesHandle != null) return yieldTwoValuesHandle;
//
// return this.yieldTwoValuesHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class, IRubyObject.class)
// .foldVoid(SET_NORMAL)
// .fold(FOLD_METHOD1)
// .fold(FOLD_TYPE1)
// .collect(5, IRubyObject[].class)
// .insert(5, new Class[] {StaticScope.class, IRubyObject.class},
// getStaticScope(), null)
// .append(new Class[] {Block.class}, Block.NULL_BLOCK)
// .permute(2, 3, 4, 5, 6, 7, 1, 0)
// .invoke(handle);
// }
//
// public MethodHandle getYieldThreeValuesHandle() {
// MethodHandle yieldThreeValuesHandle = this.yieldThreeValuesHandle;
// if (yieldThreeValuesHandle != null) return yieldThreeValuesHandle;
//
// return this.yieldThreeValuesHandle = Binder.from(IRubyObject.class, ThreadContext.class, Block.class, IRubyObject.class, IRubyObject.class, IRubyObject.class)
// .foldVoid(SET_NORMAL)
// .fold(FOLD_METHOD1)
// .fold(FOLD_TYPE1)
// .collect(5, IRubyObject[].class)
// .insert(5, new Class[] {StaticScope.class, IRubyObject.class},
// getStaticScope(), null)
// .append(new Class[] {Block.class}, Block.NULL_BLOCK)
// .permute(2, 3, 4, 5, 6, 7, 1, 0)
// .invoke(handle);
// }

@Override
protected IRubyObject callDirect(ThreadContext context, Block block, IRubyObject[] args, Block blockArg) {