提交 e0ffd929 编写于 作者: S swamyv

6653214: MemoryPoolMXBean.setUsageThreshold() does not support large heap sizes.

Reviewed-by: ysr, mchung
上级 90972b2f
...@@ -181,7 +181,7 @@ public: ...@@ -181,7 +181,7 @@ public:
void scrub(CardTableModRefBS* ctbs, BitMap* card_bm) { void scrub(CardTableModRefBS* ctbs, BitMap* card_bm) {
HeapWord* hr_bot = hr()->bottom(); HeapWord* hr_bot = hr()->bottom();
int hr_first_card_index = ctbs->index_for(hr_bot); size_t hr_first_card_index = ctbs->index_for(hr_bot);
bm()->set_intersection_at_offset(*card_bm, hr_first_card_index); bm()->set_intersection_at_offset(*card_bm, hr_first_card_index);
#if PRT_COUNT_OCCUPIED #if PRT_COUNT_OCCUPIED
recount_occupied(); recount_occupied();
......
...@@ -283,7 +283,7 @@ void CardTableModRefBS::resize_covered_region(MemRegion new_region) { ...@@ -283,7 +283,7 @@ void CardTableModRefBS::resize_covered_region(MemRegion new_region) {
} else { } else {
entry = byte_after(old_region.last()); entry = byte_after(old_region.last());
} }
assert(index_for(new_region.last()) < (int) _guard_index, assert(index_for(new_region.last()) < _guard_index,
"The guard card will be overwritten"); "The guard card will be overwritten");
// This line commented out cleans the newly expanded region and // This line commented out cleans the newly expanded region and
// not the aligned up expanded region. // not the aligned up expanded region.
......
...@@ -428,7 +428,7 @@ public: ...@@ -428,7 +428,7 @@ public:
} }
// Mapping from address to card marking array index. // Mapping from address to card marking array index.
int index_for(void* p) { size_t index_for(void* p) {
assert(_whole_heap.contains(p), assert(_whole_heap.contains(p),
"out of bounds access to card marking array"); "out of bounds access to card marking array");
return byte_for(p) - _byte_map; return byte_for(p) - _byte_map;
......
...@@ -444,9 +444,9 @@ char* SysClassPath::add_jars_to_path(char* path, const char* directory) { ...@@ -444,9 +444,9 @@ char* SysClassPath::add_jars_to_path(char* path, const char* directory) {
} }
// Parses a memory size specification string. // Parses a memory size specification string.
static bool atomll(const char *s, jlong* result) { static bool atomull(const char *s, julong* result) {
jlong n = 0; julong n = 0;
int args_read = sscanf(s, os::jlong_format_specifier(), &n); int args_read = sscanf(s, os::julong_format_specifier(), &n);
if (args_read != 1) { if (args_read != 1) {
return false; return false;
} }
...@@ -460,15 +460,20 @@ static bool atomll(const char *s, jlong* result) { ...@@ -460,15 +460,20 @@ static bool atomll(const char *s, jlong* result) {
switch (*s) { switch (*s) {
case 'T': case 't': case 'T': case 't':
*result = n * G * K; *result = n * G * K;
// Check for overflow.
if (*result/((julong)G * K) != n) return false;
return true; return true;
case 'G': case 'g': case 'G': case 'g':
*result = n * G; *result = n * G;
if (*result/G != n) return false;
return true; return true;
case 'M': case 'm': case 'M': case 'm':
*result = n * M; *result = n * M;
if (*result/M != n) return false;
return true; return true;
case 'K': case 'k': case 'K': case 'k':
*result = n * K; *result = n * K;
if (*result/K != n) return false;
return true; return true;
case '\0': case '\0':
*result = n; *result = n;
...@@ -478,10 +483,10 @@ static bool atomll(const char *s, jlong* result) { ...@@ -478,10 +483,10 @@ static bool atomll(const char *s, jlong* result) {
} }
} }
Arguments::ArgsRange Arguments::check_memory_size(jlong size, jlong min_size) { Arguments::ArgsRange Arguments::check_memory_size(julong size, julong min_size) {
if (size < min_size) return arg_too_small; if (size < min_size) return arg_too_small;
// Check that size will fit in a size_t (only relevant on 32-bit) // Check that size will fit in a size_t (only relevant on 32-bit)
if ((julong) size > max_uintx) return arg_too_big; if (size > max_uintx) return arg_too_big;
return arg_in_range; return arg_in_range;
} }
...@@ -522,10 +527,10 @@ static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) ...@@ -522,10 +527,10 @@ static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin)
static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) { static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
jlong v; julong v;
intx intx_v; intx intx_v;
bool is_neg = false; bool is_neg = false;
// Check the sign first since atomll() parses only unsigned values. // Check the sign first since atomull() parses only unsigned values.
if (*value == '-') { if (*value == '-') {
if (!CommandLineFlags::intxAt(name, &intx_v)) { if (!CommandLineFlags::intxAt(name, &intx_v)) {
return false; return false;
...@@ -533,7 +538,7 @@ static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) { ...@@ -533,7 +538,7 @@ static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
value++; value++;
is_neg = true; is_neg = true;
} }
if (!atomll(value, &v)) { if (!atomull(value, &v)) {
return false; return false;
} }
intx_v = (intx) v; intx_v = (intx) v;
...@@ -1677,9 +1682,9 @@ static bool match_option(const JavaVMOption* option, const char** names, const c ...@@ -1677,9 +1682,9 @@ static bool match_option(const JavaVMOption* option, const char** names, const c
} }
Arguments::ArgsRange Arguments::parse_memory_size(const char* s, Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
jlong* long_arg, julong* long_arg,
jlong min_size) { julong min_size) {
if (!atomll(s, long_arg)) return arg_unreadable; if (!atomull(s, long_arg)) return arg_unreadable;
return check_memory_size(*long_arg, min_size); return check_memory_size(*long_arg, min_size);
} }
...@@ -1857,7 +1862,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -1857,7 +1862,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
// -Xmn for compatibility with other JVM vendors // -Xmn for compatibility with other JVM vendors
} else if (match_option(option, "-Xmn", &tail)) { } else if (match_option(option, "-Xmn", &tail)) {
jlong long_initial_eden_size = 0; julong long_initial_eden_size = 0;
ArgsRange errcode = parse_memory_size(tail, &long_initial_eden_size, 1); ArgsRange errcode = parse_memory_size(tail, &long_initial_eden_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -1869,7 +1874,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -1869,7 +1874,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
FLAG_SET_CMDLINE(uintx, NewSize, (size_t) long_initial_eden_size); FLAG_SET_CMDLINE(uintx, NewSize, (size_t) long_initial_eden_size);
// -Xms // -Xms
} else if (match_option(option, "-Xms", &tail)) { } else if (match_option(option, "-Xms", &tail)) {
jlong long_initial_heap_size = 0; julong long_initial_heap_size = 0;
ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -1882,7 +1887,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -1882,7 +1887,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
set_min_heap_size(initial_heap_size()); set_min_heap_size(initial_heap_size());
// -Xmx // -Xmx
} else if (match_option(option, "-Xmx", &tail)) { } else if (match_option(option, "-Xmx", &tail)) {
jlong long_max_heap_size = 0; julong long_max_heap_size = 0;
ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -1915,7 +1920,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -1915,7 +1920,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
} }
// -Xss // -Xss
} else if (match_option(option, "-Xss", &tail)) { } else if (match_option(option, "-Xss", &tail)) {
jlong long_ThreadStackSize = 0; julong long_ThreadStackSize = 0;
ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000); ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -1931,9 +1936,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -1931,9 +1936,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
// HotSpot does not have separate native and Java stacks, ignore silently for compatibility // HotSpot does not have separate native and Java stacks, ignore silently for compatibility
// -Xmaxjitcodesize // -Xmaxjitcodesize
} else if (match_option(option, "-Xmaxjitcodesize", &tail)) { } else if (match_option(option, "-Xmaxjitcodesize", &tail)) {
jlong long_ReservedCodeCacheSize = 0; julong long_ReservedCodeCacheSize = 0;
ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize,
InitialCodeCacheSize); (size_t)InitialCodeCacheSize);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Invalid maximum code cache size: %s\n", "Invalid maximum code cache size: %s\n",
...@@ -2238,7 +2243,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, ...@@ -2238,7 +2243,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
} else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) { } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
// No longer used. // No longer used.
} else if (match_option(option, "-XX:TLESize=", &tail)) { } else if (match_option(option, "-XX:TLESize=", &tail)) {
jlong long_tlab_size = 0; julong long_tlab_size = 0;
ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1); ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -2293,7 +2298,7 @@ SOLARIS_ONLY( ...@@ -2293,7 +2298,7 @@ SOLARIS_ONLY(
"-XX:ParCMSPromoteBlocksToClaim in the future\n"); "-XX:ParCMSPromoteBlocksToClaim in the future\n");
} else } else
if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) { if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) {
jlong old_plab_size = 0; julong old_plab_size = 0;
ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1); ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -2301,13 +2306,13 @@ SOLARIS_ONLY( ...@@ -2301,13 +2306,13 @@ SOLARIS_ONLY(
describe_range_error(errcode); describe_range_error(errcode);
return JNI_EINVAL; return JNI_EINVAL;
} }
FLAG_SET_CMDLINE(uintx, OldPLABSize, (julong)old_plab_size); FLAG_SET_CMDLINE(uintx, OldPLABSize, old_plab_size);
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Please use -XX:OldPLABSize in place of " "Please use -XX:OldPLABSize in place of "
"-XX:ParallelGCOldGenAllocBufferSize in the future\n"); "-XX:ParallelGCOldGenAllocBufferSize in the future\n");
} else } else
if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) { if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) {
jlong young_plab_size = 0; julong young_plab_size = 0;
ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1); ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1);
if (errcode != arg_in_range) { if (errcode != arg_in_range) {
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
...@@ -2315,7 +2320,7 @@ SOLARIS_ONLY( ...@@ -2315,7 +2320,7 @@ SOLARIS_ONLY(
describe_range_error(errcode); describe_range_error(errcode);
return JNI_EINVAL; return JNI_EINVAL;
} }
FLAG_SET_CMDLINE(uintx, YoungPLABSize, (julong)young_plab_size); FLAG_SET_CMDLINE(uintx, YoungPLABSize, young_plab_size);
jio_fprintf(defaultStream::error_stream(), jio_fprintf(defaultStream::error_stream(),
"Please use -XX:YoungPLABSize in place of " "Please use -XX:YoungPLABSize in place of "
"-XX:ParallelGCToSpaceAllocBufferSize in the future\n"); "-XX:ParallelGCToSpaceAllocBufferSize in the future\n");
......
...@@ -339,9 +339,9 @@ class Arguments : AllStatic { ...@@ -339,9 +339,9 @@ class Arguments : AllStatic {
} }
static bool verify_percentage(uintx value, const char* name); static bool verify_percentage(uintx value, const char* name);
static void describe_range_error(ArgsRange errcode); static void describe_range_error(ArgsRange errcode);
static ArgsRange check_memory_size(jlong size, jlong min_size); static ArgsRange check_memory_size(julong size, julong min_size);
static ArgsRange parse_memory_size(const char* s, jlong* long_arg, static ArgsRange parse_memory_size(const char* s, julong* long_arg,
jlong min_size); julong min_size);
// methods to build strings from individual args // methods to build strings from individual args
static void build_jvm_args(const char* arg); static void build_jvm_args(const char* arg);
......
...@@ -694,10 +694,10 @@ JVM_ENTRY(jlong, jmm_SetPoolThreshold(JNIEnv* env, jobject obj, jmmThresholdType ...@@ -694,10 +694,10 @@ JVM_ENTRY(jlong, jmm_SetPoolThreshold(JNIEnv* env, jobject obj, jmmThresholdType
-1); -1);
} }
if (threshold > max_intx) { if ((size_t)threshold > max_uintx) {
THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), stringStream st;
"Invalid threshold value > max value of size_t", st.print("Invalid valid threshold value. Threshold value (" UINT64_FORMAT ") > max value of size_t (" SIZE_FORMAT ")", (size_t)threshold, max_uintx);
-1); THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), st.as_string(), -1);
} }
MemoryPool* pool = get_memory_pool_from_jobject(obj, CHECK_(0L)); MemoryPool* pool = get_memory_pool_from_jobject(obj, CHECK_(0L));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册