Skip to content

Commit

Permalink
[Misc] Fix bugs in previous commit.
Browse files Browse the repository at this point in the history
Summary:
- Initialize CleanerFactory.cleaner() before wisp.
- Refine jdk_reflect template.
- Add more comments for start thread as wisp deadlock.

Test Plan: run all jtreg tests

Reviewed-by: yulei

Issue:
#95
  • Loading branch information
nebula-xm authored and yuleil committed Jul 20, 2023
1 parent dc093fc commit 7a98290
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/classfile/vmSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
template(reflect_CallerSensitive, "jdk/internal/reflect/CallerSensitive") \
template(reflect_CallerSensitive_signature, "Ljdk/internal/reflect/CallerSensitive;") \
template(reflect_NativeConstructorAccessorImpl, "jdk/internal/reflect/NativeConstructorAccessorImpl")\
template(reflect_NativeMethodAccessorImpl, "jdk/internal/reflect/NativeMethodAccessorImpl")\
template(checkedExceptions_name, "checkedExceptions") \
template(clazz_name, "clazz") \
template(exceptionTypes_name, "exceptionTypes") \
Expand Down Expand Up @@ -726,10 +727,8 @@
template(doPrivileged_signature_2, "(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;") \
template(doPrivileged_signature_3, "(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;") \
template(doPrivileged_signature_4, "(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;") \
template(jdk_internal_reflect_NativeMethodAccessorImpl, "jdk/internal/reflect/NativeMethodAccessorImpl") \
template(invoke0_name, "invoke0") \
template(invoke0_signature, "(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;") \
template(jdk_internal_reflect_NativeConstructorAccessorImpl, "jdk/internal/reflect/NativeConstructorAccessorImpl") \
template(newInstance0_signature, "(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;") \
\
/* forEachRemaining support */ \
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/coroutine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ struct WispStealCandidate {
WispStealCandidate (Symbol *holder, Symbol *name, Symbol *signature) : _holder(holder), _name(name), _signature(signature) {}
private:
bool is_method_invoke() {
return _holder == vmSymbols::jdk_internal_reflect_NativeMethodAccessorImpl() && // jdk.internal.reflect.NativeMethodAccessorImpl.invoke0()
return _holder == vmSymbols::reflect_NativeMethodAccessorImpl() && // jdk.internal.reflect.NativeMethodAccessorImpl.invoke0()
_name == vmSymbols::invoke0_name() &&
_signature == vmSymbols::invoke0_signature();
}
bool is_constructor_newinstance() {
return _holder == vmSymbols::jdk_internal_reflect_NativeConstructorAccessorImpl() && // jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0()
return _holder == vmSymbols::reflect_NativeConstructorAccessorImpl() && // jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0()
_name == vmSymbols::newInstance0_name() &&
_signature == vmSymbols::newInstance0_signature();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jdk.internal.access.SharedSecrets;
import jdk.internal.access.WispEngineAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.ref.CleanerFactory;

import java.dyn.CoroutineExitException;
import java.dyn.CoroutineSupport;
Expand Down Expand Up @@ -335,6 +336,19 @@ private static void initializeClasses() {
Class.forName(WispEventPump.class.getName());
}
WispEngine.current().preloadClasses();
// It will load configuration files and trigger
// CleanerFactory.cleaner() when run thread as wisp firstly. But
// CleanerFactory.clean() would start another cleaner
// thread as wisp which loads configuration files again. But
// this time it sees that configuration is loading and try to
// wait it finished. So it leads to a deadlock because it waits
// for itself. So loading configurations should not be reentrant
// twice by the same thread.
// We move cleaner initialization before wisp initialization
// to avoid deadlock.
if (CleanerFactory.cleaner() == null) {
throw new InternalError("Cleaner is not available");
}
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
Expand Down

0 comments on commit 7a98290

Please sign in to comment.