Skip to content

Commit

Permalink
Showing 36 changed files with 369 additions and 435 deletions.
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -975,7 +975,7 @@ private Operand receiveBreakException(Operand block, CodeBlock codeBlock) {
addInstr(new LabelInstr(rBeginLabel));
addInstr(new ExceptionRegionStartMarkerInstr(rescueLabel));
Variable callResult = (Variable)codeBlock.run();
addInstr(new JumpInstr(rEndLabel));
addInstr(new JumpInstr(rEndLabel, true));
addInstr(new ExceptionRegionEndMarkerInstr());

// Receive exceptions (could be anything, but the handler only processes IRBreakJumps)
@@ -1331,8 +1331,8 @@ private Operand protectCodeWithRescue(CodeBlock protectedCode, CodeBlock rescueB
addInstr(new ExceptionRegionStartMarkerInstr(rescueLabel));
Object v1 = protectedCode.run(); // YIELD: Run the protected code block
addInstr(new CopyInstr(rv, (Operand)v1));
addInstr(new JumpInstr(rEndLabel, true));
addInstr(new ExceptionRegionEndMarkerInstr());
addInstr(new JumpInstr(rEndLabel));

// SSS FIXME: Create an 'Exception' operand type to eliminate the constant lookup below
// We could preload a set of constant objects that are preloaded at boot time and use them
@@ -3040,7 +3040,7 @@ public Operand buildRescue(RescueNode node) {

private Operand buildRescueInternal(RescueNode rescueNode, EnsureBlockInfo ensure) {
// Labels marking start, else, end of the begin-rescue(-ensure)-end block
Label rBeginLabel = ensure.regionStart;
Label rBeginLabel = getNewLabel();
Label rEndLabel = ensure.end;
Label rescueLabel = getNewLabel(); // Label marking start of the first rescue code.

@@ -3092,7 +3092,7 @@ private Operand buildRescueInternal(RescueNode rescueNode, EnsureBlockInfo ensur
// - If we dont have any ensure blocks, simply jump to the end of the rescue block
// - If we do, execute the ensure code.
ensure.cloneIntoHostScope(this);
addInstr(new JumpInstr(rEndLabel));
addInstr(new JumpInstr(rEndLabel, true));
} //else {
// If the body had an explicit return, the return instruction IR build takes care of setting
// up execution of all necessary ensure blocks. So, nothing to do here!
@@ -3176,7 +3176,7 @@ private void buildRescueBodyInternal(RescueBodyNode rescueBodyNode, Variable rv,
// around the current rescue block)
activeEnsureBlockStack.peek().cloneIntoHostScope(this);

addInstr(new JumpInstr(endLabel));
addInstr(new JumpInstr(endLabel, true));
}
}

16 changes: 14 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/JumpInstr.java
Original file line number Diff line number Diff line change
@@ -9,8 +9,19 @@
import org.jruby.ir.transformations.inlining.CloneInfo;

public class JumpInstr extends Instr implements FixedArityInstr {
final boolean exitsExcRegion;

public JumpInstr(Label target) {
this(target, false);
}

public JumpInstr(Label target, boolean exitsExcRegion) {
super(Operation.JUMP, new Operand[] { target });
this.exitsExcRegion = exitsExcRegion;
}

public boolean exitsExcRegion() {
return this.exitsExcRegion;
}

public Label getJumpTarget() {
@@ -19,17 +30,18 @@ public Label getJumpTarget() {

@Override
public Instr clone(CloneInfo ii) {
return new JumpInstr(ii.getRenamedLabel(getJumpTarget()));
return new JumpInstr(ii.getRenamedLabel(getJumpTarget()), exitsExcRegion);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getJumpTarget());
e.encode(exitsExcRegion);
}

public static JumpInstr decode(IRReaderDecoder d) {
return new JumpInstr(d.decodeLabel());
return new JumpInstr(d.decodeLabel(), d.decodeBoolean());
}

@Override
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,

Operation operation = instr.getOperation();
if (debug) {
Interpreter.LOG.info("I: {" + ipc + "} ", instr);
Interpreter.LOG.info("I: {" + ipc + "} ", instr + "; <#RPCs=" + rescuePCs.size() + ">");
Interpreter.interpInstrsCount++;
} else if (profile) {
Profiler.instrTick(operation);
@@ -81,8 +81,16 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
return processReturnOp(context, instr, operation, currDynScope, temp, self, blockType, currScope);
case BRANCH_OP:
switch (operation) {
case JUMP: ipc = ((JumpInstr)instr).getJumpTarget().getTargetPC(); break;
default: ipc = instr.interpretAndGetNewIPC(context, currDynScope, currScope, self, temp, ipc); break;
case JUMP:
JumpInstr jump = ((JumpInstr)instr);
if (jump.exitsExcRegion()) {
rescuePCs.pop();
}
ipc = jump.getJumpTarget().getTargetPC();
break;
default:
ipc = instr.interpretAndGetNewIPC(context, currDynScope, currScope, self, temp, ipc);
break;
}
break;
case BOOK_KEEPING_OP:
36 changes: 36 additions & 0 deletions lib/ruby/truffle/truffle/zlib.rb
Original file line number Diff line number Diff line change
@@ -8,11 +8,47 @@

module Zlib

BINARY = 0
ASCII = 1
UNKNOWN = 2

DEF_MEM_LEVEL = 8
MAX_MEM_LEVEL = 9

OS_MSDOS = 0
OS_AMIGA = 1
OS_VMS = 2
OS_CODE = 3
OS_UNIX = 3
OS_VMCMS = 4
OS_ATARI = 5
OS_OS2 = 6
OS_MACOS = 7
OS_ZSYSTEM = 8
OS_CPM = 9
OS_TOPS20 = 10
OS_WIN32 = 11
OS_QDOS = 12
OS_RISCOS = 13
OS_UNKNOWN = 255

DEFAULT_STRATEGY = 0
FILTERED = 1
HUFFMAN_ONLY = 2

NO_FLUSH = 0
SYNC_FUSH = 2
FULL_FLUSH = 3
FINISH = 4

NO_COMPRESSION = 0
BEST_SPEED = 1
BEST_COMPRESSION = 9
DEFAULT_COMPRESSION = -1

MAX_WBITS = 15


def self.crc32(*args)
Truffle::Zlib.crc32(*args)
end
6 changes: 3 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyGuards.java
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@
import org.jruby.truffle.nodes.core.MethodNodes;
import org.jruby.truffle.nodes.core.UnboundMethodNodes;
import org.jruby.truffle.runtime.ThreadLocalObject;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.*;

public abstract class RubyGuards {

public static boolean isUndefinedPlaceholder(Object value) {
return value instanceof UndefinedPlaceholder;
public static boolean isNotProvided(Object value) {
return value instanceof NotProvided;
}

public static boolean isBoolean(Object value) {
8 changes: 4 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
import org.jruby.truffle.nodes.instrument.RubyWrapperNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.sockets.NativeSockets;

@@ -66,11 +66,11 @@ public void executeVoid(VirtualFrame frame) {

// Utility methods to execute and expect a particular type

public UndefinedPlaceholder executeUndefinedPlaceholder(VirtualFrame frame) throws UnexpectedResultException {
public NotProvided executeNotProvided(VirtualFrame frame) throws UnexpectedResultException {
final Object value = execute(frame);

if (value instanceof UndefinedPlaceholder) {
return (UndefinedPlaceholder) value;
if (value instanceof NotProvided) {
return (NotProvided) value;
} else {
throw new UnexpectedResultException(value);
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;

/**
* Read pre-optional argument.
@@ -46,7 +46,7 @@ public Object execute(VirtualFrame frame) {
break;

case UNDEFINED:
return UndefinedPlaceholder.INSTANCE;
return NotProvided.INSTANCE;

case NIL:
return nil();
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ public Object execute(VirtualFrame frame) {
}

// It's possible the taintFromParameter value was misconfigured by the user, but the far more likely
// scenario is that the argument at that position is an UndefinedPlaceholder, which doesn't take up
// scenario is that the argument at that position is a NotProvided argument, which doesn't take up
// a space in the frame.
if (taintFromParameter < RubyArguments.getUserArgumentsCount(frame.getArguments())) {
final Object argument = RubyArguments.getUserArgument(frame.getArguments(), taintFromParameter);
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.array.ArrayUtils;
@@ -177,14 +177,14 @@ public InstanceEvalNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object instanceEval(VirtualFrame frame, Object receiver, RubyString string, UndefinedPlaceholder block) {
public Object instanceEval(VirtualFrame frame, Object receiver, RubyString string, NotProvided block) {
CompilerDirectives.transferToInterpreter();

return getContext().instanceEval(string.getByteList(), receiver, this);
}

@Specialization
public Object instanceEval(VirtualFrame frame, Object receiver, UndefinedPlaceholder string, RubyProc block) {
public Object instanceEval(VirtualFrame frame, Object receiver, NotProvided string, RubyProc block) {
return yield.dispatchWithModifiedSelf(frame, block, receiver, receiver);
}

@@ -205,7 +205,7 @@ public Object instanceExec(VirtualFrame frame, Object receiver, Object[] argumen
}

@Specialization
public Object instanceExec(Object receiver, Object[] arguments, UndefinedPlaceholder block) {
public Object instanceExec(Object receiver, Object[] arguments, NotProvided block) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(getContext().getCoreLibrary().localJumpError("no block given", this));
@@ -221,7 +221,7 @@ public MethodMissingNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object methodMissing(Object self, Object[] args, UndefinedPlaceholder block) {
public Object methodMissing(Object self, Object[] args, NotProvided block) {
CompilerDirectives.transferToInterpreter();

return methodMissing(self, args, (RubyProc) null);
@@ -281,7 +281,7 @@ public SendNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object send(VirtualFrame frame, Object self, Object[] args, UndefinedPlaceholder block) {
public Object send(VirtualFrame frame, Object self, Object[] args, NotProvided block) {
return send(frame, self, args, (RubyProc) null);
}

Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;

@@ -661,7 +661,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {

@TruffleBoundary
@Specialization
public RubyString toS(RubyBasicObject value, UndefinedPlaceholder undefined) {
public RubyString toS(RubyBasicObject value, NotProvided base) {
return getContext().makeString(getBigIntegerValue(value).toString());
}

Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
@@ -60,7 +60,7 @@ public NewNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, UndefinedPlaceholder block) {
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, NotProvided block) {
return doNewInstance(frame, rubyClass, args, null);
}

@@ -94,18 +94,18 @@ void moduleInitialize(VirtualFrame frame, RubyClass rubyClass, RubyProc block) {
}

@Specialization
public RubyClass initialize(RubyClass rubyClass, UndefinedPlaceholder superclass, UndefinedPlaceholder block) {
public RubyClass initialize(RubyClass rubyClass, NotProvided superclass, NotProvided block) {
return initialize(rubyClass, getContext().getCoreLibrary().getObjectClass(), block);
}

@Specialization
public RubyClass initialize(RubyClass rubyClass, RubyClass superclass, UndefinedPlaceholder block) {
public RubyClass initialize(RubyClass rubyClass, RubyClass superclass, NotProvided block) {
rubyClass.initialize(superclass);
return rubyClass;
}

@Specialization
public RubyClass initialize(VirtualFrame frame, RubyClass rubyClass, UndefinedPlaceholder superclass, RubyProc block) {
public RubyClass initialize(VirtualFrame frame, RubyClass rubyClass, NotProvided superclass, RubyProc block) {
return initialize(frame, rubyClass, getContext().getCoreLibrary().getObjectClass(), block);
}

Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
}

if (method.needsBlock()) {
argumentsNodes.add(new ReadBlockNode(context, sourceSection, UndefinedPlaceholder.INSTANCE));
argumentsNodes.add(new ReadBlockNode(context, sourceSection, NotProvided.INSTANCE));
}

final RubyNode methodNode;
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyException;
@@ -33,12 +33,12 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyBasicObject initialize(RubyException exception, UndefinedPlaceholder message) {
public RubyBasicObject initialize(RubyException exception, NotProvided message) {
exception.initialize(nil());
return exception;
}

@Specialization(guards = "!isUndefinedPlaceholder(message)")
@Specialization(guards = "!isNotProvided(message)")
public RubyBasicObject initialize(RubyException exception, Object message) {
exception.initialize(message);
return exception;
@@ -78,7 +78,7 @@ public CaptureBacktraceNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyBasicObject captureBacktrace(RubyException exception, UndefinedPlaceholder offset) {
public RubyBasicObject captureBacktrace(RubyException exception, NotProvided offset) {
return captureBacktrace(exception, 1);
}

71 changes: 3 additions & 68 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;

@@ -48,11 +48,6 @@ public AddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double add(double a, int b) {
return a + b;
}

@Specialization
public double add(double a, long b) {
return a + b;
@@ -77,11 +72,6 @@ public SubNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double sub(double a, int b) {
return a - b;
}

@Specialization
public double sub(double a, long b) {
return a - b;
@@ -111,11 +101,6 @@ public MulNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double mul(double a, int b) {
return a * b;
}

@Specialization
public double mul(double a, long b) {
return a * b;
@@ -150,11 +135,6 @@ public PowNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double pow(double a, int b) {
return Math.pow(a, b);
}

@Specialization
public double pow(double a, long b) {
return Math.pow(a, b);
@@ -198,11 +178,6 @@ public DivNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double div(double a, int b) {
return a / b;
}

@Specialization
public double div(double a, long b) {
return a / b;
@@ -243,11 +218,6 @@ public ModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double mod(double a, int b) {
return mod(a, (double) b);
}

@Specialization
public double mod(double a, long b) {
return mod(a, (double) b);
@@ -286,11 +256,6 @@ public DivModNode(RubyContext context, SourceSection sourceSection) {
divModNode = new GeneralDivModNode(context, sourceSection);
}

@Specialization
public RubyArray divMod(double a, int b) {
return divModNode.execute(a, b);
}

@Specialization
public RubyArray divMod(double a, long b) {
return divModNode.execute(a, b);
@@ -315,11 +280,6 @@ public LessNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean less(double a, int b) {
return a < b;
}

@Specialization
public boolean less(double a, long b) {
return a < b;
@@ -349,11 +309,6 @@ public LessEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean lessEqual(double a, int b) {
return a <= b;
}

@Specialization
public boolean lessEqual(double a, long b) {
return a <= b;
@@ -385,11 +340,6 @@ public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean equal(double a, int b) {
return a == b;
}

@Specialization
public boolean equal(double a, long b) {
return a == b;
@@ -433,11 +383,6 @@ public RubyBasicObject compareSecondNaN(Object a, double b) {
return nil();
}

@Specialization(guards = {"!isNaN(a)"})
public int compare(double a, int b) {
return Double.compare(a, b);
}

@Specialization(guards = {"!isNaN(a)"})
public int compare(double a, long b) {
return Double.compare(a, b);
@@ -476,11 +421,6 @@ public GreaterEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greaterEqual(double a, int b) {
return a >= b;
}

@Specialization
public boolean greaterEqual(double a, long b) {
return a >= b;
@@ -510,11 +450,6 @@ public GreaterNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean equal(double a, int b) {
return a > b;
}

@Specialization
public boolean equal(double a, long b) {
return a > b;
@@ -635,7 +570,7 @@ public RoundNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object round(double n, UndefinedPlaceholder undefinedPlaceholder) {
public Object round(double n, NotProvided ndigits) {
// Algorithm copied from JRuby - not shared as we want to branch profile it

if (Double.isInfinite(n)) {
@@ -671,7 +606,7 @@ public Object round(double n, UndefinedPlaceholder undefinedPlaceholder) {
return fixnumOrBignum.fixnumOrBignum(f);
}

@Specialization(guards = "!isUndefinedPlaceholder(ndigits)")
@Specialization(guards = "!isNotProvided(ndigits)")
public Object round(VirtualFrame frame, double n, Object ndigits) {
return ruby(frame, "round_internal(ndigits)", "ndigits", ndigits);
}
Original file line number Diff line number Diff line change
@@ -40,10 +40,6 @@ public GeneralDivModNode(RubyContext context, SourceSection sourceSection) {
fixnumOrBignumRemainder = new FixnumOrBignumNode(context, sourceSection);
}

public RubyArray execute(int a, double b) {
return divMod(a, b);
}

public RubyArray execute(long a, long b) {
return divMod(a, b);
}
@@ -64,10 +60,6 @@ public RubyArray execute(BigInteger a, BigInteger b) {
return divMod(a, b);
}

public RubyArray execute(double a, int b) {
return divMod(a, b);
}

public RubyArray execute(double a, long b) {
return divMod(a, b);
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.NextException;
import org.jruby.truffle.runtime.control.RedoException;
import org.jruby.truffle.runtime.core.RubyArray;
@@ -136,7 +136,7 @@ public TimesNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray times(VirtualFrame frame, int n, UndefinedPlaceholder block) {
public RubyArray times(VirtualFrame frame, int n, NotProvided block) {
final int[] array = new int[n];

for (int i = 0; i < n; i++) {
44 changes: 22 additions & 22 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -301,12 +301,12 @@ public CallerLocationsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray callerLocations(UndefinedPlaceholder undefined1, UndefinedPlaceholder undefined2) {
public RubyArray callerLocations(NotProvided omit, NotProvided length) {
return callerLocations(1, -1);
}

@Specialization
public RubyArray callerLocations(int omit, UndefinedPlaceholder undefined) {
public RubyArray callerLocations(int omit, NotProvided length) {
return callerLocations(omit, -1);
}

@@ -468,7 +468,7 @@ protected RubyBinding getCallerBinding(VirtualFrame frame) {
}

@Specialization
public Object eval(VirtualFrame frame, RubyString source, UndefinedPlaceholder binding, UndefinedPlaceholder filename, UndefinedPlaceholder lineNumber) {
public Object eval(VirtualFrame frame, RubyString source, NotProvided binding, NotProvided filename, NotProvided lineNumber) {
CompilerDirectives.transferToInterpreter();

return getContext().eval(source.getByteList(), getCallerBinding(frame), true, this);
@@ -479,18 +479,18 @@ public Object eval(VirtualFrame frame, RubyString source, Object noBinding, Ruby
CompilerDirectives.transferToInterpreter();

// TODO (nirvdrum Dec. 29, 2014) Do something with the supplied filename.
return eval(frame, source, UndefinedPlaceholder.INSTANCE, UndefinedPlaceholder.INSTANCE, UndefinedPlaceholder.INSTANCE);
return eval(frame, source, NotProvided.INSTANCE, NotProvided.INSTANCE, NotProvided.INSTANCE);
}

@Specialization
public Object eval(RubyString source, RubyBinding binding, UndefinedPlaceholder filename, UndefinedPlaceholder lineNumber) {
public Object eval(RubyString source, RubyBinding binding, NotProvided filename, NotProvided lineNumber) {
CompilerDirectives.transferToInterpreter();

return getContext().eval(source.getByteList(), binding, false, this);
}

@Specialization
public Object eval(RubyString source, RubyBinding binding, RubyString filename, UndefinedPlaceholder lineNumber) {
public Object eval(RubyString source, RubyBinding binding, RubyString filename, NotProvided lineNumber) {
CompilerDirectives.transferToInterpreter();

return getContext().eval(source.getByteList(), binding, false, filename.toString(), this);
@@ -504,7 +504,7 @@ public Object eval(RubyString source, RubyBinding binding, RubyString filename,
}

@Specialization(guards = "!isRubyBinding(badBinding)")
public Object eval(RubyString source, RubyBasicObject badBinding, UndefinedPlaceholder filename, UndefinedPlaceholder lineNumber) {
public Object eval(RubyString source, RubyBasicObject badBinding, NotProvided filename, NotProvided lineNumber) {
throw new RaiseException(getContext().getCoreLibrary().typeErrorWrongArgumentType(badBinding, "binding", this));
}
}
@@ -571,7 +571,7 @@ public ExitNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object exit(UndefinedPlaceholder exitCode) {
public Object exit(NotProvided exitCode) {
return exit(0);
}

@@ -603,7 +603,7 @@ public ExitBangNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyBasicObject exit(UndefinedPlaceholder exitCode) {
public RubyBasicObject exit(NotProvided exitCode) {
return exit(1);
}

@@ -991,7 +991,7 @@ public boolean load(RubyString file, boolean wrap) {
}

@Specialization
public boolean load(RubyString file, UndefinedPlaceholder wrap) {
public boolean load(RubyString file, NotProvided wrap) {
return load(file, false);
}
}
@@ -1084,7 +1084,7 @@ public MethodsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray methods(VirtualFrame frame, Object self, UndefinedPlaceholder regular) {
public RubyArray methods(VirtualFrame frame, Object self, NotProvided regular) {
return methods(frame, self, true);
}

@@ -1141,7 +1141,7 @@ public PrivateMethodsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray privateMethods(VirtualFrame frame, Object self, UndefinedPlaceholder includeAncestors) {
public RubyArray privateMethods(VirtualFrame frame, Object self, NotProvided includeAncestors) {
return privateMethods(frame, self, true);
}

@@ -1195,7 +1195,7 @@ public ProtectedMethodsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray protectedMethods(VirtualFrame frame, Object self, UndefinedPlaceholder includeAncestors) {
public RubyArray protectedMethods(VirtualFrame frame, Object self, NotProvided includeAncestors) {
return protectedMethods(frame, self, true);
}

@@ -1231,7 +1231,7 @@ public PublicMethodsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray publicMethods(VirtualFrame frame, Object self, UndefinedPlaceholder includeAncestors) {
public RubyArray publicMethods(VirtualFrame frame, Object self, NotProvided includeAncestors) {
return publicMethods(frame, self, true);
}

@@ -1263,7 +1263,7 @@ public RandNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public double rand(UndefinedPlaceholder undefined) {
public double rand(NotProvided max) {
return getContext().getRandom().nextDouble();
}

@@ -1408,7 +1408,7 @@ public RespondToNode(RubyContext context, SourceSection sourceSection) {
public abstract boolean executeDoesRespondTo(VirtualFrame frame, Object object, Object name, boolean includePrivate);

@Specialization
public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name, UndefinedPlaceholder checkVisibility) {
public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name, NotProvided checkVisibility) {
return doesRespondTo(frame, object, name, false);
}

@@ -1427,7 +1427,7 @@ public boolean doesRespondTo(VirtualFrame frame, Object object, RubyString name,
}

@Specialization
public boolean doesRespondTo(VirtualFrame frame, Object object, RubySymbol name, UndefinedPlaceholder checkVisibility) {
public boolean doesRespondTo(VirtualFrame frame, Object object, RubySymbol name, NotProvided checkVisibility) {
return doesRespondTo(frame, object, name, false);
}

@@ -1455,12 +1455,12 @@ public RespondToMissingNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public boolean doesRespondToMissing(Object object, RubyString name, UndefinedPlaceholder includeAll) {
public boolean doesRespondToMissing(Object object, RubyString name, NotProvided includeAll) {
return false;
}

@Specialization
public boolean doesRespondToMissing(Object object, RubySymbol name, UndefinedPlaceholder includeAll) {
public boolean doesRespondToMissing(Object object, RubySymbol name, NotProvided includeAll) {
return false;
}

@@ -1531,7 +1531,7 @@ public SingletonMethodsNode(RubyContext context, SourceSection sourceSection) {
public abstract RubyArray executeSingletonMethods(VirtualFrame frame, Object self, boolean includeAncestors);

@Specialization
public RubyArray singletonMethods(VirtualFrame frame, Object self, UndefinedPlaceholder includeAncestors) {
public RubyArray singletonMethods(VirtualFrame frame, Object self, NotProvided includeAncestors) {
return singletonMethods(frame, self, true);
}

@@ -1591,7 +1591,7 @@ public SleepNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public long sleep(UndefinedPlaceholder duration) {
public long sleep(NotProvided duration) {
// TODO: this should actually be "forever".
return doSleepMillis(Long.MAX_VALUE);
}
@@ -1613,7 +1613,7 @@ public long sleep(double duration) {

@Specialization(guards = "isRubiniusUndefined(duration)")
public long sleep(RubyBasicObject duration) {
return sleep(UndefinedPlaceholder.INSTANCE);
return sleep(NotProvided.INSTANCE);
}

@Specialization(guards = "!isRubiniusUndefined(duration)")
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import org.jruby.truffle.nodes.coerce.ToIntNodeGen;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.util.ByteList;
@@ -41,7 +41,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object getIndex(RubyMatchData matchData, int index, UndefinedPlaceholder undefinedPlaceholder) {
public Object getIndex(RubyMatchData matchData, int index, NotProvided length) {
CompilerDirectives.transferToInterpreter();

final Object[] values = matchData.getValues();
@@ -65,13 +65,13 @@ public Object getIndex(RubyMatchData matchData, int index, int length) {
}

@Specialization
public Object getIndex(RubyMatchData matchData, RubySymbol index, UndefinedPlaceholder undefinedPlaceholder) {
public Object getIndex(RubyMatchData matchData, RubySymbol index, NotProvided length) {
CompilerDirectives.transferToInterpreter();

try {
final int i = matchData.getBackrefNumber(index.getSymbolBytes());

return getIndex(matchData, i, UndefinedPlaceholder.INSTANCE);
return getIndex(matchData, i, NotProvided.INSTANCE);
} catch (final ValueException e) {
CompilerDirectives.transferToInterpreter();

@@ -81,13 +81,13 @@ public Object getIndex(RubyMatchData matchData, RubySymbol index, UndefinedPlace
}

@Specialization
public Object getIndex(RubyMatchData matchData, RubyString index, UndefinedPlaceholder undefinedPlaceholder) {
public Object getIndex(RubyMatchData matchData, RubyString index, NotProvided length) {
CompilerDirectives.transferToInterpreter();

try {
final int i = matchData.getBackrefNumber(index.getByteList());

return getIndex(matchData, i, UndefinedPlaceholder.INSTANCE);
return getIndex(matchData, i, NotProvided.INSTANCE);
}
catch (final ValueException e) {
CompilerDirectives.transferToInterpreter();
@@ -98,19 +98,19 @@ public Object getIndex(RubyMatchData matchData, RubyString index, UndefinedPlace
}

@Specialization(guards = {"!isRubySymbol(index)", "!isRubyString(index)", "!isIntegerFixnumRange(index)"})
public Object getIndex(VirtualFrame frame, RubyMatchData matchData, Object index, UndefinedPlaceholder undefinedPlaceholder) {
public Object getIndex(VirtualFrame frame, RubyMatchData matchData, Object index, NotProvided length) {
CompilerDirectives.transferToInterpreter();

if (toIntNode == null) {
CompilerDirectives.transferToInterpreter();
toIntNode = insert(ToIntNodeGen.create(getContext(), getSourceSection(), null));
}

return getIndex(matchData, toIntNode.doInt(frame, index), UndefinedPlaceholder.INSTANCE);
return getIndex(matchData, toIntNode.doInt(frame, index), NotProvided.INSTANCE);
}

@Specialization(guards = {"!isRubySymbol(range)", "!isRubyString(range)"})
public Object getIndex(VirtualFrame frame, RubyMatchData matchData, RubyRange.IntegerFixnumRange range, UndefinedPlaceholder undefinedPlaceholder) {
public Object getIndex(VirtualFrame frame, RubyMatchData matchData, RubyRange.IntegerFixnumRange range, NotProvided len) {
final Object[] values = matchData.getValues();
final int normalizedIndex = ArrayNodes.normalizeIndex(values.length, range.getBegin());
final int end = ArrayNodes.normalizeIndex(values.length, range.getEnd());
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import org.jruby.truffle.nodes.dispatch.MissingBehavior;
import org.jruby.truffle.nodes.dispatch.UseMethodMissingException;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBasicObject;
@@ -619,27 +619,27 @@ public LogNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public double function(int a, UndefinedPlaceholder b) {
public double function(int a, NotProvided b) {
return doFunction(a);
}

@Specialization
public double function(long a, UndefinedPlaceholder b) {
public double function(long a, NotProvided b) {
return doFunction(a);
}

@Specialization(guards = "isRubyBignum(a)")
public double function(RubyBasicObject a, UndefinedPlaceholder b) {
public double function(RubyBasicObject a, NotProvided b) {
return doFunction(BignumNodes.getBigIntegerValue(a).doubleValue());
}

@Specialization
public double function(double a, UndefinedPlaceholder b) {
public double function(double a, NotProvided b) {
return doFunction(a);
}

@Specialization
public double function(VirtualFrame frame, Object a, UndefinedPlaceholder b) {
public double function(VirtualFrame frame, Object a, NotProvided b) {
if (isANode.executeIsA(frame, a, getContext().getCoreLibrary().getNumericClass())) {
try {
return doFunction(
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import org.jruby.truffle.nodes.objects.ClassNodeGen;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.object.BasicObjectType;
@@ -133,7 +133,7 @@ public CallNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object call(VirtualFrame frame, RubyBasicObject method, Object[] arguments, UndefinedPlaceholder block) {
public Object call(VirtualFrame frame, RubyBasicObject method, Object[] arguments, NotProvided block) {
return doCall(frame, method, arguments, null);
}

60 changes: 30 additions & 30 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -598,27 +598,27 @@ protected RubyString toStr(VirtualFrame frame, Object object) {
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, NotProvided file, NotProvided line, NotProvided block) {
return classEvalSource(frame, module, code, "(eval)");
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, NotProvided line, NotProvided block) {
return classEvalSource(frame, module, code, file.toString());
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, int line, UndefinedPlaceholder block) {
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, RubyString file, int line, NotProvided block) {
return classEvalSource(frame, module, code, file.toString());
}

@Specialization(guards = "!isUndefinedPlaceholder(code)")
public Object classEval(VirtualFrame frame, RubyModule module, Object code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
@Specialization(guards = "!isNotProvided(code)")
public Object classEval(VirtualFrame frame, RubyModule module, Object code, NotProvided file, NotProvided line, NotProvided block) {
return classEvalSource(frame, module, toStr(frame, code), file.toString());
}

@Specialization(guards = "!isUndefinedPlaceholder(file)")
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, Object file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
@Specialization(guards = "!isNotProvided(file)")
public Object classEval(VirtualFrame frame, RubyModule module, RubyString code, Object file, NotProvided line, NotProvided block) {
return classEvalSource(frame, module, code, toStr(frame, file).toString());
}

@@ -638,18 +638,18 @@ public RubyNode wrap(RubyNode node) {
}

@Specialization
public Object classEval(VirtualFrame frame, RubyModule self, UndefinedPlaceholder code, UndefinedPlaceholder file, UndefinedPlaceholder line, RubyProc block) {
public Object classEval(VirtualFrame frame, RubyModule self, NotProvided code, NotProvided file, NotProvided line, RubyProc block) {
return yield.dispatchWithModifiedSelf(frame, block, self);
}

@Specialization
public Object classEval(RubyModule self, UndefinedPlaceholder code, UndefinedPlaceholder file, UndefinedPlaceholder line, UndefinedPlaceholder block) {
public Object classEval(RubyModule self, NotProvided code, NotProvided file, NotProvided line, NotProvided block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(0, 1, 2, this));
}

@Specialization(guards = "!isUndefinedPlaceholder(code)")
public Object classEval(RubyModule self, Object code, UndefinedPlaceholder file, UndefinedPlaceholder line, RubyProc block) {
@Specialization(guards = "!isNotProvided(code)")
public Object classEval(RubyModule self, Object code, NotProvided file, NotProvided line, RubyProc block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError(1, 0, this));
}
@@ -674,7 +674,7 @@ public Object classExec(VirtualFrame frame, RubyModule self, Object[] args, Ruby
}

@Specialization
public Object classExec(VirtualFrame frame, RubyModule self, Object[] args, UndefinedPlaceholder block) {
public Object classExec(VirtualFrame frame, RubyModule self, Object[] args, NotProvided block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().noBlockGiven(this));
}
@@ -775,7 +775,7 @@ private boolean booleanCast(VirtualFrame frame, Object value) {
}

@Specialization
public RubyArray constants(RubyModule module, UndefinedPlaceholder inherit) {
public RubyArray constants(RubyModule module, NotProvided inherit) {
return constants(module, true);
}

@@ -801,7 +801,7 @@ public RubyArray constants(RubyModule module, boolean inherit) {
return ArrayNodes.fromObjects(getContext().getCoreLibrary().getArrayClass(), constantsArray.toArray(new Object[constantsArray.size()]));
}

@Specialization(guards = "!isUndefinedPlaceholder(inherit)")
@Specialization(guards = "!isNotProvided(inherit)")
public RubyArray constants(VirtualFrame frame, RubyModule module, Object inherit) {
return constants(module, booleanCast(frame, inherit));
}
@@ -826,7 +826,7 @@ public RubyNode coerceToString(RubyNode name) {
}

@Specialization
public boolean isConstDefined(RubyModule module, String name, UndefinedPlaceholder inherit) {
public boolean isConstDefined(RubyModule module, String name, NotProvided inherit) {
return isConstDefined(module, name, true);
}

@@ -861,7 +861,7 @@ public RubyNode coerceToString(RubyNode name) {

// Symbol
@Specialization
public Object getConstant(VirtualFrame frame, RubyModule module, RubySymbol name, UndefinedPlaceholder inherit) {
public Object getConstant(VirtualFrame frame, RubyModule module, RubySymbol name, NotProvided inherit) {
return getConstant(frame, module, name, true);
}

@@ -877,7 +877,7 @@ public Object getConstantNoInherit(VirtualFrame frame, RubyModule module, RubySy

// String
@Specialization(guards = "!isScoped(name)")
public Object getConstant(VirtualFrame frame, RubyModule module, RubyString name, UndefinedPlaceholder inherit) {
public Object getConstant(VirtualFrame frame, RubyModule module, RubyString name, NotProvided inherit) {
return getConstant(frame, module, name, true);
}

@@ -893,7 +893,7 @@ public Object getConstantNoInherit(VirtualFrame frame, RubyModule module, RubySt

// Scoped String
@Specialization(guards = "isScoped(fullName)")
public Object getConstantScoped(VirtualFrame frame, RubyModule module, RubyString fullName, UndefinedPlaceholder inherit) {
public Object getConstantScoped(VirtualFrame frame, RubyModule module, RubyString fullName, NotProvided inherit) {
return getConstantScoped(frame, module, fullName, true);
}

@@ -998,31 +998,31 @@ public RubyNode coerceToString(RubyNode name) {

@TruffleBoundary
@Specialization
public RubySymbol defineMethod(RubyModule module, String name, UndefinedPlaceholder proc, UndefinedPlaceholder block) {
public RubySymbol defineMethod(RubyModule module, String name, NotProvided proc, NotProvided block) {
throw new RaiseException(getContext().getCoreLibrary().argumentError("needs either proc or block", this));
}

@TruffleBoundary
@Specialization
public RubySymbol defineMethod(RubyModule module, String name, UndefinedPlaceholder proc, RubyProc block) {
return defineMethod(module, name, block, UndefinedPlaceholder.INSTANCE);
public RubySymbol defineMethod(RubyModule module, String name, NotProvided proc, RubyProc block) {
return defineMethod(module, name, block, NotProvided.INSTANCE);
}

@TruffleBoundary
@Specialization
public RubySymbol defineMethod(RubyModule module, String name, RubyProc proc, UndefinedPlaceholder block) {
public RubySymbol defineMethod(RubyModule module, String name, RubyProc proc, NotProvided block) {
return defineMethod(module, name, proc);
}

@TruffleBoundary
@Specialization(guards = "isRubyMethod(method)")
public RubySymbol defineMethod(RubyModule module, String name, RubyBasicObject method, UndefinedPlaceholder block) {
public RubySymbol defineMethod(RubyModule module, String name, RubyBasicObject method, NotProvided block) {
module.addMethod(this, MethodNodes.getMethod(method).withName(name));
return getContext().getSymbolTable().getSymbol(name);
}

@Specialization(guards = "isRubyUnboundMethod(method)")
public RubySymbol defineMethod(VirtualFrame frame, RubyModule module, String name, RubyBasicObject method, UndefinedPlaceholder block) {
public RubySymbol defineMethod(VirtualFrame frame, RubyModule module, String name, RubyBasicObject method, NotProvided block) {
CompilerDirectives.transferToInterpreter();

RubyModule origin = UnboundMethodNodes.getOrigin(method);
@@ -1102,7 +1102,7 @@ void classEval(VirtualFrame frame, RubyModule module, RubyProc block) {
}

@Specialization
public RubyModule initialize(RubyModule module, UndefinedPlaceholder block) {
public RubyModule initialize(RubyModule module, NotProvided block) {
return module;
}

@@ -1201,7 +1201,7 @@ public RubyNode coerceToString(RubyNode name) {
}

@Specialization
public boolean isMethodDefined(RubyModule module, String name, UndefinedPlaceholder inherit) {
public boolean isMethodDefined(RubyModule module, String name, NotProvided inherit) {
return isMethodDefined(module, name, true);
}

@@ -1411,7 +1411,7 @@ public ProtectedInstanceMethodsNode(RubyContext context, SourceSection sourceSec
}

@Specialization
public RubyArray protectedInstanceMethods(RubyModule module, UndefinedPlaceholder argument) {
public RubyArray protectedInstanceMethods(RubyModule module, NotProvided includeAncestors) {
return protectedInstanceMethods(module, true);
}

@@ -1459,7 +1459,7 @@ public PrivateInstanceMethodsNode(RubyContext context, SourceSection sourceSecti
}

@Specialization
public RubyArray privateInstanceMethods(RubyModule module, UndefinedPlaceholder argument) {
public RubyArray privateInstanceMethods(RubyModule module, NotProvided includeAncestors) {
return privateInstanceMethods(module, true);
}

@@ -1516,7 +1516,7 @@ public PublicInstanceMethodsNode(RubyContext context, SourceSection sourceSectio
}

@Specialization
public RubyArray publicInstanceMethods(RubyModule module, UndefinedPlaceholder argument) {
public RubyArray publicInstanceMethods(RubyModule module, NotProvided includeAncestors) {
return publicInstanceMethods(module, true);
}

@@ -1563,7 +1563,7 @@ public InstanceMethodsNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray instanceMethods(RubyModule module, UndefinedPlaceholder argument) {
public RubyArray instanceMethods(RubyModule module, NotProvided argument) {
return instanceMethods(module, true);
}

Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.runtime.ModuleOperations;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.object.ObjectIDOperations;

@@ -87,7 +87,7 @@ public EachObjectNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public int eachObject(VirtualFrame frame, UndefinedPlaceholder ofClass, RubyProc block) {
public int eachObject(VirtualFrame frame, NotProvided ofClass, RubyProc block) {
CompilerDirectives.transferToInterpreter();

int count = 0;
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.util.Memo;
@@ -78,7 +78,7 @@ public CallNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object call(VirtualFrame frame, RubyProc proc, Object[] args, UndefinedPlaceholder block) {
public Object call(VirtualFrame frame, RubyProc proc, Object[] args, NotProvided block) {
return yieldNode.dispatch(frame, proc, args);
}

@@ -107,7 +107,7 @@ public RubyBasicObject initialize(RubyProc proc, RubyProc block) {

@TruffleBoundary
@Specialization
public RubyBasicObject initialize(RubyProc proc, UndefinedPlaceholder block) {
public RubyBasicObject initialize(RubyProc proc, NotProvided block) {
final Memo<Integer> frameCount = new Memo<>(0);

// The parent will be the Proc.new call. We need to go an extra level up in order to get the parent
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.signal.SignalOperations;

@@ -40,12 +40,12 @@ public ClockGetTimeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = "isMonotonic(clock_id)")
Object clock_gettime_monotonic(int clock_id, UndefinedPlaceholder unit) {
Object clock_gettime_monotonic(int clock_id, NotProvided unit) {
return clock_gettime_monotonic(CLOCK_MONOTONIC, floatSecondSymbol);
}

@Specialization(guards = "isRealtime(clock_id)")
Object clock_gettime_realtime(int clock_id, UndefinedPlaceholder unit) {
Object clock_gettime_realtime(int clock_id, NotProvided unit) {
return clock_gettime_realtime(CLOCK_REALTIME, floatSecondSymbol);
}

38 changes: 19 additions & 19 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/RangeNodes.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.core.array.ArrayBuilderNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.NextException;
import org.jruby.truffle.runtime.control.RedoException;
import org.jruby.truffle.runtime.core.RubyArray;
@@ -146,12 +146,12 @@ public Object each(VirtualFrame frame, RubyRange.LongFixnumRange range, RubyProc
}

@Specialization
public Object each(VirtualFrame frame, RubyRange.LongFixnumRange range, UndefinedPlaceholder proc) {
public Object each(VirtualFrame frame, RubyRange.LongFixnumRange range, NotProvided proc) {
return ruby(frame, "each_internal(&block)", "block", nil());
}

@Specialization
public Object each(VirtualFrame frame, RubyRange.ObjectRange range, UndefinedPlaceholder proc) {
public Object each(VirtualFrame frame, RubyRange.ObjectRange range, NotProvided proc) {
return ruby(frame, "each_internal(&block)", "block", nil());
}

@@ -208,7 +208,7 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyRange.ObjectRange initialize(RubyRange.ObjectRange range, Object begin, Object end, UndefinedPlaceholder undefined) {
public RubyRange.ObjectRange initialize(RubyRange.ObjectRange range, Object begin, Object end, NotProvided excludeEnd) {
return initialize(range, begin, end, false);
}

@@ -318,63 +318,63 @@ public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, int step
return range;
}

@Specialization(guards = {"!isStepValidInt(range, step, block)","!isUndefinedPlaceholder(step)"})
@Specialization(guards = { "!isStepValidInt(range, step, block)", "!isNotProvided(step)" })
public Object stepFallback(VirtualFrame frame, RubyRange.IntegerFixnumRange range, Object step, RubyProc block) {
return ruby(frame, "step_internal(step, &block)", "step", step, "block", block);
}

@Specialization(guards = {"!isStepValidInt(range, step, block)","!isUndefinedPlaceholder(step)"})
@Specialization(guards = { "!isStepValidInt(range, step, block)", "!isNotProvided(step)" })
public Object stepFallback(VirtualFrame frame, RubyRange.LongFixnumRange range, Object step, RubyProc block) {
return ruby(frame, "step_internal(step, &block)", "step", step, "block", block);
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, UndefinedPlaceholder step, UndefinedPlaceholder block) {
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, NotProvided step, NotProvided block) {
return ruby(frame, "step_internal");
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, UndefinedPlaceholder step, RubyProc block) {
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, NotProvided step, RubyProc block) {
return ruby(frame, "step_internal(&block)", "block", block);
}

@Specialization(guards = {"!isInteger(step)","!isLong(step)","!isUndefinedPlaceholder(step)"})
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, Object step, UndefinedPlaceholder block) {
@Specialization(guards = { "!isInteger(step)", "!isLong(step)", "!isNotProvided(step)" })
public Object step(VirtualFrame frame, RubyRange.IntegerFixnumRange range, Object step, NotProvided block) {
return ruby(frame, "step_internal(step)", "step", step);
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, UndefinedPlaceholder step, UndefinedPlaceholder block) {
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, NotProvided step, NotProvided block) {
return ruby(frame, "step_internal");
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, UndefinedPlaceholder step, RubyProc block) {
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, NotProvided step, RubyProc block) {
return ruby(frame, "step_internal(&block)", "block", block);
}

@Specialization(guards = "!isUndefinedPlaceholder(step)")
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, Object step, UndefinedPlaceholder block) {
@Specialization(guards = "!isNotProvided(step)")
public Object step(VirtualFrame frame, RubyRange.LongFixnumRange range, Object step, NotProvided block) {
return ruby(frame, "step_internal(step)", "step", step);
}

@Specialization(guards = "!isUndefinedPlaceholder(step)")
@Specialization(guards = "!isNotProvided(step)")
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, Object step, RubyProc block) {
return ruby(frame, "step_internal(step, &block)", "step", step, "block", block);
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, UndefinedPlaceholder step, UndefinedPlaceholder block) {
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, NotProvided step, NotProvided block) {
return ruby(frame, "step_internal");
}

@Specialization
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, UndefinedPlaceholder step, RubyProc block) {
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, NotProvided step, RubyProc block) {
return ruby(frame, "step_internal(&block)", "block", block);
}

@Specialization(guards = "!isUndefinedPlaceholder(step)")
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, Object step, UndefinedPlaceholder block) {
@Specialization(guards = "!isNotProvided(step)")
public Object step(VirtualFrame frame, RubyRange.ObjectRange range, Object step, NotProvided block) {
return ruby(frame, "step_internal(step)", "step", step);
}

36 changes: 18 additions & 18 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@
import org.jruby.truffle.nodes.rubinius.StringPrimitiveNodes;
import org.jruby.truffle.nodes.rubinius.StringPrimitiveNodesFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.rubinius.RubiniusByteArray;
@@ -474,7 +474,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object getIndex(VirtualFrame frame, RubyString string, int index, UndefinedPlaceholder undefined) {
public Object getIndex(VirtualFrame frame, RubyString string, int index, NotProvided length) {
int normalizedIndex = normalizeIndex(string, index);
final ByteList bytes = string.getByteList();

@@ -487,23 +487,23 @@ public Object getIndex(VirtualFrame frame, RubyString string, int index, Undefin
}

@Specialization(guards = { "!isRubyRange(index)", "!isRubyRegexp(index)", "!isRubyString(index)" })
public Object getIndex(VirtualFrame frame, RubyString string, Object index, UndefinedPlaceholder undefined) {
return getIndex(frame, string, getToIntNode().doInt(frame, index), undefined);
public Object getIndex(VirtualFrame frame, RubyString string, Object index, NotProvided length) {
return getIndex(frame, string, getToIntNode().doInt(frame, index), length);
}

@Specialization
public Object sliceIntegerRange(VirtualFrame frame, RubyString string, RubyRange.IntegerFixnumRange range, UndefinedPlaceholder undefined) {
public Object sliceIntegerRange(VirtualFrame frame, RubyString string, RubyRange.IntegerFixnumRange range, NotProvided length) {
return sliceRange(frame, string, range.getBegin(), range.getEnd(), range.doesExcludeEnd());
}

@Specialization
public Object sliceLongRange(VirtualFrame frame, RubyString string, RubyRange.LongFixnumRange range, UndefinedPlaceholder undefined) {
public Object sliceLongRange(VirtualFrame frame, RubyString string, RubyRange.LongFixnumRange range, NotProvided length) {
// TODO (nirvdrum 31-Mar-15) The begin and end values should be properly lowered, only if possible.
return sliceRange(frame, string, (int) range.getBegin(), (int) range.getEnd(), range.doesExcludeEnd());
}

@Specialization
public Object sliceObjectRange(VirtualFrame frame, RubyString string, RubyRange.ObjectRange range, UndefinedPlaceholder undefined) {
public Object sliceObjectRange(VirtualFrame frame, RubyString string, RubyRange.ObjectRange range, NotProvided length) {
// TODO (nirvdrum 31-Mar-15) The begin and end values may return Fixnums beyond int boundaries and we should handle that -- Bignums are always errors.
final int coercedBegin = getToIntNode().doInt(frame, range.getBegin());
final int coercedEnd = getToIntNode().doInt(frame, range.getEnd());
@@ -551,29 +551,29 @@ public Object slice(VirtualFrame frame, RubyString string, int start, int length
return getSubstringNode().execute(frame, string, start, length);
}

@Specialization(guards = "!isUndefinedPlaceholder(length)")
@Specialization(guards = "!isNotProvided(length)")
public Object slice(VirtualFrame frame, RubyString string, int start, Object length) {
return slice(frame, string, start, getToIntNode().doInt(frame, length));
}

@Specialization(guards = { "!isRubyRange(start)", "!isRubyRegexp(start)", "!isRubyString(start)", "!isUndefinedPlaceholder(length)" })
@Specialization(guards = { "!isRubyRange(start)", "!isRubyRegexp(start)", "!isRubyString(start)", "!isNotProvided(length)" })
public Object slice(VirtualFrame frame, RubyString string, Object start, Object length) {
return slice(frame, string, getToIntNode().doInt(frame, start), getToIntNode().doInt(frame, length));
}

@Specialization
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, UndefinedPlaceholder capture) {
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, NotProvided capture) {
return slice(frame, string, regexp, 0);
}

@Specialization(guards = "!isUndefinedPlaceholder(capture)")
@Specialization(guards = "!isNotProvided(capture)")
public Object slice(VirtualFrame frame, RubyString string, RubyRegexp regexp, Object capture) {
// Extracted from Rubinius's definition of String#[].
return ruby(frame, "match, str = subpattern(index, other); Regexp.last_match = match; str", "index", regexp, "other", capture);
}

@Specialization
public Object slice(VirtualFrame frame, RubyString string, RubyString matchStr, UndefinedPlaceholder undefined) {
public Object slice(VirtualFrame frame, RubyString string, RubyString matchStr, NotProvided length) {
if (includeNode == null) {
CompilerDirectives.transferToInterpreter();
includeNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
@@ -1226,7 +1226,7 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyString initialize(RubyString self, UndefinedPlaceholder from) {
public RubyString initialize(RubyString self, NotProvided from) {
return self;
}

@@ -1250,7 +1250,7 @@ public RubyString initialize(RubyString self, RubyString from) {
return self;
}

@Specialization(guards = { "!isRubyString(from)", "!isUndefinedPlaceholder(from)" })
@Specialization(guards = { "!isRubyString(from)", "!isNotProvided(from)" })
public RubyString initialize(VirtualFrame frame, RubyString self, Object from) {
if (toStrNode == null) {
CompilerDirectives.transferToInterpreter();
@@ -1679,7 +1679,7 @@ public ScanNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyArray scan(RubyString string, RubyString regexpString, UndefinedPlaceholder block) {
public RubyArray scan(RubyString string, RubyString regexpString, NotProvided block) {
final RubyRegexp regexp = new RubyRegexp(this, getContext().getCoreLibrary().getRegexpClass(), regexpString.getByteList(), Option.DEFAULT);
return scan(string, regexp, block);
}
@@ -1691,7 +1691,7 @@ public RubyString scan(VirtualFrame frame, RubyString string, RubyString regexpS
}

@Specialization
public RubyArray scan(RubyString string, RubyRegexp regexp, UndefinedPlaceholder block) {
public RubyArray scan(RubyString string, RubyRegexp regexp, NotProvided block) {
return ArrayNodes.fromObjects(getContext().getCoreLibrary().getArrayClass(), (Object[]) regexp.scan(string));
}

@@ -1993,11 +1993,11 @@ public Object sum(VirtualFrame frame, RubyString string, long bits) {
}

@Specialization
public Object sum(VirtualFrame frame, RubyString string, UndefinedPlaceholder bits) {
public Object sum(VirtualFrame frame, RubyString string, NotProvided bits) {
return sum(frame, string, 16);
}

@Specialization(guards = {"!isInteger(bits)", "!isLong(bits)", "!isUndefinedPlaceholder(bits)"})
@Specialization(guards = { "!isInteger(bits)", "!isLong(bits)", "!isNotProvided(bits)" })
public Object sum(VirtualFrame frame, RubyString string, Object bits) {
return ruby(frame, "sum Rubinius::Type.coerce_to(bits, Fixnum, :to_int)", "bits", bits);
}
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.subsystems.SafepointAction;
@@ -100,14 +100,14 @@ public JoinNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyThread join(RubyThread thread, UndefinedPlaceholder timeout) {
public RubyThread join(RubyThread thread, NotProvided timeout) {
thread.join();
return thread;
}

@Specialization(guards = "isNil(nil)")
public RubyThread join(RubyThread thread, Object nil) {
return join(thread, UndefinedPlaceholder.INSTANCE);
return join(thread, NotProvided.INSTANCE);
}

@Specialization
@@ -173,12 +173,12 @@ public RaiseNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyBasicObject raise(VirtualFrame frame, RubyThread thread, RubyString message, UndefinedPlaceholder undefined) {
public RubyBasicObject raise(VirtualFrame frame, RubyThread thread, RubyString message, NotProvided unused) {
return raise(frame, thread, getContext().getCoreLibrary().getRuntimeErrorClass(), message);
}

@Specialization
public RubyBasicObject raise(VirtualFrame frame, RubyThread thread, RubyClass exceptionClass, UndefinedPlaceholder message) {
public RubyBasicObject raise(VirtualFrame frame, RubyThread thread, RubyClass exceptionClass, NotProvided message) {
return raise(frame, thread, exceptionClass, getContext().makeString(""));
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.core.CoreLibrary;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyRange;
@@ -69,7 +69,7 @@ public Object execute(VirtualFrame frame) {
}
}

if (hasSeenUndefined && value instanceof UndefinedPlaceholder) {
if (hasSeenUndefined && value instanceof NotProvided) {
return value;
}

@@ -103,7 +103,7 @@ public Object execute(VirtualFrame frame) {
}
}

if (value instanceof UndefinedPlaceholder) {
if (value instanceof NotProvided) {
hasSeenUndefined = true;
return value;
}
@@ -177,9 +177,9 @@ public RubyRange.LongFixnumRange executeLongFixnumRange(VirtualFrame frame) thro
}

@Override
public UndefinedPlaceholder executeUndefinedPlaceholder(VirtualFrame frame) throws UnexpectedResultException {
public NotProvided executeNotProvided(VirtualFrame frame) throws UnexpectedResultException {
try {
return super.executeUndefinedPlaceholder(frame);
return super.executeNotProvided(frame);
} catch (UnexpectedResultException e) {
if (e.getResult() instanceof Long && canLower((long) e.getResult())) {
hasNeededToLowerLongFixnum = true;
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBasicObject;
@@ -92,11 +92,6 @@ public long addWithOverflow(int a, int b) {
return (long) a + (long) b;
}

@Specialization
public double add(int a, double b) {
return a + b;
}

@Specialization(guards = "!isRubyBignum(b)")
public Object addCoerced(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :+, b", "b", b);
@@ -146,11 +141,6 @@ public long subWithOverflow(int a, int b) {
return (long) a - (long) b;
}

@Specialization
public double sub(int a, double b) {
return a - b;
}

@Specialization(guards = "!isRubyBignum(b)")
public Object subCoerced(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :-, b", "b", b);
@@ -200,11 +190,6 @@ public long mulWithOverflow(int a, int b) {
return (long) a * (long) b;
}

@Specialization
public double mul(int a, double b) {
return a * b;
}

@Specialization(guards = "!isRubyBignum(b)")
public Object mulCoerced(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :*, b", "b", b);
@@ -312,11 +297,6 @@ public Object divEdgeCase(int a, int b) {
}
}

@Specialization
public double div(int a, double b) {
return a / b;
}

@Specialization(guards = "!isRubyBignum(b)")
public Object divCoerced(VirtualFrame frame, int a, RubyBasicObject b) {
return ruby(frame, "redo_coerced :/, b", "b", b);
@@ -474,11 +454,6 @@ public DivModNode(RubyContext context, SourceSection sourceSection) {
divModNode = new GeneralDivModNode(context, sourceSection);
}

@Specialization
public RubyArray divMod(int a, double b) {
return divModNode.execute(a, b);
}

@Specialization
public RubyArray divMod(long a, long b) {
return divModNode.execute(a, b);
@@ -508,11 +483,6 @@ public boolean less(int a, int b) {
return a < b;
}

@Specialization
public boolean less(int a, double b) {
return a < b;
}

@Specialization(guards = "isRubyBignum(b)")
public boolean less(int a, RubyBasicObject b) {
return BigInteger.valueOf(a).compareTo(BignumNodes.getBigIntegerValue(b)) < 0;
@@ -552,11 +522,6 @@ public boolean lessEqual(int a, int b) {
return a <= b;
}

@Specialization
public boolean lessEqual(int a, double b) {
return a <= b;
}

@Specialization(guards = "isRubyBignum(b)")
public boolean lessEqual(int a, RubyBasicObject b) {
return BigInteger.valueOf(a).compareTo(BignumNodes.getBigIntegerValue(b)) <= 0;
@@ -593,11 +558,6 @@ public boolean equal(int a, int b) {
return a == b;
}

@Specialization
public boolean equal(int a, double b) {
return a == b;
}

@Specialization(guards = "isRubyBignum(b)")
public boolean equal(int a, RubyBasicObject b) {
return false;
@@ -641,11 +601,6 @@ public int compare(int a, int b) {
return Integer.compare(a, b);
}

@Specialization
public int compare(int a, double b) {
return Double.compare(a, b);
}

@Specialization(guards = "isRubyBignum(b)")
public int compare(int a, RubyBasicObject b) {
return BigInteger.valueOf(a).compareTo(BignumNodes.getBigIntegerValue(b));
@@ -689,11 +644,6 @@ public boolean greaterEqual(int a, int b) {
return a >= b;
}

@Specialization
public boolean greaterEqual(int a, double b) {
return a >= b;
}

@Specialization(guards = "isRubyBignum(b)")
public boolean greaterEqual(int a, RubyBasicObject b) {
return BigInteger.valueOf(a).compareTo(BignumNodes.getBigIntegerValue(b)) >= 0;
@@ -727,11 +677,6 @@ public boolean greater(int a, int b) {
return a > b;
}

@Specialization
public boolean greater(int a, double b) {
return a > b;
}

@Specialization(guards = "isRubyBignum(b)")
public boolean greater(int a, RubyBasicObject b) {
return BigInteger.valueOf(a).compareTo(BignumNodes.getBigIntegerValue(b)
@@ -1195,13 +1140,13 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {

@TruffleBoundary
@Specialization
public RubyString toS(int n, UndefinedPlaceholder undefined) {
public RubyString toS(int n, NotProvided base) {
return getContext().makeString(Integer.toString(n));
}

@TruffleBoundary
@Specialization
public RubyString toS(long n, UndefinedPlaceholder undefined) {
public RubyString toS(long n, NotProvided base) {
return getContext().makeString(Long.toString(n));
}

Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.hash.*;
@@ -555,7 +555,7 @@ public DeleteNode(RubyContext context, SourceSection sourceSection) {
public Object deleteNull(VirtualFrame frame, RubyHash hash, Object key, Object block) {
assert HashOperations.verifyStore(hash);

if (block == UndefinedPlaceholder.INSTANCE) {
if (block == NotProvided.INSTANCE) {
return nil();
} else {
return yieldNode.dispatch(frame, (RubyProc) block, key);
@@ -587,7 +587,7 @@ public Object deletePackedArray(VirtualFrame frame, RubyHash hash, Object key, O

assert HashOperations.verifyStore(hash);

if (block == UndefinedPlaceholder.INSTANCE) {
if (block == NotProvided.INSTANCE) {
return nil();
} else {
return yieldNode.dispatch(frame, (RubyProc) block, key);
@@ -601,7 +601,7 @@ public Object delete(VirtualFrame frame, RubyHash hash, Object key, Object block
final HashLookupResult hashLookupResult = lookupEntryNode.lookup(frame, hash, key);

if (hashLookupResult.getEntry() == null) {
if (block == UndefinedPlaceholder.INSTANCE) {
if (block == NotProvided.INSTANCE) {
return nil();
} else {
return yieldNode.dispatch(frame, (RubyProc) block, key);
@@ -704,7 +704,7 @@ private Collection<KeyValue> verySlowToKeyValues(RubyHash hash) {
}

@Specialization
public Object each(VirtualFrame frame, RubyHash hash, UndefinedPlaceholder block) {
public Object each(VirtualFrame frame, RubyHash hash, NotProvided block) {
if (toEnumNode == null) {
CompilerDirectives.transferToInterpreter();
toEnumNode = insert(DispatchHeadNodeFactory.createMethodCallOnSelf(getContext()));
@@ -745,30 +745,30 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public RubyHash initialize(RubyHash hash, UndefinedPlaceholder defaultValue, UndefinedPlaceholder block) {
public RubyHash initialize(RubyHash hash, NotProvided defaultValue, NotProvided block) {
setStore(hash, null, 0, null, null);
setDefaultValue(hash, null);
setDefaultBlock(hash, null);
return hash;
}

@Specialization
public RubyHash initialize(RubyHash hash, UndefinedPlaceholder defaultValue, RubyProc block) {
public RubyHash initialize(RubyHash hash, NotProvided defaultValue, RubyProc block) {
setStore(hash, null, 0, null, null);
setDefaultValue(hash, null);
setDefaultBlock(hash, block);
return hash;
}

@Specialization(guards = "!isUndefinedPlaceholder(defaultValue)")
public RubyHash initialize(RubyHash hash, Object defaultValue, UndefinedPlaceholder block) {
@Specialization(guards = "!isNotProvided(defaultValue)")
public RubyHash initialize(RubyHash hash, Object defaultValue, NotProvided block) {
setStore(hash, null, 0, null, null);
setDefaultValue(hash, defaultValue);
setDefaultBlock(hash, null);
return hash;
}

@Specialization(guards = "!isUndefinedPlaceholder(defaultValue)")
@Specialization(guards = "!isNotProvided(defaultValue)")
public Object initialize(RubyHash hash, Object defaultValue, RubyProc block) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError("wrong number of arguments (1 for 0)", this));
@@ -925,15 +925,15 @@ public MergeNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization(guards = {"isPackedArrayStorage(hash)", "isNullStorage(other)", "!isCompareByIdentity(hash)"})
public RubyHash mergePackedArrayNull(RubyHash hash, RubyHash other, UndefinedPlaceholder block) {
public RubyHash mergePackedArrayNull(RubyHash hash, RubyHash other, NotProvided block) {
final Object[] store = (Object[]) getStore(hash);
final Object[] copy = PackedArrayStrategy.copyStore(store);
return new RubyHash(hash.getLogicalClass(), getDefaultBlock(hash), getDefaultValue(hash), copy, getSize(hash), null);
}

@ExplodeLoop
@Specialization(guards = {"isPackedArrayStorage(hash)", "isPackedArrayStorage(other)", "!isCompareByIdentity(hash)"})
public RubyHash mergePackedArrayPackedArray(VirtualFrame frame, RubyHash hash, RubyHash other, UndefinedPlaceholder block) {
public RubyHash mergePackedArrayPackedArray(VirtualFrame frame, RubyHash hash, RubyHash other, NotProvided block) {
// TODO(CS): what happens with the default block here? Which side does it get merged from?
assert HashOperations.verifyStore(hash);
assert HashOperations.verifyStore(other);
@@ -1022,7 +1022,7 @@ public RubyHash mergePackedArrayPackedArray(VirtualFrame frame, RubyHash hash, R

// TODO CS 3-Mar-15 need negative guards on this
@Specialization(guards = "!isCompareByIdentity(hash)")
public RubyHash mergeBucketsBuckets(RubyHash hash, RubyHash other, UndefinedPlaceholder block) {
public RubyHash mergeBucketsBuckets(RubyHash hash, RubyHash other, NotProvided block) {
CompilerDirectives.transferToInterpreter();

final RubyHash merged = new RubyHash(hash.getLogicalClass(), null, null, new Entry[BucketsStrategy.capacityGreaterThan(getSize(hash) + getSize(other))], 0, null);
@@ -1091,7 +1091,7 @@ public Object merge(VirtualFrame frame, RubyHash hash, Object other, Object bloc

final RubyProc blockProc;

if (block == UndefinedPlaceholder.INSTANCE) {
if (block == NotProvided.INSTANCE) {
blockProc = null;
} else {
blockProc = (RubyProc) block;
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import org.jruby.truffle.nodes.core.CoreMethod;
import org.jruby.truffle.nodes.core.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
@@ -48,13 +48,13 @@ public CRC32Node(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public int crc32(UndefinedPlaceholder message, UndefinedPlaceholder initial) {
public int crc32(NotProvided message, NotProvided initial) {
return 0;
}

@TruffleBoundary
@Specialization
public long crc32(RubyString message, UndefinedPlaceholder initial) {
public long crc32(RubyString message, NotProvided initial) {
final ByteList bytes = message.getByteList();
final CRC32 crc32 = new CRC32();
crc32.update(bytes.unsafeBytes(), bytes.begin(), bytes.length());
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.util.ByteList;
@@ -39,7 +39,7 @@ public EncodingConverterAllocateNode(RubyContext context, SourceSection sourceSe
}

@Specialization
public Object encodingConverterAllocate(RubyClass encodingConverterClass, UndefinedPlaceholder undefined1, UndefinedPlaceholder undefined2) {
public Object encodingConverterAllocate(RubyClass encodingConverterClass, NotProvided unused1, NotProvided unused2) {
return new RubyEncodingConverter(encodingConverterClass, null);
}

@@ -160,7 +160,7 @@ public RubyString encodingConverterPutback(RubyEncodingConverter encodingConvert
}

@Specialization
public RubyString encodingConverterPutback(RubyEncodingConverter encodingConverter, UndefinedPlaceholder maxBytes) {
public RubyString encodingConverterPutback(RubyEncodingConverter encodingConverter, NotProvided maxBytes) {
// Taken from org.jruby.RubyConverter#putback.

final EConv ec = encodingConverter.getEConv();
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@
import org.jruby.truffle.nodes.core.StringNodesFactory;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.rubinius.RubiniusByteArray;
@@ -200,7 +200,7 @@ public StringByteSubstringPrimitiveNode(RubyContext context, SourceSection sourc
}

@Specialization
public Object stringByteSubstring(RubyString string, int index, UndefinedPlaceholder length) {
public Object stringByteSubstring(RubyString string, int index, NotProvided length) {
final Object subString = stringByteSubstring(string, index, 1);

if (subString == nil()) {
@@ -249,7 +249,7 @@ public Object stringByteSubstring(RubyString string, int index, double length) {
}

@Specialization
public Object stringByteSubstring(RubyString string, double index, UndefinedPlaceholder length) {
public Object stringByteSubstring(RubyString string, double index, NotProvided length) {
return stringByteSubstring(string, (int) index, 1);
}

@@ -287,7 +287,7 @@ public Object stringByteSubstring(RubyString string, double index, int length) {
}

@Specialization
public Object stringByteSubstring(RubyString string, RubyRange range, UndefinedPlaceholder unused) {
public Object stringByteSubstring(RubyString string, RubyRange range, NotProvided length) {
return null;
}

Original file line number Diff line number Diff line change
@@ -10,15 +10,15 @@
package org.jruby.truffle.runtime;

/**
* The {@link UndefinedPlaceholder} is a value that represents an undefined value in Ruby. This is
* used to differentiate between nil and the true absence of a value, such as an argument that has
* not been passed.
* The {@link NotProvided} instance represents an argument which was <i>not provided</i>.
* This is necessary as we need to differentiate based on the number of passed arguments
* and there is not a single default value that fits for omitted arguments.
*/
public final class UndefinedPlaceholder {
public final class NotProvided {

public static final UndefinedPlaceholder INSTANCE = new UndefinedPlaceholder();
public static final NotProvided INSTANCE = new NotProvided();

private UndefinedPlaceholder() {
private NotProvided() {
}

}
62 changes: 34 additions & 28 deletions truffle/src/main/ruby/core/truffle/cext/require.rb
Original file line number Diff line number Diff line change
@@ -7,39 +7,45 @@
# GNU Lesser General Public License version 2.1

if Truffle::CExt.supported?
module Kernel
# Monkey patch #require, similar to how RubyGems does,
# in order to load C extensions.
alias_method :truffle_cext_original_require, :require

# Normally a Ruby method in core is not allowed to replace one defined in Java.
# But here we really want it.
remove_method :require

def require(name)
# We're getting quite hacky here. A lot of C extensions are required
# using the format foo/foo, so we need to guess that the real name is
# foo from that.

if name =~ /(.+?)\/\1/
cext_name = $1
else
cext_name = name
end

# Monkey patch #require, similar to how RubyGems does, in order to load
# C extensions.

def require(name)
# We're getting quite hacky here. A lot of C extensions are required
# using the format foo/foo, so we need to guess that the real name is
# foo from that.

if name =~ /(.+?)\/\1/
cext_name = $1
else
cext_name = name
end

# Look in each $JRUBY_TRUFFLE_CEXT_PATH directory for
# cext_name/ext/cext_name/extconf.rb
# Look in each $JRUBY_TRUFFLE_CEXT_PATH directory for
# cext_name/ext/cext_name/extconf.rb

if ENV.include? 'JRUBY_TRUFFLE_CEXT_PATH'
cext_path = ENV['JRUBY_TRUFFLE_CEXT_PATH'].split(':')
else
cext_path = [Dir.pwd]
end
if ENV.include? 'JRUBY_TRUFFLE_CEXT_PATH'
cext_path = ENV['JRUBY_TRUFFLE_CEXT_PATH'].split(':')
else
cext_path = [Dir.pwd]
end

cext_path.each do |dir|
extconf = File.join(dir, cext_name, 'ext', cext_name, 'extconf.rb')
cext_path.each do |dir|
extconf = File.join(dir, cext_name, 'ext', cext_name, 'extconf.rb')

if File.exist? extconf
return Truffle::CExt::load_extconf(extconf)
if File.exist? extconf
return Truffle::CExt::load_extconf(extconf)
end
end
end

Kernel.require name
truffle_cext_original_require name
end
module_function :require
end

end

0 comments on commit 2cb91dc

Please sign in to comment.