< prev index next >

src/hotspot/share/compiler/compileBroker.cpp

Print this page
rev 49260 : [mq]: 8198691.patch
   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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"


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

































































































2424 }
   1 /*
   2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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"


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 }
2426 
2427 // Print general/accumulated JIT information.
2428 void CompileBroker::print_info(outputStream *out) {
2429   if (out == NULL) out = tty;
2430   out->cr();
2431   out->print_cr("======================");
2432   out->print_cr("   General JIT info   ");
2433   out->print_cr("======================");
2434   out->cr();
2435   out->print_cr("            JIT is : %7s",     should_compile_new_jobs() ? "on" : "off");
2436   out->print_cr("  Compiler threads : %7d",     (int)CICompilerCount);
2437   out->cr();
2438   out->print_cr("CodeCache overview");
2439   out->print_cr("--------------------------------------------------------");
2440   out->cr();
2441   out->print_cr("         Reserved size : " SIZE_FORMAT_W(7) " KB", CodeCache::max_capacity() / K);
2442   out->print_cr("        Committed size : " SIZE_FORMAT_W(7) " KB", CodeCache::capacity() / K);
2443   out->print_cr("  Unallocated capacity : " SIZE_FORMAT_W(7) " KB", CodeCache::unallocated_capacity() / K);
2444   out->cr();
2445 
2446   out->cr();
2447   out->print_cr("CodeCache cleaning overview");
2448   out->print_cr("--------------------------------------------------------");
2449   out->cr();
2450   NMethodSweeper::print(out);
2451   out->print_cr("--------------------------------------------------------");
2452   out->cr();
2453 }
2454 
2455 void CompileBroker::print_heapinfo(outputStream* out, const char* function, const char* granularity) {
2456   TimeStamp ts_total;
2457   TimeStamp ts;
2458 
2459   bool allFun = !strcmp(function, "all");
2460   bool aggregate = !strcmp(function, "aggregate") || !strcmp(function, "analyze") || allFun;
2461   bool usedSpace = !strcmp(function, "UsedSpace") || allFun;
2462   bool freeSpace = !strcmp(function, "FreeSpace") || allFun;
2463   bool methodCount = !strcmp(function, "MethodCount") || allFun;
2464   bool methodSpace = !strcmp(function, "MethodSpace") || allFun;
2465   bool methodAge = !strcmp(function, "MethodAge") || allFun;
2466   bool methodNames = !strcmp(function, "MethodNames") || allFun;
2467   bool discard = !strcmp(function, "discard") || allFun;
2468 
2469   if (out == NULL) {
2470     out = tty;
2471   }
2472 
2473   if (!(aggregate || usedSpace || freeSpace || methodCount || methodSpace || methodAge || methodNames || discard)) {
2474     out->print_cr("\n__ CodeHeapStateAnalytics: Function %s is not supported", function);
2475     out->cr();
2476     return;
2477   }
2478 
2479   ts_total.update(); // record starting point
2480 
2481   if (aggregate) {
2482     print_info(out);
2483   }
2484 
2485   ts.update(); // record starting point
2486   MutexLockerEx mu(CodeHeapStateAnalytics_lock, Mutex::_no_safepoint_check_flag);
2487   out->cr();
2488   out->print_cr("__ CodeHeapStateAnalytics lock wait took %10.3f seconds _________", ts.seconds());
2489   out->cr();
2490 
2491   if (aggregate) {
2492     // It should be sufficient to hold the CodeCache_lock only for the aggregate step.
2493     // All other functions operate on aggregated data - except MethodNames, but that should be safe.
2494     // The separate CodeHeapStateAnalytics_lock protects the printing functions against
2495     // concurrent aggregate steps. Acquire this lock before acquiring the CodeCache_lock.
2496     // CodeHeapStateAnalytics_lock could be held by a concurrent thread for a long time,
2497     // leading to an unnecessarily long hold time of the CodeCache_lock.
2498     ts.update(); // record starting point
2499     MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
2500     out->cr();
2501     out->print_cr("__ CodeCache lock wait took %10.3f seconds _________", ts.seconds());
2502     out->cr();
2503 
2504     ts.update(); // record starting point
2505     CodeCache::aggregate(out, granularity);
2506     out->cr();
2507     out->print_cr("__ CodeCache lock hold took %10.3f seconds _________", ts.seconds());
2508     out->cr();
2509   }
2510 
2511   if (usedSpace) CodeCache::print_usedSpace(out);
2512   if (freeSpace) CodeCache::print_freeSpace(out);
2513   if (methodCount) CodeCache::print_count(out);
2514   if (methodSpace) CodeCache::print_space(out);
2515   if (methodAge) CodeCache::print_age(out);
2516   if (methodNames) CodeCache::print_names(out);
2517   if (discard) CodeCache::discard(out);
2518 
2519   out->cr();
2520   out->print_cr("__ CodeHeapStateAnalytics total duration %10.3f seconds _________", ts_total.seconds());
2521   out->cr();
2522 }
< prev index next >