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

Commits on Apr 4, 2016

  1. Copy the full SHA
    2563aef View commit details
  2. Copy the full SHA
    0d4cb5a View commit details
  3. Copy the full SHA
    d8144b8 View commit details
  4. Copy the full SHA
    72d3b98 View commit details
  5. Copy the full SHA
    8e89ce8 View commit details
  6. Copy the full SHA
    6ad5188 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
@@ -264,6 +264,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_INTEROP_EXECUTE_CACHE = integer(TRUFFLE, "truffle.interop.execute.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop EXECUTE messages.");
public static final Option<Integer> TRUFFLE_INTEROP_READ_CACHE = integer(TRUFFLE, "truffle.interop.read.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop READ messages.");
public static final Option<Integer> TRUFFLE_INTEROP_WRITE_CACHE = integer(TRUFFLE, "truffle.interop.write.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop WRITE messages.");
public static final Option<Integer> TRUFFLE_INTEROP_INVOKE_CACHE = integer(TRUFFLE, "truffle.interop.invoke.cache", TRUFFLE_DEFAULT_CACHE.load(), "Cache size for interop INVOKE messages.");

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.");

This file was deleted.

Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.interop;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
@@ -18,8 +17,6 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.language.RubyNode;

@@ -33,36 +30,16 @@ public RubyToForeignNode(RubyContext context, SourceSection sourceSection) {

public abstract Object executeConvert(VirtualFrame frame, Object value);

@Specialization(
guards = {
"isRubyString(value)",
"ropesEqual(value, cachedRope)"
},
limit = "getLimit()")
public String convertUncached(
@Specialization(guards = "isRubySymbol(value) || isRubyString(value)")
public String convert(
VirtualFrame frame,
DynamicObject value,
@Cached("privatizeRope(value)") Rope cachedRope,
@Cached("objectToString(value)") String convertedString) {
return convertedString;
@Cached("createToJavaStringNode()") ToJavaStringNode toJavaStringNode) {
return toJavaStringNode.executeToJavaString(frame, value);
}

@TruffleBoundary
@Specialization(guards = "isRubyString(value)")
public String convertStringUncached(DynamicObject value) {
return value.toString();
}

protected int getLimit() {
return getContext().getOptions().INTEROP_CONVERT_CACHE;
}

protected String objectToString(DynamicObject object) {
return object.toString();
}

@Specialization(guards = "isRubySymbol(value)")
public String convertSymbol(DynamicObject value) {
return Layouts.SYMBOL.getString(value);
protected ToJavaStringNode createToJavaStringNode() {
return ToJavaStringNodeGen.create(getContext(), null, null);
}

@Specialization(guards = {"!isRubyString(value)", "!isRubySymbol(value)"})
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.interop;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.NodeChild;
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.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.language.RubyNode;

@ImportStatic(StringCachingGuards.class)
@NodeChild(value = "value", type = RubyNode.class)
public abstract class ToJavaStringNode extends RubyNode {

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

public abstract String executeToJavaString(VirtualFrame frame, Object value);

@Specialization(
guards = {
"isRubyString(value)",
"ropesEqual(value, cachedRope)"
},
limit = "getLimit()")
public String stringUncached(
DynamicObject value,
@Cached("privatizeRope(value)") Rope cachedRope,
@Cached("value.toString()") String convertedString) {
return convertedString;
}

protected String objectToString(DynamicObject object) {
return object.toString();
}

@TruffleBoundary
@Specialization(guards = "isRubyString(value)", contains = "stringUncached")
public String stringCached(DynamicObject value) {
return value.toString();
}

@Specialization(guards = "isRubySymbol(value)")
public String symbol(DynamicObject value) {
return Layouts.SYMBOL.getString(value);
}

@Specialization
public String javaString(String value) {
return value;
}

protected int getLimit() {
return getContext().getOptions().INTEROP_CONVERT_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
/*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
/*
* Copyright (c) 2014, 2015, 2016 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
@@ -92,7 +83,7 @@ public Object executeForeignCached(
TruffleObject receiver,
Object[] args,
@Cached("args.length") int cachedArgsLength,
@Cached("createIsExecuteNode(cachedArgsLength)") Node executeNode,
@Cached("createExecuteNode(cachedArgsLength)") Node executeNode,
@Cached("create()") BranchProfile exceptionProfile) {
try {
return ForeignAccess.sendExecute(executeNode, frame, receiver, args);
@@ -109,7 +100,7 @@ public Object executeForeignUncached(
Object[] args) {
CompilerDirectives.bailout("can't compile megamorphic interop EXECUTE message sends");

final Node executeNode = createIsExecuteNode(args.length);
final Node executeNode = createExecuteNode(args.length);

try {
return ForeignAccess.sendExecute(executeNode, frame, receiver, args);
@@ -118,12 +109,88 @@ public Object executeForeignUncached(
}
}

protected Node createIsExecuteNode(int argsLength) {
protected Node createExecuteNode(int argsLength) {
return Message.createExecute(argsLength).createNode();
}

}

@CoreMethod(unsafeNeedsAudit = true, names = "invoke", isModuleFunction = true, needsSelf = false, required = 2, rest = true)
public abstract static class InvokeNode extends CoreMethodArrayArgumentsNode {

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

@Specialization(
guards = {
"isRubyString(identifier) || isRubySymbol(identifier)",
"args.length == cachedArgsLength"
},
limit = "getCacheLimit()"
)
public Object invokeCached(
VirtualFrame frame,
TruffleObject receiver,
DynamicObject identifier,
Object[] args,
@Cached("args.length") int cachedArgsLength,
@Cached("createInvokeNode(cachedArgsLength)") Node invokeNode,
@Cached("createToJavaStringNode()") ToJavaStringNode toJavaStringNode,
@Cached("create()") BranchProfile exceptionProfile) {
try {
return ForeignAccess.sendInvoke(
invokeNode,
frame,
receiver,
toJavaStringNode.executeToJavaString(frame, identifier),
args);
} catch (UnsupportedTypeException
| ArityException
| UnsupportedMessageException
| UnknownIdentifierException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
}
}

protected ToJavaStringNode createToJavaStringNode() {
return ToJavaStringNodeGen.create(getContext(), null, null);
}

@Specialization(
guards = "isRubyString(identifier) || isRubySymbol(identifier)",
contains = "invokeCached"
)
public Object invokeUncached(
VirtualFrame frame,
TruffleObject receiver,
DynamicObject identifier,
Object[] args) {
CompilerDirectives.bailout("can't compile megamorphic interop INVOKE message sends");

final Node invokeNode = createInvokeNode(args.length);

try {
return ForeignAccess.sendInvoke(invokeNode, frame, receiver, identifier.toString(), args);
} catch (UnsupportedTypeException
| ArityException
| UnsupportedMessageException
| UnknownIdentifierException e) {
throw new RuntimeException(e);
}
}

protected Node createInvokeNode(int argsLength) {
return Message.createInvoke(argsLength).createNode();
}

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

}

@CoreMethod(unsafeNeedsAudit = true, names = {"size?", "has_size_property?"}, isModuleFunction = true, needsSelf = false, required = 1)
public abstract static class HasSizeNode extends CoreMethodArrayArgumentsNode {

2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/language/Options.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import static org.jruby.util.cli.Options.TRUFFLE_INSTRUMENTATION_SERVER_PORT;
import static org.jruby.util.cli.Options.TRUFFLE_INTEROP_CONVERT_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_INTEROP_EXECUTE_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_INTEROP_INVOKE_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_INTEROP_READ_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_INTEROP_WRITE_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_IS_A_CACHE;
@@ -117,6 +118,7 @@ public class Options {
public final int INTEROP_EXECUTE_CACHE = TRUFFLE_INTEROP_EXECUTE_CACHE.load();
public final int INTEROP_READ_CACHE = TRUFFLE_INTEROP_READ_CACHE.load();
public final int INTEROP_WRITE_CACHE = TRUFFLE_INTEROP_WRITE_CACHE.load();
public final int INTEROP_INVOKE_CACHE = TRUFFLE_INTEROP_INVOKE_CACHE.load();

// Cloning and inlining

Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@
import com.oracle.truffle.api.profiles.BranchProfile;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.array.ArrayUtils;
import org.jruby.truffle.core.conversion.ToJavaStringNode;
import org.jruby.truffle.core.conversion.ToJavaStringNodeGen;
import org.jruby.truffle.core.conversion.ToSymbolNode;
import org.jruby.truffle.core.conversion.ToSymbolNodeGen;
import org.jruby.truffle.interop.ToJavaStringNode;
import org.jruby.truffle.interop.ToJavaStringNodeGen;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.methods.DeclarationContext;
@@ -67,7 +67,7 @@ public Object executeDispatch(

final DynamicObject callerClass = ignoreVisibility ? null : metaClassNode.executeMetaClass(RubyArguments.getSelf(frame));

final InternalMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeJavaString(frame, name), ignoreVisibility);
final InternalMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeToJavaString(frame, name), ignoreVisibility);

if (method != null) {
if (dispatchAction == DispatchAction.CALL_METHOD) {