mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8153514: Whitebox API should allow compilation of <clinit>
Added Whitebox API method to trigger compilation of static initializer. Reviewed-by: zmajo, kvn, iignatyev
This commit is contained in:
parent
7502a7a7f2
commit
a6c687cd6a
2 changed files with 18 additions and 6 deletions
|
@ -637,17 +637,26 @@ WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject m
|
|||
return result;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
|
||||
// Screen for unavailable/bad comp level
|
||||
if (CompileBroker::compiler(comp_level) == NULL) {
|
||||
bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) {
|
||||
// Screen for unavailable/bad comp level or null method
|
||||
if (method == NULL || CompileBroker::compiler(comp_level) == NULL) {
|
||||
return false;
|
||||
}
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
methodHandle mh(THREAD, method);
|
||||
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
return (mh->queued_for_compilation() || nm != NULL);
|
||||
}
|
||||
|
||||
WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
return WhiteBox::compile_method(Method::checked_resolve_jmethod_id(jmid), comp_level, bci, THREAD);
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_EnqueueInitializerForCompilation(JNIEnv* env, jobject o, jclass klass, jint comp_level))
|
||||
instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
|
||||
return WhiteBox::compile_method(ikh->class_initializer(), comp_level, InvocationEntryBci, THREAD);
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method, jint comp_level))
|
||||
|
@ -1643,6 +1652,8 @@ static JNINativeMethod methods[] = {
|
|||
CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod},
|
||||
{CC"enqueueMethodForCompilation0",
|
||||
CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation},
|
||||
{CC"enqueueInitializerForCompilation0",
|
||||
CC"(Ljava/lang/Class;I)Z", (void*)&WB_EnqueueInitializerForCompilation},
|
||||
{CC"clearMethodState0",
|
||||
CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState},
|
||||
{CC"lockCompilation", CC"()V", (void*)&WB_LockCompilation},
|
||||
|
|
|
@ -77,6 +77,7 @@ class WhiteBox : public AllStatic {
|
|||
static void register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread,
|
||||
JNINativeMethod* method_array, int method_count);
|
||||
static void register_extended(JNIEnv* env, jclass wbclass, JavaThread* thread);
|
||||
static bool compile_method(Method* method, int comp_level, int bci, Thread* THREAD);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue