diff --git a/src/share/vm/runtime/globals.cpp b/src/share/vm/runtime/globals.cpp index b348f98e70a78bb3a7aa42abf7846b24cf949389..71fec55248246ea07ff17c4d5eb4b7138d554805 100644 --- a/src/share/vm/runtime/globals.cpp +++ b/src/share/vm/runtime/globals.cpp @@ -69,9 +69,10 @@ bool Flag::is_external() const { void Flag::print_on(outputStream* st) { st->print("%5s %-35s %c= ", type, name, (origin != DEFAULT ? ':' : ' ')); - if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); - if (is_intx()) st->print("%-16ld", get_intx()); - if (is_uintx()) st->print("%-16lu", get_uintx()); + if (is_bool()) st->print("%-16s", get_bool() ? "true" : "false"); + if (is_intx()) st->print("%-16ld", get_intx()); + if (is_uintx()) st->print("%-16lu", get_uintx()); + if (is_uint64_t()) st->print("%-16lu", get_uint64_t()); if (is_ccstr()) { const char* cp = get_ccstr(); if (cp != NULL) { @@ -100,6 +101,8 @@ void Flag::print_as_flag(outputStream* st) { st->print("-XX:%s=" INTX_FORMAT, name, get_intx()); } else if (is_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()) { st->print("-XX:%s=", name); const char* cp = get_ccstr(); diff --git a/src/share/vm/services/attachListener.cpp b/src/share/vm/services/attachListener.cpp index 007de28da37ec36b8f7800895715596d2b326619..2de9c10221268711d79e0df6d8eae2393be93e36 100644 --- a/src/share/vm/services/attachListener.cpp +++ b/src/share/vm/services/attachListener.cpp @@ -207,7 +207,7 @@ static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* o int tmp; int n = sscanf(arg1, "%d", &tmp); 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; } value = (tmp != 0); @@ -226,11 +226,11 @@ static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* o if ((arg1 = op->arg(1)) != NULL) { int n = sscanf(arg1, INTX_FORMAT, &value); if (n != 1) { - out->print_cr("flag value has to be integer"); + out->print_cr("flag value must be an integer"); return JNI_ERR; } } - bool res = CommandLineFlags::intxAtPut((char*)name, &value, ATTACH_ON_DEMAND); + bool res = CommandLineFlags::intxAtPut((char*)name, &value, ATTACH_ON_DEMAND); if (! res) { out->print_cr("setting flag %s failed", name); } @@ -245,11 +245,30 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* if ((arg1 = op->arg(1)) != NULL) { int n = sscanf(arg1, UINTX_FORMAT, &value); 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; } } - bool res = CommandLineFlags::uintxAtPut((char*)name, &value, ATTACH_ON_DEMAND); + bool res = CommandLineFlags::uintxAtPut((char*)name, &value, ATTACH_ON_DEMAND); + if (! res) { + out->print_cr("setting flag %s failed", name); + } + + 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); } @@ -261,10 +280,10 @@ static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) { const char* value; 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; } - bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND); + bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, ATTACH_ON_DEMAND); if (res) { FREE_C_HEAP_ARRAY(char, value); } else { @@ -291,6 +310,8 @@ static jint set_flag(AttachOperation* op, outputStream* out) { return set_intx_flag(name, op, out); } else if (f->is_uintx()) { 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()) { return set_ccstr_flag(name, op, out); } else { diff --git a/src/share/vm/services/management.cpp b/src/share/vm/services/management.cpp index ee681b17146c6c54cfffbfc17bde8dec67daa794..d88af72c09bb5d931a28d3ab28139236a0e0f7c3 100644 --- a/src/share/vm/services/management.cpp +++ b/src/share/vm/services/management.cpp @@ -1507,16 +1507,17 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) return (jobjectArray)JNIHandles::make_local(env, flags_ah()); JVM_END -// utility function used by jmm_GetVMGlobals -void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, TRAPS) { +// Utility function used by jmm_GetVMGlobals. Returns false if flag type +// 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; 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 { flag_name = name; } global->name = (jstring)JNIHandles::make_local(env, flag_name()); - global->type = JMM_VMGLOBAL_TYPE_UNKNOWN; if (flag->is_bool()) { 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, } else if (flag->is_uintx()) { global->value.j = (jlong)flag->get_uintx(); 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()) { - 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->type = JMM_VMGLOBAL_TYPE_JSTRING; + } else { + global->type = JMM_VMGLOBAL_TYPE_UNKNOWN; + assert(false, "Unsupported VMGlobal Type"); + return false; } global->writeable = flag->is_writeable(); @@ -1557,6 +1565,8 @@ void add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag, default: global->origin = JMM_VMGLOBAL_ORIGIN_OTHER; } + + return true; } // Fill globals array of count length with jmmVMGlobal entries @@ -1599,8 +1609,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, Handle sh(THREAD, s); char* str = java_lang_String::as_utf8_string(s); Flag* flag = Flag::find_flag(str, strlen(str)); - if (flag != NULL) { - add_global_entry(env, sh, &globals[i], flag, THREAD); + if (flag != NULL && + add_global_entry(env, sh, &globals[i], flag, THREAD)) { num_entries++; } else { globals[i].name = NULL; @@ -1617,8 +1627,8 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, for (int i = 0; i < nFlags && num_entries < count; i++) { Flag* flag = &Flag::flags[i]; // Exclude the locked (diagnostic, experimental) flags - if (flag->is_unlocked() || flag->is_unlocker()) { - add_global_entry(env, null_h, &globals[num_entries], flag, THREAD); + if ((flag->is_unlocked() || flag->is_unlocker()) && + add_global_entry(env, null_h, &globals[num_entries], flag, THREAD)) { num_entries++; } } @@ -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); succeed = CommandLineFlags::boolAtPut(name, &bvalue, MANAGEMENT); } else if (flag->is_intx()) { - intx ivalue = new_value.j; + intx ivalue = (intx)new_value.j; succeed = CommandLineFlags::intxAtPut(name, &ivalue, MANAGEMENT); } else if (flag->is_uintx()) { - uintx uvalue = new_value.j; + uintx uvalue = (uintx)new_value.j; 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()) { oop str = JNIHandles::resolve_external_guard(new_value.l); if (str == NULL) {