Skip to content

Commit

Permalink
(re)move Thread susbtitution for better jdk 21 compatibility
Browse files Browse the repository at this point in the history
yield now has special behaviour with VirtualThreads
getState substitution doesn't seem needed since it does the same as the
bytecodes and can now be overriden
  • Loading branch information
gilles-duboscq committed Sep 5, 2023
1 parent 71db8e5 commit 1b378d9
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,17 @@ private static boolean isSystemInnocuousThread(StaticObject thread, Meta meta) {
}

@TruffleBoundary
@Substitution(isTrivial = true)
@Substitution(isTrivial = true, versionFilter = VersionFilter.Java18OrEarlier.class)
public static void yield() {
Thread.yield();
}

@TruffleBoundary
@Substitution(isTrivial = true)
public static void yield0() {
Thread.yield();
}

@SuppressWarnings("unused")
@Substitution(hasReceiver = true)
@TruffleBoundary // Host Thread.setPriority inlines too deeply.
Expand All @@ -204,19 +210,6 @@ public static boolean isAlive(@JavaType(Thread.class) StaticObject self,
return context.getThreadAccess().isAlive(self);
}

@Substitution(hasReceiver = true)
abstract static class GetState extends SubstitutionNode {
abstract @JavaType(internalName = "Ljava/lang/Thread$State;") StaticObject execute(@JavaType(Thread.class) StaticObject self);

@Specialization
@JavaType(internalName = "Ljava/lang/Thread$State;")
StaticObject doDefault(@JavaType(Thread.class) StaticObject self,
@Bind("getContext()") EspressoContext context,
@Cached("create(context.getMeta().sun_misc_VM_toThreadState.getCallTarget())") DirectCallNode toThreadState) {
return (StaticObject) toThreadState.call(context.getThreadAccess().getState(self));
}
}

@SuppressWarnings("unused")
@Substitution
public static void registerNatives() {
Expand Down

0 comments on commit 1b378d9

Please sign in to comment.