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

Commits on Nov 23, 2016

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a4b3300 View commit details
  2. [Truffle] We need to pass the updated receiver and arguments when rew…

    …riting to a RubyCallNode.
    
    * Otherwise the call node will get outdated receiver and arguments
      which might cause a rewrite loop as all rewrites happening before
      the call node rewrite will be lost.
    eregon committed Nov 23, 2016
    Copy the full SHA
    9d2cb83 View commit details
  3. [Truffle] Check if we already rewrote to a call node.

    * Avoid creating extra nodes and limits to a single rewrite.
    eregon committed Nov 23, 2016
    Copy the full SHA
    f63d3b1 View commit details
  4. Copy the full SHA
    f2c4cb4 View commit details
  5. [Truffle] No special case for LLVM errors.

    * The message will be shown anyway and it's more consistent.
    eregon committed Nov 23, 2016
    Copy the full SHA
    bb5186f View commit details
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.NodeUtil;

import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.CoreMethodNodeManager;
import org.jruby.truffle.core.array.ArrayUtils;
@@ -38,6 +40,8 @@ public class InlinedCoreMethodNode extends RubyNode {
@Child RubyNode receiverNode;
@Children final RubyNode[] argumentNodes;

private RubyCallNode replacedBy = null;

public InlinedCoreMethodNode(RubyCallNodeParameters callNodeParameters, InternalMethod method, InlinableBuiltin builtin) {
super(callNodeParameters.getContext(), callNodeParameters.getSection());
this.callNodeParameters = callNodeParameters;
@@ -83,13 +87,24 @@ private Object[] executeArguments(VirtualFrame frame, Object self) {

private RubyCallNode rewriteToCallNode() {
CompilerDirectives.transferToInterpreterAndInvalidate();
RubyCallNode callNode = new RubyCallNode(callNodeParameters);
return replace(callNode, method.getName() + " was redefined");
return atomic(() -> {
// Check if we are still in the AST
boolean found = !NodeUtil.forEachChild(getParent(), node -> node != this);

if (found) {
// We need to pass the updated children of this node to the call node
RubyCallNode callNode = new RubyCallNode(callNodeParameters.withReceiverAndArguments(receiverNode, argumentNodes, callNodeParameters.getBlock()));
replacedBy = callNode;
return replace(callNode, method.getName() + " could not be executed inline");
} else {
return replacedBy;
}
});
}

public static InlinedCoreMethodNode inlineBuiltin(RubyCallNodeParameters callParameters, InternalMethod method, NodeFactory<? extends InlinableBuiltin> builtinFactory) {
final RubyContext context = callParameters.getContext();
// Let arguments to null as we need to execute self once to lookup resolves the same method
// Let arguments to null as we need to execute the receiver ourselves to lookup the method
final List<RubyNode> arguments = Arrays.asList(new RubyNode[1 + callParameters.getArguments().length]);
final InlinableBuiltin builtinNode = CoreMethodNodeManager.createNodeFromFactory(context, callParameters.getSection(), builtinFactory, arguments);

Original file line number Diff line number Diff line change
@@ -50,6 +50,10 @@ public RubyCallNodeParameters(RubyContext context, SourceSection section,
this.isAttrAssign = isAttrAssign;
}

public RubyCallNodeParameters withReceiverAndArguments(RubyNode receiver, RubyNode[] arguments, RubyNode block) {
return new RubyCallNodeParameters(context, section, receiver, methodName, block, arguments, isSplatted, ignoreVisibility, isVCall, isSafeNavigation, isAttrAssign);
}

public RubyContext getContext() {
return context;
}
Original file line number Diff line number Diff line change
@@ -191,26 +191,20 @@ public DynamicObject translate(Throwable throwable) {
while (t != null) {
final String message = t.getMessage();

if (message != null && message.startsWith("LLVM error")) {
messageBuilder.append(t.getClass().getSimpleName());
messageBuilder.append(" ");
if (message != null) {
messageBuilder.append(message);
} else {
messageBuilder.append(t.getClass().getSimpleName());
messageBuilder.append(" ");

if (message != null) {
messageBuilder.append(message);
} else {
messageBuilder.append("<no message>");
}
messageBuilder.append("<no message>");
}

if (t.getStackTrace().length > 0) {
messageBuilder.append(" ");
messageBuilder.append(t.getStackTrace()[0].toString());
}
if (t.getStackTrace().length > 0) {
messageBuilder.append(" ");
messageBuilder.append(t.getStackTrace()[0].toString());
}

t = t.getCause();

if (t != null) {
messageBuilder.append("\nCaused by: ");
}