diff options
Diffstat (limited to 'src/share/vm/runtime')
-rw-r--r-- | src/share/vm/runtime/arguments.cpp | 55 | ||||
-rw-r--r-- | src/share/vm/runtime/globals.hpp | 2 | ||||
-rw-r--r-- | src/share/vm/runtime/os.cpp | 12 | ||||
-rw-r--r-- | src/share/vm/runtime/os.hpp | 2 | ||||
-rw-r--r-- | src/share/vm/runtime/serviceThread.cpp | 12 |
5 files changed, 59 insertions, 24 deletions
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp index b2ff4e5f9..bf149fcd0 100644 --- a/src/share/vm/runtime/arguments.cpp +++ b/src/share/vm/runtime/arguments.cpp @@ -747,16 +747,16 @@ void Arguments::add_string(char*** bldarray, int* count, const char* arg) { return; } - int index = *count; + int new_count = *count + 1; // expand the array and add arg to the last element - (*count)++; if (*bldarray == NULL) { - *bldarray = NEW_C_HEAP_ARRAY(char*, *count, mtInternal); + *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal); } else { - *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count, mtInternal); + *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal); } - (*bldarray)[index] = strdup(arg); + (*bldarray)[*count] = strdup(arg); + *count = new_count; } void Arguments::build_jvm_args(const char* arg) { @@ -1617,30 +1617,38 @@ void Arguments::set_heap_size() { FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max); } - // If the initial_heap_size has not been set with InitialHeapSize - // or -Xms, then set it as fraction of the size of physical memory, - // respecting the maximum and minimum sizes of the heap. - if (FLAG_IS_DEFAULT(InitialHeapSize)) { + // If the minimum or initial heap_size have not been set or requested to be set + // ergonomically, set them accordingly. + if (InitialHeapSize == 0 || min_heap_size() == 0) { julong reasonable_minimum = (julong)(OldSize + NewSize); reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); - julong reasonable_initial = phys_mem / InitialRAMFraction; + if (InitialHeapSize == 0) { + julong reasonable_initial = phys_mem / InitialRAMFraction; - reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); - reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); + reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size()); + reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); - reasonable_initial = limit_by_allocatable_memory(reasonable_initial); + reasonable_initial = limit_by_allocatable_memory(reasonable_initial); - if (PrintGCDetails && Verbose) { - // Cannot use gclog_or_tty yet. - tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); - tty->print_cr(" Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum); + if (PrintGCDetails && Verbose) { + // Cannot use gclog_or_tty yet. + tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); + } + FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); + } + // If the minimum heap size has not been set (via -Xms), + // synchronize with InitialHeapSize to avoid errors with the default value. + if (min_heap_size() == 0) { + set_min_heap_size(MIN2((uintx)reasonable_minimum, InitialHeapSize)); + if (PrintGCDetails && Verbose) { + // Cannot use gclog_or_tty yet. + tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size()); + } } - FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); - set_min_heap_size((uintx)reasonable_minimum); } } @@ -2043,6 +2051,10 @@ bool Arguments::check_vm_args_consistency() { "G1RefProcDrainInterval"); status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1, "G1ConcMarkStepDurationMillis"); + status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte, + "G1ConcRSHotCardLimit"); + status = status && verify_interval(G1ConcRSLogCacheSize, 0, 31, + "G1ConcRSLogCacheSize"); } #endif // INCLUDE_ALL_GCS @@ -2426,7 +2438,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, // -Xms } else if (match_option(option, "-Xms", &tail)) { julong long_initial_heap_size = 0; - ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); + // an initial heap size of 0 means automatically determine + ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0); if (errcode != arg_in_range) { jio_fprintf(defaultStream::error_stream(), "Invalid initial heap size: %s\n", option->optionString); @@ -2437,7 +2450,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, // Currently the minimum size and the initial heap sizes are the same. set_min_heap_size(InitialHeapSize); // -Xmx - } else if (match_option(option, "-Xmx", &tail)) { + } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) { julong long_max_heap_size = 0; ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); if (errcode != arg_in_range) { diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp index f927120dc..54c91f6b3 100644 --- a/src/share/vm/runtime/globals.hpp +++ b/src/share/vm/runtime/globals.hpp @@ -2968,7 +2968,7 @@ class CommandLineFlags { \ /* gc parameters */ \ product(uintx, InitialHeapSize, 0, \ - "Initial heap size (in bytes); zero means OldSize + NewSize") \ + "Initial heap size (in bytes); zero means use ergonomics") \ \ product(uintx, MaxHeapSize, ScaleForWordSize(96*M), \ "Maximum heap size (in bytes)") \ diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp index aff49e806..e9c5b2612 100644 --- a/src/share/vm/runtime/os.cpp +++ b/src/share/vm/runtime/os.cpp @@ -1457,6 +1457,18 @@ char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint) { return result; } + +char* os::reserve_memory(size_t bytes, char* addr, size_t alignment_hint, + MEMFLAGS flags) { + char* result = pd_reserve_memory(bytes, addr, alignment_hint); + if (result != NULL) { + MemTracker::record_virtual_memory_reserve((address)result, bytes, CALLER_PC); + MemTracker::record_virtual_memory_type((address)result, flags); + } + + return result; +} + char* os::attempt_reserve_memory_at(size_t bytes, char* addr) { char* result = pd_attempt_reserve_memory_at(bytes, addr); if (result != NULL) { diff --git a/src/share/vm/runtime/os.hpp b/src/share/vm/runtime/os.hpp index 2ea7b8b75..51fc54ddc 100644 --- a/src/share/vm/runtime/os.hpp +++ b/src/share/vm/runtime/os.hpp @@ -255,6 +255,8 @@ class os: AllStatic { static int vm_allocation_granularity(); static char* reserve_memory(size_t bytes, char* addr = 0, size_t alignment_hint = 0); + static char* reserve_memory(size_t bytes, char* addr, + size_t alignment_hint, MEMFLAGS flags); static char* reserve_memory_aligned(size_t size, size_t alignment); static char* attempt_reserve_memory_at(size_t bytes, char* addr); static void split_reserved_memory(char *base, size_t size, diff --git a/src/share/vm/runtime/serviceThread.cpp b/src/share/vm/runtime/serviceThread.cpp index 3c121e962..66d457252 100644 --- a/src/share/vm/runtime/serviceThread.cpp +++ b/src/share/vm/runtime/serviceThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,8 @@ #include "runtime/mutexLocker.hpp" #include "prims/jvmtiImpl.hpp" #include "services/gcNotifier.hpp" +#include "services/diagnosticArgument.hpp" +#include "services/diagnosticFramework.hpp" ServiceThread* ServiceThread::_instance = NULL; @@ -83,6 +85,7 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { bool sensors_changed = false; bool has_jvmti_events = false; bool has_gc_notification_event = false; + bool has_dcmd_notification_event = false; JvmtiDeferredEvent jvmti_event; { // Need state transition ThreadBlockInVM so that this thread @@ -98,7 +101,8 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); while (!(sensors_changed = LowMemoryDetector::has_pending_requests()) && !(has_jvmti_events = JvmtiDeferredEventQueue::has_events()) && - !(has_gc_notification_event = GCNotifier::has_event())) { + !(has_gc_notification_event = GCNotifier::has_event()) && + !(has_dcmd_notification_event = DCmdFactory::has_pending_jmx_notification())) { // wait until one of the sensors has pending requests, or there is a // pending JVMTI event or JMX GC notification to post Service_lock->wait(Mutex::_no_safepoint_check_flag); @@ -120,6 +124,10 @@ void ServiceThread::service_thread_entry(JavaThread* jt, TRAPS) { if(has_gc_notification_event) { GCNotifier::sendNotification(CHECK); } + + if(has_dcmd_notification_event) { + DCmdFactory::send_notification(CHECK); + } } } |