< prev index next >

src/share/vm/prims/whitebox.cpp

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include <new>
  28 
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/stringTable.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "compiler/methodMatcher.hpp"
  33 #include "jvmtifiles/jvmtiEnv.hpp"
  34 #include "memory/metadataFactory.hpp"
  35 #include "memory/metaspaceShared.hpp"
  36 #include "memory/universe.hpp"

  37 #include "oops/oop.inline.hpp"
  38 #include "prims/wbtestmethods/parserTests.hpp"
  39 #include "prims/whitebox.hpp"
  40 #include "runtime/arguments.hpp"
  41 #include "runtime/compilationPolicy.hpp"
  42 #include "runtime/deoptimization.hpp"
  43 #include "runtime/interfaceSupport.hpp"
  44 #include "runtime/javaCalls.hpp"
  45 #include "runtime/os.hpp"
  46 #include "runtime/sweeper.hpp"
  47 #include "runtime/thread.hpp"
  48 #include "runtime/vm_version.hpp"
  49 #include "utilities/array.hpp"
  50 #include "utilities/debug.hpp"
  51 #include "utilities/exceptions.hpp"
  52 #include "utilities/macros.hpp"
  53 #if INCLUDE_ALL_GCS
  54 #include "gc/g1/concurrentMarkThread.hpp"
  55 #include "gc/g1/g1CollectedHeap.inline.hpp"
  56 #include "gc/g1/g1ConcurrentMark.hpp"


1288 
1289 WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz))
1290   return (jboolean)MetaspaceShared::is_in_shared_space(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
1291 WB_END
1292 
1293 WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
1294   oop obj_oop = JNIHandles::resolve(obj);
1295   return (jboolean) obj_oop->mark()->has_monitor();
1296 WB_END
1297 
1298 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb))
1299   VM_ForceSafepoint force_safepoint_op;
1300   VMThread::execute(&force_safepoint_op);
1301 WB_END
1302 
1303 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1304   instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1305   return (jlong) ikh->constants();
1306 WB_END
1307 
































