提交 49fcde7c 编写于 作者: P phh

6898160: Need serviceability support for new vm argument type 'uint64_t'

Summary: Add serviceability support for uint64_t. Flags of unknown type assert in debug builds and are ignored in product builds.
Reviewed-by: never, xlu, mchung, dcubed
上级 42926b73
...@@ -72,6 +72,7 @@ void Flag::print_on(outputStream* st) { ...@@ -72,6 +72,7 @@ void Flag::print_on(outputStream* st) {
if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false");
if (is_intx()) st->print("%-16ld", get_intx()); if (is_intx()) st->print("%-16ld", get_intx());
if (is_uintx()) st->print("%-16lu", get_uintx()); if (is_uintx()) st->print("%-16lu", get_uintx());
if (is_uint64_t()) st->print("%-16lu", get_uint64_t());
if (is_ccstr()) { if (is_ccstr()) {
const char* cp = get_ccstr(); const char* cp = get_ccstr();
if (cp != NULL) { if (cp != NULL) {
...@@ -100,6 +101,8 @@ void Flag::print_as_flag(outputStream* st) { ...@@ -100,6 +101,8 @@ void Flag::print_as_flag(outputStream* st) {
st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
} else if (is_uintx()) { } else if (is_uintx()) {
st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx()); st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
} else if (is_uint64_t()) {
st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
} else if (is_ccstr()) { } else if (is_ccstr()) {
st->print("-XX:%s=", name); st->print("-XX:%s=", name);
const char* cp = get_ccstr(); const char* cp = get_ccstr();
......
...@@ -207,7 +207,7 @@ static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* o ...@@ -207,7 +207,7 @@ static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* o
int tmp; int tmp;
int n = sscanf(arg1, "%d", &tmp); int n = sscanf(arg1, "%d", &tmp);
if (n != 1) { if (n != 1) {
out->print_cr("flag value has to be boolean (1 or 0)"); out->print_cr("flag value must be a boolean (1 or 0)");
return JNI_ERR; return JNI_ERR;
} }
value = (tmp != 0); value = (tmp != 0);
...@@ -226,7 +226,7 @@ static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* o ...@@ -226,7 +226,7 @@ static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* o
if ((arg1 = op->arg(1)) != NULL) { if ((arg1 = op->arg(1)) != NULL) {
int n = sscanf(arg1, INTX_FORMAT, &value); int n = sscanf(arg1, INTX_FORMAT, &value);
if (n != 1) { if (n != 1) {
out->print_cr("flag value has to be integer"); out->print_cr("flag value must be an integer");
return JNI_ERR; return JNI_ERR;
} }
} }
...@@ -245,7 +245,7 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* ...@@ -245,7 +245,7 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream*
if ((arg1 = op->arg(1)) != NULL) { if ((arg1 = op->arg(1)) != NULL) {
int n = sscanf(arg1, UINTX_FORMAT, &value); int n = sscanf(arg1, UINTX_FORMAT, &value);
if (n != 1) { if (n != 1) {
out->print_cr("flag value has to be integer"); out->print_cr("flag value must be an unsigned integer");
return JNI_ERR; return JNI_ERR;
} }
} }
...@@ -257,11 +257,30 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* ...@@ -257,11 +257,30 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream*
return res? JNI_OK : JNI_ERR; return res? JNI_OK : JNI_ERR;
} }
// set a uint64_t global flag using value from AttachOperation
static jint set_uint64_t_flag(const char* name, AttachOperation* op, outputStream* out) {
uint64_t value;
const char* arg1;
if ((arg1 = op->arg(1)) != NULL) {
int n = sscanf(arg1, UINT64_FORMAT, &value);
if (n != 1) {
out->print_cr("flag value must be an unsigned 64-bit integer");
return JNI_ERR;
}
}
bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, ATTACH_ON_DEMAND);
if (! res) {
out->print_cr("setting flag %s failed", name);
}
return res? JNI_OK : JNI_ERR;
}
// set a string global flag using value from AttachOperation // set a string global flag using value from AttachOperation
static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) { static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) {
const char* value; const char* value;
if ((value = op->arg(1)) == NULL) { if ((value = op->arg(1)) == NULL) {
out->print_cr("flag value has to be a string"); out->print_cr("flag value must be a string");
return JNI_ERR; return JNI_ERR;
} }
bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND); bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND);
...@@ -291,6 +310,8 @@ static jint set_flag(AttachOperation* op, outputStream* out) { ...@@ -291,6 +310,8 @@ static jint set_flag(AttachOperation* op, outputStream* out) {
return set_intx_flag(name, op, out); return set_intx_flag(name, op, out);
} else if (f->is_uintx()) { } else if (f->is_uintx()) {
return set_uintx_flag(name, op, out); return set_uintx_flag(name, op, out);
} else if (f->is_uint64_t()) {
return set_uint64_t_flag(name, op, out);
} else if (f->is_ccstr()) { } else if (f->is_ccstr()) {
return set_ccstr_flag(name, op, out); return set_ccstr_flag(name, op, out);
} else { } else {
......
...@@ -1507,16 +1507,17 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) ...@@ -1507,16 +1507,17 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
return (jobjectArray)JNIHandles::make_local(env, flags_ah()); return (jobjectArray)JNIHandles::make_local(env, flags_ah());
JVM_END JVM_END
// utility function used by jmm_GetVMGlobals // Utility function used by jmm_GetVMGlobals. Returns false if flag type
void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, TRAPS) { // can't be determined, true otherwise. If false is returned, then *global
// will be incomplete and invalid.
bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, TRAPS) {
Handle flag_name; Handle flag_name;
if (name() == NULL) { if (name() == NULL) {
flag_name = java_lang_String::create_from_str(flag->name, CHECK); flag_name = java_lang_String::create_from_str(flag->name, CHECK_false);
} else { } else {
flag_name = name; flag_name = name;
} }
global->name = (jstring)JNIHandles::make_local(env, flag_name()); global->name = (jstring)JNIHandles::make_local(env, flag_name());
global->type = JMM_VMGLOBAL_TYPE_UNKNOWN;
if (flag->is_bool()) { if (flag->is_bool()) {
global->value.z = flag->get_bool() ? JNI_TRUE : JNI_FALSE; global->value.z = flag->get_bool() ? JNI_TRUE : JNI_FALSE;
...@@ -1527,10 +1528,17 @@ void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, ...@@ -1527,10 +1528,17 @@ void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag,
} else if (flag->is_uintx()) { } else if (flag->is_uintx()) {
global->value.j = (jlong)flag->get_uintx(); global->value.j = (jlong)flag->get_uintx();
global->type = JMM_VMGLOBAL_TYPE_JLONG; global->type = JMM_VMGLOBAL_TYPE_JLONG;
} else if (flag->is_uint64_t()) {
global->value.j = (jlong)flag->get_uint64_t();
global->type = JMM_VMGLOBAL_TYPE_JLONG;
} else if (flag->is_ccstr()) { } else if (flag->is_ccstr()) {
Handle str = java_lang_String::create_from_str(flag->get_ccstr(), CHECK); Handle str = java_lang_String::create_from_str(flag->get_ccstr(), CHECK_false);
global->value.l = (jobject)JNIHandles::make_local(env, str()); global->value.l = (jobject)JNIHandles::make_local(env, str());
global->type = JMM_VMGLOBAL_TYPE_JSTRING; global->type = JMM_VMGLOBAL_TYPE_JSTRING;
} else {
global->type = JMM_VMGLOBAL_TYPE_UNKNOWN;
assert(false, "Unsupported VMGlobal Type");
return false;
} }
global->writeable = flag->is_writeable(); global->writeable = flag->is_writeable();
...@@ -1557,6 +1565,8 @@ void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, ...@@ -1557,6 +1565,8 @@ void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag,
default: default:
global->origin = JMM_VMGLOBAL_ORIGIN_OTHER; global->origin = JMM_VMGLOBAL_ORIGIN_OTHER;
} }
return true;
} }
// Fill globals array of count length with jmmVMGlobal entries // Fill globals array of count length with jmmVMGlobal entries
...@@ -1599,8 +1609,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, ...@@ -1599,8 +1609,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
Handle sh(THREAD, s); Handle sh(THREAD, s);
char* str = java_lang_String::as_utf8_string(s); char* str = java_lang_String::as_utf8_string(s);
Flag* flag = Flag::find_flag(str, strlen(str)); Flag* flag = Flag::find_flag(str, strlen(str));
if (flag != NULL) { if (flag != NULL &&
add_global_entry(env, sh, &globals[i], flag, THREAD); add_global_entry(env, sh, &globals[i], flag, THREAD)) {
num_entries++; num_entries++;
} else { } else {
globals[i].name = NULL; globals[i].name = NULL;
...@@ -1617,8 +1627,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, ...@@ -1617,8 +1627,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env,
for (int i = 0; i < nFlags && num_entries < count; i++) { for (int i = 0; i < nFlags && num_entries < count; i++) {
Flag* flag = &Flag::flags[i]; Flag* flag = &Flag::flags[i];
// Exclude the locked (diagnostic, experimental) flags // Exclude the locked (diagnostic, experimental) flags
if (flag->is_unlocked() || flag->is_unlocker()) { if ((flag->is_unlocked() || flag->is_unlocker()) &&
add_global_entry(env, null_h, &globals[num_entries], flag, THREAD); add_global_entry(env, null_h, &globals[num_entries], flag, THREAD)) {
num_entries++; num_entries++;
} }
} }
...@@ -1650,11 +1660,14 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value ...@@ -1650,11 +1660,14 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value
bool bvalue = (new_value.z == JNI_TRUE ? true : false); bool bvalue = (new_value.z == JNI_TRUE ? true : false);
succeed = CommandLineFlags::boolAtPut(name, &bvalue, MANAGEMENT); succeed = CommandLineFlags::boolAtPut(name, &bvalue, MANAGEMENT);
} else if (flag->is_intx()) { } else if (flag->is_intx()) {
intx ivalue = new_value.j; intx ivalue = (intx)new_value.j;
succeed = CommandLineFlags::intxAtPut(name, &ivalue, MANAGEMENT); succeed = CommandLineFlags::intxAtPut(name, &ivalue, MANAGEMENT);
} else if (flag->is_uintx()) { } else if (flag->is_uintx()) {
uintx uvalue = new_value.j; uintx uvalue = (uintx)new_value.j;
succeed = CommandLineFlags::uintxAtPut(name, &uvalue, MANAGEMENT); succeed = CommandLineFlags::uintxAtPut(name, &uvalue, MANAGEMENT);
} else if (flag->is_uint64_t()) {
uint64_t uvalue = (uint64_t)new_value.j;
succeed = CommandLineFlags::uint64_tAtPut(name, &uvalue, MANAGEMENT);
} else if (flag->is_ccstr()) { } else if (flag->is_ccstr()) {
oop str = JNIHandles::resolve_external_guard(new_value.l); oop str = JNIHandles::resolve_external_guard(new_value.l);
if (str == NULL) { if (str == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册