提交 2115a695 编写于 作者: V vladidan

8005204: Code Cache Reduction: command line options implementation

Summary: Adding more detailed output on CodeCache usage
Reviewed-by: kvn, vladidan
Contributed-by: NAlexander Harlap <alexander.harlap@oracle.com>
上级 52bd9ff0
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "code/icBuffer.hpp" #include "code/icBuffer.hpp"
#include "code/nmethod.hpp" #include "code/nmethod.hpp"
#include "code/pcDesc.hpp" #include "code/pcDesc.hpp"
#include "compiler/compileBroker.hpp"
#include "gc_implementation/shared/markSweep.hpp" #include "gc_implementation/shared/markSweep.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/gcLocker.hpp" #include "memory/gcLocker.hpp"
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
#include "oops/objArrayOop.hpp" #include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp" #include "runtime/handles.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/icache.hpp" #include "runtime/icache.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/mutexLocker.hpp" #include "runtime/mutexLocker.hpp"
...@@ -168,6 +170,8 @@ nmethod* CodeCache::next_nmethod (CodeBlob* cb) { ...@@ -168,6 +170,8 @@ nmethod* CodeCache::next_nmethod (CodeBlob* cb) {
return (nmethod*)cb; return (nmethod*)cb;
} }
static size_t maxCodeCacheUsed = 0;
CodeBlob* CodeCache::allocate(int size) { CodeBlob* CodeCache::allocate(int size) {
// Do not seize the CodeCache lock here--if the caller has not // Do not seize the CodeCache lock here--if the caller has not
// already done so, we are going to lose bigtime, since the code // already done so, we are going to lose bigtime, since the code
...@@ -192,6 +196,8 @@ CodeBlob* CodeCache::allocate(int size) { ...@@ -192,6 +196,8 @@ CodeBlob* CodeCache::allocate(int size) {
(address)_heap->end() - (address)_heap->begin()); (address)_heap->end() - (address)_heap->begin());
} }
} }
maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
(address)_heap->low_boundary()) - unallocated_capacity());
verify_if_often(); verify_if_often();
print_trace("allocation", cb, size); print_trace("allocation", cb, size);
return cb; return cb;
...@@ -928,7 +934,14 @@ void CodeCache::print_internals() { ...@@ -928,7 +934,14 @@ void CodeCache::print_internals() {
FREE_C_HEAP_ARRAY(int, buckets, mtCode); FREE_C_HEAP_ARRAY(int, buckets, mtCode);
} }
#endif // !PRODUCT
void CodeCache::print() { void CodeCache::print() {
print_summary(tty);
#ifndef PRODUCT
if (!Verbose) return;
CodeBlob_sizes live; CodeBlob_sizes live;
CodeBlob_sizes dead; CodeBlob_sizes dead;
...@@ -953,7 +966,7 @@ void CodeCache::print() { ...@@ -953,7 +966,7 @@ void CodeCache::print() {
} }
if (Verbose) { if (WizardMode) {
// print the oop_map usage // print the oop_map usage
int code_size = 0; int code_size = 0;
int number_of_blobs = 0; int number_of_blobs = 0;
...@@ -977,20 +990,30 @@ void CodeCache::print() { ...@@ -977,20 +990,30 @@ void CodeCache::print() {
tty->print_cr(" map size = %d", map_size); tty->print_cr(" map size = %d", map_size);
} }
#endif // !PRODUCT
} }
#endif // PRODUCT void CodeCache::print_summary(outputStream* st, bool detailed) {
size_t total = (_heap->high_boundary() - _heap->low_boundary());
void CodeCache::print_bounds(outputStream* st) { st->print_cr("CodeCache: size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT
st->print_cr("Code Cache [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT
_heap->low_boundary(), "Kb max_free_chunk=" SIZE_FORMAT "Kb",
_heap->high(), total/K, (total - unallocated_capacity())/K,
_heap->high_boundary()); maxCodeCacheUsed/K, unallocated_capacity()/K, largest_free_block()/K);
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
" adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT "Kb" if (detailed) {
" largest_free_block=" SIZE_FORMAT, st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
nof_blobs(), nof_nmethods(), nof_adapters(), _heap->low_boundary(),
unallocated_capacity()/K, largest_free_block()); _heap->high(),
_heap->high_boundary());
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
" adapters=" UINT32_FORMAT,
nof_blobs(), nof_nmethods(), nof_adapters());
st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
"enabled" : Arguments::mode() == Arguments::_int ?
"disabled (interpreter mode)" :
"disabled (not enough contiguous free space left)");
}
} }
void CodeCache::log_state(outputStream* st) { void CodeCache::log_state(outputStream* st) {
......
...@@ -145,11 +145,11 @@ class CodeCache : AllStatic { ...@@ -145,11 +145,11 @@ class CodeCache : AllStatic {
static void prune_scavenge_root_nmethods(); static void prune_scavenge_root_nmethods();
// Printing/debugging // Printing/debugging
static void print() PRODUCT_RETURN; // prints summary static void print(); // prints summary
static void print_internals(); static void print_internals();
static void verify(); // verifies the code cache static void verify(); // verifies the code cache
static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN; static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN;
static void print_bounds(outputStream* st); // Prints a summary of the bounds of the code cache static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage
static void log_state(outputStream* st); static void log_state(outputStream* st);
// The full limits of the codeCache // The full limits of the codeCache
......
...@@ -1714,6 +1714,20 @@ void CompileBroker::maybe_block() { ...@@ -1714,6 +1714,20 @@ void CompileBroker::maybe_block() {
} }
} }
// wrapper for CodeCache::print_summary()
static void codecache_print(bool detailed)
{
ResourceMark rm;
stringStream s;
// Dump code cache into a buffer before locking the tty,
{
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
CodeCache::print_summary(&s, detailed);
}
ttyLocker ttyl;
tty->print_cr(s.as_string());
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// CompileBroker::invoke_compiler_on_method // CompileBroker::invoke_compiler_on_method
// //
...@@ -1841,6 +1855,9 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { ...@@ -1841,6 +1855,9 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
tty->print_cr("size: %d time: %d inlined: %d bytes", code_size, (int)time.milliseconds(), task->num_inlined_bytecodes()); tty->print_cr("size: %d time: %d inlined: %d bytes", code_size, (int)time.milliseconds(), task->num_inlined_bytecodes());
} }
if (PrintCodeCacheOnCompilation)
codecache_print(/* detailed= */ false);
// Disable compilation, if required. // Disable compilation, if required.
switch (compilable) { switch (compilable) {
case ciEnv::MethodCompilable_never: case ciEnv::MethodCompilable_never:
...@@ -1885,6 +1902,7 @@ void CompileBroker::handle_full_code_cache() { ...@@ -1885,6 +1902,7 @@ void CompileBroker::handle_full_code_cache() {
UseInterpreter = true; UseInterpreter = true;
if (UseCompiler || AlwaysCompileLoopMethods ) { if (UseCompiler || AlwaysCompileLoopMethods ) {
if (xtty != NULL) { if (xtty != NULL) {
ResourceMark rm;
stringStream s; stringStream s;
// Dump code cache state into a buffer before locking the tty, // Dump code cache state into a buffer before locking the tty,
// because log_state() will use locks causing lock conflicts. // because log_state() will use locks causing lock conflicts.
...@@ -1898,9 +1916,9 @@ void CompileBroker::handle_full_code_cache() { ...@@ -1898,9 +1916,9 @@ void CompileBroker::handle_full_code_cache() {
} }
warning("CodeCache is full. Compiler has been disabled."); warning("CodeCache is full. Compiler has been disabled.");
warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
CodeCache::print_bounds(tty);
#ifndef PRODUCT #ifndef PRODUCT
if (CompileTheWorld || ExitOnFullCodeCache) { if (CompileTheWorld || ExitOnFullCodeCache) {
codecache_print(/* detailed= */ true);
before_exit(JavaThread::current()); before_exit(JavaThread::current());
exit_globals(); // will delete tty exit_globals(); // will delete tty
vm_direct_exit(CompileTheWorld ? 0 : 1); vm_direct_exit(CompileTheWorld ? 0 : 1);
...@@ -1913,6 +1931,7 @@ void CompileBroker::handle_full_code_cache() { ...@@ -1913,6 +1931,7 @@ void CompileBroker::handle_full_code_cache() {
AlwaysCompileLoopMethods = false; AlwaysCompileLoopMethods = false;
} }
} }
codecache_print(/* detailed= */ true);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
......
...@@ -929,11 +929,14 @@ class CommandLineFlags { ...@@ -929,11 +929,14 @@ class CommandLineFlags {
"Starts debugger when an implicit OS (e.g., NULL) " \ "Starts debugger when an implicit OS (e.g., NULL) " \
"exception happens") \ "exception happens") \
\ \
notproduct(bool, PrintCodeCache, false, \ product(bool, PrintCodeCache, false, \
"Print the compiled_code cache when exiting") \ "Print the code cache memory usage when exiting") \
\ \
develop(bool, PrintCodeCache2, false, \ develop(bool, PrintCodeCache2, false, \
"Print detailed info on the compiled_code cache when exiting") \ "Print detailed usage info on the code cache when exiting") \
\
product(bool, PrintCodeCacheOnCompilation, false, \
"Print the code cache memory usage each time a method is compiled") \
\ \
diagnostic(bool, PrintStubCode, false, \ diagnostic(bool, PrintStubCode, false, \
"Print generated stub code") \ "Print generated stub code") \
......
...@@ -368,6 +368,12 @@ void print_statistics() { ...@@ -368,6 +368,12 @@ void print_statistics() {
if (CITime) { if (CITime) {
CompileBroker::print_times(); CompileBroker::print_times();
} }
if (PrintCodeCache) {
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
CodeCache::print();
}
#ifdef COMPILER2 #ifdef COMPILER2
if (PrintPreciseBiasedLockingStatistics) { if (PrintPreciseBiasedLockingStatistics) {
OptoRuntime::print_named_counters(); OptoRuntime::print_named_counters();
......
...@@ -702,7 +702,7 @@ void VMError::report(outputStream* st) { ...@@ -702,7 +702,7 @@ void VMError::report(outputStream* st) {
if (_verbose && Universe::is_fully_initialized()) { if (_verbose && Universe::is_fully_initialized()) {
// print code cache information before vm abort // print code cache information before vm abort
CodeCache::print_bounds(st); CodeCache::print_summary(st);
st->cr(); st->cr();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册