Skip to content

Commit

Permalink
Showing 30 changed files with 427 additions and 751 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -99,3 +99,8 @@ core/.gitignore
core/.project
core/.settings
core/.apt_generated

# Truffle findbugs
truffle-findbugs-report.html
findbugs-noUpdateChecks-3.0.0.tar.gz
findbugs-3.0.0
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -62,12 +62,15 @@ matrix:
jdk: oraclejdk8
- env: COMMAND=test/check_versions.sh
jdk: oraclejdk8
- env: COMMAND=tool/truffle-findbugs.sh
jdk: oraclejdk8
fast_finish: true
allow_failures:
- env: PHASE='-Pcomplete'
- env: PHASE='-Prake -Dtask=spec:jrubyc'
- env: PHASE='-Prake -Dtask=spec:profiler'
- env: PHASE='-Ptruffle-specs-rubysl'
- env: COMMAND=tool/truffle-findbugs.sh

branches:
only:
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -3380,7 +3380,8 @@ public RubyBoolean include_p(ThreadContext context, IRubyObject obj) {
@JRubyMethod(name = "include?")
public RubyBoolean include_p19(ThreadContext context, IRubyObject obj) {
Ruby runtime = context.runtime;
return StringSupport.index(this, this.value, this.strLength(this.checkEncoding(obj.convertToString())), obj.convertToString(), obj.convertToString().value, obj.convertToString().strLength(this.checkEncoding(obj.convertToString())), 0, this.checkEncoding(obj.convertToString())) == -1 ? runtime.getFalse() : runtime.getTrue();
RubyString coerced = obj.convertToString();
return StringSupport.index(this, this.value, this.strLength(this.checkEncoding(coerced)), coerced, coerced.value, coerced.strLength(this.checkEncoding(coerced)), 0, this.checkEncoding(coerced)) == -1 ? runtime.getFalse() : runtime.getTrue();
}

@JRubyMethod
50 changes: 49 additions & 1 deletion core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -13,11 +13,15 @@
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrument.Probe;
import com.oracle.truffle.api.instrument.ProbeNode;
import com.oracle.truffle.api.instrument.TruffleEventReceiver;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.dispatch.Dispatch;
import org.jruby.truffle.nodes.instrument.RubyWrapperNode;
import org.jruby.truffle.nodes.yield.YieldDispatchNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
@@ -33,7 +37,7 @@
*/
@TypeSystemReference(RubyTypes.class)
@GenerateNodeFactory
public abstract class RubyNode extends Node {
public abstract class RubyNode extends Node implements ProbeNode.Instrumentable {

private final RubyContext context;

@@ -225,6 +229,50 @@ public RubyBignum bignum(BigInteger value) {
return new RubyBignum(getContext().getCoreLibrary().getBignumClass(), value);
}

public RubyNode getNonWrapperNode() {
return this;
}

public Probe probe() {
final Node parent = getParent();

if (parent == null) {
throw new IllegalStateException("Cannot call probe() on a node without a parent.");
}

if (parent instanceof RubyWrapperNode) {
return ((RubyWrapperNode) parent).getProbe();
}

// Create a new wrapper/probe with this node as its child.
final RubyWrapperNode wrapper = new RubyWrapperNode(this);

// Connect it to a Probe
final Probe probe = ProbeNode.insertProbe(wrapper);

// Replace this node in the AST with the wrapper
this.replace(wrapper);

return probe;
}

public void probeLite(TruffleEventReceiver eventReceiver) {
final Node parent = getParent();

if (parent == null) {
throw new IllegalStateException("Cannot call probeLite() on a node without a parent");
}

if (parent instanceof RubyWrapperNode) {
throw new IllegalStateException("Cannot call probeLite() on a node that already has a wrapper.");
}

final RubyWrapperNode wrapper = new RubyWrapperNode(this);
ProbeNode.insertProbeLite(wrapper, eventReceiver);

this.replace(wrapper);
}

// Copied from RubyTypesGen

@SuppressWarnings("static-method")
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ public AndNode(RubyContext context, SourceSection sourceSection, RubyNode left,
@Override
public Object execute(VirtualFrame frame) {
final Object leftValue = left.execute(frame);
boolean leftBoolean = leftCast.executeBoolean(frame, leftValue);
if (conditionProfile.profile(leftBoolean)) {
if (conditionProfile.profile(leftCast.executeBoolean(frame, leftValue))) {
// Right expression evaluated and returned if left expression returns true.
return right.execute(frame);
} else {
32 changes: 4 additions & 28 deletions core/src/main/java/org/jruby/truffle/nodes/control/IfNode.java
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.cast.BooleanCastNode;
import org.jruby.truffle.runtime.RubyContext;
@@ -26,12 +26,7 @@ public class IfNode extends RubyNode {
@Child protected BooleanCastNode condition;
@Child protected RubyNode thenBody;
@Child protected RubyNode elseBody;

private final BranchProfile thenProfile = BranchProfile.create();
private final BranchProfile elseProfile = BranchProfile.create();

@CompilerDirectives.CompilationFinal private int thenCount;
@CompilerDirectives.CompilationFinal private int elseCount;
private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();

public IfNode(RubyContext context, SourceSection sourceSection, BooleanCastNode condition, RubyNode thenBody, RubyNode elseBody) {
super(context, sourceSection);
@@ -47,29 +42,10 @@ public IfNode(RubyContext context, SourceSection sourceSection, BooleanCastNode

@Override
public Object execute(VirtualFrame frame) {
if (CompilerDirectives.injectBranchProbability(getBranchProbability(), condition.executeBoolean(frame))) {
if (CompilerDirectives.inInterpreter()) {
thenCount++;
}
thenProfile.enter();
if (conditionProfile.profile(condition.executeBoolean(frame))) {
return thenBody.execute(frame);
} else {
if (CompilerDirectives.inInterpreter()) {
elseCount++;
}
elseProfile.enter();
return elseBody.execute(frame);
}
}

private double getBranchProbability() {
final int totalCount = thenCount + elseCount;

if (totalCount == 0) {
return 0;
} else {
return (double) thenCount / (double) (thenCount + elseCount);
}
}

}
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/truffle/nodes/control/OrNode.java
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.control;

import com.oracle.truffle.api.utilities.ConditionProfile;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
@@ -24,6 +25,8 @@ public class OrNode extends RubyNode {
@Child protected RubyNode left;
@Child protected BooleanCastNode leftCast;
@Child protected RubyNode right;
private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();


public OrNode(RubyContext context, SourceSection sourceSection, RubyNode left, RubyNode right) {
super(context, sourceSection);
@@ -35,12 +38,10 @@ public OrNode(RubyContext context, SourceSection sourceSection, RubyNode left, R
@Override
public Object execute(VirtualFrame frame) {
final Object leftValue = left.execute(frame);

if (leftCast.executeBoolean(frame, leftValue)) {
if (conditionProfile.profile(leftCast.executeBoolean(frame, leftValue))) {
return leftValue;
} else {
return right.execute(frame);
}

return right.execute(frame);
}

}
56 changes: 24 additions & 32 deletions core/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2013, 2015 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:
*
@@ -13,19 +13,21 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrument.KillException;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.core.*;

public class TraceNode extends WrapperNode {
public class TraceNode extends RubyNode {

private final RubyContext context;
@Child protected RubyNode child;

@CompilerDirectives.CompilationFinal private Assumption traceAssumption;
@CompilerDirectives.CompilationFinal private RubyProc traceFunc;
@@ -36,7 +38,8 @@ public class TraceNode extends WrapperNode {
private final int line;

public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection, child);
super(context, sourceSection);
this.child = child;
this.context = context;
traceAssumption = context.getTraceManager().getTraceAssumption();
traceFunc = null;
@@ -47,7 +50,19 @@ public TraceNode(RubyContext context, SourceSection sourceSection, RubyNode chil
}

@Override
public void enter(VirtualFrame frame) {
public Object execute(VirtualFrame frame) {
trace(frame);
return child.execute(frame);
}


@Override
public void executeVoid(VirtualFrame frame) {
trace(frame);
child.executeVoid(frame);
}

public void trace(VirtualFrame frame) {
try {
traceAssumption.check();
} catch (InvalidAssumptionException e) {
@@ -84,30 +99,7 @@ public void enter(VirtualFrame frame) {
}

@Override
void leave(VirtualFrame frame) {
}

@Override
void leave(VirtualFrame frame, boolean result) {
}

@Override
void leave(VirtualFrame frame, int result) {
}

@Override
void leave(VirtualFrame frame, long result) {
}

@Override
void leave(VirtualFrame frame, double result) {
}

@Override
void leave(VirtualFrame frame, Object result) {
}

@Override
void leaveExceptional(VirtualFrame frame, Exception e) {
public Object isDefined(VirtualFrame frame) {
return child.isDefined(frame);
}
}
610 changes: 0 additions & 610 deletions core/src/main/java/org/jruby/truffle/nodes/control/WrapperNode.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ public RubyArray geHeadLongFixnum(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
} else {
final int size = array.getSize() - index;
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((long[]) array.getStore(), 0, array.getSize() - index), array.getSize() - index);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((long[]) array.getStore(), 0, size), size);
}
}

@@ -74,7 +74,7 @@ public RubyArray getHeadFloat(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
} else {
final int size = array.getSize() - index;
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((double[]) array.getStore(), 0, array.getSize() - index), array.getSize() - index);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((double[]) array.getStore(), 0, size), size);
}
}

@@ -86,7 +86,7 @@ public RubyArray getHeadObject(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
} else {
final int size = array.getSize() - index;
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((Object[]) array.getStore(), 0, array.getSize() - index), array.getSize() - index);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOfRange((Object[]) array.getStore(), 0, size), size);
}
}

18 changes: 0 additions & 18 deletions core/src/main/java/org/jruby/truffle/nodes/core/ClassNodes.java
Original file line number Diff line number Diff line change
@@ -86,24 +86,6 @@ private RubyBasicObject doNewInstance(VirtualFrame frame, RubyClass rubyClass, O
initialize.call(frame, instance, "initialize", block, args);
return instance;
}

private RubyClass cachedClass(RubyClass rubyClass) {
if (isCached) {
if (cachedClass == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
cachedClass = rubyClass;
}

if (rubyClass == cachedClass) {
return cachedClass;
} else {
CompilerDirectives.transferToInterpreterAndInvalidate();
isCached = false;
cachedClass = null;
}
}
return rubyClass;
}
}

@CoreMethod(names = "initialize", optional = 1, needsBlock = true)
Original file line number Diff line number Diff line change
@@ -140,7 +140,6 @@ public RubyArray searchConvpath(RubyString source, RubyString destination) {
EncodingUtils.econvArgs(context, new IRubyObject[]{getContext().toJRuby(source), getContext().toJRuby(destination)}, encNames, encs, ecflags_p, ecopts_p);

TranscoderDB.searchPath(encNames[0], encNames[1], new TranscoderDB.SearchPathCallback() {
EncodingService es = runtime.getEncodingService();

public void call(byte[] source, byte[] destination, int depth) {
Object v;
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
Original file line number Diff line number Diff line change
@@ -75,9 +75,8 @@ public RubyArray readLines(RubyString file) {

final List<Object> lines = new ArrayList<>();

try {
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toString())));

try(final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toString())))) {

while (true) {
final String line = reader.readLine();

Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@

public abstract class CachedUnboxedDispatchNode extends CachedDispatchNode {

private final Class expectedClass;
private final Class<?> expectedClass;
private final Assumption unmodifiedAssumption;

private final Object value;
@@ -38,7 +38,7 @@ public abstract class CachedUnboxedDispatchNode extends CachedDispatchNode {
@Child protected IndirectCallNode indirectCallNode;

public CachedUnboxedDispatchNode(RubyContext context, Object cachedName, DispatchNode next,
Class expectedClass, Assumption unmodifiedAssumption, Object value,
Class<?> expectedClass, Assumption unmodifiedAssumption, Object value,
RubyMethod method, boolean indirect) {
super(context, cachedName, next, indirect);
this.expectedClass = expectedClass;
Original file line number Diff line number Diff line change
@@ -13,4 +13,6 @@

public class UseMethodMissingException extends SlowPathException {

private static final long serialVersionUID = -4534089746905620428L;

}
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public GetFromThreadLocalNode(GetFromThreadLocalNode prev) {
}

@Specialization
public Object get(ThreadLocal threadLocal) {
public Object get(ThreadLocal<?> threadLocal) {
return threadLocal.get();
}

@@ -38,7 +38,7 @@ public Object get(Object value) {

public static Object get(RubyContext context, Object value) {
if (value instanceof ThreadLocal) {
return ((ThreadLocal) value).get();
return ((ThreadLocal<?>) value).get();
} else {
return value;
}
Original file line number Diff line number Diff line change
@@ -27,14 +27,14 @@ public WrapInThreadLocalNode(WrapInThreadLocalNode prev) {
}

@Specialization
public ThreadLocal wrap(Object value) {
public ThreadLocal<?> wrap(Object value) {
return wrap(getContext(), value);
}

public static ThreadLocal wrap(RubyContext context, Object value) {
public static ThreadLocal<Object> wrap(RubyContext context, Object value) {
final RubyContext finalContext = context;

final ThreadLocal threadLocal = new ThreadLocal() {
final ThreadLocal<Object> threadLocal = new ThreadLocal<Object>() {

@Override
protected Object initialValue() {
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
/*
* Copyright (c) 2013, 2014, 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.nodes.instrument;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrument.KillException;
import com.oracle.truffle.api.instrument.Probe;
import com.oracle.truffle.api.instrument.ProbeNode;
import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
import com.oracle.truffle.api.instrument.TruffleEventReceiver;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBignum;
import org.jruby.truffle.runtime.core.RubyString;

@NodeInfo(cost = NodeCost.NONE)
public final class RubyWrapperNode extends RubyNode implements WrapperNode {

@Child private RubyNode child;
@Child private ProbeNode probeNode;

public RubyWrapperNode(RubyNode child) {
super(child.getContext(), child.getSourceSection());
assert !(child instanceof RubyWrapperNode);
this.child = child;
}

public String instrumentationInfo() {
return "Wrapper node for Ruby";
}

@Override
public RubyNode getNonWrapperNode() {
return child;
}

public void insertProbe(ProbeNode newProbeNode) {
this.probeNode = insert(newProbeNode);
}

public Probe getProbe() {
try {
return probeNode.getProbe();
} catch (IllegalStateException e) {
throw new UnsupportedOperationException("A lite-Probed wrapper has no explicit Probe");
}
}

public RubyNode getChild() {
return child;
}

@Override
public Object execute(VirtualFrame frame) {
probeNode.enter(child, frame);

Object result;

try {
result = child.execute(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public RubyArray executeArray(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

RubyArray result;

try {
result = child.executeArray(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public RubyBignum executeBignum(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

RubyBignum result;

try {
result = child.executeBignum(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

boolean result;

try {
result = child.executeBoolean(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public Object isDefined(VirtualFrame frame) {
return child.isDefined(frame);
}

@Override
public int executeIntegerFixnum(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

int result;

try {
result = child.executeIntegerFixnum(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public long executeLongFixnum(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

long result;

try {
result = child.executeLongFixnum(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public double executeFloat(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

double result;

try {
result = child.executeFloat(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public RubyString executeString(VirtualFrame frame) throws UnexpectedResultException {
probeNode.enter(child, frame);

RubyString result;

try {
result = child.executeString(frame);
probeNode.returnValue(child, frame, result);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}

return result;
}

@Override
public void executeVoid(VirtualFrame frame) {
probeNode.enter(child, frame);

try {
child.executeVoid(frame);
probeNode.returnVoid(child, frame);
} catch (KillException e) {
throw e;
} catch (Exception e) {
probeNode.returnExceptional(child, frame, e);
throw e;
}
}

@Override
public Probe probe() {
throw new UnsupportedOperationException("Cannot call probe() on a wrapper.");
}

@Override
public void probeLite(TruffleEventReceiver eventReceiver) {
throw new UnsupportedOperationException("Cannot call probeLite() on a wrapper.");
}
}
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public Object dispatchWithModifiedBlock(VirtualFrame frame, RubyProc block, Ruby
}

@Override
public Object dispatchWithModifiedSelf(VirtualFrame frame, RubyProc block, Object self, Object[] argumentsObjects) {
public Object dispatchWithModifiedSelf(VirtualFrame frame, RubyProc block, Object self, Object... argumentsObjects) {
return callNode.call(frame, block.getCallTarget(), RubyArguments.pack(block, block.getDeclarationFrame(), self, block.getBlockCapturedInScope(), argumentsObjects));
}

Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ public Object dispatchWithModifiedBlock(VirtualFrame frame, RubyProc block, Ruby
}

@Override
public Object dispatchWithModifiedSelf(VirtualFrame frame, RubyProc block, Object self, Object[] argumentsObjects) {
public Object dispatchWithModifiedSelf(VirtualFrame frame, RubyProc block, Object self, Object... argumentsObjects) {
CompilerDirectives.transferToInterpreterAndInvalidate();

depth++;
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ public RubyContext(Ruby runtime) {
safepointManager = new SafepointManager(this);

this.runtime = runtime;
translator = new TranslatorDriver(this);
translator = new TranslatorDriver();

warnings = new Warnings(this);

Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@

public class TruffleFatalException extends RuntimeException {

private static final long serialVersionUID = -3119467647792546222L;

public TruffleFatalException(String message, Exception cause) {
super(message, cause);
}
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ public void initialize(RubyClass superclass) {
public void initCopy(RubyModule other) {
super.initCopy(other);
assert other instanceof RubyClass;
final RubyClass otherClass = (RubyClass) other;
}

private RubyClass ensureSingletonConsistency() {
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ public class RubyTime extends RubyBasicObject {

private long seconds;
private long nanoseconds;
private boolean isdst;

public RubyTime(RubyClass timeClass, long seconds, long nanoseconds) {
super(timeClass);
60 changes: 31 additions & 29 deletions core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
Original file line number Diff line number Diff line change
@@ -86,6 +86,8 @@ public BodyTranslator(RubyNode currentNode, RubyContext context, BodyTranslator
this.parent = parent;
this.environment = environment;
this.topLevel = topLevel;
initGlobalVariableAliases();
initReadOnlyGlobalVariables();
}

@Override
@@ -797,7 +799,7 @@ public RubyNode visitDVarNode(org.jruby.ast.DVarNode node) {

TranslatorEnvironment e = environment;

for (int n = 0; n < node.getDepth(); n++) {
for (int n = 0; n < depth; n++) {
e = e.getParent();
}

@@ -1092,28 +1094,33 @@ private static org.jruby.ast.Node setRHS(org.jruby.ast.Node node, org.jruby.ast.
}
}

private final Set<String> readOnlyGlobalVariables = new HashSet<String>() {{
add("$:");
add("$LOAD_PATH");
add("$-I");
add("$\"");
add("$LOADED_FEATURES");
add("$<");
add("$FILENAME");
add("$?");
add("$-a");
add("$-l");
add("$-p");
}};

private final Map<String, String> globalVariableAliases = new HashMap<String, String>() {{
put("$-I", "$LOAD_PATH");
put("$:", "$LOAD_PATH");
put("$-d", "$DEBUG");
put("$-v", "$VERBOSE");
put("$-w", "$VERBOSE");
put("$-0", "$/");
}};
private final Set<String> readOnlyGlobalVariables = new HashSet<String>();
private final Map<String, String> globalVariableAliases = new HashMap<String, String>();

private void initReadOnlyGlobalVariables() {
Set<String> s = readOnlyGlobalVariables;
s.add("$:");
s.add("$LOAD_PATH");
s.add("$-I");
s.add("$\"");
s.add("$LOADED_FEATURES");
s.add("$<");
s.add("$FILENAME");
s.add("$?");
s.add("$-a");
s.add("$-l");
s.add("$-p");
}

private void initGlobalVariableAliases() {
Map<String, String> m = globalVariableAliases;
m.put("$-I", "$LOAD_PATH");
m.put("$:", "$LOAD_PATH");
m.put("$-d", "$DEBUG");
m.put("$-v", "$VERBOSE");
m.put("$-w", "$VERBOSE");
m.put("$-0", "$/");
}

@Override
public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
@@ -1397,12 +1404,7 @@ public RubyNode visitLocalAsgnNode(org.jruby.ast.LocalAsgnNode node) {
}
}

RubyNode translated = ((ReadNode) lhs).makeWriteNode(rhs);

final SharedMethodInfo methodIdentifier = environment.findMethodForLocalVar(node.getName());

// return instrumenter.instrumentAsLocalAssignment(translated, methodIdentifier, node.getName());
return translated;
return ((ReadNode) lhs).makeWriteNode(rhs);
}

@Override
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
/**
* Collects paramter names from a JRuby AST.
*/
public class ParameterCollector extends AbstractNodeVisitor {
public class ParameterCollector extends AbstractNodeVisitor<Object> {

private final List<String> parameters = new ArrayList<>();
private final List<String> keywords = new ArrayList<>();
Original file line number Diff line number Diff line change
@@ -44,13 +44,8 @@ public static enum ParserContext {
TOP_LEVEL, SHELL, MODULE
}

private final RubyContext context;
private long nextReturnID = 0;

public TranslatorDriver(RubyContext context) {
this.context = context;
}

public MethodDefinitionNode parse(RubyContext context, org.jruby.ast.Node parseTree, org.jruby.ast.ArgsNode argsNode, org.jruby.ast.Node bodyNode, RubyNode currentNode) {
final SourceSection sourceSection = null;

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/OutputStrings.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ public static String getBasicUsageHelp() {
.append(" --client use the non-optimizing \"client\" JVM\n")
.append(" (improves startup; default)\n")
.append(" --server use the optimizing \"server\" JVM (improves perf)\n")
.append(" --dev prioritize startup time over long term performance\n")
.append(" --manage enable remote JMX management and monitoring of the VM\n")
.append(" and JRuby\n")
.append(" --headless do not launch a GUI window, no matter what\n")
6 changes: 6 additions & 0 deletions tool/truffle-findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*NodeFactory.*" />
</Match>
</FindBugsFilter>
31 changes: 31 additions & 0 deletions tool/truffle-findbugs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Runs findbugs for the Truffle classes only. By default writes to stdout. Use
# with --report to get a HTML report.

if [[ $* == *--report* ]]
then
ui_options="-html -output truffle-findbugs-report.html"
else
ui_options=""
fi

mvn package || exit $?

version=3.0.0
shasum=30bdcee2c909a0eef61a4f60f4489cd2f5a4d21c
tarball=findbugs-noUpdateChecks-$version.tar.gz

if [ ! -e findbugs-$version ]
then
wget http://prdownloads.sourceforge.net/findbugs/$tarball || exit $?
echo "$shasum $tarball" | shasum -c || exit $?
tar -xf $tarball || exit $?
fi

findbugs-3.0.0/bin/findbugs \
-textui $ui_options \
-exclude tool/truffle-findbugs-exclude.xml \
-exitcode \
-low \
core/target/classes/org/jruby/truffle/ || exit $?

0 comments on commit e898e9c

Please sign in to comment.