Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions core/src/main/java/org/jruby/ir/builder/IRBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;

import static org.jruby.api.Warn.warning;
import static org.jruby.ir.IRFlags.*;
Expand All @@ -67,6 +68,7 @@
import static org.jruby.runtime.CallType.NORMAL;
import static org.jruby.runtime.ThreadContext.CALL_KEYWORD;
import static org.jruby.runtime.ThreadContext.CALL_KEYWORD_REST;
import static org.jruby.runtime.ThreadContext.CALL_FORWARDING;
import static org.jruby.util.RubyStringBuilder.str;

public abstract class IRBuilder<U, V, W, X, Y, Z> {
Expand All @@ -87,6 +89,9 @@ public abstract class IRBuilder<U, V, W, X, Y, Z> {
int lastProcessedLineNum = -1;
private Variable currentModuleVariable = null;

// Used for forwarding callInfo in argument-forwarding methods
protected Variable forwardingCallInfo;

// FIXME: AST does not use this but Prism does. AST could put encoding up to RootNode since it is same
protected Encoding encoding;
protected int flipVariableCount = 0;
Expand Down Expand Up @@ -2803,22 +2808,32 @@ protected Operand buildSuper(Variable aResult, U iterNode, U argsNode, int line,
int[] flags = new int[] { 0 };
Operand[] args = setupCallArgs(argsNode, flags);

// propagate callInfo when forwarding arguments
if (forwardingCallInfo != null) flags[0] = CALL_FORWARDING;

determineIfWeNeedLineNumber(line, isNewline, false, false); // backtrace needs line of call in case of exception.
if ((flags[0] & CALL_KEYWORD_REST) != 0) { // {**k}, {**{}, **k}, etc...
Variable test = addResultInstr(new RuntimeHelperCall(temp(), IS_HASH_EMPTY, new Operand[] { args[args.length - 1] }));
if_else(test, tru(),
() -> receiveBreakException(block,
determineSuperInstr(result, removeArg(args), block, flags[0], inClassBody, isInstanceMethod)),
determineSuperInstr(result, removeArg(args), block, forwardingCallInfo, flags[0], inClassBody, isInstanceMethod)),
() -> receiveBreakException(block,
determineSuperInstr(result, args, block, flags[0], inClassBody, isInstanceMethod)));
determineSuperInstr(result, args, block, forwardingCallInfo, flags[0], inClassBody, isInstanceMethod)));
} else {
receiveBreakException(block,
determineSuperInstr(result, args, block, flags[0], inClassBody, isInstanceMethod));
determineSuperInstr(result, args, block, forwardingCallInfo, flags[0], inClassBody, isInstanceMethod));
}

return result;
}

private CallInstr forwardCallInfo(Operand forwardingCallInfo, Supplier<CallInstr> operandToWrap) {
if (forwardingCallInfo != null) {
addInstr(new RuntimeHelperCall(temp(), RESTORE_CALL_INFO, new Operand[] { forwardingCallInfo }));
}
return operandToWrap.get();
}

protected Operand buildUndef(Operand name) {
return addResultInstr(new UndefMethodInstr(temp(), name));
}
Expand Down Expand Up @@ -2914,13 +2929,13 @@ protected Operand buildZSuper(Variable result, Operand block) {
Variable test = addResultInstr(new RuntimeHelperCall(temp(), IS_HASH_EMPTY, new Operand[] { keywordRest }));
if_else(test, tru(),
() -> receiveBreakException(block,
determineSuperInstr(zsuperResult, args, block, flags[0], inClassBody, isInstanceMethod)),
determineSuperInstr(zsuperResult, args, block, null, flags[0], inClassBody, isInstanceMethod)),
() -> receiveBreakException(block,
determineSuperInstr(zsuperResult, addArg(args, keywordRest), block, flags[0], inClassBody, isInstanceMethod)));
determineSuperInstr(zsuperResult, addArg(args, keywordRest), block, null, flags[0], inClassBody, isInstanceMethod)));
} else {
Operand[] args = getZSuperCallOperands(scope, callArgs, keywordArgs, flags);
receiveBreakException(block,
determineSuperInstr(zsuperResult, args, block, flags[0], inClassBody, isInstanceMethod));
determineSuperInstr(zsuperResult, args, block, null, flags[0], inClassBody, isInstanceMethod));
}

