Skip to content
Permalink

Comparing changes

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

Open a pull request

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

Commits on Apr 19, 2016

  1. Copy the full SHA
    072ee6c View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    831ca13 View commit details
Showing with 27 additions and 57 deletions.
  1. +15 −15 truffle/src/main/java/org/jruby/truffle/core/CoreMethodNodeManager.java
  2. +12 −42 truffle/src/main/java/org/jruby/truffle/core/ProcessNodes.java
Original file line number Diff line number Diff line change
@@ -219,22 +219,22 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails

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;
args[1] = sourceSection;
System.arraycopy(argumentsNodes.toArray(new RubyNode[argumentsNodes.size()]), 0, args, 2, argumentsNodes.size());
methodNode = nodeFactory.createNode(args);
final RubyNode[] argumentsArray = argumentsNodes.toArray(new RubyNode[argumentsNodes.size()]);
if (signature.size() == 1 && signature.get(0) == RubyNode[].class) {
methodNode = nodeFactory.createNode(new Object[] { argumentsArray });
} else if (signature.size() >= 3 && signature.get(2) == RubyNode[].class) {
methodNode = nodeFactory.createNode(context, sourceSection, argumentsArray);
} else if (signature.get(0) != RubyContext.class) {
Object[] args = argumentsArray;
methodNode = nodeFactory.createNode(args);
} else {
Object[] args = new Object[2 + argumentsNodes.size()];
args[0] = context;
args[1] = sourceSection;
System.arraycopy(argumentsArray, 0, args, 2, argumentsNodes.size());
methodNode = nodeFactory.createNode(args);
}
}

if (System.getenv("TRUFFLE_CHECK_AMBIGUOUS_OPTIONAL_ARGS") != null) {
54 changes: 12 additions & 42 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,47 +46,17 @@ 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

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

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;
public ClockGetTimeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

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

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

}, unit);
return DefaultValueNodeGen.create(null, null, floatSecondSymbol, unit);
}

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

private Object timeToUnit(long time, DynamicObject unit) {
assert RubyGuards.isRubySymbol(unit);
if (unit == getNanosecondSymbol()) {
if (unit == nanosecondSymbol) {
return time;
} else if (unit == getFloatSecondSymbol()) {
return time / 1e9;
} else if (unit == getFloatMicrosecondSymbol()) {
} else if (unit == floatMicrosecondSymbol) {
return time / 1e3;
} else if (unit == floatSecondSymbol) {
return time / 1e9;
} else {
throw new UnsupportedOperationException(Layouts.SYMBOL.getString(unit));
}