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

Commits on Sep 1, 2015

  1. [Truffle] When you have a Rubinius primitive implemented as a call yo…

    …u still need to handle the return issues.
    chrisseaton committed Sep 1, 2015
    Copy the full SHA
    d749df2 View commit details
  2. Copy the full SHA
    40f9069 View commit details

Commits on Sep 3, 2015

  1. Copy the full SHA
    44be094 View commit details

Commits on Sep 13, 2015

  1. Copy the full SHA
    689bc06 View commit details
  2. Merge branch 'truffle-java-interop' into truffle-head

    Conflicts:
    	truffle/pom.rb
    	truffle/pom.xml
    	truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedForeignDispatchNode.java
    	truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
    chrisseaton committed Sep 13, 2015
    Copy the full SHA
    674db03 View commit details
  3. Copy the full SHA
    300d72a View commit details
2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
repository( :url => 'http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/',
:id => 'truffle' )

truffle_version = '1d804d691dc7ee471e9cd70e0997d756049ac784-SNAPSHOT'
truffle_version = '597953a8e6f01142b9ba4368622d076bb2dc0401-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
@@ -31,23 +31,23 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>1d804d691dc7ee471e9cd70e0997d756049ac784-SNAPSHOT</version>
<version>597953a8e6f01142b9ba4368622d076bb2dc0401-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-debug</artifactId>
<version>1d804d691dc7ee471e9cd70e0997d756049ac784-SNAPSHOT</version>
<version>597953a8e6f01142b9ba4368622d076bb2dc0401-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>1d804d691dc7ee471e9cd70e0997d756049ac784-SNAPSHOT</version>
<version>597953a8e6f01142b9ba4368622d076bb2dc0401-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>1d804d691dc7ee471e9cd70e0997d756049ac784-SNAPSHOT</version>
<version>597953a8e6f01142b9ba4368622d076bb2dc0401-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
17 changes: 16 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,22 @@
public abstract class RubyTypes {

@ImplicitCast
public static long int2long(int value) {
public static long castByteToLong(byte value) {
return value;
}

@ImplicitCast
public static long castShortToLong(short value) {
return value;
}

@ImplicitCast
public static long castIntegerToLong(int value) {
return value;
}

@ImplicitCast
public static double castFloatToDouble(float value) {
return value;
}

Original file line number Diff line number Diff line change
@@ -35,6 +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, false, DispatchAction.CALL_METHOD);
@@ -58,6 +59,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?")) {
nullCheck = Message.IS_NULL.createNode();
} else {
@@ -106,8 +113,14 @@ private Object doDispatch(VirtualFrame frame, TruffleObject receiverObject, Obje
args[0] = nameForMessage;
return ForeignAccess.execute(directField, frame, receiverObject, args);
} else if (directCall != null) {
Object[] args = prepareArguments.convertArguments(frame, arguments, 1);
args[0] = receiverObject;
Object[] args;

if (passReceiver) {
args = prepareArguments.convertArguments(frame, arguments, 1);
args[0] = receiverObject;
} else {
args = prepareArguments.convertArguments(frame, arguments, 0);
}
return ForeignAccess.execute(directCall, frame, receiverObject, args);
} else if (nullCheck != null) {
Object[] args = prepareArguments.convertArguments(frame, arguments, 0);
Original file line number Diff line number Diff line change
@@ -52,13 +52,7 @@ public ExceptionTranslatingNode(RubyContext context, SourceSection sourceSection
@Override
public Object execute(VirtualFrame frame) {
try {
assert assertArgumentsShouldBeVisible(frame);

final Object result = child.execute(frame);

assert shouldObjectBeVisible(result) : "result@" + getEncapsulatingSourceSection().getShortDescription();

return result;
return child.execute(frame);
} catch (StackOverflowError error) {
// TODO: we might want to do sth smarter here to avoid consuming frames when we are almost out of it.
CompilerDirectives.transferToInterpreter();
@@ -173,35 +167,5 @@ public DynamicObject translate(Throwable throwable) {
return getContext().getCoreLibrary().internalError(String.format("%s %s ???", throwable.getClass().getSimpleName(), throwable.getMessage()), this);
}
}
private boolean shouldObjectBeVisible(Object object) {
return object instanceof TruffleObject
|| object instanceof Boolean
|| object instanceof Integer
|| object instanceof Long
|| object instanceof Double;
}

private boolean assertArgumentsShouldBeVisible(VirtualFrame frame) {
final Object self = RubyArguments.getSelf(frame.getArguments());

assert shouldObjectBeVisible(self) : "self=" + (self == null ? "null" : self.getClass()) + "@" + getEncapsulatingSourceSection().getShortDescription();

final Object[] arguments = RubyArguments.extractUserArguments(frame.getArguments());

for (int n = 0; n < arguments.length; n++) {
final Object argument = arguments[n];
assert shouldObjectBeVisible(argument) : "arg[" + n + "]=" + (argument == null ? "null" : argument.getClass() + "=" + toString(argument)) + "@" + getEncapsulatingSourceSection().getShortDescription();
}

return true;
}

private String toString(Object object) {
if (object instanceof Object[]) {
return Arrays.toString((Object[]) object);
} else {
return object.toString();
}
}

}
Original file line number Diff line number Diff line change
@@ -41,10 +41,6 @@ public RubiniusPrimitiveConstructor getPrimitive(String name) {
return constructor;
}

private void addPrimitive(String name, RubiniusPrimitiveConstructor constructor) {
primitives.putIfAbsent(name, constructor);
}

public void addAnnotatedPrimitives() {
final List<NodeFactory<? extends RubyNode>> nodeFactories = new ArrayList<>();

@@ -78,13 +74,13 @@ public void addAnnotatedPrimitives() {
final GeneratedBy generatedBy = nodeFactory.getClass().getAnnotation(GeneratedBy.class);
final Class<?> nodeClass = generatedBy.value();
final RubiniusPrimitive annotation = nodeClass.getAnnotation(RubiniusPrimitive.class);
addPrimitive(annotation.name(), new RubiniusPrimitiveNodeConstructor(annotation, nodeFactory));
primitives.putIfAbsent(annotation.name(), new RubiniusPrimitiveNodeConstructor(annotation, nodeFactory));
}
}

@TruffleBoundary
public void installPrimitive(String name, DynamicObject method) {
assert RubyGuards.isRubyMethod(method);
addPrimitive(name, new RubiniusPrimitiveCallConstructor(method));
primitives.put(name, new RubiniusPrimitiveCallConstructor(method));
}
}
Original file line number Diff line number Diff line change
@@ -126,21 +126,6 @@ public Object doCatch(VirtualFrame frame, Object tag, DynamicObject block) {
}
}

@RubiniusPrimitive(name = "vm_gc_start", needsSelf = false)
public static abstract class VMGCStartPrimitiveNode extends RubiniusPrimitiveNode {

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

@Specialization
public DynamicObject vmGCStart() {
System.gc();
return nil();
}

}

@RubiniusPrimitive(name = "vm_get_module_name", needsSelf = false)
public static abstract class VMGetModuleNamePrimitiveNode extends RubiniusPrimitiveNode {

@@ -555,4 +540,20 @@ public DynamicObject setClass(DynamicObject object, DynamicObject newClass) {

}

@RubiniusPrimitive(name = "vm_gc_start", needsSelf = false)
public static abstract class VMGCStartPrimitiveNode extends RubiniusPrimitiveNode {

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

@Specialization
public DynamicObject vmGCStart() {
System.gc();
return nil();
}

}


}
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.interop.java.JavaInterop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
@@ -177,6 +179,8 @@ public class CoreLibrary {

@CompilationFinal private InternalMethod basicObjectSendMethod;

private static final TruffleObject systemObject = JavaInterop.asTruffleObject(System.class);

public String getCoreLoadPath() {
String path = context.getOptions().CORE_LOAD_PATH;

@@ -624,6 +628,11 @@ private void initializeConstants() {
Layouts.MODULE.getFields(encodingConverterClass).setConstant(node, "XML_TEXT_DECORATOR", EConvFlags.XML_TEXT_DECORATOR);
Layouts.MODULE.getFields(encodingConverterClass).setConstant(node, "XML_ATTR_CONTENT_DECORATOR", EConvFlags.XML_ATTR_CONTENT_DECORATOR);
Layouts.MODULE.getFields(encodingConverterClass).setConstant(node, "XML_ATTR_QUOTE_DECORATOR", EConvFlags.XML_ATTR_QUOTE_DECORATOR);

// Java interop

final DynamicObject javaModule = defineModule(truffleModule, "Java");
Layouts.MODULE.getFields(javaModule).setConstant(null, "System", systemObject);
}

private void initializeSignalConstants() {
@@ -773,10 +782,16 @@ public DynamicObject getMetaClass(Object object) {
} else {
return falseClass;
}
} else if (object instanceof Byte) {
return fixnumClass;
} else if (object instanceof Short) {
return fixnumClass;
} else if (object instanceof Integer) {
return fixnumClass;
} else if (object instanceof Long) {
return fixnumClass;
} else if (object instanceof Float) {
return floatClass;
} else if (object instanceof Double) {
return floatClass;
} else if (object == null) {
@@ -796,10 +811,16 @@ public DynamicObject getLogicalClass(Object object) {
} else {
return falseClass;
}
} else if (object instanceof Byte) {
return fixnumClass;
} else if (object instanceof Short) {
return fixnumClass;
} else if (object instanceof Integer) {
return fixnumClass;
} else if (object instanceof Long) {
return fixnumClass;
} else if (object instanceof Float) {
return floatClass;
} else if (object instanceof Double) {
return floatClass;
} else if (object == null) {
10 changes: 10 additions & 0 deletions truffle/src/main/ruby/core/rubinius/primitives.rb
Original file line number Diff line number Diff line change
@@ -33,5 +33,15 @@ def self.module_mirror(obj)

Truffle::Primitive.install_rubinius_primitive method(:module_mirror)

if Truffle::Primitive.substrate?

def self.vm_gc_start(force)
Truffle::Interop.execute(Truffle::Interop.read_property(Truffle::Java::System, :gc))
end

Truffle::Primitive.install_rubinius_primitive method(:vm_gc_start)

end

end
end