8135068: Extract method matchers from CompilerOracle

Ecapsulate code to enable reuse

Reviewed-by: roland, kvn
This commit is contained in:
Nils Eliasson 2015-09-18 10:11:11 +02:00
parent ff77d8762c
commit 5ca8983920
17 changed files with 1072 additions and 523 deletions

View file

@ -29,6 +29,7 @@
#include "classfile/classLoaderData.hpp"
#include "classfile/stringTable.hpp"
#include "code/codeCache.hpp"
#include "compiler/methodMatcher.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceShared.hpp"
@ -625,6 +626,32 @@ WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobjec
return (mh->queued_for_compilation() || nm != NULL);
WB_END
WB_ENTRY(jint, WB_MatchesMethod(JNIEnv* env, jobject o, jobject method, jstring pattern))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
ResourceMark rm;
char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern));
const char* error_msg = NULL;
BasicMatcher* m = BasicMatcher::parse_method_pattern(method_str, error_msg);
if (m == NULL) {
assert(error_msg != NULL, "Must have error_msg");
tty->print_cr("Got error: %s", error_msg);
return -1;
}
// Pattern works - now check if it matches
int result = m->matches(mh);
delete m;
assert(result == 0 || result == 1, "Result out of range");
return result;
WB_END
class AlwaysFalseClosure : public BoolObjectClosure {
public:
bool do_object_b(oop p) { return false; }
@ -1430,6 +1457,9 @@ static JNINativeMethod methods[] = {
CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState},
{CC"lockCompilation", CC"()V", (void*)&WB_LockCompilation},
{CC"unlockCompilation", CC"()V", (void*)&WB_UnlockCompilation},
{CC"matchesMethod",
CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)I",
(void*)&WB_MatchesMethod},
{CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
{CC"isLockedVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag},
{CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},