< prev index next >

src/hotspot/share/compiler/compileBroker.cpp

Print this page
rev 49285 : [mq]: 8198691.patch


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"

  31 #include "code/dependencyContext.hpp"
  32 #include "compiler/compileBroker.hpp"
  33 #include "compiler/compileLog.hpp"
  34 #include "compiler/compilerOracle.hpp"
  35 #include "compiler/directivesParser.hpp"
  36 #include "interpreter/linkResolver.hpp"
  37 #include "logging/log.hpp"
  38 #include "logging/logStream.hpp"
  39 #include "memory/allocation.inline.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "oops/methodData.hpp"
  42 #include "oops/method.inline.hpp"
  43 #include "oops/oop.inline.hpp"
  44 #include "prims/nativeLookup.hpp"
  45 #include "prims/whitebox.hpp"
  46 #include "runtime/arguments.hpp"
  47 #include "runtime/atomic.hpp"
  48 #include "runtime/compilationPolicy.hpp"
  49 #include "runtime/init.hpp"
  50 #include "runtime/interfaceSupport.inline.hpp"


2405   int bps = tcs == 0.0 ? 0 : (int)(tcb / tcs);
2406   tty->print_cr("  Average compilation speed : %8d bytes/s", bps);
2407   tty->cr();
2408   tty->print_cr("  nmethod code size         : %8d bytes", nmethods_code_size);
2409   tty->print_cr("  nmethod total size        : %8d bytes", nmethods_size);
2410 }
2411 
2412 // Debugging output for failure
2413 void CompileBroker::print_last_compile() {
2414   if (_last_compile_level != CompLevel_none &&
2415       compiler(_last_compile_level) != NULL &&
2416       _last_compile_type != no_compile) {
2417     if (_last_compile_type == osr_compile) {
2418       tty->print_cr("Last parse:  [osr]%d+++(%d) %s",
2419                     _osr_compilation_id, _last_compile_level, _last_method_compiled);
2420     } else {
2421       tty->print_cr("Last parse:  %d+++(%d) %s",
2422                     _compilation_id, _last_compile_level, _last_method_compiled);
2423     }
2424   }












































































































2425 }


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/codeHeapState.hpp"
  32 #include "code/dependencyContext.hpp"
  33 #include "compiler/compileBroker.hpp"
  34 #include "compiler/compileLog.hpp"
  35 #include "compiler/compilerOracle.hpp"
  36 #include "compiler/directivesParser.hpp"
  37 #include "interpreter/linkResolver.hpp"
  38 #include "logging/log.hpp"
  39 #include "logging/logStream.hpp"
  40 #include "memory/allocation.inline.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "oops/methodData.hpp"
  43 #include "oops/method.inline.hpp"
  44 #include "oops/oop.inline.hpp"
  45 #include "prims/nativeLookup.hpp"
  46 #include "prims/whitebox.hpp"
  47 #include "runtime/arguments.hpp"
  48 #include "runtime/atomic.hpp"
  49 #include "runtime/compilationPolicy.hpp"
  50 #include "runtime/init.hpp"
  51 #include "runtime/interfaceSupport.inline.hpp"


