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

Commits on Feb 24, 2016

  1. Copy the full SHA
    e842fbe View commit details
  2. Copy the full SHA
    bf2436d View commit details
  3. Copy the full SHA
    2c8e164 View commit details
  4. Copy the full SHA
    5fa9781 View commit details
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -248,6 +248,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval lookup cache size");
public static final Option<Integer> TRUFFLE_CLASS_CACHE = integer(TRUFFLE, "truffle.class.cache", TRUFFLE_DEFAULT_CACHE.load(), ".class and .metaclass cache size");
public static final Option<Integer> TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE = integer(TRUFFLE, "truffle.encoding_compatible_query.cache", TRUFFLE_DEFAULT_CACHE.load(), "Encoding.compatible? cache size");
public static final Option<Integer> TRUFFLE_THREAD_CACHE = integer(TRUFFLE, "truffle.thread.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size of operations that depend on a particular thread");

public static final Option<Boolean> TRUFFLE_CLONE_DEFAULT = bool(TRUFFLE, "truffle.clone.default", true, "Default option for cloning.");
public static final Option<Boolean> TRUFFLE_INLINE_DEFAULT = bool(TRUFFLE, "truffle.inline.default", true, "Default option for inlining.");
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ public class Options {
public final int EVAL_CACHE = TRUFFLE_EVAL_CACHE.load();
public final int CLASS_CACHE = TRUFFLE_CLASS_CACHE.load();
public final int ENCODING_COMPATIBILE_QUERY_CACHE = TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE.load();
public final int THREAD_CACHE = TRUFFLE_THREAD_CACHE.load();

// Cloning and inlining

Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public UnlessNode(RubyContext context, SourceSection sourceSection, RubyNode con

@Override
public Object execute(VirtualFrame frame) {
if (conditionProfile.profile(!condition.executeBoolean(frame))) {
if (!conditionProfile.profile(condition.executeBoolean(frame))) {
return thenBody.execute(frame);
} else {
return nil();
Original file line number Diff line number Diff line change
@@ -61,6 +61,12 @@ public WhileRepeatingBaseNode(RubyContext context, RubyNode condition, RubyNode
this.condition = BooleanCastNodeGen.create(context, condition.getSourceSection(), condition);
this.body = body;
}

@Override
public String toString() {
return condition.getEncapsulatingSourceSection().getShortDescription();
}

}

private static class WhileRepeatingNode extends WhileRepeatingBaseNode implements RepeatingNode {
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.language.objects.ReadObjectFieldNode;
import org.jruby.truffle.language.objects.ReadObjectFieldNodeGen;
import org.jruby.truffle.language.objects.ThreadLocalObjectNode;
import org.jruby.truffle.language.objects.ThreadLocalObjectNodeGen;

public class ReadThreadLocalGlobalVariableNode extends RubyNode {

@@ -27,7 +28,7 @@ public class ReadThreadLocalGlobalVariableNode extends RubyNode {

public ReadThreadLocalGlobalVariableNode(RubyContext context, SourceSection sourceSection, String name) {
super(context, sourceSection);
this.threadLocalVariablesObjectNode = new ThreadLocalObjectNode(context, sourceSection);
this.threadLocalVariablesObjectNode = ThreadLocalObjectNodeGen.create(context, sourceSection);
readNode = ReadObjectFieldNodeGen.create(getContext(), name, nil());
}

Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@ public class FlipFlopNode extends RubyNode {
@Child private BooleanCastNode end;
@Child private FlipFlopStateNode stateNode;

public FlipFlopNode(boolean exclusive, SourceSection sourceSection, RubyNode begin, RubyNode end,
FlipFlopStateNode stateNode, RubyContext context) {
public FlipFlopNode(RubyContext context, SourceSection sourceSection, RubyNode begin, RubyNode end,
FlipFlopStateNode stateNode, boolean exclusive) {
super(context, sourceSection);
this.exclusive = exclusive;
this.begin = BooleanCastNodeGen.create(context, sourceSection, begin);
Original file line number Diff line number Diff line change
@@ -9,48 +9,48 @@
*/
package org.jruby.truffle.language.objects;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.language.RubyNode;

public class ThreadLocalObjectNode extends RubyNode {

@CompilationFinal private DynamicObject firstThreadSeen;
@CompilationFinal private DynamicObject firstThreadSeenLocals;
private final ConditionProfile firstThreadProfile = ConditionProfile.createCountingProfile();
public abstract class ThreadLocalObjectNode extends RubyNode {

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

@Override
public DynamicObject executeDynamicObject(VirtualFrame frame) {
if (firstThreadSeen == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
firstThreadSeen = currentThread();
firstThreadSeenLocals = Layouts.THREAD.getThreadLocals(firstThreadSeen);
}

if (firstThreadProfile.profile(currentThread() == firstThreadSeen)) {
return firstThreadSeenLocals;
} else {
return Layouts.THREAD.getThreadLocals(currentThread());
}
public abstract DynamicObject executeDynamicObject(VirtualFrame frame);

@Specialization(
guards = "cachedThread == getCurrentThread(frame)",
limit = "getCacheLimit()"
)
protected DynamicObject getThreadLocalObjectCached(VirtualFrame frame,
@Cached("getCurrentThread(frame)") DynamicObject cachedThread,
@Cached("getThreadLocals(cachedThread)") DynamicObject cachedThreadLocals) {
return cachedThreadLocals;
}

@Override
public Object execute(VirtualFrame frame) {
return executeDynamicObject(frame);
@Specialization(contains = "getThreadLocalObjectCached")
protected DynamicObject getThreadLocalObjectUncached(VirtualFrame frame) {
return getThreadLocals(getCurrentThread(frame));
}

private DynamicObject currentThread() {
protected DynamicObject getCurrentThread(VirtualFrame frame) {
return getContext().getThreadManager().getCurrentThread();
}

protected DynamicObject getThreadLocals(DynamicObject thread) {
return Layouts.THREAD.getThreadLocals(thread);
}

protected int getCacheLimit() {
return getContext().getOptions().THREAD_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -157,6 +157,7 @@
import org.jruby.truffle.language.objects.SingletonClassNode;
import org.jruby.truffle.language.objects.SingletonClassNodeGen;
import org.jruby.truffle.language.objects.ThreadLocalObjectNode;
import org.jruby.truffle.language.objects.ThreadLocalObjectNodeGen;
import org.jruby.truffle.language.objects.WriteClassVariableNode;
import org.jruby.truffle.language.objects.WriteInstanceVariableNode;
import org.jruby.truffle.language.yield.YieldNode;
@@ -1397,7 +1398,7 @@ public RubyNode visitFlipNode(org.jruby.ast.FlipNode node) {

final FlipFlopStateNode stateNode = createFlipFlopState(sourceSection, 0);

final RubyNode ret = new FlipFlopNode(node.isExclusive(), sourceSection, begin, end, stateNode, context);
final RubyNode ret = new FlipFlopNode(context, sourceSection, begin, end, stateNode, node.isExclusive());
return addNewlineIfNeeded(node, ret);
}

@@ -1605,7 +1606,7 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
}

if (THREAD_LOCAL_GLOBAL_VARIABLES.contains(name)) {
final ThreadLocalObjectNode threadLocalVariablesObjectNode = new ThreadLocalObjectNode(context, sourceSection);
final ThreadLocalObjectNode threadLocalVariablesObjectNode = ThreadLocalObjectNodeGen.create(context, sourceSection);
return addNewlineIfNeeded(node, new WriteInstanceVariableNode(context, sourceSection, name, threadLocalVariablesObjectNode, rhs));
} else if (FRAME_LOCAL_GLOBAL_VARIABLES.contains(name)) {
if (environment.getNeverAssignInParentScope()) {