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

Commits on Jul 24, 2015

  1. [Truffle] All fields of Fiber should be final or volatile.

    * Since they are accessed by multiple threads.
    eregon committed Jul 24, 2015
    3
    Copy the full SHA
    3202478 View commit details
  2. Copy the full SHA
    8de626b View commit details
  3. [Truffle] Make sure to mark Fiber dead before letting another Fiber run.

    * (by sending a message which will wake it up)
    eregon committed Jul 24, 2015
    Copy the full SHA
    b7589b5 View commit details
Showing with 14 additions and 8 deletions.
  1. +8 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/FiberNodes.java
  2. +6 −4 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyFiber.java
Original file line number Diff line number Diff line change
@@ -67,7 +67,13 @@ private static void handleFiberExceptions(final RubyBasicObject fiber, final Rub
public void run() {
try {
final Object[] args = waitForResume(fiber);
final Object result = ProcNodes.rootCall(block, args);
final Object result;
try {
result = ProcNodes.rootCall(block, args);
} finally {
// Make sure that other fibers notice we are dead before they gain control back
getFields(fiber).alive = false;
}
resume(fiber, getFields(fiber).lastResumedByFiber, true, result);
} catch (FiberExitException e) {
assert !getFields(fiber).isRootFiber;
@@ -176,10 +182,8 @@ public static void shutdown(RubyBasicObject fiber) {
}

public static boolean isAlive(RubyBasicObject fiber) {
// TODO CS 2-Feb-15 race conditions (but everything in JRuby+Truffle is currently a race condition)
// TODO CS 2-Feb-15 should just be alive?
assert RubyGuards.isRubyFiber(fiber);
return getFields(fiber).alive || !getFields(fiber).messageQueue.isEmpty();
return getFields(fiber).alive;
}

public static RubyBasicObject createRubyFiber(RubyBasicObject parent, RubyBasicObject rubyClass, String name) {
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
import org.jruby.truffle.runtime.subsystems.FiberManager;
import org.jruby.truffle.runtime.subsystems.ThreadManager;

import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

@@ -28,12 +30,12 @@ public class RubyFiber extends RubyBasicObject {

public static class FiberFields {
public final RubyBasicObject rubyThread;
public String name;
@CompilationFinal public String name;
public final boolean isRootFiber;
// we need 2 slots when the safepoint manager sends the kill message and there is another message unprocessed
// we need 2 slots when the FiberManager sends the kill message and there is another message unprocessed
public final BlockingQueue<FiberNodes.FiberMessage> messageQueue = new LinkedBlockingQueue<>(2);
public RubyBasicObject lastResumedByFiber = null;
public boolean alive = true;
public volatile RubyBasicObject lastResumedByFiber = null;
public volatile boolean alive = true;
public volatile Thread thread;

public FiberFields(RubyBasicObject rubyThread, boolean isRootFiber) {