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: 97fa30d23784
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dc467714a6aa
Choose a head ref
  • 3 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 4, 2016

  1. [Truffle] code style

    pitr-ch committed Jan 4, 2016
    Copy the full SHA
    fbb40d1 View commit details
  2. 3
    Copy the full SHA
    1eb3fc0 View commit details
  3. [Truffle] tag slow spec

    pitr-ch committed Jan 4, 2016
    Copy the full SHA
    dc46771 View commit details
1 change: 1 addition & 0 deletions spec/truffle/tags/language/predefined/data_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ slow:The DATA constant does not exist when the main script contains no __END__
slow:The DATA constant does not exist when an included file has a __END__
slow:The DATA constant does not change when an included files also has a __END__
slow:The DATA constant is included in an otherwise empty file
slow:The DATA constant succeeds in locking the file DATA came from
Original file line number Diff line number Diff line change
@@ -235,7 +235,7 @@ public GraalNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public boolean graal() {
return Truffle.getRuntime().getName().toLowerCase(Locale.ENGLISH).contains("graal");
return getContext().onGraal();
}

}
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ public Object mulCoerced(VirtualFrame frame, long a, DynamicObject b) {
}
}

@CoreMethod(names = {"/", "__slash__"}, required = 1)
@CoreMethod(names = { "/", "__slash__" }, required = 1)
public abstract static class DivNode extends CoreMethodArrayArgumentsNode {

private final BranchProfile bGreaterZero = BranchProfile.create();
@@ -558,7 +558,7 @@ public Object lessEqualCoerced(VirtualFrame frame, long a, Object b) {
}
}

@CoreMethod(names = {"==", "==="}, required = 1)
@CoreMethod(names = { "==", "===" }, required = 1)
public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {

@Child private CallDispatchHeadNode reverseCallNode;
@@ -596,7 +596,7 @@ public boolean equal(long a, DynamicObject b) {
@Specialization(guards = {
"!isInteger(b)",
"!isLong(b)",
"!isRubyBignum(b)"})
"!isRubyBignum(b)" })
public Object equal(VirtualFrame frame, Object a, Object b) {
return reverseCallNode.call(frame, b, "==", null, a);
}
@@ -636,10 +636,10 @@ public int compare(long a, DynamicObject b) {
}

