Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/arguments.cpp @ 10241:d17700c82d7d
8006088: Incompatible heap size flags accepted by VM
Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing.
Reviewed-by: johnc, jwilhelm, tamao
author | tschatzl |
---|---|
date | Mon, 06 May 2013 17:19:42 +0200 |
parents | 30860066ae8f |
children | 194f52aa2f23 |
comparison
equal
deleted
inserted
replaced
10240:30860066ae8f | 10241:d17700c82d7d |
---|---|
1615 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max); | 1615 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max); |
1616 } | 1616 } |
1617 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max); | 1617 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max); |
1618 } | 1618 } |
1619 | 1619 |
1620 // If the initial_heap_size has not been set with InitialHeapSize | 1620 // If the minimum or initial heap_size have not been set or requested to be set |
1621 // or -Xms, then set it as fraction of the size of physical memory, | 1621 // ergonomically, set them accordingly. |
1622 // respecting the maximum and minimum sizes of the heap. | 1622 if (InitialHeapSize == 0 || min_heap_size() == 0) { |
1623 if (FLAG_IS_DEFAULT(InitialHeapSize)) { | |
1624 julong reasonable_minimum = (julong)(OldSize + NewSize); | 1623 julong reasonable_minimum = (julong)(OldSize + NewSize); |
1625 | 1624 |
1626 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); | 1625 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); |
1627 | 1626 |
1628 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); | 1627 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); |
1629 | 1628 |
1630 julong reasonable_initial = phys_mem / InitialRAMFraction; | 1629 if (InitialHeapSize == 0) { |
1631 | 1630 julong reasonable_initial = phys_mem / InitialRAMFraction; |
1632 reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); | 1631 |
1633 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); | 1632 reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size()); |
1634 | 1633 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); |
1635 reasonable_initial = limit_by_allocatable_memory(reasonable_initial); | 1634 |
1636 | 1635 reasonable_initial = limit_by_allocatable_memory(reasonable_initial); |
1637 if (PrintGCDetails && Verbose) { | 1636 |
1638 // Cannot use gclog_or_tty yet. | 1637 if (PrintGCDetails && Verbose) { |
1639 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); | 1638 // Cannot use gclog_or_tty yet. |
1640 tty->print_cr(" Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum); | 1639 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); |
1641 } | 1640 } |
1642 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); | 1641 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); |
1643 set_min_heap_size((uintx)reasonable_minimum); | 1642 } |
1643 // If the minimum heap size has not been set (via -Xms), | |
1644 // synchronize with InitialHeapSize to avoid errors with the default value. | |
1645 if (min_heap_size() == 0) { | |
1646 set_min_heap_size(MIN2((uintx)reasonable_minimum, InitialHeapSize)); | |
1647 if (PrintGCDetails && Verbose) { | |
1648 // Cannot use gclog_or_tty yet. | |
1649 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size()); | |
1650 } | |
1651 } | |
1644 } | 1652 } |
1645 } | 1653 } |
1646 | 1654 |
1647 // This must be called after ergonomics because we want bytecode rewriting | 1655 // This must be called after ergonomics because we want bytecode rewriting |
1648 // if the server compiler is used, or if UseSharedSpaces is disabled. | 1656 // if the server compiler is used, or if UseSharedSpaces is disabled. |
2424 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_eden_size); | 2432 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_eden_size); |
2425 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_eden_size); | 2433 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_eden_size); |
2426 // -Xms | 2434 // -Xms |
2427 } else if (match_option(option, "-Xms", &tail)) { | 2435 } else if (match_option(option, "-Xms", &tail)) { |
2428 julong long_initial_heap_size = 0; | 2436 julong long_initial_heap_size = 0; |
2429 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); | 2437 // an initial heap size of 0 means automatically determine |
2438 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0); | |
2430 if (errcode != arg_in_range) { | 2439 if (errcode != arg_in_range) { |
2431 jio_fprintf(defaultStream::error_stream(), | 2440 jio_fprintf(defaultStream::error_stream(), |
2432 "Invalid initial heap size: %s\n", option->optionString); | 2441 "Invalid initial heap size: %s\n", option->optionString); |
2433 describe_range_error(errcode); | 2442 describe_range_error(errcode); |
2434 return JNI_EINVAL; | 2443 return JNI_EINVAL; |
2435 } | 2444 } |
2436 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size); | 2445 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size); |
2437 // Currently the minimum size and the initial heap sizes are the same. | 2446 // Currently the minimum size and the initial heap sizes are the same. |
2438 set_min_heap_size(InitialHeapSize); | 2447 set_min_heap_size(InitialHeapSize); |
2439 // -Xmx | 2448 // -Xmx |
2440 } else if (match_option(option, "-Xmx", &tail)) { | 2449 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) { |
2441 julong long_max_heap_size = 0; | 2450 julong long_max_heap_size = 0; |
2442 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); | 2451 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); |
2443 if (errcode != arg_in_range) { | 2452 if (errcode != arg_in_range) { |
2444 jio_fprintf(defaultStream::error_stream(), | 2453 jio_fprintf(defaultStream::error_stream(), |
2445 "Invalid maximum heap size: %s\n", option->optionString); | 2454 "Invalid maximum heap size: %s\n", option->optionString); |