mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 18:44:38 +02:00
8150646: Add support for blocking compiles though whitebox API
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com> Reviewed-by: kvn, ppunegov, simonis, neliasso
This commit is contained in:
parent
59193ab336
commit
173a62a8d6
10 changed files with 238 additions and 70 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "classfile/stringTable.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "compiler/methodMatcher.hpp"
|
||||
#include "compiler/directivesParser.hpp"
|
||||
#include "jvmtifiles/jvmtiEnv.hpp"
|
||||
#include "memory/metadataFactory.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
|
@ -636,6 +637,10 @@ WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject m
|
|||
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) {
|
||||
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));
|
||||
|
@ -1502,6 +1507,27 @@ void WhiteBox::register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread,
|
|||
}
|
||||
}
|
||||
|
||||
WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirect))
|
||||
// can't be in VM when we call JNI
|
||||
ThreadToNativeFromVM ttnfv(thread);
|
||||
const char* dir = env->GetStringUTFChars(compDirect, NULL);
|
||||
int ret;
|
||||
{
|
||||
ThreadInVMfromNative ttvfn(thread); // back to VM
|
||||
ret = DirectivesParser::parse_string(dir, tty);
|
||||
}
|
||||
env->ReleaseStringUTFChars(compDirect, dir);
|
||||
// -1 for error parsing directive. Return 0 as number of directives added.
|
||||
if (ret == -1) {
|
||||
ret = 0;
|
||||
}
|
||||
return (jint) ret;
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(void, WB_RemoveCompilerDirective(JNIEnv* env, jobject o, jint count))
|
||||
DirectivesStack::pop(count);
|
||||
WB_END
|
||||
|
||||
#define CC (char*)
|
||||
|
||||
static JNINativeMethod methods[] = {
|
||||
|
@ -1677,6 +1703,9 @@ static JNINativeMethod methods[] = {
|
|||
{CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
|
||||
{CC"areSharedStringsIgnored", CC"()Z", (void*)&WB_AreSharedStringsIgnored },
|
||||
{CC"clearInlineCaches", CC"()V", (void*)&WB_ClearInlineCaches },
|
||||
{CC"addCompilerDirective", CC"(Ljava/lang/String;)I",
|
||||
(void*)&WB_AddCompilerDirective },
|
||||
{CC"removeCompilerDirective", CC"(I)V", (void*)&WB_RemoveCompilerDirective },
|
||||
};
|
||||
|
||||
#undef CC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue