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: 558732233bdd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8b1b05418aaf
Choose a head ref
  • 7 commits
  • 23 files changed
  • 1 contributor

Commits on Feb 19, 2015

  1. [Truffle] Inline unsafeSetParent since it is only used in one place.

    * Avoids double invalidation.
    eregon committed Feb 19, 2015
    Copy the full SHA
    6f08f81 View commit details
  2. Copy the full SHA
    b42ec86 View commit details
  3. Copy the full SHA
    cd2a23f View commit details
  4. [Truffle] More final.

    eregon committed Feb 19, 2015
    Copy the full SHA
    5bec6d0 View commit details
  5. [Truffle] Fix FindBugs bugs.

    eregon committed Feb 19, 2015
    Copy the full SHA
    357f0d7 View commit details
  6. [Truffle] No need for casting.

    eregon committed Feb 19, 2015
    Copy the full SHA
    eab6508 View commit details
  7. Copy the full SHA
    8b1b054 View commit details
Showing with 76 additions and 65 deletions.
  1. +4 −0 tool/truffle-findbugs-exclude.xml
  2. +10 −1 tool/truffle-findbugs.sh
  3. +5 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  4. +7 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/MutexNodes.java
  5. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  6. +4 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/TruffleNodes.java
  7. +1 −6 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/FixnumPrimitiveNodes.java
  8. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/FloatPrimitiveNodes.java
  9. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
  10. +2 −1 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  11. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyArray.java
  12. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyBignum.java
  13. +21 −20 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyClass.java
  14. +2 −2 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyFiber.java
  15. +0 −10 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
  16. +2 −2 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyThread.java
  17. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/FeatureManager.java
  18. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/SafepointManager.java
  19. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/StackServerManager.java
  20. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/TraceManager.java
  21. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/Warnings.java
  22. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/util/FileUtils.java
  23. +2 −2 truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
4 changes: 4 additions & 0 deletions tool/truffle-findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@
<Match>
<Class name="~.*NodeFactory.*" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.core.MutexNodes$UnlockNode" />
<Bug pattern="IMSE_DONT_CATCH_IMSE" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.rubinius.VMPrimitiveNodes$VMGCStartPrimitiveNode" />
<Bug pattern="DM_GC" />
11 changes: 10 additions & 1 deletion tool/truffle-findbugs.sh
Original file line number Diff line number Diff line change
@@ -24,8 +24,17 @@ then
fi

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

