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

Commits on Jul 26, 2015

  1. [Truffle] Fix the clearing of $! to affect the current thread.

    * And not the one who created the AST.
    eregon committed Jul 26, 2015
    Copy the full SHA
    fa16fc1 View commit details
  2. Copy the full SHA
    d94e2f0 View commit details
4 changes: 0 additions & 4 deletions test/mri/excludes_truffle/TestTimeout.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
exclude :test_cannot_convert_into_time_interval, "needs investigation"
exclude :test_custom_exception, "needs investigation"
exclude :test_enumerator_next, "needs investigation"
exclude :test_exit_exception, "needs investigation"
exclude :test_queue, "needs investigation"
exclude :test_rescue_exit, "needs investigation"
exclude :test_skip_rescue, "needs investigation"
exclude :test_timeout, "needs investigation"
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2015 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.nodes.exceptions;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.ThreadLocalObjectNode;
import org.jruby.truffle.nodes.literal.LiteralNode;
import org.jruby.truffle.nodes.objects.WriteInstanceVariableNode;
import org.jruby.truffle.runtime.RubyContext;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

/** Clear the thread-local $! */
public class ClearExceptionVariableNode extends RubyNode {

@Child private WriteInstanceVariableNode writeNode;

public ClearExceptionVariableNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
writeNode = new WriteInstanceVariableNode(context, sourceSection, "$!",
new ThreadLocalObjectNode(context, sourceSection),
new LiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
true);
}

@Override
public Object execute(VirtualFrame frame) {
return writeNode.execute(frame);
}

}
Original file line number Diff line number Diff line change
@@ -9,22 +9,20 @@
*/
package org.jruby.truffle.nodes.exceptions;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ControlFlowException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.ThreadNodes;
import org.jruby.truffle.nodes.defined.DefinedWrapperNode;
import org.jruby.truffle.nodes.literal.LiteralNode;
import org.jruby.truffle.nodes.methods.ExceptionTranslatingNode;
import org.jruby.truffle.nodes.objects.WriteInstanceVariableNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.control.RetryException;
import org.jruby.truffle.runtime.core.RubyBasicObject;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ControlFlowException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;

/**
* Represents a block of code run with exception handlers. There's no {@code try} keyword in Ruby -
* it's implicit - but it's similar to a try statement in any other language.
@@ -34,7 +32,7 @@ public class TryNode extends RubyNode {
@Child private ExceptionTranslatingNode tryPart;
@Children final RescueNode[] rescueParts;
@Child private RubyNode elsePart;
@Child private WriteInstanceVariableNode clearExceptionVariableNode;
@Child private ClearExceptionVariableNode clearExceptionVariableNode;

private final BranchProfile elseProfile = BranchProfile.create();
private final BranchProfile controlFlowProfile = BranchProfile.create();
@@ -45,12 +43,7 @@ public TryNode(RubyContext context, SourceSection sourceSection, ExceptionTransl
this.tryPart = tryPart;
this.rescueParts = rescueParts;
this.elsePart = elsePart;
clearExceptionVariableNode = new WriteInstanceVariableNode(context, sourceSection, "$!",
new LiteralNode(context, sourceSection, ThreadNodes.getThreadLocals(context.getThreadManager().getCurrentThread())),
new DefinedWrapperNode(context, sourceSection,
new LiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil"),
true);
clearExceptionVariableNode = new ClearExceptionVariableNode(context, sourceSection);
}

@Override
Original file line number Diff line number Diff line change
@@ -37,46 +37,51 @@
*/
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import static jnr.constants.platform.Errno.ECHILD;
import static jnr.constants.platform.Errno.EINTR;
import static jnr.constants.platform.WaitFlags.WNOHANG;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.List;

import jnr.constants.platform.Sysconf;
import jnr.posix.Passwd;
import jnr.posix.Times;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.core.BasicObjectNodes;
import org.jruby.truffle.nodes.core.BasicObjectNodes.ReferenceEqualNode;
import org.jruby.truffle.nodes.core.BasicObjectNodesFactory;
import org.jruby.truffle.nodes.core.BasicObjectNodesFactory.ReferenceEqualNodeFactory;
import org.jruby.truffle.nodes.core.BignumNodes;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.nodes.core.ModuleNodes;
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.defined.DefinedWrapperNode;
import org.jruby.truffle.nodes.literal.LiteralNode;
import org.jruby.truffle.nodes.exceptions.ClearExceptionVariableNode;
import org.jruby.truffle.nodes.objects.ClassNode;
import org.jruby.truffle.nodes.objects.ClassNodeGen;
import org.jruby.truffle.nodes.objects.WriteInstanceVariableNode;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.control.ThrowException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.signal.ProcSignalHandler;
import org.jruby.truffle.runtime.signal.SignalOperations;
import org.jruby.truffle.runtime.subsystems.ThreadManager;
import org.jruby.util.io.PosixShim;
import sun.misc.Signal;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.List;
import sun.misc.Signal;

import static jnr.constants.platform.Errno.ECHILD;
import static jnr.constants.platform.Errno.EINTR;
import static jnr.constants.platform.WaitFlags.WNOHANG;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

/**
* Rubinius primitives associated with the VM.
@@ -88,7 +93,7 @@ public abstract static class CatchNode extends RubiniusPrimitiveNode {

@Child private YieldDispatchHeadNode dispatchNode;
@Child private BasicObjectNodes.ReferenceEqualNode referenceEqualNode;
@Child private WriteInstanceVariableNode clearExceptionVariableNode;
@Child private ClearExceptionVariableNode clearExceptionVariableNode;

public CatchNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -113,18 +118,8 @@ public Object doCatch(VirtualFrame frame, Object tag, RubyBasicObject block) {
if (areSame(frame, e.getTag(), tag)) {
if (clearExceptionVariableNode == null) {
CompilerDirectives.transferToInterpreter();
RubyContext context = getContext();
SourceSection sourceSection = getSourceSection();
clearExceptionVariableNode = insert(
new WriteInstanceVariableNode(getContext(), getSourceSection(), "$!",
new LiteralNode(getContext(), getSourceSection(), ThreadNodes.getThreadLocals(getContext().getThreadManager().getCurrentThread())),
new DefinedWrapperNode(context, sourceSection,
new LiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil"),
true)
);
clearExceptionVariableNode = new ClearExceptionVariableNode(getContext(), getSourceSection());
}

clearExceptionVariableNode.execute(frame);
return e.getValue();
} else {