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: 8a4ac9cf02d3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: be07196bb2fd
Choose a head ref
  • 6 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 9, 2015

  1. Mark as used by JIT.

    headius committed Apr 9, 2015
    Copy the full SHA
    20e0a16 View commit details
  2. Copy the full SHA
    870aa4a View commit details
  3. Copy the full SHA
    fd67247 View commit details
  4. Copy the full SHA
    730cd7e View commit details
  5. Copy the full SHA
    fba81a9 View commit details
  6. Copy the full SHA
    be07196 View commit details
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyProc.java
Original file line number Diff line number Diff line change
@@ -249,8 +249,8 @@ public static IRubyObject[] prepareArgs(ThreadContext context, Block.Type type,
if (args == null) return IRubyObject.NULL_ARRAY;

if (type == Block.Type.LAMBDA) {
if (blockBody instanceof InterpretedIRBlockBody) {
((InterpretedIRBlockBody) blockBody).getSignature().checkArity(context.runtime, args);
if (blockBody instanceof IRBlockBody) {
((IRBlockBody) blockBody).getSignature().checkArity(context.runtime, args);
} else {
arity.checkArity(context.runtime, args.length);
}
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

/**
@@ -70,8 +71,8 @@ public static ReceivePostReqdArgInstr decode(IRReaderDecoder d) {
return new ReceivePostReqdArgInstr(d.decodeVariable(), d.decodeInt(), d.decodeInt(), d.decodeInt());
}

public IRubyObject receivePostReqdArg(IRubyObject[] args, boolean acceptsKeywordArgument) {
return IRRuntimeHelpers.receivePostReqdArg(args, preReqdArgsCount, postReqdArgsCount, argIndex, acceptsKeywordArgument);
public IRubyObject receivePostReqdArg(ThreadContext context, IRubyObject[] args, boolean acceptsKeywordArgument) {
return IRRuntimeHelpers.receivePostReqdArg(context, args, preReqdArgsCount, postReqdArgsCount, argIndex, acceptsKeywordArgument);
}

@Override
Original file line number Diff line number Diff line change
@@ -247,9 +247,8 @@ protected static void receiveArg(ThreadContext context, Instr i, Operation opera
setResult(temp, currDynScope, instr.getResult(), result);
return;
case RECV_POST_REQD_ARG:
result = ((ReceivePostReqdArgInstr)instr).receivePostReqdArg(args, acceptsKeywordArgument);
// For blocks, missing arg translates to nil
setResult(temp, currDynScope, instr.getResult(), result == null ? context.nil : result);
result = ((ReceivePostReqdArgInstr)instr).receivePostReqdArg(context, args, acceptsKeywordArgument);
setResult(temp, currDynScope, instr.getResult(), result);
return;
case RECV_RUBY_EXC:
setResult(temp, currDynScope, instr.getResult(), IRRuntimeHelpers.unwrapRubyException(exception));
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -489,6 +489,7 @@ public static IRubyObject[] convertValueIntoArgArray(ThreadContext context, IRub
}
}

@JIT
public static Block getBlockFromObject(ThreadContext context, Object value) {
Block block;
if (value instanceof Block) {
@@ -790,11 +791,12 @@ public static IRubyObject constructRestArg(ThreadContext context, Object[] args,
return context.runtime.newArray(restArgs);
}

public static IRubyObject receivePostReqdArg(IRubyObject[] args, int preReqdArgsCount, int postReqdArgsCount, int argIndex, boolean acceptsKeywordArgument) {
@JIT
public static IRubyObject receivePostReqdArg(ThreadContext context, IRubyObject[] args, int preReqdArgsCount, int postReqdArgsCount, int argIndex, boolean acceptsKeywordArgument) {
boolean kwargs = extractKwargsHash(args, preReqdArgsCount + postReqdArgsCount, acceptsKeywordArgument) != null;
int n = kwargs ? args.length - 1 : args.length;
int remaining = n - preReqdArgsCount;
if (remaining <= argIndex) return null; // For blocks!
if (remaining <= argIndex) return context.nil;

return (remaining > postReqdArgsCount) ? args[n - postReqdArgsCount + argIndex] : args[preReqdArgsCount + argIndex];
}
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1546,12 +1546,13 @@ public void ReceivePreReqdArgInstr(ReceivePreReqdArgInstr instr) {

@Override
public void ReceivePostReqdArgInstr(ReceivePostReqdArgInstr instr) {
jvmMethod().loadContext();
jvmMethod().loadArgs();
jvmAdapter().pushInt(instr.preReqdArgsCount);
jvmAdapter().pushInt(instr.postReqdArgsCount);
jvmAdapter().pushInt(instr.getArgIndex());
jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs());
jvmMethod().invokeIRHelper("receivePostReqdArg", sig(IRubyObject.class, IRubyObject[].class, int.class, int.class, int.class, boolean.class));
jvmMethod().invokeIRHelper("receivePostReqdArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, int.class, int.class, boolean.class));
jvmStoreLocal(instr.getResult());
}

34 changes: 27 additions & 7 deletions core/src/main/java/org/jruby/runtime/Signature.java
Original file line number Diff line number Diff line change
@@ -254,22 +254,42 @@ public static Signature from(PostExeNode iter) {
return Signature.NO_ARGUMENTS;
}

private static final int MAX_ENCODED_ARGS_EXPONENT = 8;
private static final int MAX_ENCODED_ARGS_MASK = 0xFF;
private static final int ENCODE_RESTKWARGS_SHIFT = 0;
private static final int ENCODE_REQKWARGS_SHIFT = ENCODE_RESTKWARGS_SHIFT + 1;
private static final int ENCODE_KWARGS_SHIFT = ENCODE_REQKWARGS_SHIFT + 1;
private static final int ENCODE_REST_SHIFT = ENCODE_KWARGS_SHIFT + 1;
private static final int ENCODE_POST_SHIFT = ENCODE_REST_SHIFT + MAX_ENCODED_ARGS_EXPONENT;
private static final int ENCODE_OPT_SHIFT = ENCODE_POST_SHIFT + MAX_ENCODED_ARGS_EXPONENT;
private static final int ENCODE_PRE_SHIFT = ENCODE_OPT_SHIFT + MAX_ENCODED_ARGS_EXPONENT;

public long encode() {
return ((long)pre << 48) | ((long)opt << 32) | ((long)post << 16) | (rest.ordinal() << 8) | (kwargs?1:0);
return
((long)pre << ENCODE_PRE_SHIFT) |
((long)opt << ENCODE_OPT_SHIFT) |
((long)post << ENCODE_POST_SHIFT) |
(rest.ordinal() << ENCODE_REST_SHIFT) |
((kwargs?1:0) << ENCODE_KWARGS_SHIFT) |
((requiredKwargs?1:0) << ENCODE_REQKWARGS_SHIFT) |
((restKwargs?1:0) << ENCODE_RESTKWARGS_SHIFT);
}

public static Signature decode(long l) {
return Signature.from(
(int)(l >> 48) & 0xFFFF,
(int)(l >> 32) & 0xFFFF,
(int)(l >> 16) & 0xFFFF,
Rest.values()[(int)((l >> 8) & 0xFF)],
(l & 0xFF)==1 ? true : false
(int)(l >> ENCODE_PRE_SHIFT) & MAX_ENCODED_ARGS_MASK,
(int)(l >> ENCODE_OPT_SHIFT) & MAX_ENCODED_ARGS_MASK,
(int)(l >> ENCODE_POST_SHIFT) & MAX_ENCODED_ARGS_MASK,
Rest.values()[(int)((l >> ENCODE_REST_SHIFT) & MAX_ENCODED_ARGS_MASK)],
((int)(l >> ENCODE_KWARGS_SHIFT) & 0x1)==1 ? true : false,
((int)(l >> ENCODE_REQKWARGS_SHIFT) & 0x1)==1 ? true : false,
((int)(l >> ENCODE_RESTKWARGS_SHIFT) & 0x1)==1 ? true : false

);
}

public String toString() {
return "signature(pre=" + pre + ",opt=" + opt + ",post=" + post + ",rest=" + rest + ",kwargs=" + kwargs + ")";
return "signature(pre=" + pre + ",opt=" + opt + ",post=" + post + ",rest=" + rest + ",kwargs=" + kwargs + ",kwreq=" + requiredKwargs + ",kwrest=" + restKwargs + ")";
}

public void checkArity(Ruby runtime, IRubyObject[] args) {
4 changes: 0 additions & 4 deletions test/mri/excludes/TestKeywordArguments.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
exclude :test_implicit_hash_conversion, "JIT-only"
exclude :test_lambda, "JIT-only"
exclude :test_p6, "JIT-only"
exclude :test_required_keyword_with_reserved, "needs investigation"
exclude :test_rest_keyrest, "needs investigation"