< prev index next >

src/hotspot/share/prims/whitebox.cpp

Print this page


1199     mh->set_prev_time(0);
1200 #endif
1201   }
1202 WB_END
1203 
1204 template <typename T>
1205 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAt)(const JVMFlag*, T*)) {
1206   if (name == NULL) {
1207     return false;
1208   }
1209   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1210   const char* flag_name = env->GetStringUTFChars(name, NULL);
1211   CHECK_JNI_EXCEPTION_(env, false);
1212   const JVMFlag* flag = JVMFlag::find_declared_flag(flag_name);
1213   JVMFlag::Error result = (*TAt)(flag, value);
1214   env->ReleaseStringUTFChars(name, flag_name);
1215   return (result == JVMFlag::SUCCESS);
1216 }
1217 
1218 template <typename T>
1219 static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(JVMFlag* flag, T*, JVMFlag::Flags)) {
1220   if (name == NULL) {
1221     return false;
1222   }
1223   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1224   const char* flag_name = env->GetStringUTFChars(name, NULL);
1225   CHECK_JNI_EXCEPTION_(env, false);
1226   JVMFlag* flag = JVMFlag::find_flag(flag_name);
1227   JVMFlag::Error result = (*TAtPut)(flag, value, JVMFlag::INTERNAL);
1228   env->ReleaseStringUTFChars(name, flag_name);
1229   return (result == JVMFlag::SUCCESS);
1230 }
1231 
1232 template <typename T>
1233 static jobject box(JavaThread* thread, JNIEnv* env, Symbol* name, Symbol* sig, T value) {
1234   ResourceMark rm(thread);
1235   jclass clazz = env->FindClass(name->as_C_string());
1236   CHECK_JNI_EXCEPTION_(env, NULL);
1237   jmethodID methodID = env->GetStaticMethodID(clazz,
1238         vmSymbols::valueOf_name()->as_C_string(),
1239         sig->as_C_string());


1346   if (GetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAt)) {
1347     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1348     return doubleBox(thread, env, result);
1349   }
1350   return NULL;
1351 WB_END
1352 
1353 WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name))
1354   ccstr ccstrResult;
1355   if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAt)) {
1356     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1357     jstring result = env->NewStringUTF(ccstrResult);
1358     CHECK_JNI_EXCEPTION_(env, NULL);
1359     return result;
1360   }
1361   return NULL;
1362 WB_END
1363 
1364 WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value))
1365   bool result = value == JNI_TRUE ? true : false;
1366   SetVMFlag <bool> (thread, env, name, &result, &JVMFlag::boolAtPut);
1367 WB_END
1368 
1369 WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1370   int result = value;
1371   SetVMFlag <int> (thread, env, name, &result, &JVMFlag::intAtPut);
1372 WB_END
1373 
1374 WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1375   uint result = value;
1376   SetVMFlag <uint> (thread, env, name, &result, &JVMFlag::uintAtPut);
1377 WB_END
1378 
1379 WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1380   intx result = value;
1381   SetVMFlag <intx> (thread, env, name, &result, &JVMFlag::intxAtPut);
1382 WB_END
1383 
1384 WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1385   uintx result = value;
1386   SetVMFlag <uintx> (thread, env, name, &result, &JVMFlag::uintxAtPut);
1387 WB_END
1388 
1389 WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1390   uint64_t result = value;
1391   SetVMFlag <uint64_t> (thread, env, name, &result, &JVMFlag::uint64_tAtPut);
1392 WB_END
1393 
1394 WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1395   size_t result = value;
1396   SetVMFlag <size_t> (thread, env, name, &result, &JVMFlag::size_tAtPut);
1397 WB_END
1398 
1399 WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value))
1400   double result = value;
1401   SetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAtPut);
1402 WB_END
1403 
1404 WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value))
1405   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1406   const char* ccstrValue;
1407   if (value == NULL) {
1408     ccstrValue = NULL;
1409   }
1410   else {
1411     ccstrValue = env->GetStringUTFChars(value, NULL);
1412     CHECK_JNI_EXCEPTION(env);
1413   }
1414   ccstr ccstrResult = ccstrValue;
1415   bool needFree;
1416   {
1417     ThreadInVMfromNative ttvfn(thread); // back to VM
1418     needFree = SetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAtPut);








1419   }
1420   if (value != NULL) {
1421     env->ReleaseStringUTFChars(value, ccstrValue);
1422   }
1423   if (needFree) {
1424     FREE_C_HEAP_ARRAY(char, ccstrResult);
1425   }
1426 WB_END
1427 
1428 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
1429   WhiteBox::compilation_locked = true;
1430 WB_END
1431 
1432 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1433   MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1434   WhiteBox::compilation_locked = false;
1435   mo.notify_all();
1436 WB_END
1437 
1438 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))