exit_code=$?
if [ $exit_code -eq 2 ]
then
exit 0 # just some classes missing
else
exit $exit_code
fi
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jcodings.Encoding;
import org.jruby.common.IRubyWarnings;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
@@ -787,7 +788,9 @@ public RubyString gets(VirtualFrame frame) {
// TODO(CS): having some trouble interacting with JRuby stdin - so using this hack
final InputStream in = getContext().getRuntime().getInstanceConfig().getInput();

final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
Encoding encoding = getContext().getRuntime().getDefaultExternalEncoding();

final BufferedReader reader = new BufferedReader(new InputStreamReader(in, encoding.getCharset()));

final String line = getContext().getThreadManager().runUntilResult(new BlockingActionWithoutGlobalLock<String>() {
@Override
@@ -1849,7 +1852,7 @@ public long sleep(UndefinedPlaceholder duration) {

@Specialization
public long sleep(int duration) {
return doSleepMillis(duration * 1000);
return doSleepMillis(duration * 1000L);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -148,11 +148,16 @@ public RubyMutex unlock(RubyMutex mutex) {

try {
lock.unlock();
thread.releasedLock(lock);
} catch (IllegalMonitorStateException e) {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is not locked", this));
if (!lock.isLocked()) {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is not locked", this));
} else {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is locked by another thread", this));
}
}

thread.releasedLock(lock);

return mutex;
}

Original file line number Diff line number Diff line change
@@ -1987,9 +1987,9 @@ public static ByteList swapcase(RubyString string) {
char current = charArray[i];

if (Character.isLowerCase(current)) {
newString.append(Character.toString(current).toUpperCase());
newString.append(Character.toString(current).toUpperCase(Locale.ENGLISH));
} else if (Character.isUpperCase(current)){
newString.append(Character.toString(current).toLowerCase());
newString.append(Character.toString(current).toLowerCase(Locale.ENGLISH));
} else {
newString.append(current);
}
Original file line number Diff line number Diff line change
@@ -9,9 +9,12 @@
*/
package org.jruby.truffle.nodes.core;

import java.util.Locale;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyString;

@@ -31,7 +34,7 @@ public GraalNode(GraalNode prev) {

@Specialization
public boolean graal() {
return Truffle.getRuntime().getName().toLowerCase().contains("graal");
return Truffle.getRuntime().getName().toLowerCase(Locale.ENGLISH).contains("graal");
}

}
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ public Object pow(long a, long b) {

@Specialization
public Object pow(long a, double b) {
if (complexProfile.profile(a < 0 && b != Math.round(b))) {
if (complexProfile.profile(a < 0)) {
return null; // Primitive failure
} else {
return Math.pow(a, b);
@@ -185,11 +185,6 @@ public Object pow(long a, RubyBignum b) {
return null; // Primitive failure
}

if (b.bigIntegerValue().equals(b)) {
// This is a bug of course
return pow(a, b.bigIntegerValue().longValue());
}

getContext().getRuntime().getWarnings().warn("in a**b, b may be too big");
// b >= 2**63 && (a > 1 || a < -1) => larger than largest double
// MRI behavior/bug: always positive Infinity even if a negative and b odd (likely due to libc pow(a, +inf)).
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public RubyArray dToA(double value) {

String string = String.format(Locale.ENGLISH, "%.9f", value);

if (string.toLowerCase().contains("e")) {
if (string.toLowerCase(Locale.ENGLISH).contains("e")) {
throw new UnsupportedOperationException();
}

@@ -56,7 +56,7 @@ public RubyArray dToA(double value) {
throw new UnsupportedOperationException();
}

string.replace(".", "");
string = string.replace(".", "");
}

final int sign = value < 0 ? 1 : 0;
Original file line number Diff line number Diff line change
@@ -89,8 +89,8 @@ public RubyTime timeSSpecificUTC(long seconds, long nanoseconds, boolean isUTC,
@Specialization(guards = "isTrue(arguments[2])")
public RubyTime timeSSpecificUTC(int seconds, int nanoseconds, boolean isUTC, RubyNilClass offset) {
// TODO(CS): overflow checks needed?
final long milliseconds = seconds * 1_000 + (nanoseconds / 1_000_000);
return new RubyTime(getContext().getCoreLibrary().getTimeClass(), new DateTime(milliseconds), null);
final long milliseconds = seconds * 1_000L + (nanoseconds / 1_000_000);
return new RubyTime(getContext().getCoreLibrary().getTimeClass(), new DateTime(milliseconds, DateTimeZone.UTC), null);
}

@Specialization(guards = "!isTrue(arguments[2])")
@@ -141,7 +141,7 @@ public TimeUSecondsPrimitiveNode(TimeUSecondsPrimitiveNode prev) {

@Specialization
public long timeUSeconds(RubyTime time) {
return time.getDateTime().getMillisOfSecond() * 1_000;
return time.getDateTime().getMillisOfSecond() * 1_000L;
}

}
@@ -345,7 +345,7 @@ public TimeNSecondsPrimitiveNode(TimeNSecondsPrimitiveNode prev) {

@Specialization
public long timeNSeconds(RubyTime time) {
return time.getDateTime().getMillisOfSecond() * 1_000_000;
return time.getDateTime().getMillisOfSecond() * 1_000_000L;
}

}
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Locale;
import java.util.Queue;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
@@ -120,7 +121,7 @@ public RubyContext(Ruby runtime) {
new StackServerManager(this, Options.TRUFFLE_STACK_SERVER_PORT.load()).start();
}

runningOnWindows = System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
runningOnWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).indexOf("win") >= 0;
}

public Shape getEmptyShape() {
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@ private static Object randomizeStorageStrategy(Object store, int size) {
case 0:
return boxedStore;
case 1:
ArrayUtils.longCopyOf((int[]) canonicalStore);
return ArrayUtils.longCopyOf((int[]) canonicalStore);
case 2:
return canonicalStore;
default:
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ public class RubyBignum extends RubyBasicObject {
private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE);
private static final BigInteger LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE);

private BigInteger value;
private final BigInteger value;

public RubyBignum(RubyClass rubyClass, BigInteger value) {
super(rubyClass);
41 changes: 21 additions & 20 deletions truffle/src/main/java/org/jruby/truffle/runtime/core/RubyClass.java
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public class RubyClass extends RubyModule {
// TODO(CS): is this compilation final needed? Is it a problem for correctness?
@CompilationFinal Allocator allocator;

private boolean isSingleton;
private final boolean isSingleton;
private final Set<RubyClass> subClasses = Collections.newSetFromMap(new WeakHashMap<RubyClass, Boolean>());

/**
@@ -64,16 +64,32 @@ protected RubyClass(RubyContext context, RubyClass classClass, RubyModule lexica
}
}

public void setAllocator(Allocator allocator) {
this.allocator = allocator;
}

public void initialize(RubyClass superclass) {
unsafeSetSuperclass(superclass);
ensureSingletonConsistency();
allocator = superclass.allocator;
}

public void setAllocator(Allocator allocator) {
this.allocator = allocator;
}

/**
* This method supports initialization and solves boot-order problems and should not normally be
* used.
*/
protected void unsafeSetSuperclass(RubyClass superClass) {
RubyNode.notDesignedForCompilation();

assert parentModule == null;

parentModule = superClass;
superClass.addDependent(this);
superClass.subClasses.add(this);

newVersion();
}

@Override
public void initCopy(RubyModule other) {
super.initCopy(other);
@@ -113,21 +129,6 @@ private RubyClass createOneSingletonClass() {
return metaClass;
}

/**
* This method supports initialization and solves boot-order problems and should not normally be
* used.
*/
public void unsafeSetSuperclass(RubyClass newSuperclass) {
RubyNode.notDesignedForCompilation();

assert parentModule == null;

unsafeSetParent(newSuperclass);
newSuperclass.subClasses.add(this);

newVersion();
}

public RubyBasicObject allocate(RubyNode currentNode) {
return allocator.allocate(getContext(), this, currentNode);
}
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ private static class FiberExitMessage implements FiberMessage {

private static class FiberExceptionMessage implements FiberMessage {

public RubyException exception;
private final RubyException exception;

public FiberExceptionMessage(RubyException exception) {
this.exception = exception;
@@ -88,7 +88,7 @@ public static class FiberExitException extends ControlFlowException {
private final RubyThread rubyThread;

private String name;
private boolean topLevel;
private final boolean topLevel;
private final BlockingQueue<FiberMessage> messageQueue = new ArrayBlockingQueue<>(1);
private RubyFiber lastResumedByFiber = null;
private boolean alive = true;
Original file line number Diff line number Diff line change
@@ -173,16 +173,6 @@ public boolean isOnlyAModule() {
return !(this instanceof RubyClass);
}

/**
* This method supports initialization and solves boot-order problems and should not normally be
* used.
*/
protected void unsafeSetParent(RubyModule parent) {
parentModule = parent;
parent.addDependent(this);
newVersion();
}

@TruffleBoundary
public void include(Node currentNode, RubyModule module) {
RubyNode.notDesignedForCompilation();
Original file line number Diff line number Diff line change
@@ -43,9 +43,9 @@ public class RubyThread extends RubyBasicObject {
private volatile RubyException exception;
private volatile Object value;

private RubyBasicObject threadLocals;
private final RubyBasicObject threadLocals;

private List<Lock> ownedLocks = new ArrayList<Lock>();
private final List<Lock> ownedLocks = new ArrayList<Lock>();

public RubyThread(RubyClass rubyClass, ThreadManager manager) {
super(rubyClass);
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
*/
public class FeatureManager {

private RubyContext context;
private final RubyContext context;

public FeatureManager(RubyContext context) {
this.context = context;
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public class SafepointManager {

@CompilerDirectives.CompilationFinal private Assumption assumption = Truffle.getRuntime().createAssumption();
private final Phaser phaser = new Phaser();
private Consumer<RubyThread> action;
private volatile Consumer<RubyThread> action;

public SafepointManager(RubyContext context) {
this.context = context;
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
httpExchange.getResponseHeaders().set("Content-Type","text/plain");
httpExchange.sendResponseHeaders(200, 0);

final PrintStream stream = new PrintStream(httpExchange.getResponseBody());
final PrintStream stream = new PrintStream(httpExchange.getResponseBody(), false, "UTF-8");

context.getSafepointManager().pauseAllThreadsAndExecuteFromNonRubyThread(new Consumer<RubyThread>() {

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

public class TraceManager {

private CyclicAssumption traceAssumption = new CyclicAssumption("trace-func");
private final CyclicAssumption traceAssumption = new CyclicAssumption("trace-func");
private RubyProc traceFunc = null;
private boolean isInTraceFunc = false;

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

public class Warnings {

private RubyContext context;
private final RubyContext context;

public Warnings(RubyContext context) {
this.context = context;
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ public class FileUtils {
public static byte[] readAllBytesInterruptedly(RubyContext context, String file) {
RubyNode.notDesignedForCompilation();

final Path path = Paths.get(file.toString());
final Path path = Paths.get(file);

return context.getThreadManager().runUntilResult(new BlockingActionWithoutGlobalLock<byte[]>() {
@Override
Original file line number Diff line number Diff line change
@@ -1780,8 +1780,8 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgn19Node node) {
final SourceSection sourceSection = translate(node.getPosition());

final org.jruby.ast.ArrayNode preArray = (org.jruby.ast.ArrayNode) node.getPre();
final org.jruby.ast.ArrayNode postArray = (org.jruby.ast.ArrayNode) node.getPost();
final org.jruby.ast.ListNode preArray = node.getPre();
final org.jruby.ast.ListNode postArray = node.getPost();
final org.jruby.ast.Node rhs = node.getValueNode();

RubyNode rhsTranslated;