Skip to content

Commit 45a62d2

Browse files
committed
The Fiber thread field does not need to be volatile
* It is always read from the Fiber's thread, except in Thread#wakeup which is inherently racy. * Around 2 billion iterations/s now for benchmark { begin; raise "foo"; rescue; end }.
1 parent eee4974 commit 45a62d2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/org/truffleruby/core/fiber/FiberLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DynamicObject createFiber(DynamicObjectFactory factory,
3434
DynamicObject rubyThread,
3535
@Volatile @Nullable DynamicObject lastResumedByFiber,
3636
@Volatile boolean alive,
37-
@Volatile @Nullable Thread thread,
37+
@Nullable Thread thread,
3838
@Volatile boolean transferred);
3939

4040
boolean isFiber(DynamicObject object);

src/main/java/org/truffleruby/core/thread/ThreadNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public DynamicObject wakeup(DynamicObject rubyThread,
430430
@Cached("new()") YieldNode yieldNode) {
431431
final DynamicObject currentFiber = Layouts.THREAD.getFiberManager(rubyThread).getCurrentFiberRacy();
432432
final Thread thread = Layouts.FIBER.getThread(currentFiber);
433-
if (thread == null) {
433+
if (!Layouts.FIBER.getAlive(currentFiber) || thread == null) {
434434
throw new RaiseException(getContext(), coreExceptions().threadErrorKilledThread(this));
435435
}
436436

0 commit comments

Comments
 (0)