1199     mh->set_prev_time(0);
1200 #endif
1201   }
1202 WB_END
1203 
1204 template <typename T>
1205 static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAt)(const JVMFlag*, T*)) {
1206   if (name == NULL) {
1207     return false;
1208   }
1209   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1210   const char* flag_name = env->GetStringUTFChars(name, NULL);
1211   CHECK_JNI_EXCEPTION_(env, false);
1212   const JVMFlag* flag = JVMFlag::find_declared_flag(flag_name);
1213   JVMFlag::Error result = (*TAt)(flag, value);
1214   env->ReleaseStringUTFChars(name, flag_name);
1215   return (result == JVMFlag::SUCCESS);
1216 }
1217 
1218 template <typename T>
1219 static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T value, JVMFlag::Error (*TAtPut)(JVMFlag* flag, T, JVMFlag::Flags)) {
1220   if (name == NULL) {
1221     return false;
1222   }
1223   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1224   const char* flag_name = env->GetStringUTFChars(name, NULL);
1225   CHECK_JNI_EXCEPTION_(env, false);
1226   JVMFlag* flag = JVMFlag::find_flag(flag_name);
1227   JVMFlag::Error result = (*TAtPut)(flag, value, JVMFlag::INTERNAL);
1228   env->ReleaseStringUTFChars(name, flag_name);
1229   return (result == JVMFlag::SUCCESS);
1230 }
1231 
1232 template <typename T>
1233 static jobject box(JavaThread* thread, JNIEnv* env, Symbol* name, Symbol* sig, T value) {
1234   ResourceMark rm(thread);
1235   jclass clazz = env->FindClass(name->as_C_string());
1236   CHECK_JNI_EXCEPTION_(env, NULL);
1237   jmethodID methodID = env->GetStaticMethodID(clazz,
1238         vmSymbols::valueOf_name()->as_C_string(),
1239         sig->as_C_string());


1346   if (GetVMFlag <double> (thread, env, name, &result, &JVMFlag::doubleAt)) {
1347     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1348     return doubleBox(thread, env, result);
1349   }
1350   return NULL;
1351 WB_END
1352 
1353 WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name))
1354   ccstr ccstrResult;
1355   if (GetVMFlag <ccstr> (thread, env, name, &ccstrResult, &JVMFlag::ccstrAt)) {
1356     ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1357     jstring result = env->NewStringUTF(ccstrResult);
1358     CHECK_JNI_EXCEPTION_(env, NULL);
1359     return result;
1360   }
1361   return NULL;
1362 WB_END
1363 
1364 WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value))
1365   bool result = value == JNI_TRUE ? true : false;
1366   SetVMFlag <bool> (thread, env, name, result, &JVMFlag::boolAtPut);
1367 WB_END
1368 
1369 WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1370   int result = value;
1371   SetVMFlag <int> (thread, env, name, result, &JVMFlag::intAtPut);
1372 WB_END
1373 
1374 WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1375   uint result = value;
1376   SetVMFlag <uint> (thread, env, name, result, &JVMFlag::uintAtPut);
1377 WB_END
1378 
1379 WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1380   intx result = value;
1381   SetVMFlag <intx> (thread, env, name, result, &JVMFlag::intxAtPut);
1382 WB_END
1383 
1384 WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1385   uintx result = value;
1386   SetVMFlag <uintx> (thread, env, name, result, &JVMFlag::uintxAtPut);
1387 WB_END
1388 
1389 WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1390   uint64_t result = value;
1391   SetVMFlag <uint64_t> (thread, env, name, result, &JVMFlag::uint64_tAtPut);
1392 WB_END
1393 
1394 WB_ENTRY(void, WB_SetSizeTVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
1395   size_t result = value;
1396   SetVMFlag <size_t> (thread, env, name, result, &JVMFlag::size_tAtPut);
1397 WB_END
1398 
1399 WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value))
1400   double result = value;
1401   SetVMFlag <double> (thread, env, name, result, &JVMFlag::doubleAtPut);
1402 WB_END
1403 
1404 WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value))
1405   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
1406   const char* ccstrValue;
1407   if (value == NULL) {
1408     ccstrValue = NULL;
1409   }
1410   else {
1411     ccstrValue = env->GetStringUTFChars(value, NULL);
1412     CHECK_JNI_EXCEPTION(env);
1413   }
1414   ccstr ccstrResult = ccstrValue;
1415   bool needFree = false;
1416   {
1417     if (name != NULL) {
1418       const char* flag_name = env->GetStringUTFChars(name, NULL);
1419       CHECK_JNI_EXCEPTION(env);
1420       JVMFlag* flag = JVMFlag::find_flag(flag_name);
1421       JVMFlag::Error result = JVMFlag::ccstrAtPut(flag, &ccstrResult, JVMFlag::INTERNAL);
1422       env->ReleaseStringUTFChars(name, flag_name);
1423       if (result == JVMFlag::SUCCESS) {
1424         needFree = true;
1425       }
1426     }
1427   }
1428   if (value != NULL) {
1429     env->ReleaseStringUTFChars(value, ccstrValue);
1430   }
1431   if (needFree) {
1432     FREE_C_HEAP_ARRAY(char, ccstrResult);
1433   }
1434 WB_END
1435 
1436 WB_ENTRY(void, WB_LockCompilation(JNIEnv* env, jobject o, jlong timeout))
1437   WhiteBox::compilation_locked = true;
1438 WB_END
1439 
1440 WB_ENTRY(void, WB_UnlockCompilation(JNIEnv* env, jobject o))
1441   MonitorLocker mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1442   WhiteBox::compilation_locked = false;
1443   mo.notify_all();
1444 WB_END
1445 
1446 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))


< prev index next >