hotspot/src/share/vm/prims/whitebox.cpp
changeset 36616 5172e3dd60f2
parent 36508 5f9eee6b383b
parent 36597 ee256e343585
child 37289 9989add27bf4
child 37179 4dbcb3a642d2
equal deleted inserted replaced
36615:c744e3b0f8c5 36616:5172e3dd60f2
    29 #include "classfile/classLoaderData.hpp"
    29 #include "classfile/classLoaderData.hpp"
    30 #include "classfile/modules.hpp"
    30 #include "classfile/modules.hpp"
    31 #include "classfile/stringTable.hpp"
    31 #include "classfile/stringTable.hpp"
    32 #include "code/codeCache.hpp"
    32 #include "code/codeCache.hpp"
    33 #include "compiler/methodMatcher.hpp"
    33 #include "compiler/methodMatcher.hpp"
       
    34 #include "compiler/directivesParser.hpp"
    34 #include "jvmtifiles/jvmtiEnv.hpp"
    35 #include "jvmtifiles/jvmtiEnv.hpp"
    35 #include "memory/metadataFactory.hpp"
    36 #include "memory/metadataFactory.hpp"
    36 #include "memory/metaspaceShared.hpp"
    37 #include "memory/metaspaceShared.hpp"
    37 #include "memory/universe.hpp"
    38 #include "memory/universe.hpp"
    38 #include "oops/constantPool.hpp"
    39 #include "oops/constantPool.hpp"
   635   mh->set_force_inline(value == JNI_TRUE);
   636   mh->set_force_inline(value == JNI_TRUE);
   636   return result;
   637   return result;
   637 WB_END
   638 WB_END
   638 
   639 
   639 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
   640 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
       
   641   // Screen for unavailable/bad comp level
       
   642   if (CompileBroker::compiler(comp_level) == NULL) {
       
   643     return false;
       
   644   }
   640   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   645   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
   641   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
   646   CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
   642   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   647   methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
   643   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
   648   nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
   644   MutexLockerEx mu(Compile_lock);
   649   MutexLockerEx mu(Compile_lock);
  1536         break;
  1541         break;
  1537       }
  1542       }
  1538     }
  1543     }
  1539   }
  1544   }
  1540 }
  1545 }
       
  1546 
       
  1547 WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirect))
       
  1548   // can't be in VM when we call JNI
       
  1549   ThreadToNativeFromVM ttnfv(thread);
       
  1550   const char* dir = env->GetStringUTFChars(compDirect, NULL);
       
  1551   int ret;
       
  1552   {
       
  1553     ThreadInVMfromNative ttvfn(thread); // back to VM
       
  1554     ret = DirectivesParser::parse_string(dir, tty);
       
  1555   }
       
  1556   env->ReleaseStringUTFChars(compDirect, dir);
       
  1557   // -1 for error parsing directive. Return 0 as number of directives added.
       
  1558   if (ret == -1) {
       
  1559     ret = 0;
       
  1560   }
       
  1561   return (jint) ret;
       
  1562 WB_END
       
  1563 
       
  1564 WB_ENTRY(void, WB_RemoveCompilerDirective(JNIEnv* env, jobject o, jint count))
       
  1565   DirectivesStack::pop(count);
       
  1566 WB_END
  1541 
  1567 
  1542 #define CC (char*)
  1568 #define CC (char*)
  1543 
  1569 
  1544 static JNINativeMethod methods[] = {
  1570 static JNINativeMethod methods[] = {
  1545   {CC"getObjectAddress0",                CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress  },
  1571   {CC"getObjectAddress0",                CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress  },
  1730                                                       (void*)&WB_GetMethodStringOption},
  1756                                                       (void*)&WB_GetMethodStringOption},
  1731   {CC"isShared",           CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
  1757   {CC"isShared",           CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
  1732   {CC"isSharedClass",      CC"(Ljava/lang/Class;)Z",  (void*)&WB_IsSharedClass },
  1758   {CC"isSharedClass",      CC"(Ljava/lang/Class;)Z",  (void*)&WB_IsSharedClass },
  1733   {CC"areSharedStringsIgnored",           CC"()Z",    (void*)&WB_AreSharedStringsIgnored },
  1759   {CC"areSharedStringsIgnored",           CC"()Z",    (void*)&WB_AreSharedStringsIgnored },
  1734   {CC"clearInlineCaches",  CC"()V",                   (void*)&WB_ClearInlineCaches },
  1760   {CC"clearInlineCaches",  CC"()V",                   (void*)&WB_ClearInlineCaches },
       
  1761   {CC"addCompilerDirective",    CC"(Ljava/lang/String;)I",
       
  1762                                                       (void*)&WB_AddCompilerDirective },
       
  1763   {CC"removeCompilerDirective", CC"(I)V",             (void*)&WB_RemoveCompilerDirective },
  1735 };
  1764 };
  1736 
  1765 
  1737 #undef CC
  1766 #undef CC
  1738 
  1767 
  1739 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
  1768 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))