src/share/vm/code/codeCache.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/code/codeCache.cpp	Tue Sep 30 15:26:14 2014
--- new/src/share/vm/code/codeCache.cpp	Tue Sep 30 15:26:13 2014

*** 156,207 **** --- 156,207 ---- // Initial size of constant table (this may be increased if a compiled method needs more space) code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size(); #endif // Calculate default CodeHeap sizes if not set by user ! if (!FLAG_IS_CMDLINE(NonMethodCodeHeapSize) && !FLAG_IS_CMDLINE(ProfiledCodeHeapSize) ! if (!FLAG_IS_CMDLINE(NonNMethodCodeHeapSize) && !FLAG_IS_CMDLINE(ProfiledCodeHeapSize) && !FLAG_IS_CMDLINE(NonProfiledCodeHeapSize)) { ! // Increase default NonMethodCodeHeapSize to account for compiler buffers ! FLAG_SET_ERGO(uintx, NonMethodCodeHeapSize, NonMethodCodeHeapSize + code_buffers_size); ! // Increase default NonNMethodCodeHeapSize to account for compiler buffers ! FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + code_buffers_size); ! // Check if we have enough space for the non-nmethod code heap ! if (ReservedCodeCacheSize > NonMethodCodeHeapSize) { ! // Use the default value for NonMethodCodeHeapSize and one half of the ! if (ReservedCodeCacheSize > NonNMethodCodeHeapSize) { ! // Use the default value for NonNMethodCodeHeapSize and one half of the // remaining size for non-profiled methods and one half for profiled methods ! size_t remaining_size = ReservedCodeCacheSize - NonMethodCodeHeapSize; ! size_t remaining_size = ReservedCodeCacheSize - NonNMethodCodeHeapSize; size_t profiled_size = remaining_size / 2; size_t non_profiled_size = remaining_size - profiled_size; FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size); } else { ! // Use all space for the non-nmethod heap and set other heaps to minimal size ! FLAG_SET_ERGO(uintx, NonMethodCodeHeapSize, ReservedCodeCacheSize - os::vm_page_size() * 2); ! FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, ReservedCodeCacheSize - os::vm_page_size() * 2); FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, os::vm_page_size()); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, os::vm_page_size()); } } // We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap if(!heap_available(CodeBlobType::MethodProfiled)) { FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize + ProfiledCodeHeapSize); FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, 0); } ! // We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap if(!heap_available(CodeBlobType::MethodNonProfiled)) { ! FLAG_SET_ERGO(uintx, NonMethodCodeHeapSize, NonMethodCodeHeapSize + NonProfiledCodeHeapSize); ! FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + NonProfiledCodeHeapSize); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 0); } // Make sure we have enough space for VM internal code uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace; ! if (NonMethodCodeHeapSize < (min_code_cache_size + code_buffers_size)) { ! vm_exit_during_initialization("Not enough space in non-method code heap to run VM."); ! if (NonNMethodCodeHeapSize < (min_code_cache_size + code_buffers_size)) { ! vm_exit_during_initialization("Not enough space in non-nmethod code heap to run VM."); } ! guarantee(NonProfiledCodeHeapSize + ProfiledCodeHeapSize + NonMethodCodeHeapSize <= ReservedCodeCacheSize, "Size check"); ! guarantee(NonProfiledCodeHeapSize + ProfiledCodeHeapSize + NonNMethodCodeHeapSize <= ReservedCodeCacheSize, "Size check"); // Align reserved sizes of CodeHeaps ! size_t non_method_size = ReservedCodeSpace::allocation_align_size_up(NonMethodCodeHeapSize); ! size_t non_method_size = ReservedCodeSpace::allocation_align_size_up(NonNMethodCodeHeapSize); size_t profiled_size = ReservedCodeSpace::allocation_align_size_up(ProfiledCodeHeapSize); size_t non_profiled_size = ReservedCodeSpace::allocation_align_size_up(NonProfiledCodeHeapSize); // Compute initial sizes of CodeHeaps size_t init_non_method_size = MIN2(InitialCodeCacheSize, non_method_size);
*** 211,234 **** --- 211,234 ---- // Reserve one continuous chunk of memory for CodeHeaps and split it into // parts for the individual heaps. The memory layout looks like this: // ---------- high ----------- // Non-profiled nmethods // Profiled nmethods ! // Non-nmethods // ---------- low ------------ ReservedCodeSpace rs = reserve_heap_memory(non_profiled_size + profiled_size + non_method_size); ReservedSpace non_method_space = rs.first_part(non_method_size); ReservedSpace rest = rs.last_part(non_method_size); ReservedSpace profiled_space = rest.first_part(profiled_size); ReservedSpace non_profiled_space = rest.last_part(profiled_size); ! // Non-nmethods (stubs, adapters, ...) ! add_heap(non_method_space, "Code Heap 'non-methods'", init_non_method_size, CodeBlobType::NonMethod); ! add_heap(non_method_space, "CodeHeap 'non-nmethods'", init_non_method_size, CodeBlobType::NonNMethod); // Tier 2 and tier 3 (profiled) methods - add_heap(profiled_space, "Code Heap 'profiled nmethods'", init_profiled_size, CodeBlobType::MethodProfiled); // Tier 1 and tier 4 (non-profiled) methods and native methods - add_heap(non_profiled_space, "Code Heap 'non-profiled nmethods'", init_non_profiled_size, CodeBlobType::MethodNonProfiled); } ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) { // Determine alignment const size_t page_size = os::can_execute_large_page_memory() ?
*** 255,271 **** --- 255,271 ---- // No segmentation: use a single code heap return (code_blob_type == CodeBlobType::All); } else if ((Arguments::mode() == Arguments::_int) || (TieredStopAtLevel == CompLevel_none)) { // Interpreter only: we don't need any method code heaps ! return (code_blob_type == CodeBlobType::NonMethod); ! return (code_blob_type == CodeBlobType::NonNMethod); } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) { // Tiered compilation: use all code heaps return (code_blob_type < CodeBlobType::All); } else { ! // No TieredCompilation: we only need the non-nmethod and non-profiled code heap ! return (code_blob_type == CodeBlobType::NonMethod) || ! return (code_blob_type == CodeBlobType::NonNMethod) || (code_blob_type == CodeBlobType::MethodNonProfiled); } } void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type) {
*** 353,374 **** --- 353,374 ---- while (true) { cb = (CodeBlob*)heap->allocate(size, is_critical); if (cb != NULL) break; if (!heap->expand_by(CodeCacheExpansionSize)) { // Expansion failed ! if (SegmentedCodeCache && (code_blob_type == CodeBlobType::NonMethod)) { ! // Fallback solution: Store non-method code in the non-profiled code heap ! if (SegmentedCodeCache && (code_blob_type == CodeBlobType::NonNMethod)) { ! // Fallback solution: Store non-nmethod code in the non-profiled code heap return allocate(size, CodeBlobType::MethodNonProfiled, is_critical); } return NULL; } if (PrintCodeCacheExtension) { ResourceMark rm; if (SegmentedCodeCache) { tty->print("%s", heap->name()); } else { - tty->print("Code Cache"); } tty->print_cr(" extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)", (intptr_t)heap->low_boundary(), (intptr_t)heap->high(), (address)heap->high() - (address)heap->low_boundary()); }
*** 818,828 **** --- 818,828 ---- // Use multiple code heaps initialize_heaps(); } else { // Use a single code heap ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); - add_heap(rs, "Code Cache", InitialCodeCacheSize, CodeBlobType::All); } // Initialize ICache flush mechanism // This service is needed for os::register_code_area icache_init();
*** 1239,1249 **** --- 1239,1249 ---- CodeHeap* heap = (*heap_iterator); size_t total = (heap->high_boundary() - heap->low_boundary()); if (SegmentedCodeCache) { st->print("%s:", heap->name()); } else { - st->print("Code Cache:"); } st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb", total/K, (total - heap->unallocated_capacity())/K, heap->max_allocated_capacity()/K, heap->unallocated_capacity()/K);

src/share/vm/code/codeCache.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File