2406   int bps = tcs == 0.0 ? 0 : (int)(tcb / tcs);
2407   tty->print_cr("  Average compilation speed : %8d bytes/s", bps);
2408   tty->cr();
2409   tty->print_cr("  nmethod code size         : %8d bytes", nmethods_code_size);
2410   tty->print_cr("  nmethod total size        : %8d bytes", nmethods_size);
2411 }
2412 
2413 // Debugging output for failure
2414 void CompileBroker::print_last_compile() {
2415   if (_last_compile_level != CompLevel_none &&
2416       compiler(_last_compile_level) != NULL &&
2417       _last_compile_type != no_compile) {
2418     if (_last_compile_type == osr_compile) {
2419       tty->print_cr("Last parse:  [osr]%d+++(%d) %s",
2420                     _osr_compilation_id, _last_compile_level, _last_method_compiled);
2421     } else {
2422       tty->print_cr("Last parse:  %d+++(%d) %s",
2423                     _compilation_id, _last_compile_level, _last_method_compiled);
2424     }
2425   }
2426 }
2427 
2428 // Print general/accumulated JIT information.
2429 void CompileBroker::print_info(outputStream *out) {
2430   if (out == NULL) out = tty;
2431   out->cr();
2432   out->print_cr("======================");
2433   out->print_cr("   General JIT info   ");
2434   out->print_cr("======================");
2435   out->cr();
2436   out->print_cr("            JIT is : %7s",     should_compile_new_jobs() ? "on" : "off");
2437   out->print_cr("  Compiler threads : %7d",     (int)CICompilerCount);
2438   out->cr();
2439   out->print_cr("CodeCache overview");
2440   out->print_cr("--------------------------------------------------------");
2441   out->cr();
2442   out->print_cr("         Reserved size : " SIZE_FORMAT_W(7) " KB", CodeCache::max_capacity() / K);
2443   out->print_cr("        Committed size : " SIZE_FORMAT_W(7) " KB", CodeCache::capacity() / K);
2444   out->print_cr("  Unallocated capacity : " SIZE_FORMAT_W(7) " KB", CodeCache::unallocated_capacity() / K);
2445   out->cr();
2446 
2447   out->cr();
2448   out->print_cr("CodeCache cleaning overview");
2449   out->print_cr("--------------------------------------------------------");
2450   out->cr();
2451   NMethodSweeper::print(out);
2452   out->print_cr("--------------------------------------------------------");
2453   out->cr();
2454 }
2455 
2456 // Note: tty_lock must not be held upon entry to this function.
2457 //       Print functions called from herein do "micro-locking" on tty_lock.
2458 //       That's a tradeoff which keeps together important blocks of output.
2459 //       At the same time, continuous tty_lock hold time is kept in check,
2460 //       preventing concurrently printing threads from stalling a long time.
2461 void CompileBroker::print_heapinfo(outputStream* out, const char* function, const char* granularity) {
2462   TimeStamp ts_total;
2463   TimeStamp ts;
2464 
2465   bool allFun = !strcmp(function, "all");
2466   bool aggregate = !strcmp(function, "aggregate") || !strcmp(function, "analyze") || allFun;
2467   bool usedSpace = !strcmp(function, "UsedSpace") || allFun;
2468   bool freeSpace = !strcmp(function, "FreeSpace") || allFun;
2469   bool methodCount = !strcmp(function, "MethodCount") || allFun;
2470   bool methodSpace = !strcmp(function, "MethodSpace") || allFun;
2471   bool methodAge = !strcmp(function, "MethodAge") || allFun;
2472   bool methodNames = !strcmp(function, "MethodNames") || allFun;
2473   bool discard = !strcmp(function, "discard") || allFun;
2474 
2475   if (out == NULL) {
2476     out = tty;
2477   }
2478 
2479   if (!(aggregate || usedSpace || freeSpace || methodCount || methodSpace || methodAge || methodNames || discard)) {
2480     out->print_cr("\n__ CodeHeapStateAnalytics: Function %s is not supported", function);
2481     out->cr();
2482     return;
2483   }
2484 
2485   ts_total.update(); // record starting point
2486 
2487   if (aggregate) {
2488     print_info(out);
2489   }
2490 
2491   // We hold the CodeHeapStateAnalytics_lock all the time, from here until we leave this function.
2492   // That helps us getting a consistent view on the CodeHeap, at least for the "all" function.
2493   // When we request individual parts of the analysis via the jcmd interface, it is possible
2494   // that in between another thread (another jcmd user or the vm running into CodeCache OOM)
2495   // updated the aggregated data. That's a tolerable tradeoff because we can't hold a lock
2496   // across user interaction.
2497   ts.update(); // record starting point
2498   MutexLockerEx mu1(CodeHeapStateAnalytics_lock, Mutex::_no_safepoint_check_flag);
2499   out->cr();
2500   out->print_cr("__ CodeHeapStateAnalytics lock wait took %10.3f seconds _________", ts.seconds());
2501   out->cr();
2502 
2503   if (aggregate) {
2504     // It is sufficient to hold the CodeCache_lock only for the aggregate step.
2505     // All other functions operate on aggregated data - except MethodNames, but that should be safe.
2506     // The separate CodeHeapStateAnalytics_lock protects the printing functions against
2507     // concurrent aggregate steps. Acquire this lock before acquiring the CodeCache_lock.
2508     // CodeHeapStateAnalytics_lock could be held by a concurrent thread for a long time,
2509     // leading to an unnecessarily long hold time of the CodeCache_lock.
2510     ts.update(); // record starting point
2511     MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
2512     out->cr();
2513     out->print_cr("__ CodeCache lock wait took %10.3f seconds _________", ts.seconds());
2514     out->cr();
2515 
2516     ts.update(); // record starting point
2517     CodeCache::aggregate(out, granularity);
2518     out->cr();
2519     out->print_cr("__ CodeCache lock hold took %10.3f seconds _________", ts.seconds());
2520     out->cr();
2521   }
2522 
2523   if (usedSpace) CodeCache::print_usedSpace(out);
2524   if (freeSpace) CodeCache::print_freeSpace(out);
2525   if (methodCount) CodeCache::print_count(out);
2526   if (methodSpace) CodeCache::print_space(out);
2527   if (methodAge) CodeCache::print_age(out);
2528   if (methodNames) CodeCache::print_names(out);
2529   if (discard) CodeCache::discard(out);
2530 
2531   out->cr();
2532   out->print_cr("__ CodeHeapStateAnalytics total duration %10.3f seconds _________", ts_total.seconds());
2533   out->cr();
2534 }
< prev index next >