1308 WB_ENTRY(void, WB_ClearInlineCaches(JNIEnv* env, jobject wb))
1309   VM_ClearICs clear_ics;
1310   VMThread::execute(&clear_ics);
1311 WB_END
1312 
1313 template <typename T>
1314 static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jstring name, T* value) {
1315   assert(value != NULL, "sanity");
1316   if (method == NULL || name == NULL) {
1317     return false;
1318   }
1319   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
1320   CHECK_JNI_EXCEPTION_(env, false);
1321   methodHandle mh(thread, Method::checked_resolve_jmethod_id(jmid));
1322   // can't be in VM when we call JNI
1323   ThreadToNativeFromVM ttnfv(thread);
1324   const char* flag_name = env->GetStringUTFChars(name, NULL);
1325   bool result =  CompilerOracle::has_option_value(mh, flag_name, *value);
1326   env->ReleaseStringUTFChars(name, flag_name);
1327   return result;


1603   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1604   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1605   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1606   {CC"getNMethod0",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1607                                                       (void*)&WB_GetNMethod         },
1608   {CC"forceNMethodSweep",  CC"()V",                   (void*)&WB_ForceNMethodSweep  },
1609   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1610   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1611   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1612   {CC"getCompilationActivityMode",
1613                            CC"()I",                   (void*)&WB_GetCompilationActivityMode},
1614   {CC"getMethodData0",     CC"(Ljava/lang/reflect/Executable;)J",
1615                                                       (void*)&WB_GetMethodData      },
1616   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
1617   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1618   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
1619   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
1620   {CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
1621   {CC"forceSafepoint",     CC"()V",                   (void*)&WB_ForceSafepoint     },
1622   {CC"getConstantPool0",   CC"(Ljava/lang/Class;)J",  (void*)&WB_GetConstantPool    },






1623   {CC"getMethodBooleanOption",
1624       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
1625                                                       (void*)&WB_GetMethodBooleaneOption},
1626   {CC"getMethodIntxOption",
1627       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1628                                                       (void*)&WB_GetMethodIntxOption},
1629   {CC"getMethodUintxOption",
1630       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1631                                                       (void*)&WB_GetMethodUintxOption},
1632   {CC"getMethodDoubleOption",
1633       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
1634                                                       (void*)&WB_GetMethodDoubleOption},
1635   {CC"getMethodStringOption",
1636       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String;",
1637                                                       (void*)&WB_GetMethodStringOption},
1638   {CC"isShared",           CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
1639   {CC"areSharedStringsIgnored",           CC"()Z",    (void*)&WB_AreSharedStringsIgnored },
1640   {CC"clearInlineCaches",  CC"()V",                   (void*)&WB_ClearInlineCaches },
1641 };
1642 


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include <new>
  28 
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/stringTable.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "compiler/methodMatcher.hpp"
  33 #include "jvmtifiles/jvmtiEnv.hpp"
  34 #include "memory/metadataFactory.hpp"
  35 #include "memory/metaspaceShared.hpp"
  36 #include "memory/universe.hpp"
  37 #include "oops/constantPool.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "prims/wbtestmethods/parserTests.hpp"
  40 #include "prims/whitebox.hpp"
  41 #include "runtime/arguments.hpp"
  42 #include "runtime/compilationPolicy.hpp"
  43 #include "runtime/deoptimization.hpp"
  44 #include "runtime/interfaceSupport.hpp"
  45 #include "runtime/javaCalls.hpp"
  46 #include "runtime/os.hpp"
  47 #include "runtime/sweeper.hpp"
  48 #include "runtime/thread.hpp"
  49 #include "runtime/vm_version.hpp"
  50 #include "utilities/array.hpp"
  51 #include "utilities/debug.hpp"
  52 #include "utilities/exceptions.hpp"
  53 #include "utilities/macros.hpp"
  54 #if INCLUDE_ALL_GCS
  55 #include "gc/g1/concurrentMarkThread.hpp"
  56 #include "gc/g1/g1CollectedHeap.inline.hpp"
  57 #include "gc/g1/g1ConcurrentMark.hpp"


1289 
1290 WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz))
1291   return (jboolean)MetaspaceShared::is_in_shared_space(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
1292 WB_END
1293 
1294 WB_ENTRY(jboolean, WB_IsMonitorInflated(JNIEnv* env, jobject wb, jobject obj))
1295   oop obj_oop = JNIHandles::resolve(obj);
1296   return (jboolean) obj_oop->mark()->has_monitor();
1297 WB_END
1298 
1299 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb))
1300   VM_ForceSafepoint force_safepoint_op;
1301   VMThread::execute(&force_safepoint_op);
1302 WB_END
1303 
1304 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1305   instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1306   return (jlong) ikh->constants();
1307 WB_END
1308 
1309 WB_ENTRY(jint, WB_GetConstantPoolCacheIndexTag(JNIEnv* env, jobject wb))
1310   return ConstantPool::CPCACHE_INDEX_TAG;
1311 WB_END
1312 
1313 WB_ENTRY(jint, WB_GetConstantPoolCacheLength(JNIEnv* env, jobject wb, jclass klass))
1314   instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1315   ConstantPool* cp = ikh->constants();
1316   if (cp->cache() == NULL) {
1317       return -1;
1318   }
1319   return cp->cache()->length();
1320 WB_END
1321 
1322 WB_ENTRY(jint, WB_ConstantPoolRemapInstructionOperandFromCache(JNIEnv* env, jobject wb, jclass klass, jint index))
1323   instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1324   ConstantPool* cp = ikh->constants();
1325   if (cp->cache() == NULL) {
1326     THROW_MSG_0(vmSymbols::java_lang_IllegalStateException(), "Constant pool does not have a cache");
1327   }
1328   jint cpci = index;
1329   jint cpciTag = ConstantPool::CPCACHE_INDEX_TAG;
1330   if (cpciTag > cpci || cpci >= cp->cache()->length() + cpciTag) {
1331     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Constant pool cache index is out of range");
1332   }
1333   jint cpi = cp->remap_instruction_operand_from_cache(cpci);
1334   return cpi;
1335 WB_END
1336 
1337 WB_ENTRY(jint, WB_ConstantPoolEncodeIndyIndex(JNIEnv* env, jobject wb, jint index))
1338   return ConstantPool::encode_invokedynamic_index(index);
1339 WB_END
1340 
1341 WB_ENTRY(void, WB_ClearInlineCaches(JNIEnv* env, jobject wb))
1342   VM_ClearICs clear_ics;
1343   VMThread::execute(&clear_ics);
1344 WB_END
1345 
1346 template <typename T>
1347 static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jstring name, T* value) {
1348   assert(value != NULL, "sanity");
1349   if (method == NULL || name == NULL) {
1350     return false;
1351   }
1352   jmethodID jmid = reflected_method_to_jmid(thread, env, method);
1353   CHECK_JNI_EXCEPTION_(env, false);
1354   methodHandle mh(thread, Method::checked_resolve_jmethod_id(jmid));
1355   // can't be in VM when we call JNI
1356   ThreadToNativeFromVM ttnfv(thread);
1357   const char* flag_name = env->GetStringUTFChars(name, NULL);
1358   bool result =  CompilerOracle::has_option_value(mh, flag_name, *value);
1359   env->ReleaseStringUTFChars(name, flag_name);
1360   return result;


1636   {CC"incMetaspaceCapacityUntilGC", CC"(J)J",         (void*)&WB_IncMetaspaceCapacityUntilGC },
1637   {CC"metaspaceCapacityUntilGC", CC"()J",             (void*)&WB_MetaspaceCapacityUntilGC },
1638   {CC"getCPUFeatures",     CC"()Ljava/lang/String;",  (void*)&WB_GetCPUFeatures     },
1639   {CC"getNMethod0",         CC"(Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object;",
1640                                                       (void*)&WB_GetNMethod         },
1641   {CC"forceNMethodSweep",  CC"()V",                   (void*)&WB_ForceNMethodSweep  },
1642   {CC"allocateCodeBlob",   CC"(II)J",                 (void*)&WB_AllocateCodeBlob   },
1643   {CC"freeCodeBlob",       CC"(J)V",                  (void*)&WB_FreeCodeBlob       },
1644   {CC"getCodeHeapEntries", CC"(I)[Ljava/lang/Object;",(void*)&WB_GetCodeHeapEntries },
1645   {CC"getCompilationActivityMode",
1646                            CC"()I",                   (void*)&WB_GetCompilationActivityMode},
1647   {CC"getMethodData0",     CC"(Ljava/lang/reflect/Executable;)J",
1648                                                       (void*)&WB_GetMethodData      },
1649   {CC"getCodeBlob",        CC"(J)[Ljava/lang/Object;",(void*)&WB_GetCodeBlob        },
1650   {CC"getThreadStackSize", CC"()J",                   (void*)&WB_GetThreadStackSize },
1651   {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
1652   {CC"assertMatchingSafepointCalls", CC"(ZZ)V",       (void*)&WB_AssertMatchingSafepointCalls },
1653   {CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated  },
1654   {CC"forceSafepoint",     CC"()V",                   (void*)&WB_ForceSafepoint     },
1655   {CC"getConstantPool0",   CC"(Ljava/lang/Class;)J",  (void*)&WB_GetConstantPool    },
1656   {CC"getConstantPoolCacheIndexTag0", CC"()I",  (void*)&WB_GetConstantPoolCacheIndexTag},
1657   {CC"getConstantPoolCacheLength0", CC"(Ljava/lang/Class;)I",  (void*)&WB_GetConstantPoolCacheLength},
1658   {CC"remapInstructionOperandFromCPCache0",
1659       CC"(Ljava/lang/Class;I)I",                      (void*)&WB_ConstantPoolRemapInstructionOperandFromCache},
1660   {CC"encodeConstantPoolIndyIndex0",
1661       CC"(I)I",                      (void*)&WB_ConstantPoolEncodeIndyIndex},
1662   {CC"getMethodBooleanOption",
1663       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
1664                                                       (void*)&WB_GetMethodBooleaneOption},
1665   {CC"getMethodIntxOption",
1666       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1667                                                       (void*)&WB_GetMethodIntxOption},
1668   {CC"getMethodUintxOption",
1669       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
1670                                                       (void*)&WB_GetMethodUintxOption},
1671   {CC"getMethodDoubleOption",
1672       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
1673                                                       (void*)&WB_GetMethodDoubleOption},
1674   {CC"getMethodStringOption",
1675       CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String;",
1676                                                       (void*)&WB_GetMethodStringOption},
1677   {CC"isShared",           CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
1678   {CC"areSharedStringsIgnored",           CC"()Z",    (void*)&WB_AreSharedStringsIgnored },
1679   {CC"clearInlineCaches",  CC"()V",                   (void*)&WB_ClearInlineCaches },
1680 };
1681 
< prev index next >