Skip to content

Commit

Permalink
Showing 100 changed files with 500 additions and 3,085 deletions.
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@
@NodeChild(value = "right", type = RubyNode.class)})
public abstract class BinaryCoreMethodNode extends CoreMethodNode {

public BinaryCoreMethodNode() {
}

public BinaryCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
@NodeChild(value = "arguments", type = RubyNode[].class)
public abstract class CoreMethodArrayArgumentsNode extends CoreMethodNode {

public CoreMethodArrayArgumentsNode() {
}

public CoreMethodArrayArgumentsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
@GenerateNodeFactory
public abstract class CoreMethodNode extends RubyNode {

public CoreMethodNode() {
}

public CoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -217,9 +217,18 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
assert signatures.size() == 1;
List<Class<?>> signature = signatures.get(0);

if (signature.size() >= 3 && signature.get(2) == RubyNode[].class) {
if (signature.size() == 0) {
methodNode = nodeFactory.createNode();
} else if (signature.size() == 1 && signature.get(0) == RubyNode[].class) {
Object[] args = argumentsNodes.toArray(new RubyNode[argumentsNodes.size()]);
methodNode = nodeFactory.createNode(new Object[]{args});
} else if (signature.size() >= 3 && signature.get(2) == RubyNode[].class) {
Object[] args = argumentsNodes.toArray(new RubyNode[argumentsNodes.size()]);
methodNode = nodeFactory.createNode(context, sourceSection, args);
} else if (signature.get(0) != RubyContext.class) {
Object[] args = new Object[argumentsNodes.size()];
System.arraycopy(argumentsNodes.toArray(new RubyNode[argumentsNodes.size()]), 0, args, 0, argumentsNodes.size());
methodNode = nodeFactory.createNode(args);
} else {
Object[] args = new Object[2 + argumentsNodes.size()];
args[0] = context;
100 changes: 8 additions & 92 deletions truffle/src/main/java/org/jruby/truffle/core/MathNodes.java
Original file line number Diff line number Diff line change
@@ -31,10 +31,6 @@ public abstract class MathNodes {
@CoreMethod(names = "acos", isModuleFunction = true, required = 1)
public abstract static class ACosNode extends SimpleMonadicMathNode {

public ACosNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
if (a < -1.0 || a > 1.0) {
@@ -50,10 +46,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "acosh", isModuleFunction = true, required = 1)
public abstract static class ACosHNode extends SimpleMonadicMathNode {

public ACosHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
// Copied from RubyMath - see copyright notices there
@@ -75,10 +67,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "asin", isModuleFunction = true, required = 1)
public abstract static class ASinNode extends SimpleMonadicMathNode {

public ASinNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
if (a < -1.0 || a > 1.0) {
@@ -94,10 +82,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "asinh", isModuleFunction = true, required = 1)
public abstract static class ASinHNode extends SimpleMonadicMathNode {

public ASinHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
// Copied from RubyMath - see copyright notices there
@@ -124,10 +108,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "atan", isModuleFunction = true, required = 1)
public abstract static class ATanNode extends SimpleMonadicMathNode {

public ATanNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.atan(a);
@@ -138,10 +118,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "atan2", isModuleFunction = true, required = 2)
public abstract static class ATan2Node extends SimpleDyadicMathNode {

public ATan2Node(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a, double b) {
return Math.atan2(a, b);
@@ -152,10 +128,6 @@ protected double doFunction(double a, double b) {
@CoreMethod(names = "atanh", isModuleFunction = true, required = 1)
public abstract static class ATanHNode extends SimpleMonadicMathNode {

public ATanHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
// Copied from RubyMath - see copyright notices there
@@ -187,10 +159,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "cbrt", isModuleFunction = true, required = 1)
public abstract static class CbRtNode extends SimpleMonadicMathNode {

public CbRtNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.cbrt(a);
@@ -201,10 +169,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "cos", isModuleFunction = true, required = 1)
public abstract static class CosNode extends SimpleMonadicMathNode {

public CosNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.cos(a);
@@ -215,10 +179,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "cosh", isModuleFunction = true, required = 1)
public abstract static class CosHNode extends SimpleMonadicMathNode {

public CosHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.cosh(a);
@@ -229,10 +189,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "erf", isModuleFunction = true, required = 1)
public abstract static class ErfNode extends SimpleMonadicMathNode {

public ErfNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
// Copied from RubyMath - see copyright notices there
@@ -257,10 +213,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "erfc", isModuleFunction = true, required = 1)
public abstract static class ErfcNode extends SimpleMonadicMathNode {

public ErfcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
public double doFunction(double a) {
return erfc(a);
@@ -298,10 +250,6 @@ public static double erfc(double a) {
@CoreMethod(names = "exp", isModuleFunction = true, required = 1)
public abstract static class ExpNode extends SimpleMonadicMathNode {

public ExpNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.exp(a);
@@ -376,10 +324,6 @@ public DynamicObject frexp(VirtualFrame frame, Object a) {
@CoreMethod(names = "gamma", isModuleFunction = true, required = 1)
public abstract static class GammaNode extends SimpleMonadicMathNode {

public GammaNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
// Copied from RubyMath - see copyright notices there
@@ -429,10 +373,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "hypot", isModuleFunction = true, required = 2)
public abstract static class HypotNode extends SimpleDyadicMathNode {

public HypotNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a, double b) {
return Math.hypot(a, b);
@@ -591,10 +531,6 @@ public DynamicObject lgamma(VirtualFrame frame, Object a) {
@CoreMethod(names = "log", isModuleFunction = true, required = 1, optional = 1)
public abstract static class LogNode extends SimpleDyadicMathNode {

public LogNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double function(int a, NotProvided b) {
return doFunction(a);
@@ -649,10 +585,6 @@ protected double doFunction(double a, double b) {
@CoreMethod(names = "log10", isModuleFunction = true, required = 1)
public abstract static class Log10Node extends SimpleMonadicMathNode {

public Log10Node(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
if (a < 0) {
@@ -670,10 +602,6 @@ public abstract static class Log2Node extends SimpleMonadicMathNode {

private final double LOG2 = Math.log(2);

public Log2Node(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
if (a < 0) {
@@ -689,10 +617,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "sin", isModuleFunction = true, required = 1)
public abstract static class SinNode extends SimpleMonadicMathNode {

public SinNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.sin(a);
@@ -703,10 +627,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "sinh", isModuleFunction = true, required = 1)
public abstract static class SinHNode extends SimpleMonadicMathNode {

public SinHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.sinh(a);
@@ -717,10 +637,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "tan", isModuleFunction = true, required = 1)
public abstract static class TanNode extends SimpleMonadicMathNode {

public TanNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.tan(a);
@@ -731,10 +647,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "tanh", isModuleFunction = true, required = 1)
public abstract static class TanHNode extends SimpleMonadicMathNode {

public TanHNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.tanh(a);
@@ -745,10 +657,6 @@ protected double doFunction(double a) {
@CoreMethod(names = "sqrt", isModuleFunction = true, required = 1)
public abstract static class SqrtNode extends SimpleMonadicMathNode {

public SqrtNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
protected double doFunction(double a) {
return Math.sqrt(a);
@@ -761,6 +669,10 @@ protected abstract static class SimpleMonadicMathNode extends CoreMethodArrayArg
@Child private IsANode isANode;
@Child private CallDispatchHeadNode floatNode;

protected SimpleMonadicMathNode() {
this(null, null);
}

protected SimpleMonadicMathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
isANode = IsANodeGen.create(context, sourceSection, null, null);
@@ -811,6 +723,10 @@ protected abstract static class SimpleDyadicMathNode extends CoreMethodArrayArgu
@Child protected CallDispatchHeadNode floatANode;
@Child protected CallDispatchHeadNode floatBNode;

protected SimpleDyadicMathNode() {
this(null, null);
}

protected SimpleDyadicMathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
isANode = IsANodeGen.create(context, sourceSection, null, null);
60 changes: 41 additions & 19 deletions truffle/src/main/java/org/jruby/truffle/core/ProcessNodes.java
Original file line number Diff line number Diff line change
@@ -16,16 +16,16 @@
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.cast.DefaultValueNodeGen;
import org.jruby.truffle.core.cast.LazyDefaultValueNodeGen;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.platform.posix.ClockGetTime;
import org.jruby.truffle.platform.posix.TimeSpec;
import org.jruby.truffle.platform.signal.Signal;
import org.jruby.util.func.Function0;

@CoreClass(name = "Process")
public abstract class ProcessNodes {
@@ -46,17 +46,47 @@ public abstract static class ClockGetTimeNode extends CoreMethodNode {
public static final int CLOCK_THREAD_CPUTIME_ID = 3; // Linux only
public static final int CLOCK_MONOTONIC_RAW_ID = 4; // Linux only

private final DynamicObject floatSecondSymbol = getContext().getSymbolTable().getSymbol("float_second");
private final DynamicObject floatMicrosecondSymbol = getContext().getSymbolTable().getSymbol("float_microsecond");
private final DynamicObject nanosecondSymbol = getContext().getSymbolTable().getSymbol("nanosecond");
@CompilerDirectives.CompilationFinal private DynamicObject floatSecondSymbol;
@CompilerDirectives.CompilationFinal private DynamicObject floatMicrosecondSymbol;
@CompilerDirectives.CompilationFinal private DynamicObject nanosecondSymbol;

public ClockGetTimeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
private DynamicObject getFloatSecondSymbol() {
if (floatSecondSymbol == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
floatSecondSymbol = getContext().getSymbolTable().getSymbol("float_second");
}

return floatSecondSymbol;
}

private DynamicObject getFloatMicrosecondSymbol() {
if (floatMicrosecondSymbol == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
floatMicrosecondSymbol = getContext().getSymbolTable().getSymbol("float_microsecond");
}

return floatMicrosecondSymbol;
}

private DynamicObject getNanosecondSymbol() {
if (nanosecondSymbol == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
nanosecondSymbol = getContext().getSymbolTable().getSymbol("nanosecond");
}

return nanosecondSymbol;
}

@CreateCast("unit")
public RubyNode coerceUnit(RubyNode unit) {
return DefaultValueNodeGen.create(getContext(), getSourceSection(), floatSecondSymbol, unit);
return LazyDefaultValueNodeGen.create(null, null, new Function0<Object>() {

@Override
public Object apply() {
return getFloatSecondSymbol();
}

}, unit);
}

@Specialization(guards = { "isMonotonic(clock_id)", "isRubySymbol(unit)" })
@@ -96,11 +126,11 @@ private Object clock_gettime_clock_id(int clock_id, DynamicObject unit) {

private Object timeToUnit(long time, DynamicObject unit) {
assert RubyGuards.isRubySymbol(unit);
if (unit == nanosecondSymbol) {
if (unit == getNanosecondSymbol()) {
return time;
} else if (unit == floatSecondSymbol) {
} else if (unit == getFloatSecondSymbol()) {
return time / 1e9;
} else if (unit == floatMicrosecondSymbol) {
} else if (unit == getFloatMicrosecondSymbol()) {
return time / 1e3;
} else {
throw new UnsupportedOperationException(Layouts.SYMBOL.getString(unit));
@@ -128,10 +158,6 @@ protected static boolean isMonotonicRaw(int clock_id) {
@CoreMethod(names = "kill", onSingleton = true, required = 2, unsafe = {UnsafeGroup.PROCESSES, UnsafeGroup.SIGNALS})
public abstract static class KillNode extends CoreMethodArrayArgumentsNode {

public KillNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isRubySymbol(signalName)")
public int kill(DynamicObject signalName, int pid) {
@@ -160,10 +186,6 @@ private int raise(String signalName) {
@CoreMethod(names = "pid", onSingleton = true)
public abstract static class PidNode extends CoreMethodArrayArgumentsNode {

public PidNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int pid() {
return posix().getpid();
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
@NodeChild(value = "operand", type = RubyNode.class)
public abstract class UnaryCoreMethodNode extends CoreMethodNode {

public UnaryCoreMethodNode() {
}

public UnaryCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -23,6 +23,10 @@ public abstract class YieldingCoreMethodNode extends CoreMethodArrayArgumentsNod
@Child private YieldNode dispatchNode;
@Child private BooleanCastNode booleanCastNode;

public YieldingCoreMethodNode() {
this(null, null);
}

public YieldingCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
dispatchNode = new YieldNode(context);
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
@ImportStatic(ArrayGuards.class)
public abstract class ArrayCoreMethodNode extends CoreMethodArrayArgumentsNode {

public ArrayCoreMethodNode() {
}

public ArrayCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
131 changes: 11 additions & 120 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -64,13 +64,9 @@ public abstract class BasicObjectNodes {
@CoreMethod(names = "!")
public abstract static class NotNode extends UnaryCoreMethodNode {

public NotNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CreateCast("operand")
public RubyNode createCast(RubyNode operand) {
return BooleanCastNodeGen.create(getContext(), getSourceSection(), operand);
return BooleanCastNodeGen.create(null, null, operand);
}

@Specialization
@@ -100,10 +96,6 @@ public boolean equal(VirtualFrame frame, Object a, Object b) {
@CoreMethod(names = { "equal?", "==" }, required = 1)
public abstract static class ReferenceEqualNode extends BinaryCoreMethodNode {

public ReferenceEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract boolean executeReferenceEqual(VirtualFrame frame, Object a, Object b);

@Specialization
@@ -159,10 +151,6 @@ protected boolean notSameClass(Object a, Object b) {
@CoreMethod(names = "initialize", needsSelf = false)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject initialize() {
return nil();
@@ -241,10 +229,6 @@ public Object instanceExec(Object receiver, Object[] arguments, NotProvided bloc
@CoreMethod(names = "__instance_variables__")
public abstract static class InstanceVariablesNode extends CoreMethodArrayArgumentsNode {

public InstanceVariablesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract DynamicObject executeObject(DynamicObject self);

@TruffleBoundary
@@ -270,10 +254,6 @@ public DynamicObject instanceVariables(DynamicObject self) {
@CoreMethod(names = "method_missing", needsBlock = true, rest = true, optional = 1, visibility = Visibility.PRIVATE)
public abstract static class MethodMissingNode extends CoreMethodArrayArgumentsNode {

public MethodMissingNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object methodMissingNoName(Object self, NotProvided name, Object[] args, NotProvided block) {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -300,10 +300,6 @@ protected int getCacheLimit() {
@CoreMethod(names = "local_variables")
public abstract static class LocalVariablesNode extends CoreMethodArrayArgumentsNode {

public LocalVariablesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject localVariables(DynamicObject binding) {
MaterializedFrame frame = Layouts.BINDING.getFrame(binding);
@@ -331,10 +327,6 @@ public static DynamicObject listLocalVariables(RubyContext context, Frame frame)
@CoreMethod(names = "receiver")
public abstract static class ReceiverNode extends UnaryCoreMethodNode {

public ReceiverNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object receiver(DynamicObject binding) {
return RubyArguments.getSelf(Layouts.BINDING.getFrame(binding).getArguments());
@@ -344,10 +336,6 @@ public Object receiver(DynamicObject binding) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
Original file line number Diff line number Diff line change
@@ -25,10 +25,6 @@ public abstract class FalseClassNodes {
@CoreMethod(names = "&", needsSelf = false, required = 1)
public abstract static class AndNode extends UnaryCoreMethodNode {

public AndNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean and(Object other) {
return false;
@@ -38,13 +34,9 @@ public boolean and(Object other) {
@CoreMethod(names = { "|", "^" }, needsSelf = false, required = 1)
public abstract static class OrXorNode extends UnaryCoreMethodNode {

public OrXorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CreateCast("operand")
public RubyNode createCast(RubyNode operand) {
return BooleanCastNodeGen.create(getContext(), getSourceSection(), operand);
return BooleanCastNodeGen.create(null, null, operand);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -26,13 +26,9 @@ public abstract class TrueClassNodes {
@CoreMethod(names = "&", needsSelf = false, required = 1)
public abstract static class AndNode extends UnaryCoreMethodNode {

public AndNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CreateCast("operand")
public RubyNode createCast(RubyNode operand) {
return BooleanCastNodeGen.create(getContext(), getSourceSection(), operand);
return BooleanCastNodeGen.create(null, null, operand);
}

@Specialization
@@ -44,10 +40,6 @@ public boolean and(boolean other) {
@CoreMethod(names = "|", needsSelf = false, required = 1)
public abstract static class OrNode extends CoreMethodArrayArgumentsNode {

public OrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean or(Object other) {
return true;
@@ -57,13 +49,9 @@ public boolean or(Object other) {
@CoreMethod(names = "^", needsSelf = false, required = 1)
public abstract static class XorNode extends UnaryCoreMethodNode {

public XorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CreateCast("operand")
public RubyNode createCast(RubyNode operand) {
return BooleanCastNodeGen.create(getContext(), getSourceSection(), operand);
return BooleanCastNodeGen.create(null, null, operand);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;
import org.jruby.util.func.Function0;

@NodeChild(value = "value", type = RubyNode.class)
public abstract class LazyDefaultValueNode extends RubyNode {

private final Function0<Object> defaultValueProducer;

@CompilerDirectives.CompilationFinal private boolean hasDefault;
@CompilerDirectives.CompilationFinal private Object defaultValue;

public LazyDefaultValueNode(RubyContext context, SourceSection sourceSection, Function0<Object> defaultValueProducer) {
super(context, sourceSection);
this.defaultValueProducer = defaultValueProducer;
}

@Specialization
public Object doDefault(NotProvided value) {
if (!hasDefault) {
CompilerDirectives.transferToInterpreter();
defaultValue = defaultValueProducer.apply();
hasDefault = true;
}

return defaultValue;
}

@Specialization(guards = "wasProvided(value)")
public Object doProvided(Object value) {
return value;
}

}
Original file line number Diff line number Diff line change
@@ -40,21 +40,21 @@ public TaintResultNode(boolean taintFromSelf, int taintFromParameter, RubyNode m
this.taintFromSelf = taintFromSelf;
this.taintFromParameter = taintFromParameter;
this.method = method;
this.isTaintedNode = IsTaintedNodeGen.create(getContext(), getSourceSection(), null);
this.isTaintedNode = IsTaintedNodeGen.create(null, null, null);
}

public TaintResultNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
this.taintFromSelf = false;
this.taintFromParameter = -1;
this.isTaintedNode = IsTaintedNodeGen.create(getContext(), getSourceSection(), null);
this.isTaintedNode = IsTaintedNodeGen.create(null, null, null);
}

public Object maybeTaint(DynamicObject source, DynamicObject result) {
if (taintProfile.profile(isTaintedNode.executeIsTainted(source))) {
if (taintNode == null) {
CompilerDirectives.transferToInterpreter();
taintNode = insert(TaintNodeGen.create(getContext(), getSourceSection(), null));
taintNode = insert(TaintNodeGen.create(null, null, null));
}

taintNode.executeTaint(result);
Original file line number Diff line number Diff line change
@@ -49,10 +49,6 @@ public static DynamicObject createEncodingConverter(DynamicObject rubyClass, ECo
@CoreMethod(names = "initialize_jruby", required = 2, optional = 1, visibility = Visibility.PRIVATE)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject initialize(DynamicObject self, Object source, Object destination, Object unusedOptions) {
@@ -178,10 +174,6 @@ public Object transcodingMap(VirtualFrame frame) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends CoreMethodArrayArgumentsNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
return createEncodingConverter(rubyClass, null);
Original file line number Diff line number Diff line change
@@ -98,10 +98,6 @@ public static DynamicObject createRubyEncoding(DynamicObject encodingClass, Enco
@CoreMethod(names = "ascii_compatible?")
public abstract static class AsciiCompatibleNode extends CoreMethodArrayArgumentsNode {

public AsciiCompatibleNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object isCompatible(DynamicObject encoding) {
return EncodingOperations.getEncoding(encoding).isAsciiCompatible();
@@ -111,10 +107,6 @@ public Object isCompatible(DynamicObject encoding) {
@CoreMethod(names = "compatible?", needsSelf = false, onSingleton = true, required = 2)
public abstract static class CompatibleQueryNode extends CoreMethodArrayArgumentsNode {

public CompatibleQueryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = {
"isRubyString(first)",
"isRubyString(second)",
@@ -317,10 +309,6 @@ public abstract static class SetDefaultExternalNode extends CoreMethodArrayArgum

@Child private ToStrNode toStrNode;

public SetDefaultExternalNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isRubyEncoding(encoding)")
public DynamicObject defaultExternalEncoding(DynamicObject encoding) {
@@ -362,10 +350,6 @@ public abstract static class SetDefaultInternalNode extends CoreMethodArrayArgum

@Child private ToStrNode toStrNode;

public SetDefaultInternalNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization(guards = "isRubyEncoding(encoding)")
public DynamicObject defaultInternal(DynamicObject encoding) {
@@ -400,10 +384,6 @@ public DynamicObject defaultInternal(VirtualFrame frame, Object encoding) {
@CoreMethod(names = "list", onSingleton = true)
public abstract static class ListNode extends CoreMethodArrayArgumentsNode {

public ListNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject list() {
@@ -417,10 +397,6 @@ public DynamicObject list() {
@CoreMethod(names = "locale_charmap", onSingleton = true)
public abstract static class LocaleCharacterMapNode extends CoreMethodArrayArgumentsNode {

public LocaleCharacterMapNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject localeCharacterMap() {
@@ -432,10 +408,6 @@ public DynamicObject localeCharacterMap() {
@CoreMethod(names = "dummy?")
public abstract static class DummyNode extends CoreMethodArrayArgumentsNode {

public DummyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean isDummy(DynamicObject encoding) {
return Layouts.ENCODING.getDummy(encoding);
@@ -539,10 +511,6 @@ public Object indexLookup(DynamicObject[] encodings, Encoding encoding) {
@CoreMethod(names = { "name", "to_s" })
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {

public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject toS(DynamicObject encoding) {
@@ -555,10 +523,6 @@ public DynamicObject toS(DynamicObject encoding) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
Original file line number Diff line number Diff line change
@@ -37,10 +37,6 @@ public abstract class ExceptionNodes {
@CoreMethod(names = "initialize", optional = 1)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject initialize(DynamicObject exception, NotProvided message) {
Layouts.EXCEPTION.setMessage(exception, nil());
@@ -60,10 +56,6 @@ public abstract static class BacktraceNode extends CoreMethodArrayArgumentsNode

@Child private ReadObjectFieldNode readCustomBacktraceNode;

public BacktraceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object backtrace(
DynamicObject exception,
@@ -86,7 +78,7 @@ public Object backtrace(
private ReadObjectFieldNode getReadCustomBacktraceNode() {
if (readCustomBacktraceNode == null) {
CompilerDirectives.transferToInterpreter();
readCustomBacktraceNode = insert(ReadObjectFieldNodeGen.create(getContext(),
readCustomBacktraceNode = insert(ReadObjectFieldNodeGen.create(
"@custom_backtrace", null));
}

@@ -99,10 +91,6 @@ private ReadObjectFieldNode getReadCustomBacktraceNode() {
@CoreMethod(names = "capture_backtrace!", optional = 1)
public abstract static class CaptureBacktraceNode extends CoreMethodArrayArgumentsNode {

public CaptureBacktraceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject captureBacktrace(DynamicObject exception, NotProvided offset) {
return captureBacktrace(exception, 1);
@@ -121,10 +109,6 @@ public DynamicObject captureBacktrace(DynamicObject exception, int offset) {
@CoreMethod(names = "message")
public abstract static class MessageNode extends CoreMethodArrayArgumentsNode {

public MessageNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object message(
DynamicObject exception,
24 changes: 2 additions & 22 deletions truffle/src/main/java/org/jruby/truffle/core/fiber/FiberNodes.java
Original file line number Diff line number Diff line change
@@ -211,10 +211,6 @@ public abstract static class FiberTransferNode extends CoreMethodArrayArgumentsN

@Child SingleValueCastNode singleValueCastNode;

public FiberTransferNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

protected Object singleValue(VirtualFrame frame, Object[] args) {
if (singleValueCastNode == null) {
CompilerDirectives.transferToInterpreter();
@@ -248,10 +244,6 @@ protected Object transfer(VirtualFrame frame, DynamicObject fiber, boolean isYie
@CoreMethod(names = "initialize", needsBlock = true, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR, unsafe = UnsafeGroup.THREADS)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject initialize(DynamicObject fiber, DynamicObject block) {
@@ -268,7 +260,7 @@ public abstract static class ResumeNode extends CoreMethodArrayArgumentsNode {

public ResumeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(context, sourceSection, new RubyNode[] { null, null, null });
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
}

@Specialization
@@ -285,7 +277,7 @@ public abstract static class YieldNode extends CoreMethodArrayArgumentsNode {

public YieldNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(context, sourceSection, new RubyNode[] { null, null, null });
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
}

@Specialization
@@ -355,10 +347,6 @@ public static class FiberExitException extends ControlFlowException {
@CoreMethod(names = "alive?", unsafe = UnsafeGroup.THREADS)
public abstract static class AliveNode extends UnaryCoreMethodNode {

public AliveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean alive(DynamicObject fiber) {
return Layouts.FIBER.getAlive(fiber);
@@ -369,10 +357,6 @@ public boolean alive(DynamicObject fiber) {
@CoreMethod(names = "current", onSingleton = true)
public abstract static class CurrentNode extends CoreMethodNode {

public CurrentNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject current() {
final DynamicObject currentThread = getContext().getThreadManager().getCurrentThread();
@@ -384,10 +368,6 @@ public DynamicObject current() {
@CoreMethod(names = "allocate", constructor = true, unsafe = UnsafeGroup.THREADS)
public abstract static class AllocateNode extends CoreMethodArrayArgumentsNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
54 changes: 1 addition & 53 deletions truffle/src/main/java/org/jruby/truffle/core/hash/HashNodes.java
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(context, sourceSection, null, null);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
callDefaultNode = DispatchHeadNodeFactory.createMethodCall(context);
lookupEntryNode = new LookupEntryNode(context, sourceSection);
}
@@ -398,10 +398,6 @@ public Object set(VirtualFrame frame, DynamicObject hash, Object key, Object val
@ImportStatic(HashGuards.class)
public abstract static class ClearNode extends CoreMethodArrayArgumentsNode {

public ClearNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isNullHash(hash)")
public DynamicObject emptyNull(DynamicObject hash) {
return hash;
@@ -425,10 +421,6 @@ public DynamicObject empty(DynamicObject hash) {
@CoreMethod(names = "compare_by_identity", raiseIfFrozenSelf = true)
public abstract static class CompareByIdentityNode extends CoreMethodArrayArgumentsNode {

public CompareByIdentityNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject compareByIdentity(DynamicObject hash) {
Layouts.HASH.setCompareByIdentity(hash, true);
@@ -456,10 +448,6 @@ public boolean compareByIdentity(DynamicObject hash) {
@CoreMethod(names = "default_proc")
public abstract static class DefaultProcNode extends CoreMethodArrayArgumentsNode {

public DefaultProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object defaultProc(DynamicObject hash) {
if (Layouts.HASH.getDefaultBlock(hash) == null) {
@@ -658,10 +646,6 @@ private Object yieldPair(VirtualFrame frame, DynamicObject block, Object key, Ob
@ImportStatic(HashGuards.class)
public abstract static class EmptyNode extends CoreMethodArrayArgumentsNode {

public EmptyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isNullHash(hash)")
public boolean emptyNull(DynamicObject hash) {
return true;
@@ -678,10 +662,6 @@ public boolean emptyPackedArray(DynamicObject hash) {
@ImportStatic(HashGuards.class)
public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode {

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject initialize(DynamicObject hash, NotProvided defaultValue, NotProvided block) {
assert HashOperations.verifyStore(getContext(), null, 0, null, null);
@@ -733,10 +713,6 @@ public Object initialize(DynamicObject hash, Object defaultValue, DynamicObject
@ImportStatic(HashGuards.class)
public abstract static class InitializeCopyNode extends CoreMethodArrayArgumentsNode {

public InitializeCopyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = {"isRubyHash(from)", "isNullHash(from)"})
public DynamicObject replaceNull(DynamicObject self, DynamicObject from) {
if (self == from) {
@@ -808,10 +784,6 @@ private void copyOtherFields(DynamicObject self, DynamicObject from) {
@ImportStatic(HashGuards.class)
public abstract static class MapNode extends YieldingCoreMethodNode {

public MapNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isNullHash(hash)")
public DynamicObject mapNull(VirtualFrame frame, DynamicObject hash, DynamicObject block) {
assert HashOperations.verifyStore(getContext(), hash);
@@ -1219,10 +1191,6 @@ public Object merge(VirtualFrame frame, DynamicObject hash, Object other, Object
@CoreMethod(names = "default=", required = 1, raiseIfFrozenSelf = true)
public abstract static class SetDefaultNode extends CoreMethodArrayArgumentsNode {

public SetDefaultNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object setDefault(DynamicObject hash, Object defaultValue) {
Layouts.HASH.setDefaultValue(hash, defaultValue);
@@ -1237,10 +1205,6 @@ public abstract static class ShiftNode extends CoreMethodArrayArgumentsNode {

@Child private YieldNode yieldNode;

public ShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = {"isEmptyHash(hash)", "!hasDefaultValue(hash)", "!hasDefaultBlock(hash)"})
public DynamicObject shiftEmpty(DynamicObject hash) {
return nil();
@@ -1346,10 +1310,6 @@ public DynamicObject shiftBuckets(DynamicObject hash) {
@ImportStatic(HashGuards.class)
public abstract static class SizeNode extends CoreMethodArrayArgumentsNode {

public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isNullHash(hash)")
public int sizeNull(DynamicObject hash) {
return 0;
@@ -1434,10 +1394,6 @@ public DynamicObject rehashBuckets(DynamicObject hash) {
@NodeChild(type = RubyNode.class, value = "self")
public abstract static class DefaultValueNode extends CoreMethodNode {

public DefaultValueNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object defaultValue(DynamicObject hash) {
final Object value = Layouts.HASH.getDefaultValue(hash);
@@ -1457,10 +1413,6 @@ public Object defaultValue(DynamicObject hash) {
})
public abstract static class SetDefaultValueNode extends CoreMethodNode {

public SetDefaultValueNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object setDefaultValue(DynamicObject hash, Object defaultValue) {
Layouts.HASH.setDefaultValue(hash, defaultValue);
@@ -1476,10 +1428,6 @@ public Object setDefaultValue(DynamicObject hash, Object defaultValue) {
})
public abstract static class SetDefaultProcNode extends CoreMethodNode {

public SetDefaultProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isRubyProc(defaultProc)")
public DynamicObject setDefaultProc(DynamicObject hash, DynamicObject defaultProc) {
Layouts.HASH.setDefaultValue(hash, null);
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public LookupEntryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(context, sourceSection, null, null);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
}

public HashLookupResult lookup(VirtualFrame frame, DynamicObject hash, Object key) {
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public SetNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(context, sourceSection, null, null);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null);
}

public abstract Object executeSet(VirtualFrame frame, DynamicObject hash, Object key, Object value, boolean byIdentity);
182 changes: 24 additions & 158 deletions truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -266,10 +266,6 @@ public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode
@Child private ModuleNodes.InitializeNode moduleInitializeNode;
@Child private CallDispatchHeadNode inheritedNode;

public InitializeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

void triggerInheritedHook(VirtualFrame frame, DynamicObject subClass, DynamicObject superClass) {
if (inheritedNode == null) {
CompilerDirectives.transferToInterpreter();
@@ -281,7 +277,7 @@ void triggerInheritedHook(VirtualFrame frame, DynamicObject subClass, DynamicObj
void moduleInitialize(VirtualFrame frame, DynamicObject rubyClass, DynamicObject block) {
if (moduleInitializeNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(new RubyNode[]{ null, null }));
}
moduleInitializeNode.executeInitialize(frame, rubyClass, block);
}
@@ -331,10 +327,6 @@ private DynamicObject initializeGeneralWithBlock(VirtualFrame frame, DynamicObje
@CoreMethod(names = "inherited", required = 1, visibility = Visibility.PRIVATE)
public abstract static class InheritedNode extends CoreMethodArrayArgumentsNode {

public InheritedNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject inherited(Object subclass) {
return nil();
@@ -345,10 +337,6 @@ public DynamicObject inherited(Object subclass) {
@CoreMethod(names = "superclass")
public abstract static class SuperClassNode extends CoreMethodArrayArgumentsNode {

public SuperClassNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = { "rubyClass == cachedRubyCLass", "cachedSuperclass != null" }, limit = "getCacheLimit()")
public Object getSuperClass(DynamicObject rubyClass,
@Cached("rubyClass") DynamicObject cachedRubyCLass,
@@ -380,10 +368,6 @@ protected int getCacheLimit() {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateConstructorNode extends CoreMethodArrayArgumentsNode {

public AllocateConstructorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
return createRubyClass(getContext(), coreLibrary().getClassClass(), null, coreLibrary().getObjectClass(), null, false, null, false);
Original file line number Diff line number Diff line change
@@ -55,14 +55,10 @@ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {

@Child protected ReferenceEqualNode referenceEqualNode;

public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

protected boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(getContext(), getSourceSection(), null, null));
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null, null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
}
@@ -82,10 +78,6 @@ public boolean equal(DynamicObject a, Object b) {
@CoreMethod(names = "arity")
public abstract static class ArityNode extends CoreMethodArrayArgumentsNode {

public ArityNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int arity(DynamicObject method) {
return Layouts.METHOD.getMethod(method).getSharedMethodInfo().getArity().getArityNumber();
@@ -115,10 +107,6 @@ protected Object call(VirtualFrame frame, DynamicObject method, Object[] argumen
@CoreMethod(names = "name")
public abstract static class NameNode extends CoreMethodArrayArgumentsNode {

public NameNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject name(DynamicObject method) {
CompilerDirectives.transferToInterpreter();
@@ -131,10 +119,6 @@ public DynamicObject name(DynamicObject method) {
@CoreMethod(names = "owner")
public abstract static class OwnerNode extends CoreMethodArrayArgumentsNode {

public OwnerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject owner(DynamicObject method) {
return Layouts.METHOD.getMethod(method).getDeclaringModule();
@@ -145,10 +129,6 @@ public DynamicObject owner(DynamicObject method) {
@CoreMethod(names = "parameters")
public abstract static class ParametersNode extends CoreMethodArrayArgumentsNode {

public ParametersNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject parameters(DynamicObject method) {
@@ -162,10 +142,6 @@ public DynamicObject parameters(DynamicObject method) {
@CoreMethod(names = "receiver")
public abstract static class ReceiverNode extends CoreMethodArrayArgumentsNode {

public ReceiverNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object receiver(DynamicObject method) {
return Layouts.METHOD.getReceiver(method);
@@ -176,10 +152,6 @@ public Object receiver(DynamicObject method) {
@CoreMethod(names = "source_location")
public abstract static class SourceLocationNode extends CoreMethodArrayArgumentsNode {

public SourceLocationNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object sourceLocation(DynamicObject method) {
CompilerDirectives.transferToInterpreter();
@@ -218,10 +190,6 @@ public DynamicObject unbind(VirtualFrame frame, DynamicObject method) {
@CoreMethod(names = "to_proc")
public abstract static class ToProcNode extends CoreMethodArrayArgumentsNode {

public ToProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "methodObject == cachedMethodObject", limit = "getCacheLimit()")
public DynamicObject toProcCached(DynamicObject methodObject,
@Cached("methodObject") DynamicObject cachedMethodObject,
@@ -289,10 +257,6 @@ public Object execute(VirtualFrame frame) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
Original file line number Diff line number Diff line change
@@ -38,10 +38,6 @@ public abstract class UnboundMethodNodes {
@CoreMethod(names = "==", required = 1)
public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {

public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isRubyUnboundMethod(other)")
boolean equal(DynamicObject self, DynamicObject other) {
return Layouts.UNBOUND_METHOD.getMethod(self) == Layouts.UNBOUND_METHOD.getMethod(other) && Layouts.UNBOUND_METHOD.getOrigin(self) == Layouts.UNBOUND_METHOD.getOrigin(other);
@@ -57,10 +53,6 @@ boolean equal(DynamicObject self, Object other) {
@CoreMethod(names = "arity")
public abstract static class ArityNode extends CoreMethodArrayArgumentsNode {

public ArityNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int arity(DynamicObject method) {
return Layouts.UNBOUND_METHOD.getMethod(method).getSharedMethodInfo().getArity().getArityNumber();
@@ -108,10 +100,6 @@ protected DynamicObject metaClass(Object object) {
@CoreMethod(names = "name")
public abstract static class NameNode extends CoreMethodArrayArgumentsNode {

public NameNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject name(DynamicObject unboundMethod) {
return getSymbol(Layouts.UNBOUND_METHOD.getMethod(unboundMethod).getName());
@@ -123,10 +111,6 @@ public DynamicObject name(DynamicObject unboundMethod) {
@CoreMethod(names = "origin", visibility = Visibility.PRIVATE)
public abstract static class OriginNode extends CoreMethodArrayArgumentsNode {

public OriginNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject origin(DynamicObject unboundMethod) {
return Layouts.UNBOUND_METHOD.getOrigin(unboundMethod);
@@ -137,10 +121,6 @@ public DynamicObject origin(DynamicObject unboundMethod) {
@CoreMethod(names = "owner")
public abstract static class OwnerNode extends CoreMethodArrayArgumentsNode {

public OwnerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject owner(DynamicObject unboundMethod) {
return Layouts.UNBOUND_METHOD.getMethod(unboundMethod).getDeclaringModule();
@@ -151,10 +131,6 @@ public DynamicObject owner(DynamicObject unboundMethod) {
@CoreMethod(names = "parameters")
public abstract static class ParametersNode extends CoreMethodArrayArgumentsNode {

public ParametersNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject parameters(DynamicObject method) {
@@ -168,10 +144,6 @@ public DynamicObject parameters(DynamicObject method) {
@CoreMethod(names = "source_location")
public abstract static class SourceLocationNode extends CoreMethodArrayArgumentsNode {

public SourceLocationNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public Object sourceLocation(DynamicObject unboundMethod) {
@@ -191,10 +163,6 @@ public Object sourceLocation(DynamicObject unboundMethod) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
178 changes: 27 additions & 151 deletions truffle/src/main/java/org/jruby/truffle/core/module/ModuleNodes.java

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions truffle/src/main/java/org/jruby/truffle/core/mutex/MutexNodes.java
Original file line number Diff line number Diff line change
@@ -52,10 +52,6 @@ public DynamicObject allocate(DynamicObject rubyClass) {
@CoreMethod(names = "lock")
public abstract static class LockNode extends UnaryCoreMethodNode {

public LockNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject lock(DynamicObject mutex) {
final ReentrantLock lock = Layouts.MUTEX.getLock(mutex);
@@ -69,10 +65,6 @@ public DynamicObject lock(DynamicObject mutex) {
@CoreMethod(names = "locked?")
public abstract static class IsLockedNode extends UnaryCoreMethodNode {

public IsLockedNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean isLocked(DynamicObject mutex) {
return Layouts.MUTEX.getLock(mutex).isLocked();
@@ -83,10 +75,6 @@ public boolean isLocked(DynamicObject mutex) {
@CoreMethod(names = "owned?")
public abstract static class IsOwnedNode extends UnaryCoreMethodNode {

public IsOwnedNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean isOwned(DynamicObject mutex) {
return Layouts.MUTEX.getLock(mutex).isHeldByCurrentThread();
@@ -97,10 +85,6 @@ public boolean isOwned(DynamicObject mutex) {
@CoreMethod(names = "try_lock")
public abstract static class TryLockNode extends UnaryCoreMethodNode {

public TryLockNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean tryLock(
DynamicObject mutex,
@@ -130,10 +114,6 @@ private boolean doTryLock(final ReentrantLock lock) {
@CoreMethod(names = "unlock")
public abstract static class UnlockNode extends UnaryCoreMethodNode {

public UnlockNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject unlock(DynamicObject mutex) {
final ReentrantLock lock = Layouts.MUTEX.getLock(mutex);
@@ -149,10 +129,6 @@ public abstract static class SleepNode extends CoreMethodArrayArgumentsNode {

private final ConditionProfile durationLessThanZeroProfile = ConditionProfile.createBinaryProfile();

public SleepNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public long sleep(DynamicObject mutex, NotProvided duration) {
return doSleepMillis(mutex, Long.MAX_VALUE);
112 changes: 0 additions & 112 deletions truffle/src/main/java/org/jruby/truffle/core/numeric/BignumNodes.java
Original file line number Diff line number Diff line change
@@ -39,10 +39,6 @@ public static abstract class BignumCoreMethodNode extends CoreMethodArrayArgumen

@Child private FixnumOrBignumNode fixnumOrBignum;

public BignumCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public Object fixnumOrBignum(BigInteger value) {
if (fixnumOrBignum == null) {
CompilerDirectives.transferToInterpreter();
@@ -56,10 +52,6 @@ public Object fixnumOrBignum(BigInteger value) {
@CoreMethod(names = "-@")
public abstract static class NegNode extends BignumCoreMethodNode {

public NegNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object neg(DynamicObject value) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(value).negate());
@@ -70,10 +62,6 @@ public Object neg(DynamicObject value) {
@CoreMethod(names = "+", required = 1)
public abstract static class AddNode extends BignumCoreMethodNode {

public AddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object add(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).add(BigInteger.valueOf(b)));
@@ -94,10 +82,6 @@ public Object add(DynamicObject a, DynamicObject b) {
@CoreMethod(names = "-", required = 1)
public abstract static class SubNode extends BignumCoreMethodNode {

public SubNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object sub(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).subtract(BigInteger.valueOf(b)));
@@ -118,10 +102,6 @@ public Object sub(DynamicObject a, DynamicObject b) {
@CoreMethod(names = "*", required = 1)
public abstract static class MulNode extends BignumCoreMethodNode {

public MulNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public Object mul(DynamicObject a, long b) {
@@ -149,10 +129,6 @@ public Object mul(VirtualFrame frame, DynamicObject a, Object b) {
@CoreMethod(names = {"/", "__slash__"}, required = 1)
public abstract static class DivNode extends BignumCoreMethodNode {

public DivNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object div(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).divide(BigInteger.valueOf(b)));
@@ -173,10 +149,6 @@ public Object div(DynamicObject a, DynamicObject b) {
@CoreMethod(names = {"%", "modulo"}, required = 1)
public abstract static class ModNode extends BignumCoreMethodNode {

public ModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object mod(DynamicObject a, long b) {
if (b == 0) {
@@ -212,10 +184,6 @@ public Object mod(VirtualFrame frame, DynamicObject a, Object b) {
@CoreMethod(names = "<", required = 1)
public abstract static class LessNode extends CoreMethodArrayArgumentsNode {

public LessNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean less(DynamicObject a, long b) {
return Layouts.BIGNUM.getValue(a).compareTo(BigInteger.valueOf(b)) < 0;
@@ -245,10 +213,6 @@ public Object lessCoerced(VirtualFrame frame, DynamicObject a, Object b) {
@CoreMethod(names = "<=", required = 1)
public abstract static class LessEqualNode extends CoreMethodArrayArgumentsNode {

public LessEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean lessEqual(DynamicObject a, long b) {
return Layouts.BIGNUM.getValue(a).compareTo(BigInteger.valueOf(b)) <= 0;
@@ -280,10 +244,6 @@ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {
@Child private BooleanCastNode booleanCastNode;
@Child private CallDispatchHeadNode reverseCallNode;

public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean equal(DynamicObject a, int b) {
return false;
@@ -325,10 +285,6 @@ public boolean equal(VirtualFrame frame, DynamicObject a, DynamicObject b) {
@CoreMethod(names = ">=", required = 1)
public abstract static class GreaterEqualNode extends CoreMethodArrayArgumentsNode {

public GreaterEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greaterEqual(DynamicObject a, long b) {
return Layouts.BIGNUM.getValue(a).compareTo(BigInteger.valueOf(b)) >= 0;
@@ -357,10 +313,6 @@ public Object greaterEqualCoerced(VirtualFrame frame, DynamicObject a, Object b)
@CoreMethod(names = ">", required = 1)
public abstract static class GreaterNode extends CoreMethodArrayArgumentsNode {

public GreaterNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greater(DynamicObject a, long b) {
return Layouts.BIGNUM.getValue(a).compareTo(BigInteger.valueOf(b)) > 0;
@@ -389,10 +341,6 @@ public Object greaterCoerced(VirtualFrame frame, DynamicObject a, Object b) {
@CoreMethod(names = "~")
public abstract static class ComplementNode extends BignumCoreMethodNode {

public ComplementNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object complement(DynamicObject value) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(value).not());
@@ -403,10 +351,6 @@ public Object complement(DynamicObject value) {
@CoreMethod(names = "&", required = 1)
public abstract static class BitAndNode extends BignumCoreMethodNode {

public BitAndNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object bitAnd(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).and(BigInteger.valueOf(b)));
@@ -421,10 +365,6 @@ public Object bitAnd(DynamicObject a, DynamicObject b) {
@CoreMethod(names = "|", required = 1)
public abstract static class BitOrNode extends BignumCoreMethodNode {

public BitOrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object bitOr(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).or(BigInteger.valueOf(b)));
@@ -439,10 +379,6 @@ public Object bitOr(DynamicObject a, DynamicObject b) {
@CoreMethod(names = "^", required = 1)
public abstract static class BitXOrNode extends BignumCoreMethodNode {

public BitXOrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object bitXOr(DynamicObject a, long b) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).xor(BigInteger.valueOf(b)));
@@ -459,10 +395,6 @@ public abstract static class LeftShiftNode extends BignumCoreMethodNode {

private final BranchProfile bLessThanZero = BranchProfile.create();

public LeftShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object leftShift(DynamicObject a, int b) {
if (b >= 0) {
@@ -480,10 +412,6 @@ public abstract static class RightShiftNode extends BignumCoreMethodNode {

private final BranchProfile bLessThanZero = BranchProfile.create();

public RightShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object leftShift(DynamicObject a, int b) {
if (b >= 0) {
@@ -499,10 +427,6 @@ public Object leftShift(DynamicObject a, int b) {
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends BignumCoreMethodNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object abs(DynamicObject value) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(value).abs());
@@ -513,10 +437,6 @@ public Object abs(DynamicObject value) {
@CoreMethod(names = "bit_length")
public abstract static class BitLengthNode extends CoreMethodArrayArgumentsNode {

public BitLengthNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int bitLength(DynamicObject value) {
return Layouts.BIGNUM.getValue(value).bitLength();
@@ -527,10 +447,6 @@ public int bitLength(DynamicObject value) {
@CoreMethod(names = "coerce", required = 1)
public abstract static class CoerceNode extends CoreMethodArrayArgumentsNode {

public CoerceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject coerce(DynamicObject a, int b) {
CompilerDirectives.transferToInterpreter();
@@ -591,10 +507,6 @@ public DynamicObject divMod(DynamicObject a, DynamicObject b) {
@CoreMethod(names = "even?")
public abstract static class EvenNode extends BignumCoreMethodNode {

public EvenNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean even(DynamicObject value) {
@@ -606,10 +518,6 @@ public boolean even(DynamicObject value) {
@CoreMethod(names = "hash")
public abstract static class HashNode extends CoreMethodArrayArgumentsNode {

public HashNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int hash(DynamicObject value) {
return Layouts.BIGNUM.getValue(value).hashCode();
@@ -620,10 +528,6 @@ public int hash(DynamicObject value) {
@CoreMethod(names = "odd?")
public abstract static class OddNode extends BignumCoreMethodNode {

public OddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean odd(DynamicObject value) {
@@ -635,10 +539,6 @@ public boolean odd(DynamicObject value) {
@CoreMethod(names = "size")
public abstract static class SizeNode extends CoreMethodArrayArgumentsNode {

public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int size(DynamicObject value) {
return (Layouts.BIGNUM.getValue(value).bitLength() + 7) / 8;
@@ -649,10 +549,6 @@ public int size(DynamicObject value) {
@CoreMethod(names = "to_f")
public abstract static class ToFNode extends CoreMethodArrayArgumentsNode {

public ToFNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double toF(DynamicObject value) {
return Layouts.BIGNUM.getValue(value).doubleValue();
@@ -663,10 +559,6 @@ public double toF(DynamicObject value) {
@CoreMethod(names = {"to_s", "inspect"}, optional = 1)
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {

public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject toS(DynamicObject value, NotProvided base) {
@@ -689,10 +581,6 @@ public DynamicObject toS(DynamicObject value, int base) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
106 changes: 3 additions & 103 deletions truffle/src/main/java/org/jruby/truffle/core/numeric/FixnumNodes.java
Original file line number Diff line number Diff line change
@@ -46,10 +46,6 @@ public abstract static class NegNode extends CoreMethodArrayArgumentsNode {

@Child private FixnumOrBignumNode fixnumOrBignumNode;

public NegNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = ArithmeticException.class)
public int neg(int value) {
return ExactMath.subtractExact(0, value);
@@ -83,10 +79,6 @@ public Object negWithOverflow(long value) {
@CoreMethod(names = "+", required = 1)
public abstract static class AddNode extends BignumNodes.BignumCoreMethodNode {

public AddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = ArithmeticException.class)
public int add(int a, int b) {
return ExactMath.addExact(a, b);
@@ -132,10 +124,6 @@ public Object addCoerced(VirtualFrame frame, long a, DynamicObject b) {
@CoreMethod(names = "-", required = 1)
public abstract static class SubNode extends BignumNodes.BignumCoreMethodNode {

public SubNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = ArithmeticException.class)
public int sub(int a, int b) {
return ExactMath.subtractExact(a, b);
@@ -181,10 +169,6 @@ public Object subCoerced(VirtualFrame frame, long a, DynamicObject b) {
@CoreMethod(names = "*", required = 1)
public abstract static class MulNode extends BignumNodes.BignumCoreMethodNode {

public MulNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = ArithmeticException.class)
public int mul(int a, int b) {
return ExactMath.multiplyExact(a, b);
@@ -240,10 +224,6 @@ public abstract static class DivNode extends CoreMethodArrayArgumentsNode {
private final BranchProfile bMinusOneANotMinimum = BranchProfile.create();
private final BranchProfile finalCase = BranchProfile.create();

public DivNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = UnexpectedResultException.class)
public int div(int a, int b) throws UnexpectedResultException {
if (b > 0) {
@@ -387,10 +367,6 @@ public abstract static class ModNode extends BignumNodes.BignumCoreMethodNode {

private final BranchProfile adjustProfile = BranchProfile.create();

public ModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int mod(int a, int b) {
int mod = a % b;
@@ -479,10 +455,6 @@ public DynamicObject divMod(long a, double b) {
@CoreMethod(names = "<", required = 1, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class LessNode extends CoreMethodArrayArgumentsNode {

public LessNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean less(int a, int b) {
return a < b;
@@ -521,10 +493,6 @@ public Object lessCoerced(VirtualFrame frame, long a, Object b) {
@CoreMethod(names = "<=", required = 1, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class LessEqualNode extends CoreMethodArrayArgumentsNode {

public LessEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean lessEqual(int a, int b) {
return a <= b;
@@ -608,10 +576,6 @@ public Object equal(VirtualFrame frame, Object a, Object b) {
@CoreMethod(names = "<=>", required = 1)
public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {

public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int compare(int a, int b) {
return Integer.compare(a, b);
@@ -651,10 +615,6 @@ public Object compare(VirtualFrame frame, Object a, Object b) {
@CoreMethod(names = ">=", required = 1, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class GreaterEqualNode extends CoreMethodArrayArgumentsNode {

public GreaterEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greaterEqual(int a, int b) {
return a >= b;
@@ -693,10 +653,6 @@ public Object greaterEqualCoerced(VirtualFrame frame, long a, Object b) {
@CoreMethod(names = ">", required = 1, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class GreaterNode extends CoreMethodArrayArgumentsNode {

public GreaterNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greater(int a, int b) {
return a > b;
@@ -736,10 +692,6 @@ public Object greaterCoerced(VirtualFrame frame, long a, Object b) {
@CoreMethod(names = "~")
public abstract static class ComplementNode extends CoreMethodArrayArgumentsNode {

public ComplementNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int complement(int n) {
return ~n;
@@ -755,10 +707,6 @@ public long complement(long n) {
@CoreMethod(names = "&", required = 1)
public abstract static class BitAndNode extends BignumNodes.BignumCoreMethodNode {

public BitAndNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int bitAndIntInt(int a, int b) {
return a & b;
@@ -788,10 +736,6 @@ public Object bitAndBignum(long a, DynamicObject b) {
@CoreMethod(names = "|", required = 1)
public abstract static class BitOrNode extends BignumNodes.BignumCoreMethodNode {

public BitOrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int bitOr(int a, int b) {
return a | b;
@@ -811,10 +755,6 @@ public Object bitOr(long a, DynamicObject b) {
@CoreMethod(names = "^", required = 1)
public abstract static class BitXOrNode extends BignumNodes.BignumCoreMethodNode {

public BitXOrNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int bitXOr(int a, int b) {
return a ^ b;
@@ -843,10 +783,6 @@ public abstract static class LeftShiftNode extends BignumNodes.BignumCoreMethodN
@Child private RightShiftNode rightShiftNode;
@Child private CallDispatchHeadNode fallbackCallNode;

public LeftShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract Object executeLeftShift(VirtualFrame frame, Object a, Object b);

@Specialization(guards = { "b >= 0", "canShiftIntoInt(a, b)" })
@@ -877,7 +813,7 @@ public Object leftShiftWithOverflow(long a, int b) {
public Object leftShiftNeg(VirtualFrame frame, long a, int b) {
if (rightShiftNode == null) {
CompilerDirectives.transferToInterpreter();
rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(new RubyNode[]{ null, null }));
}
return rightShiftNode.executeRightShift(frame, a, -b);
}
@@ -911,10 +847,6 @@ public abstract static class RightShiftNode extends CoreMethodArrayArgumentsNode
@Child private CallDispatchHeadNode fallbackCallNode;
@Child private LeftShiftNode leftShiftNode;

public RightShiftNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract Object executeRightShift(VirtualFrame frame, Object a, Object b);

@Specialization(guards = "b >= 0")
@@ -941,7 +873,7 @@ public Object rightShift(VirtualFrame frame, long a, int b,
public Object rightShiftNeg(VirtualFrame frame, long a, int b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
}
return leftShiftNode.executeLeftShift(frame, a, -b);
}
@@ -961,7 +893,7 @@ public int rightShift(long a, DynamicObject b) {
public Object rightShiftNeg(VirtualFrame frame, long a, DynamicObject b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
}
return leftShiftNode.executeLeftShift(frame, a, Layouts.BIGNUM.getValue(b).negate());
}
@@ -984,10 +916,6 @@ protected static boolean isPositive(DynamicObject b) {
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends CoreMethodArrayArgumentsNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(rewriteOn = ArithmeticException.class)
public int absIntInBounds(int n) {
return (n < 0) ? ExactMath.subtractExact(0, n) : n;
@@ -1019,10 +947,6 @@ public Object abs(long n) {
@CoreMethod(names = "bit_length")
public abstract static class BitLengthNode extends CoreMethodArrayArgumentsNode {

public BitLengthNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int bitLength(int n) {
if (n < 0) {
@@ -1046,10 +970,6 @@ public int bitLength(long n) {
@CoreMethod(names = "floor")
public abstract static class FloorNode extends CoreMethodArrayArgumentsNode {

public FloorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int floor(int n) {
return n;
@@ -1065,10 +985,6 @@ public long floor(long n) {
@CoreMethod(names = "inspect")
public abstract static class InspectNode extends CoreMethodArrayArgumentsNode {

public InspectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject inspect(int n) {
return createString(new LazyIntRope(n));
@@ -1089,10 +1005,6 @@ public DynamicObject inspect(long n) {
@CoreMethod(names = "size", needsSelf = false)
public abstract static class SizeNode extends CoreMethodArrayArgumentsNode {

public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int size() {
return Long.SIZE / Byte.SIZE;
@@ -1103,10 +1015,6 @@ public int size() {
@CoreMethod(names = "to_f")
public abstract static class ToFNode extends CoreMethodArrayArgumentsNode {

public ToFNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double toF(int n) {
return n;
@@ -1122,10 +1030,6 @@ public double toF(long n) {
@CoreMethod(names = "to_s", optional = 1)
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {

public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject toS(int n, NotProvided base) {
return createString(new LazyIntRope(n));
@@ -1160,10 +1064,6 @@ public DynamicObject toS(long n, int base) {
@CoreMethod(names = "zero?")
public abstract static class ZeroNode extends CoreMethodArrayArgumentsNode {

public ZeroNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean zero(int n) {
return n == 0;
Original file line number Diff line number Diff line change
@@ -37,10 +37,6 @@ public abstract class FloatNodes {
@CoreMethod(names = "-@")
public abstract static class NegNode extends CoreMethodArrayArgumentsNode {

public NegNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double neg(double value) {
return -value;
@@ -51,10 +47,6 @@ public double neg(double value) {
@CoreMethod(names = "+", required = 1)
public abstract static class AddNode extends CoreMethodArrayArgumentsNode {

public AddNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double add(double a, long b) {
return a + b;
@@ -80,10 +72,6 @@ public Object addCoerced(VirtualFrame frame, double a, DynamicObject b) {
@CoreMethod(names = "-", required = 1)
public abstract static class SubNode extends CoreMethodArrayArgumentsNode {

public SubNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double sub(double a, long b) {
return a - b;
@@ -109,10 +97,6 @@ public Object subCoerced(VirtualFrame frame, double a, DynamicObject b) {
@CoreMethod(names = "*", required = 1)
public abstract static class MulNode extends CoreMethodArrayArgumentsNode {

public MulNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double mul(double a, long b) {
return a * b;
@@ -143,10 +127,6 @@ public abstract static class PowNode extends CoreMethodArrayArgumentsNode {

private final ConditionProfile complexProfile = ConditionProfile.createBinaryProfile();

public PowNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = {
"exponent == cachedExponent",
"cachedExponent >= 0",
@@ -200,10 +180,6 @@ public abstract static class DivNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode redoCoercedNode;

public DivNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double div(double a, long b) {
return a / b;
@@ -240,10 +216,6 @@ public abstract static class ModNode extends CoreMethodArrayArgumentsNode {

private final ConditionProfile lessThanZeroProfile = ConditionProfile.createBinaryProfile();

public ModNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double mod(double a, long b) {
return mod(a, (double) b);
@@ -312,10 +284,6 @@ public Object divModCoerced(VirtualFrame frame, double a, DynamicObject b) {
@CoreMethod(names = "<", required = 1)
public abstract static class LessNode extends CoreMethodArrayArgumentsNode {

public LessNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean less(double a, long b) {
return a < b;
@@ -344,10 +312,6 @@ public Object lessCoerced(VirtualFrame frame, double a, Object b) {
@CoreMethod(names = "<=", required = 1)
public abstract static class LessEqualNode extends CoreMethodArrayArgumentsNode {

public LessEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean lessEqual(double a, long b) {
return a <= b;
@@ -376,10 +340,6 @@ public Object lessEqualCoerced(VirtualFrame frame, double a, Object b) {
@CoreMethod(names = "eql?", required = 1)
public abstract static class EqlNode extends CoreMethodArrayArgumentsNode {

public EqlNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean eql(double a, double b) {
return a == b;
@@ -396,10 +356,6 @@ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode fallbackCallNode;

public EqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean equal(double a, long b) {
return a == b;
@@ -429,10 +385,6 @@ public Object equal(VirtualFrame frame, double a, DynamicObject b) {
@CoreMethod(names = "<=>", required = 1)
public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {

public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "isNaN(a)")
public DynamicObject compareFirstNaN(double a, Object b) {
return nil();
@@ -477,10 +429,6 @@ public DynamicObject compare(double a, DynamicObject b) {
@CoreMethod(names = ">=", required = 1)
public abstract static class GreaterEqualNode extends CoreMethodArrayArgumentsNode {

public GreaterEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greaterEqual(double a, long b) {
return a >= b;
@@ -510,10 +458,6 @@ public Object greaterEqualCoerced(VirtualFrame frame, double a, Object b) {
@CoreMethod(names = ">", required = 1)
public abstract static class GreaterNode extends CoreMethodArrayArgumentsNode {

public GreaterNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean greater(double a, long b) {
return a > b;
@@ -542,10 +486,6 @@ public Object greaterCoerced(VirtualFrame frame, double a, Object b) {
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends CoreMethodArrayArgumentsNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double abs(double n) {
return Math.abs(n);
@@ -590,10 +530,6 @@ public Object floor(double n) {
@CoreMethod(names = "infinite?")
public abstract static class InfiniteNode extends CoreMethodArrayArgumentsNode {

public InfiniteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object infinite(double value) {
if (Double.isInfinite(value)) {
@@ -612,10 +548,6 @@ public Object infinite(double value) {
@CoreMethod(names = "nan?")
public abstract static class NaNNode extends CoreMethodArrayArgumentsNode {

public NaNNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean nan(double value) {
return Double.isNaN(value);
@@ -748,10 +680,6 @@ Object toI(double value) {
@CoreMethod(names = "to_f")
public abstract static class ToFNode extends CoreMethodArrayArgumentsNode {

public ToFNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public double toF(double value) {
return value;
@@ -762,10 +690,6 @@ public double toF(double value) {
@CoreMethod(names = { "to_s", "inspect" })
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {

public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject toS(double value) {
Original file line number Diff line number Diff line change
@@ -37,10 +37,6 @@ public abstract static class DownToNode extends YieldingCoreMethodNode {

@Child private CallDispatchHeadNode downtoInternalCall;

public DownToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object downto(VirtualFrame frame, int from, int to, DynamicObject block) {
int count = 0;
@@ -111,10 +107,6 @@ public abstract static class TimesNode extends YieldingCoreMethodNode {

// TODO CS 2-May-15 we badly need OSR in this node

public TimesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject times(VirtualFrame frame, int n, NotProvided block) {
// TODO (eregon, 16 June 2015): this should return an enumerator
@@ -179,10 +171,6 @@ public Object times(VirtualFrame frame, DynamicObject n, DynamicObject block,
@CoreMethod(names = { "to_i", "to_int" })
public abstract static class ToINode extends CoreMethodArrayArgumentsNode {

public ToINode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int toI(int n) {
return n;
@@ -205,10 +193,6 @@ public abstract static class UpToNode extends YieldingCoreMethodNode {

@Child private CallDispatchHeadNode uptoInternalCall;

public UpToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object upto(VirtualFrame frame, int from, int to, DynamicObject block) {
int count = 0;
Original file line number Diff line number Diff line change
@@ -40,10 +40,6 @@ public abstract class ObjectSpaceNodes {
@ImportStatic(ObjectIDOperations.class)
public abstract static class ID2RefNode extends CoreMethodArrayArgumentsNode {

public ID2RefNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "id == NIL")
public Object id2RefNil(long id) {
return nil();
@@ -90,7 +86,7 @@ public double id2RefFloat(DynamicObject id) {
}

protected ReadObjectFieldNode createReadObjectIDNode() {
return ReadObjectFieldNodeGen.create(getContext(), Layouts.OBJECT_ID_IDENTIFIER, 0L);
return ReadObjectFieldNodeGen.create(Layouts.OBJECT_ID_IDENTIFIER, 0L);
}

protected boolean isLargeFixnumID(DynamicObject id) {
@@ -106,10 +102,6 @@ protected boolean isFloatID(DynamicObject id) {
@CoreMethod(names = "each_object", isModuleFunction = true, needsBlock = true, optional = 1, returnsEnumeratorIfNoBlock = true)
public abstract static class EachObjectNode extends YieldingCoreMethodNode {

public EachObjectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int eachObject(VirtualFrame frame, NotProvided ofClass, DynamicObject block) {
CompilerDirectives.transferToInterpreter();
@@ -178,10 +170,6 @@ public DynamicObject defineFinalizer(VirtualFrame frame, DynamicObject object, O
@CoreMethod(names = "undefine_finalizer", isModuleFunction = true, required = 1)
public abstract static class UndefineFinalizerNode extends CoreMethodArrayArgumentsNode {

public UndefineFinalizerNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public Object undefineFinalizer(Object object) {
49 changes: 9 additions & 40 deletions truffle/src/main/java/org/jruby/truffle/core/proc/ProcNodes.java
Original file line number Diff line number Diff line change
@@ -46,10 +46,6 @@ public abstract class ProcNodes {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends UnaryCoreMethodNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
throw new RaiseException(coreExceptions().typeErrorAllocatorUndefinedFor(rubyClass, this));
@@ -63,13 +59,6 @@ public abstract static class ProcNewNode extends CoreMethodArrayArgumentsNode {
@Child private CallDispatchHeadNode initializeNode;
@Child private AllocateObjectNode allocateObjectNode;

protected final DynamicObject PROC_CLASS = coreLibrary().getProcClass();
protected final Shape PROC_SHAPE = coreLibrary().getProcFactory().getShape();

public ProcNewNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract DynamicObject executeProcNew(
VirtualFrame frame,
DynamicObject procClass,
@@ -90,11 +79,19 @@ public DynamicObject proc(VirtualFrame frame, DynamicObject procClass, Object[]
return executeProcNew(frame, procClass, args, parentBlock);
}

@Specialization(guards = { "procClass == PROC_CLASS", "block.getShape() == PROC_SHAPE" })
@Specialization(guards = { "procClass == getProcClass()", "block.getShape() == getProcShape()" })
public DynamicObject procNormalOptimized(DynamicObject procClass, Object[] args, DynamicObject block) {
return block;
}

protected DynamicObject getProcClass() {
return coreLibrary().getProcClass();
}

protected Shape getProcShape() {
return coreLibrary().getProcFactory().getShape();
}

@Specialization(guards = "procClass == metaClass(block)")
public DynamicObject procNormal(DynamicObject procClass, Object[] args, DynamicObject block) {
return block;
@@ -150,10 +147,6 @@ public abstract static class DupNode extends UnaryCoreMethodNode {

@Child private AllocateObjectNode allocateObjectNode;

public DupNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject dup(DynamicObject proc) {
final DynamicObject copy = getAllocateObjectNode().allocate(
@@ -185,10 +178,6 @@ private AllocateObjectNode getAllocateObjectNode() {
@CoreMethod(names = "arity")
public abstract static class ArityNode extends CoreMethodArrayArgumentsNode {

public ArityNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int arity(DynamicObject proc) {
return Layouts.PROC.getSharedMethodInfo(proc).getArity().getArityNumber();
@@ -199,10 +188,6 @@ public int arity(DynamicObject proc) {
@CoreMethod(names = "binding")
public abstract static class BindingNode extends CoreMethodArrayArgumentsNode {

public BindingNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject binding(DynamicObject proc) {
final MaterializedFrame frame = Layouts.PROC.getDeclarationFrame(proc);
@@ -214,10 +199,6 @@ public DynamicObject binding(DynamicObject proc) {
@CoreMethod(names = {"call", "[]", "yield"}, rest = true, needsBlock = true)
public abstract static class CallNode extends YieldingCoreMethodNode {

public CallNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object call(VirtualFrame frame, DynamicObject proc, Object[] args, NotProvided block) {
return yield(frame, proc, args);
@@ -233,10 +214,6 @@ public Object call(VirtualFrame frame, DynamicObject proc, Object[] args, Dynami
@CoreMethod(names = "lambda?")
public abstract static class LambdaNode extends CoreMethodArrayArgumentsNode {

public LambdaNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean lambda(DynamicObject proc) {
return Layouts.PROC.getType(proc) == ProcType.LAMBDA;
@@ -247,10 +224,6 @@ public boolean lambda(DynamicObject proc) {
@CoreMethod(names = "parameters")
public abstract static class ParametersNode extends CoreMethodArrayArgumentsNode {

public ParametersNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject parameters(DynamicObject proc) {
@@ -264,10 +237,6 @@ public DynamicObject parameters(DynamicObject proc) {
@CoreMethod(names = "source_location")
public abstract static class SourceLocationNode extends CoreMethodArrayArgumentsNode {

public SourceLocationNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public Object sourceLocation(DynamicObject proc) {
Original file line number Diff line number Diff line change
@@ -59,10 +59,6 @@ public DynamicObject allocate(DynamicObject rubyClass) {
@CoreMethod(names = { "push", "<<", "enq" }, required = 1)
public abstract static class PushNode extends CoreMethodArrayArgumentsNode {

public PushNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public DynamicObject push(DynamicObject self, final Object value) {
final BlockingQueue<Object> queue = Layouts.QUEUE.getQueue(self);
@@ -86,13 +82,9 @@ private void doPush(final Object value, final BlockingQueue<Object> queue) {
})
public abstract static class PopNode extends CoreMethodNode {

public PopNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@CreateCast("nonBlocking")
public RubyNode coerceToBoolean(RubyNode nonBlocking) {
return BooleanCastWithDefaultNodeGen.create(getContext(), getSourceSection(), false, nonBlocking);
return BooleanCastWithDefaultNodeGen.create(null, null, false, nonBlocking);
}

@Specialization(guards = "!nonBlocking")
@@ -140,10 +132,6 @@ private Object doPoll(final BlockingQueue<Object> queue) {
})
public abstract static class ReceiveTimeoutNode extends CoreMethodNode {

public ReceiveTimeoutNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public Object receiveTimeout(DynamicObject self, int duration) {
return receiveTimeout(self, (double) duration);
@@ -186,10 +174,6 @@ public Object block() throws InterruptedException {
@CoreMethod(names = "empty?")
public abstract static class EmptyNode extends CoreMethodArrayArgumentsNode {

public EmptyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public boolean empty(DynamicObject self) {
@@ -202,10 +186,6 @@ public boolean empty(DynamicObject self) {
@CoreMethod(names = { "size", "length" })
public abstract static class SizeNode extends CoreMethodArrayArgumentsNode {

public SizeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public int size(DynamicObject self) {
@@ -218,10 +198,6 @@ public int size(DynamicObject self) {
@CoreMethod(names = "clear")
public abstract static class ClearNode extends CoreMethodArrayArgumentsNode {

public ClearNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject clear(DynamicObject self) {
@@ -235,10 +211,6 @@ public DynamicObject clear(DynamicObject self) {
@CoreMethod(names = "marshal_dump")
public abstract static class MarshalDumpNode extends CoreMethodArrayArgumentsNode {

public MarshalDumpNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
@TruffleBoundary
public Object marshal_dump(DynamicObject self) {
@@ -250,10 +222,6 @@ public Object marshal_dump(DynamicObject self) {
@CoreMethod(names = "num_waiting")
public abstract static class NumWaitingNode extends CoreMethodArrayArgumentsNode {

public NumWaitingNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int num_waiting(DynamicObject self) {
final LinkedBlockingQueueLocksConditions<Object> queue = Layouts.QUEUE.getQueue(self);
Loading

1 comment on commit fd65c2d

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jruby/truffle removed 2,500 lines of code! These constructors that just pass on the context and source section are no longer needed. It should start to be possible to use @Cached in many more places than before and lead to more code reduction.

Sorry, something went wrong.

Please sign in to comment.