return zsuperResult;
Expand Down Expand Up @@ -3154,19 +3169,23 @@ protected Variable createCall(Variable result, Operand receiver, CallType callTy
// check for refinement calls before building any closure
if (callType == FUNCTIONAL) determineIfMaybeRefined(name, args);
Operand block = setupCallClosure(argsNode, iter);

// propagate callInfo when forwarding arguments
if (forwardingCallInfo != null) flags[0] = CALL_FORWARDING;

determineIfWeNeedLineNumber(line, isNewline, false, false); // backtrace needs line of call in case of exception.
if ((flags[0] & CALL_KEYWORD_REST) != 0) { // {**k}, {**{}, **k}, etc...
Variable test = addResultInstr(new RuntimeHelperCall(temp(), IS_HASH_EMPTY, new Operand[] { args[args.length - 1] }));
if_else(test, tru(),
() -> receiveBreakException(block,
CallInstr.create(scope, callType, result, name, receiver, removeArg(args), block, flags[0])),
forwardCallInfo(forwardingCallInfo, () -> CallInstr.create(scope, callType, result, name, receiver, removeArg(args), block, flags[0]))),
() -> receiveBreakException(block,
CallInstr.create(scope, callType, result, name, receiver, args, block, flags[0])));
forwardCallInfo(forwardingCallInfo, () -> CallInstr.create(scope, callType, result, name, receiver, args, block, flags[0]))));
} else {
if (callType == FUNCTIONAL) checkForOptimizableDefineMethod(name, iter, block);

receiveBreakException(block,
CallInstr.create(scope, callType, result, name, receiver, args, block, flags[0]));
forwardCallInfo(forwardingCallInfo, () -> CallInstr.create(scope, callType, result, name, receiver, args, block, flags[0])));
}

return result;
Expand Down Expand Up @@ -3205,18 +3224,19 @@ protected void determineIfMaybeRefined(RubySymbol methodName, Operand[] args) {
if (refinement) scope.setIsMaybeUsingRefinements();
}

