Skip to content

Commit

Permalink
Showing 7 changed files with 52 additions and 44 deletions.
2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
repository( :url => 'http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/',
:id => 'truffle' )

truffle_version = 'a6a1efa177d2aba0b726e024755ec571b601b4d2-SNAPSHOT'
truffle_version = '66f79c26f8977bb7eb246b70d90b39385f846be7-SNAPSHOT'
jar 'com.oracle.truffle:truffle-api:' + truffle_version
jar 'com.oracle.truffle:truffle-debug:' + truffle_version
jar 'com.oracle.truffle:truffle-dsl-processor:' + truffle_version, :scope => 'provided'
8 changes: 4 additions & 4 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -36,23 +36,23 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>a6a1efa177d2aba0b726e024755ec571b601b4d2-SNAPSHOT</version>
<version>66f79c26f8977bb7eb246b70d90b39385f846be7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-debug</artifactId>
<version>a6a1efa177d2aba0b726e024755ec571b601b4d2-SNAPSHOT</version>
<version>66f79c26f8977bb7eb246b70d90b39385f846be7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>a6a1efa177d2aba0b726e024755ec571b601b4d2-SNAPSHOT</version>
<version>66f79c26f8977bb7eb246b70d90b39385f846be7-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>a6a1efa177d2aba0b726e024755ec571b601b4d2-SNAPSHOT</version>
<version>66f79c26f8977bb7eb246b70d90b39385f846be7-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public final class CachedForeignDispatchNode extends CachedDispatchNode {
@Child private Node nullCheck;
@Child private Node access;
@Child private PrepareArguments prepareArguments;
@CompilerDirectives.CompilationFinal private boolean passReceiver;


public CachedForeignDispatchNode(RubyContext context, DispatchNode next, Object cachedName, int arity) {
super(context, cachedName, next, DispatchAction.CALL_METHOD);
@@ -57,16 +57,12 @@ private void initializeNodes(RubyContext context, int arity) {
directArray = Message.WRITE.createNode();
} else if (name.endsWith("=") && arity == 1) {
directField = Message.WRITE.createNode();
} else if (name.endsWith("static_call")) {
directCall = Message.createExecute(arity).createNode();
passReceiver = false;
} else if (name.endsWith("call")) {// arity + 1 for receiver
directCall = Message.createExecute(arity + 1).createNode();
passReceiver = true;
} else if (name.endsWith("nil?")) {
} else if (name.equals("call")) {
directCall = Message.createExecute(arity).createNode();
} else if (name.equals("nil?")) {
nullCheck = Message.IS_NULL.createNode();
} else {
access = Message.createInvoke(arity + 1).createNode();
access = Message.createInvoke(arity).createNode();
}
prepareArguments = new PrepareArguments(context, getSourceSection(), arity);
}
@@ -111,21 +107,14 @@ private Object doDispatch(VirtualFrame frame, TruffleObject receiverObject, Obje
return ForeignAccess.execute(directField, frame, receiverObject, args);
} else if (directCall != null) {
Object[] args;

if (passReceiver) {
args = prepareArguments.convertArguments(frame, arguments, 1);
args[0] = receiverObject;
} else {
args = prepareArguments.convertArguments(frame, arguments, 0);
}
args = prepareArguments.convertArguments(frame, arguments, 0);
return ForeignAccess.execute(directCall, frame, receiverObject, args);
} else if (nullCheck != null) {
Object[] args = prepareArguments.convertArguments(frame, arguments, 0);
return ForeignAccess.execute(nullCheck, frame, receiverObject, args);
} else if (access != null) {
Object[] args = prepareArguments.convertArguments(frame, arguments, 2);
Object[] args = prepareArguments.convertArguments(frame, arguments, 1);
args[0] = name;
args[1] = receiverObject;
return ForeignAccess.execute(access, frame, receiverObject, args);
} else {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -159,17 +159,17 @@ protected Object doCall(VirtualFrame frame, DynamicObject method,
@Cached("getMethod(cachedMethod)") InternalMethod internalMethod,
@Cached("create(getMethod(cachedMethod).getCallTarget())") DirectCallNode callNode) {
final List<Object> faArgs = ForeignAccess.getArguments(frame);
// skip first argument; it's the receiver but a RubyMethod knows its receiver
Object[] args = faArgs.subList(1, faArgs.size()).toArray();

Object[] args = faArgs.subList(0, faArgs.size()).toArray();
return callNode.call(frame, RubyArguments.pack(internalMethod, null, null, Layouts.METHOD.getReceiver(cachedMethod), null, DeclarationContext.METHOD, args));
}

@Specialization(guards = "isRubyMethod(method)")
protected Object doCall(VirtualFrame frame, DynamicObject method) {
final InternalMethod internalMethod = Layouts.METHOD.getMethod(method);
final List<Object> faArgs = ForeignAccess.getArguments(frame);
// skip first argument; it's the receiver but a RubyMethod knows its receiver
Object[] args = faArgs.subList(1, faArgs.size()).toArray();

Object[] args = faArgs.subList(0, faArgs.size()).toArray();
return callNode.call(frame, internalMethod.getCallTarget(), RubyArguments.pack(
internalMethod,
null,
@@ -733,12 +733,10 @@ private static class InteropArgumentsNode extends RubyNode {

public InteropArgumentsNode(RubyContext context, SourceSection sourceSection, int arity) {
super(context, sourceSection);
this.arguments = new InteropArgumentNode[arity - 1]; // exclude the receiver
// Execute(Read(receiver, label), a0 (which is the receiver), a1, a2)
// the arguments array looks like:
// label, a0 (which is the receiver), a1, a2, ...
for (int i = 2; i < 2 + arity - 1; i++) {
arguments[i - 2] = new InteropArgumentNode(context, sourceSection, i - 1);
this.arguments = new InteropArgumentNode[arity];
// index 0 is the lable
for (int i = 1; i < 1 + arity; i++) {
arguments[i - 1] = new InteropArgumentNode(context, sourceSection, i);
}
}

Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ private SourceSection nextUserSourceSection(List<Activation> activations, int n)
}

private boolean isCore(SourceSection sourceSection) {
return sourceSection == null || sourceSection.getSource() == null || sourceSection.getSource().getPath().startsWith(SourceLoader.TRUFFLE_SCHEME);
return sourceSection == null || sourceSection.getSource() == null || (sourceSection.getSource().getPath() != null && sourceSection.getSource().getPath().startsWith(SourceLoader.TRUFFLE_SCHEME));
}

}
Original file line number Diff line number Diff line change
@@ -173,7 +173,11 @@ public String getSourcePath(Source source) {
if (source == mainScriptSource) {
return mainScriptFullPath;
} else {
return source.getPath();
if (source.getPath() == null) {
return source.getShortName();
} else {
return source.getPath();
}
}
}

Original file line number Diff line number Diff line change
@@ -416,7 +416,7 @@ public RubyNode visitCallNode(org.jruby.ast.CallNode node) {
}
} else if (receiver instanceof org.jruby.ast.VCallNode // undefined.equal?(obj)
&& ((org.jruby.ast.VCallNode) receiver).getName().equals("undefined")
&& sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")
&& getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")
&& methodName.equals("equal?")) {
RubyNode argument = translateArgumentsAndBlock(sourceSection, null, node.getArgsNode(), methodName).getArguments()[0];
final RubyNode ret = new IsRubiniusUndefinedNode(context, sourceSection, argument);
@@ -952,6 +952,22 @@ public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
return addNewlineIfNeeded(node, ret);
}

private String getSourcePath(SourceSection sourceSection) {
final Source source = sourceSection.getSource();

if (source == null) {
return "(unknown)";
}

final String path = source.getPath();

if (path == null) {
return source.getShortName();
}

return path;
}

@Override
public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {
// Unqualified constant access, as in CONST
@@ -966,13 +982,13 @@ public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {

final String name = ConstantReplacer.replacementName(sourceSection, node.getName());

if (name.equals("Rubinius") && sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius")) {
if (name.equals("Rubinius") && getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius")) {
final RubyNode ret = new org.jruby.ast.Colon3Node(node.getPosition(), name).accept(this);
return addNewlineIfNeeded(node, ret);
}

// TODO (pitr 01-Dec-2015): remove when RUBY_PLATFORM is set to "truffle"
if (name.equals("RUBY_PLATFORM") && sourceSection.getSource().getPath().contains("test/xml_mini/jdom_engine_test.rb")) {
if (name.equals("RUBY_PLATFORM") && getSourcePath(sourceSection).contains("test/xml_mini/jdom_engine_test.rb")) {
final LiteralNode ret = new LiteralNode(context, sourceSection, StringOperations.createString(context, StringOperations.encodeByteList("truffle", UTF8Encoding.INSTANCE)));
return addNewlineIfNeeded(node, ret);
}
@@ -1093,7 +1109,7 @@ public RubyNode visitDefnNode(org.jruby.ast.DefnNode node) {
// a bit different than aliasing because normally if a Rubinius method name conflicts with an already defined
// method, we simply ignore the method definition. Here we explicitly rename the method so it's always defined.

final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String coreRubiniusPath = context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/";
if (path.startsWith(coreRubiniusPath)) {
boolean rename = false;
@@ -1424,7 +1440,8 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
return new UpdateLastBacktraceNode(context, sourceSection, rhs);
}

final boolean inCore = rhs.getSourceSection().getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/");
final boolean inCore = getSourcePath(rhs.getSourceSection()).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/");

if (!inCore && READ_ONLY_GLOBAL_VARIABLES.contains(name)) {
return addNewlineIfNeeded(node, new WriteReadOnlyGlobalNode(context, sourceSection, name, rhs));
}
@@ -1489,7 +1506,7 @@ public RubyNode visitGlobalVarNode(org.jruby.ast.GlobalVarNode node) {
RubyNode readNode = environment.findLocalVarNode(name, sourceSection);

if (name.equals("$_")) {
if (sourceSection.getSource().getPath().equals(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/common/regexp.rb")) {
if (getSourcePath(sourceSection).equals(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/common/regexp.rb")) {
readNode = new RubiniusLastStringReadNode(context, sourceSection);
} else {
readNode = GetFromThreadLocalNodeGen.create(context, sourceSection, readNode);
@@ -1588,7 +1605,7 @@ public RubyNode visitInstAsgnNode(org.jruby.ast.InstAsgnNode node) {
// Also note the check for frozen.
final RubyNode self = new RaiseIfFrozenNode(new SelfNode(context, sourceSection));

final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String corePath = context.getCoreLibrary().getCoreLoadPath() + "/core/";
final RubyNode ret;
if (path.equals(corePath + "rubinius/common/time.rb")) {
@@ -1649,7 +1666,7 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
* expects that we'll replace it statically with a call to Array#size. We also replace @tuple with
* self, and @start to be 0.
*/
final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String corePath = context.getCoreLibrary().getCoreLoadPath() + "/core/";
final RubyNode ret;
if (path.equals(corePath + "rubinius/common/array.rb") || path.equals(corePath + "rubinius/api/shims/array.rb")) {
@@ -2628,7 +2645,7 @@ public RubyNode visitUntilNode(org.jruby.ast.UntilNode node) {
@Override
public RubyNode visitVCallNode(org.jruby.ast.VCallNode node) {
final SourceSection sourceSection = translate(node.getPosition());
if (node.getName().equals("undefined") && sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")) {
if (node.getName().equals("undefined") && getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")) {
final RubyNode ret = new LiteralNode(context, sourceSection, context.getCoreLibrary().getRubiniusUndefined());
return addNewlineIfNeeded(node, ret);
}

0 comments on commit 1a483cd

Please sign in to comment.