# HG changeset patch # User kvn # Date 1264524804 28800 # Node ID 99af867dfa05d439db19552ed74790260eee24ae # Parent cf0685d550f119a9da2689553f8189810255e706 6919886: Sweep CodeCache more aggressively to reduce its usage for CompileTheWorld Summary: Add safepoint after CompileTheWorldSafepointInterval (100) compilations and do full sweep of CodeCache each time. Reviewed-by: never Contributed-by: eric.caspole@amd.com diff -r cf0685d550f1 -r 99af867dfa05 src/share/vm/classfile/classLoader.cpp --- a/src/share/vm/classfile/classLoader.cpp Wed Jan 20 22:10:33 2010 -0800 +++ b/src/share/vm/classfile/classLoader.cpp Tue Jan 26 08:53:24 2010 -0800 @@ -1249,6 +1249,7 @@ } int ClassLoader::_compile_the_world_counter = 0; +static int _codecache_sweep_counter = 0; void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { int len = (int)strlen(name); @@ -1293,6 +1294,13 @@ for (int n = 0; n < k->methods()->length(); n++) { methodHandle m (THREAD, methodOop(k->methods()->obj_at(n))); if (CompilationPolicy::canBeCompiled(m)) { + + if (++_codecache_sweep_counter == CompileTheWorldSafepointInterval) { + // Give sweeper a chance to keep up with CTW + VM_ForceSafepoint op; + VMThread::execute(&op); + _codecache_sweep_counter = 0; + } // Force compilation CompileBroker::compile_method(m, InvocationEntryBci, methodHandle(), 0, "CTW", THREAD); diff -r cf0685d550f1 -r 99af867dfa05 src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Wed Jan 20 22:10:33 2010 -0800 +++ b/src/share/vm/runtime/arguments.cpp Tue Jan 26 08:53:24 2010 -0800 @@ -2815,6 +2815,15 @@ DebugNonSafepoints = true; } +#ifndef PRODUCT + if (CompileTheWorld) { + // Force NmethodSweeper to sweep whole CodeCache each time. + if (FLAG_IS_DEFAULT(NmethodSweepFraction)) { + NmethodSweepFraction = 1; + } + } +#endif + if (PrintCommandLineFlags) { CommandLineFlags::printSetFlags(); } diff -r cf0685d550f1 -r 99af867dfa05 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Wed Jan 20 22:10:33 2010 -0800 +++ b/src/share/vm/runtime/globals.hpp Tue Jan 26 08:53:24 2010 -0800 @@ -2447,6 +2447,9 @@ notproduct(bool, CompileTheWorldIgnoreInitErrors, false, \ "Compile all methods although class initializer failed") \ \ + notproduct(intx, CompileTheWorldSafepointInterval, 100, \ + "Force a safepoint every n compiles so sweeper can keep up") \ + \ develop(bool, TraceIterativeGVN, false, \ "Print progress during Iterative Global Value Numbering") \ \