protected CallInstr determineSuperInstr(Variable result, Operand[] args, Operand block, int flags,
boolean inClassBody, boolean isInstanceMethod) {
if (result == null) result = temp();
return inClassBody ?
isInstanceMethod ?
new InstanceSuperInstr(scope, result, getCurrentModuleVariable(), getName(), args, block, flags, scope.maybeUsingRefinements()) :
new ClassSuperInstr(scope, result, getCurrentModuleVariable(), getName(), args, block, flags, scope.maybeUsingRefinements()) :
// We dont always know the method name we are going to be invoking if the super occurs in a closure.
// This is because the super can be part of a block that will be used by 'define_method' to define
// a new method. In that case, the method called by super will be determined by the 'name' argument
// to 'define_method'.
new UnresolvedSuperInstr(scope, result, buildSelf(), args, block, flags, scope.maybeUsingRefinements());
protected CallInstr determineSuperInstr(Variable result, Operand[] args, Operand block, Operand forwardingCallInfo,
int flags, boolean inClassBody, boolean isInstanceMethod) {
final Variable result2 = result == null ? temp() : result;
return forwardCallInfo(forwardingCallInfo, () ->
inClassBody ?
isInstanceMethod ?
new InstanceSuperInstr(scope, result2, getCurrentModuleVariable(), getName(), args, block, flags, scope.maybeUsingRefinements()) :
new ClassSuperInstr(scope, result2, getCurrentModuleVariable(), getName(), args, block, flags, scope.maybeUsingRefinements()) :
// We dont always know the method name we are going to be invoking if the super occurs in a closure.
// This is because the super can be part of a block that will be used by 'define_method' to define
// a new method. In that case, the method called by super will be determined by the 'name' argument
// to 'define_method'.
new UnresolvedSuperInstr(scope, result2, buildSelf(), args, block, flags, scope.maybeUsingRefinements()));
}

protected Operand findContainerModule() {
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,12 @@ protected void receiveBlockArg(final ArgsNode argsNode) {
public void receiveArgs(final ArgsNode argsNode) {
Signature signature = scope.getStaticScope().getSignature();

// If the method is forwarding arguments, preserve callInfo for later use.
if (scope instanceof IRMethod && scope.getStaticScope().exists(CommonByteLists.FWD_ALL.toString()) >= 0) {
forwardingCallInfo = temp();
addInstr(new RuntimeHelperCall(forwardingCallInfo, CAPTURE_CALL_INFO, Operand.EMPTY_ARRAY));
}

Variable keywords = addResultInstr(new ReceiveKeywordsInstr(temp(), signature.hasRest(), argsNode.hasKwargs()));

KeywordRestArgNode keyRest = argsNode.getKeyRest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum Methods {
IS_DEFINED_BACKREF, IS_DEFINED_NTH_REF, IS_DEFINED_GLOBAL,
IS_DEFINED_CLASS_VAR, IS_DEFINED_SUPER, IS_DEFINED_METHOD, IS_DEFINED_CALL,
IS_DEFINED_CONSTANT_OR_METHOD, MERGE_KWARGS, IS_HASH_EMPTY, HASH_CHECK, ARRAY_LENGTH,
TRACE_RESCUE, RESET_GVAR_UNDERSCORE;
TRACE_RESCUE, RESET_GVAR_UNDERSCORE, CAPTURE_CALL_INFO, RESTORE_CALL_INFO;

private static final Methods[] VALUES = values();

Expand Down Expand Up @@ -108,6 +108,8 @@ public Object callHelper(ThreadContext context, StaticScope currScope, DynamicSc

// These have special operands[0] that we may not want to execute
switch (helperMethod) {
case CAPTURE_CALL_INFO:
return IRRuntimeHelpers.captureCallInfo(context);
case RESET_GVAR_UNDERSCORE:
return context.setErrorInfo((IRubyObject) operands[0].retrieve(context, self, currScope, currDynScope, temp));
case IS_DEFINED_BACKREF:
Expand All @@ -127,6 +129,8 @@ public Object callHelper(ThreadContext context, StaticScope currScope, DynamicSc
case TRACE_RESCUE:
IRRuntimeHelpers.traceRescue(context, ((Stringable) operands[0]).getString(), (int) ((Integer) operands[1]).getValue());
return context.nil;
case RESTORE_CALL_INFO:
return IRRuntimeHelpers.restoreCallInfo(context, (IRubyObject) operands[0].retrieve(context, self, currScope, currDynScope, temp));
}

Object arg1 = operands[0].retrieve(context, self, currScope, currDynScope, temp);
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
private static boolean isRubyExceptionHandled(ThreadContext context, IRubyObject excType, IRubyObject excObj) {
// SSS FIXME: Should this check be "runtime.getModule().isInstance(excType)"??
if (!(excType instanceof RubyModule)) {
throw context.runtime.newTypeError("class or module required for rescue clause. Found: " + excType);

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / Dependency check

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 21 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars,test -Dinvoker.test=extended (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 25 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 21 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain,test -Dinvoker.test=extended (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / regression-specs-jit

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / error-prone (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 26 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pcomplete (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 26 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain,test -Dinvoker.test=extended (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 25 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars,test -Dinvoker.test=extended (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Posgi (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Posgi (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pdist (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pcomplete (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pdist (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / jruby-tests-dev

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 21 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 26)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 26 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / Build JRuby release artifacts (21)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 25 -indy)

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / Verify build artifacts

[deprecation] newTypeError(String) in Ruby has been deprecated

Check warning on line 446 in core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby_complete_jar_extended -Dinvoker.skip=true (Java 25)

[deprecation] newTypeError(String) in Ruby has been deprecated
}

if (((RubyModule) excType).callMethod(context, "===", excObj).isTrue()) {
Expand Down Expand Up @@ -961,6 +961,10 @@

@JIT @Interp
public static void setCallInfo(ThreadContext context, int flags) {
// Forwarding args set callInfo elsewhere based on the incoming call structure.
// We leave them as-is and return.
if ((flags & CALL_FORWARDING) != 0) return;

// CALL_KEYWORD_EMPTY is set dynamically while building this call's arguments (argsPush,
// isHashEmpty, irSplat) when a keyword-rest or splat turns out to be empty, and it must
// survive into the call so the callee treats the kwargs as explicitly empty. It is only
Expand All @@ -976,6 +980,17 @@
}
}

@JIT @Interp
public static RubyFixnum captureCallInfo(ThreadContext context) {
return context.runtime.newFixnum(context.callInfo);
}

@JIT @Interp
public static IRubyObject restoreCallInfo(ThreadContext context, IRubyObject callInfo) {
context.callInfo = (int) ((RubyFixnum) callInfo).getValue();
return callInfo;
}

public static void checkForExtraUnwantedKeywordArgs(ThreadContext context, final StaticScope scope, RubyHash keywordArgs) {
// we do an inexpensive non-gathering scan first to see if there's a bad keyword
try {
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,17 @@ public void ReturnOrRethrowSavedExcInstr(ReturnOrRethrowSavedExcInstr instr) {
@Override
public void RuntimeHelperCall(RuntimeHelperCall runtimehelpercall) {
switch (runtimehelpercall.getHelperMethod()) {
case CAPTURE_CALL_INFO:
jvmMethod().loadContext();
jvmMethod().invokeIRHelper("captureCallInfo", sig(RubyFixnum.class, ThreadContext.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case RESTORE_CALL_INFO:
jvmMethod().loadContext();
visit(runtimehelpercall.getArgs()[0]);
jvmMethod().invokeIRHelper("restoreCallInfo", sig(IRubyObject.class, ThreadContext.class, IRubyObject.class));
jvmStoreLocal(runtimehelpercall.getResult());
break;
case RESET_GVAR_UNDERSCORE:
jvmMethod().loadContext();
visit(runtimehelpercall.getArgs()[0]);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/runtime/ThreadContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
// generally live detected info at a callsite that we are passing an empty hash as kwrest.
// it is also statically determined by literal **{} (which is only found in test suites).
public final static int CALL_KEYWORD_EMPTY = 1 << 3;
// The callInfo for this call has been restored from an enclosing forwarding argument list.
public final static int CALL_FORWARDING = 1 << 4;

public int callInfo;

Expand Down Expand Up @@ -236,7 +238,7 @@
}

@Override
protected void finalize() throws Throwable {

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / Dependency check

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 21 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jrubyc (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:profiler (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars,test -Dinvoker.test=extended (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 25 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 21 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain,test -Dinvoker.test=extended (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / regression-specs-jit

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / error-prone (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:jruby (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 26 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ffi (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pcomplete (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ji (Java 26 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:regression (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pmain,test -Dinvoker.test=extended (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:compiler (Java 25 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake spec:ruby:debug (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby-jars,test -Dinvoker.test=extended (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Posgi (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Posgi (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pdist (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pcomplete (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pdist (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / jruby-tests-dev

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 21 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:slow_suites (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:aot (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:int (Java 26)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 26 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / Build JRuby release artifacts (21)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / rake test:jruby:jit (Java 25 -indy)

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / Verify build artifacts

[removal] finalize() in Object has been deprecated and marked for removal

Check warning on line 241 in core/src/main/java/org/jruby/runtime/ThreadContext.java

View workflow job for this annotation

GitHub Actions / mvn -Pjruby_complete_jar_extended -Dinvoker.skip=true (Java 25)

[removal] finalize() in Object has been deprecated and marked for removal
if (thread != null) {
thread.dispose();
}
Expand Down
18 changes: 18 additions & 0 deletions spec/ruby/language/delegation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ def delegate(...)
h2 = a.new.delegate(h)
h2.should.equal?(h)
end

it "preserves positional arguments when forwarding to super" do
forwarding = Module.new
forwarding.module_eval(<<-RUBY)
def initialize(...)
super(...)
end
RUBY

prepended = included = nil
-> {
prepended = Struct.new(:a, :b, :c) { prepend forwarding }.new(1, 2, 3)
included = Struct.new(:a, :b, :c) { include forwarding }.new(1, 2, 3)
}.should_not complain

[prepended.a, prepended.b, prepended.c].should == [1, 2, 3]
[included.a, included.b, included.c].should == [1, 2, 3]
end
end

describe "delegation with def(x, ...)" do
Expand Down
Loading