@Specialization(guards = {
"!isInteger(b)",
"!isLong(b)",
"!isDouble(b)",
"!isRubyBignum(b)"})
"!isInteger(b)",
"!isLong(b)",
"!isDouble(b)",
"!isRubyBignum(b)" })
public Object compare(VirtualFrame frame, Object a, Object b) {
return ruby(frame, "begin; b, a = math_coerce(other, :compare_error); a <=> b; rescue ArgumentError; nil; end", "other", b);
}
@@ -682,7 +682,7 @@ public boolean greaterEqual(long a, DynamicObject b) {
"!isRubyBignum(b)",
"!isInteger(b)",
"!isLong(b)",
"!isDouble(b)"})
"!isDouble(b)" })
public Object greaterEqualCoerced(VirtualFrame frame, long a, Object b) {
return ruby(frame, "b, a = math_coerce other, :compare_error; a >= b", "other", b);
}
@@ -725,7 +725,7 @@ public boolean greater(long a, DynamicObject b) {
"!isRubyBignum(b)",
"!isInteger(b)",
"!isLong(b)",
"!isDouble(b)"})
"!isDouble(b)" })
public Object greaterCoerced(VirtualFrame frame, long a, Object b) {
return ruby(frame, "b, a = math_coerce(other, :compare_error); a > b", "other", b);
}
@@ -875,7 +875,7 @@ public Object leftShiftWithOverflow(long a, int b) {
public Object leftShiftNeg(VirtualFrame frame, long a, int b) {
if (rightShiftNode == null) {
CompilerDirectives.transferToInterpreter();
rightShiftNode = insert(RightShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[] { null, null }));
rightShiftNode = insert(RightShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
}
return rightShiftNode.executeRightShift(frame, a, -b);
}
@@ -917,7 +917,7 @@ public RightShiftNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "b >= 0")
public int rightShift(VirtualFrame frame, int a, int b,
@Cached("createBinaryProfile()") ConditionProfile profile) {
@Cached("createBinaryProfile()") ConditionProfile profile) {
if (profile.profile(b >= Integer.SIZE - 1)) {
return a < 0 ? -1 : 0;
} else {
@@ -927,7 +927,7 @@ public int rightShift(VirtualFrame frame, int a, int b,

@Specialization(guards = "b >= 0")
public Object rightShift(VirtualFrame frame, long a, int b,
@Cached("createBinaryProfile()") ConditionProfile profile) {
@Cached("createBinaryProfile()") ConditionProfile profile) {
if (profile.profile(b >= Long.SIZE - 1)) {
return a < 0 ? -1 : 0; // int
} else {
@@ -939,7 +939,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(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
}
return leftShiftNode.executeLeftShift(frame, a, -b);
}
@@ -959,7 +959,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(getContext(), getSourceSection(), new RubyNode[]{ null, null }));
}
return leftShiftNode.executeLeftShift(frame, a, Layouts.BIGNUM.getValue(b).negate());
}
@@ -979,7 +979,7 @@ protected static boolean isPositive(DynamicObject b) {

}

@CoreMethod(names = {"abs", "magnitude"})
@CoreMethod(names = { "abs", "magnitude" })
public abstract static class AbsNode extends CoreMethodArrayArgumentsNode {

public AbsNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ public enum YAMLEncoding {
YAML_ANY_ENCODING(UTF8Encoding.INSTANCE),
YAML_UTF8_ENCODING(UTF8Encoding.INSTANCE),
YAML_UTF16LE_ENCODING(UTF16LEEncoding.INSTANCE),
YAML_UTF16BE_ENCODING(UTF16BEEncoding.INSTANCE), ;
YAML_UTF16BE_ENCODING(UTF16BEEncoding.INSTANCE);

YAMLEncoding(Encoding encoding) {
this.encoding = encoding;
@@ -163,7 +163,7 @@ private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicOb
Object notExplicit = !((DocumentEndEvent) event).getExplicit();
invoke(handler, "end_document", notExplicit);
} else if (event.is(Event.ID.Alias)) {
Object alias = stringOrNilFor(((AliasEvent)event).getAnchor(), tainted);
Object alias = stringOrNilFor(((AliasEvent) event).getAnchor(), tainted);
invoke(handler, "alias", alias);
} else if (event.is(Event.ID.Scalar)) {
handleScalar((ScalarEvent) event, tainted, handler);
@@ -239,14 +239,14 @@ private void handleDocumentStart(DocumentStartEvent dse, boolean tainted, Object
DumperOptions.Version _version = dse.getVersion();
Integer[] versionInts = _version == null ? null : _version.getArray();
Object version = versionInts == null ?
Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0):
Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{versionInts[0], versionInts[1]}, 2);
Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0) :
Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{ versionInts[0], versionInts[1] }, 2);

Map<String, String> tagsMap = dse.getTags();
DynamicObject tags = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);
if (tagsMap != null && tagsMap.size() > 0) {
for (Map.Entry<String, String> tag : tagsMap.entrySet()) {
Object key = stringFor(tag.getKey(), tainted);
Object key = stringFor(tag.getKey(), tainted);
Object value = stringFor(tag.getValue(), tainted);
ruby("tags.push [key, value]", "tags", tags, "key", key, "value", value);
}
@@ -317,12 +317,18 @@ private static int translateStyle(Character style) {
if (style == null) return 0; // any

switch (style) {
case 0: return 1; // plain
case '\'': return 2; // single-quoted
case '"': return 3; // double-quoted
case '|': return 4; // literal
case '>': return 5; // folded
default: return 0; // any
case 0:
return 1; // plain
case '\'':
return 2; // single-quoted
case '"':
return 3; // double-quoted
case '|':
return 4; // literal
case '>':
return 5; // folded
default:
return 0; // any
}
}

Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
@@ -125,6 +126,10 @@ public RubyContext(Ruby runtime, TruffleLanguage.Env env) {

compilerOptions = Truffle.getRuntime().createCompilerOptions();

if (!onGraal()) {
System.err.println("JRuby+Truffle is designed to be run with a JVM that has the Graal compiler. See https://github.com/jruby/jruby/wiki/Truffle-FAQ#how-do-i-get-jrubytruffle");
}

if (compilerOptions.supportsOption("MinTimeThreshold")) {
compilerOptions.setOption("MinTimeThreshold", 100000000);
}
@@ -200,6 +205,10 @@ public RubyContext(Ruby runtime, TruffleLanguage.Env env) {
initialize();
}

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

public Object send(Object object, String methodName, DynamicObject block, Object... arguments) {
CompilerAsserts.neverPartOfCompilation();

Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@ public class BodyTranslator extends Translator {
Arrays.asList("$:", "$LOAD_PATH", "$-I", "$\"", "$LOADED_FEATURES", "$<", "$FILENAME", "$?", "$-a", "$-l", "$-p", "$!"));

private static final Map<String, String> GLOBAL_VARIABLE_ALIASES = new HashMap<String, String>();

static {
Map<String, String> m = GLOBAL_VARIABLE_ALIASES;
m.put("$-I", "$LOAD_PATH");
@@ -817,6 +818,7 @@ private RubyNode openModule(SourceSection sourceSection, RubyNode defineOrGetNod
* for self, which is the module or class object that is being defined. Therefore for a module or
* class definition we translate into a special method. We run that method with self set to be the
* newly allocated module or class.
* </p>
*/
private MethodDefinitionNode compileClassNode(SourceSection sourceSection, String name, org.jruby.ast.Node bodyNode) {
RubyNode body;
@@ -1151,7 +1153,7 @@ public RubyNode visitDefsNode(org.jruby.ast.DefsNode node) {
}

protected RubyNode translateMethodDefinition(SourceSection sourceSection, RubyNode classNode, String methodName, org.jruby.ast.ArgsNode argsNode, org.jruby.ast.Node bodyNode,
boolean isDefs) {
boolean isDefs) {
final Arity arity = MethodTranslator.getArity(argsNode);
final ArgumentDescriptor[] argumentDescriptors = Helpers.argsNodeToArgumentDescriptors(argsNode);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), arity, methodName, false, argumentDescriptors, false, false, false);
@@ -1629,7 +1631,7 @@ public RubyNode visitInstAsgnNode(org.jruby.ast.InstAsgnNode node) {
}
} else if (path.equals(corePath + "rubinius/bootstrap/string.rb") || path.equals(corePath + "rubinius/common/string.rb")) {
if (name.equals("@hash")) {
ret = StringNodesFactory.ModifyBangNodeFactory.create(context, sourceSection, new RubyNode[] {});
ret = StringNodesFactory.ModifyBangNodeFactory.create(context, sourceSection, new RubyNode[]{});
return addNewlineIfNeeded(node, ret);
}
} else if (path.equals(corePath + "rubinius/common/range.rb")) {
@@ -1692,18 +1694,18 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
ret = new RubyCallNode(context, sourceSection, "full", self, null, false);
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@regexp")) {
ret = MatchDataNodesFactory.RegexpNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = MatchDataNodesFactory.RegexpNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@names")) {
ret = RegexpNodesFactory.RubiniusNamesNodeGen.create(context, sourceSection, self);
return addNewlineIfNeeded(node, ret);
}
} else if (path.equals(corePath + "rubinius/bootstrap/string.rb") || path.equals(corePath + "rubinius/common/string.rb")) {
if (name.equals("@num_bytes")) {
ret = StringNodesFactory.ByteSizeNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = StringNodesFactory.ByteSizeNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@data")) {
final RubyNode bytes = StringNodesFactory.BytesNodeFactory.create(context, sourceSection, new RubyNode[] { self });
final RubyNode bytes = StringNodesFactory.BytesNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
// Wrap in a StringData instance, see shims.
LiteralNode stringDataClass = new LiteralNode(context, sourceSection, context.getCoreLibrary().getStringDataClass());
ret = new RubyCallNode(context, sourceSection, "new", stringDataClass, null, false, bytes);
@@ -1722,21 +1724,21 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
ret = HashNodesFactory.DefaultValueNodeFactory.create(context, sourceSection, self);
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@default_proc")) {
ret = HashNodesFactory.DefaultProcNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = HashNodesFactory.DefaultProcNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@size")) {
ret = HashNodesFactory.SizeNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = HashNodesFactory.SizeNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
}
} else if (path.equals(corePath + "rubinius/common/range.rb") || path.equals(corePath + "rubinius/api/shims/range.rb")) {
if (name.equals("@begin")) {
ret = RangeNodesFactory.BeginNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = RangeNodesFactory.BeginNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@end")) {
ret = RangeNodesFactory.EndNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = RangeNodesFactory.EndNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
} else if (name.equals("@excl")) {
ret = RangeNodesFactory.ExcludeEndNodeFactory.create(context, sourceSection, new RubyNode[] { self });
ret = RangeNodesFactory.ExcludeEndNodeFactory.create(context, sourceSection, new RubyNode[]{ self });
return addNewlineIfNeeded(node, ret);
}
}
@@ -2409,7 +2411,7 @@ private RubyNode translateRationalComplex(SourceSection sourceSection, String na
return new RubyCallNode(
context, sourceSection, "convert",
new ReadLiteralConstantNode(context, sourceSection, moduleNode, name),
null, false, true, new RubyNode[]{a, b});
null, false, true, new RubyNode[]{ a, b });
}

@Override
@@ -2634,9 +2636,9 @@ public RubyNode visitUndefNode(org.jruby.ast.UndefNode node) {
final SourceSection sourceSection = translate(node.getPosition());
final DynamicObject nameSymbol = translateNameNodeToSymbol(node.getName());

final RubyNode ret = UndefMethodNodeFactory.create(context, sourceSection, new RubyNode[] {
final RubyNode ret = UndefMethodNodeFactory.create(context, sourceSection, new RubyNode[]{
new RaiseIfFrozenNode(new GetDefaultDefineeNode(context, sourceSection)),
new LiteralNode(context, sourceSection, new Object[] { nameSymbol })
new LiteralNode(context, sourceSection, new Object[]{ nameSymbol })
});
return addNewlineIfNeeded(node, ret);
}