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

Commits on Aug 18, 2015

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    e1780ae View commit details
  2. [Truffle] Implement OM DSL support for volatile int and use that to r…

    …emove the last thread field.
    chrisseaton committed Aug 18, 2015
    Copy the full SHA
    6aabccc View commit details
  3. Copy the full SHA
    60ca99d View commit details
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
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.nodes.core.ThreadNodes;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

public class ThreadLocalObjectNode extends RubyNode {

@@ -23,7 +23,7 @@ public ThreadLocalObjectNode(RubyContext context, SourceSection sourceSection) {

@Override
public DynamicObject executeDynamicObject(VirtualFrame frame) {
return ThreadNodes.getThreadLocals(getContext().getThreadManager().getCurrentThread());
return Layouts.THREAD.getThreadLocals(getContext().getThreadManager().getCurrentThread());
}

@Override
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ public static void start(DynamicObject fiber) {
assert RubyGuards.isRubyFiber(fiber);
Layouts.FIBER.getFields(fiber).thread = Thread.currentThread();
Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(fiber)).getContext().getThreadManager().initializeCurrentThread(Layouts.FIBER.getFields(fiber).rubyThread);
ThreadNodes.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).registerFiber(fiber);
Layouts.THREAD.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).registerFiber(fiber);
Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(fiber)).getContext().getSafepointManager().enterThread();
}

@@ -108,7 +108,7 @@ public static void cleanup(DynamicObject fiber) {
assert RubyGuards.isRubyFiber(fiber);
Layouts.FIBER.getFields(fiber).alive = false;
Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(fiber)).getContext().getSafepointManager().leaveThread();
ThreadNodes.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).unregisterFiber(fiber);
Layouts.THREAD.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).unregisterFiber(fiber);
Layouts.FIBER.getFields(fiber).thread = null;
}

@@ -132,7 +132,7 @@ public FiberMessage block() throws InterruptedException {
}
});

ThreadNodes.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).setCurrentFiber(fiber);
Layouts.THREAD.getFiberManager(Layouts.FIBER.getFields(fiber).rubyThread).setCurrentFiber(fiber);

if (message instanceof FiberExitMessage) {
throw new FiberExitException();
@@ -229,7 +229,7 @@ protected Object transfer(VirtualFrame frame, DynamicObject fiber, boolean isYie
throw new RaiseException(getContext().getCoreLibrary().fiberError("fiber called across threads", this));
}

final DynamicObject sendingFiber = ThreadNodes.getFiberManager(currentThread).getCurrentFiber();
final DynamicObject sendingFiber = Layouts.THREAD.getFiberManager(currentThread).getCurrentFiber();

return singleValue(frame, transferControlTo(sendingFiber, fiber, isYield, args));
}
@@ -283,7 +283,7 @@ public YieldNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public Object yield(VirtualFrame frame, Object[] args) {
final DynamicObject currentThread = getContext().getThreadManager().getCurrentThread();
final DynamicObject yieldingFiber = ThreadNodes.getFiberManager(currentThread).getCurrentFiber();
final DynamicObject yieldingFiber = Layouts.THREAD.getFiberManager(currentThread).getCurrentFiber();
final DynamicObject fiberYieldedTo = Layouts.FIBER.getFields(yieldingFiber).lastResumedByFiber;

if (Layouts.FIBER.getFields(yieldingFiber).isRootFiber || fiberYieldedTo == null) {
Original file line number Diff line number Diff line change
@@ -1847,7 +1847,7 @@ private long doSleepMillis(final long durationInMillis) {

// Clear the wakeUp flag, following Ruby semantics:
// it should only be considered if we are inside the sleep when Thread#{run,wakeup} is called.
ThreadNodes.shouldWakeUp(thread);
Layouts.THREAD.getWakeUp(thread).getAndSet(false);

return sleepFor(getContext(), durationInMillis);
}
@@ -1865,7 +1865,7 @@ public Long block() throws InterruptedException {
long now = System.currentTimeMillis();
long slept = now - start;

if (slept >= durationInMillis || ThreadNodes.shouldWakeUp(thread)) {
if (slept >= durationInMillis || Layouts.THREAD.getWakeUp(thread).getAndSet(false)) {
return slept;
}
Thread.sleep(durationInMillis - slept);
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ protected static void lock(final ReentrantLock lock, final DynamicObject thread,
@Override
public Boolean block() throws InterruptedException {
lock.lockInterruptibly();
ThreadNodes.acquiredLock(thread, lock);
Layouts.THREAD.getOwnedLocks(thread).add(lock);
return SUCCESS;
}
});
@@ -124,7 +124,7 @@ public boolean tryLock(DynamicObject mutex) {

if (lock.tryLock()) {
final DynamicObject thread = getContext().getThreadManager().getCurrentThread();
ThreadNodes.acquiredLock(thread, lock);
Layouts.THREAD.getOwnedLocks(thread).add(lock);
return true;
} else {
return false;
@@ -165,7 +165,7 @@ protected static void unlock(ReentrantLock lock, DynamicObject thread, RubyNode
}
}

ThreadNodes.releasedLock(thread, lock);
Layouts.THREAD.getOwnedLocks(thread).remove(lock);
}

}
@@ -210,7 +210,7 @@ public long doSleepMillis(DynamicObject mutex, long durationInMillis) {
// Here we do it before unlocking for providing nice semantics for
// thread1: mutex.sleep
// thread2: mutex.synchronize { <ensured that thread1 is sleeping and thread1.wakeup will wake it up> }
ThreadNodes.shouldWakeUp(thread);
Layouts.THREAD.getWakeUp(thread).getAndSet(false);

UnlockNode.unlock(lock, thread, this);
try {
Original file line number Diff line number Diff line change
@@ -208,7 +208,7 @@ public static Object matchCommon(DynamicObject regexp, DynamicObject source, boo
public static void setThread(DynamicObject regexp, String name, Object value) {
assert RubyGuards.isRubyRegexp(regexp);
assert value != null;
ThreadNodes.getThreadLocals(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(regexp)).getContext().getThreadManager().getCurrentThread()).define(name, value, 0);
Layouts.THREAD.getThreadLocals(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(regexp)).getContext().getThreadManager().getCurrentThread()).define(name, value, 0);
}

@TruffleBoundary
Loading