Wed, 15 Feb 2012 16:29:40 -0800
7142680: default GC affected by jvm path
Summary: Removed old tiered code
Reviewed-by: never, kvn
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 27 | #include "code/codeCache.hpp" |
stefank@2314 | 28 | #include "gc_interface/collectedHeap.inline.hpp" |
stefank@2314 | 29 | #include "interpreter/oopMapCache.hpp" |
stefank@2314 | 30 | #include "memory/generation.hpp" |
stefank@2314 | 31 | #include "memory/permGen.hpp" |
stefank@2314 | 32 | #include "memory/resourceArea.hpp" |
stefank@2314 | 33 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 34 | #include "runtime/jniHandles.hpp" |
stefank@2314 | 35 | #include "runtime/memprofiler.hpp" |
stefank@2314 | 36 | #include "runtime/mutexLocker.hpp" |
stefank@2314 | 37 | #include "runtime/os.hpp" |
stefank@2314 | 38 | #include "runtime/task.hpp" |
stefank@2314 | 39 | #include "runtime/vmThread.hpp" |
stefank@2314 | 40 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 41 | # include "thread_linux.inline.hpp" |
stefank@2314 | 42 | #endif |
stefank@2314 | 43 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 44 | # include "thread_solaris.inline.hpp" |
stefank@2314 | 45 | #endif |
stefank@2314 | 46 | #ifdef TARGET_OS_FAMILY_windows |
stefank@2314 | 47 | # include "thread_windows.inline.hpp" |
stefank@2314 | 48 | #endif |
never@3156 | 49 | #ifdef TARGET_OS_FAMILY_bsd |
never@3156 | 50 | # include "thread_bsd.inline.hpp" |
never@3156 | 51 | #endif |
duke@435 | 52 | |
duke@435 | 53 | #ifndef PRODUCT |
duke@435 | 54 | |
duke@435 | 55 | // -------------------------------------------------------- |
duke@435 | 56 | // MemProfilerTask |
duke@435 | 57 | |
duke@435 | 58 | class MemProfilerTask : public PeriodicTask { |
duke@435 | 59 | public: |
duke@435 | 60 | MemProfilerTask(int interval_time) : PeriodicTask(interval_time) {} |
duke@435 | 61 | void task(); |
duke@435 | 62 | }; |
duke@435 | 63 | |
duke@435 | 64 | |
duke@435 | 65 | void MemProfilerTask::task() { |
duke@435 | 66 | // Get thread lock to provide mutual exclusion, and so we can iterate safely over the thread list. |
duke@435 | 67 | MutexLocker mu(Threads_lock); |
duke@435 | 68 | MemProfiler::do_trace(); |
duke@435 | 69 | } |
duke@435 | 70 | |
duke@435 | 71 | |
duke@435 | 72 | //---------------------------------------------------------- |
duke@435 | 73 | // Implementation of MemProfiler |
duke@435 | 74 | |
duke@435 | 75 | MemProfilerTask* MemProfiler::_task = NULL; |
duke@435 | 76 | FILE* MemProfiler::_log_fp = NULL; |
duke@435 | 77 | |
duke@435 | 78 | |
duke@435 | 79 | bool MemProfiler::is_active() { |
duke@435 | 80 | return _task != NULL; |
duke@435 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | |
duke@435 | 84 | void MemProfiler::engage() { |
duke@435 | 85 | const char *log_name = "mprofile.log"; |
duke@435 | 86 | if (!is_active()) { |
duke@435 | 87 | // Create log file |
duke@435 | 88 | _log_fp = fopen(log_name , "w+"); |
duke@435 | 89 | if (_log_fp == NULL) { |
jcoomes@1845 | 90 | fatal(err_msg("MemProfiler: Cannot create log file: %s", log_name)); |
duke@435 | 91 | } |
duke@435 | 92 | fprintf(_log_fp, "MemProfiler: sizes are in Kb, time is in seconds since startup\n\n"); |
duke@435 | 93 | fprintf(_log_fp, " time, #thr, #cls, heap, heap, perm, perm, code, hndls, rescs, oopmp\n"); |
duke@435 | 94 | fprintf(_log_fp, " used, total, used, total, total, total, total, total\n"); |
duke@435 | 95 | fprintf(_log_fp, "--------------------------------------------------------------------------\n"); |
duke@435 | 96 | |
duke@435 | 97 | _task = new MemProfilerTask(MemProfilingInterval); |
duke@435 | 98 | _task->enroll(); |
duke@435 | 99 | } |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | |
duke@435 | 103 | void MemProfiler::disengage() { |
duke@435 | 104 | if (!is_active()) return; |
duke@435 | 105 | // Do one last trace at disengage time |
duke@435 | 106 | do_trace(); |
duke@435 | 107 | |
duke@435 | 108 | // Close logfile |
duke@435 | 109 | fprintf(_log_fp, "MemProfiler detached\n"); |
duke@435 | 110 | fclose(_log_fp); |
duke@435 | 111 | |
duke@435 | 112 | // remove MemProfilerTask |
duke@435 | 113 | assert(_task != NULL, "sanity check"); |
duke@435 | 114 | _task->disenroll(); |
duke@435 | 115 | delete _task; |
duke@435 | 116 | _task = NULL; |
duke@435 | 117 | } |
duke@435 | 118 | |
duke@435 | 119 | |
duke@435 | 120 | void MemProfiler::do_trace() { |
duke@435 | 121 | // Calculate thread local sizes |
duke@435 | 122 | size_t handles_memory_usage = VMThread::vm_thread()->handle_area()->size_in_bytes(); |
duke@435 | 123 | size_t resource_memory_usage = VMThread::vm_thread()->resource_area()->size_in_bytes(); |
duke@435 | 124 | JavaThread *cur = Threads::first(); |
duke@435 | 125 | while (cur != NULL) { |
duke@435 | 126 | handles_memory_usage += cur->handle_area()->size_in_bytes(); |
duke@435 | 127 | resource_memory_usage += cur->resource_area()->size_in_bytes(); |
duke@435 | 128 | cur = cur->next(); |
duke@435 | 129 | } |
duke@435 | 130 | |
duke@435 | 131 | // Print trace line in log |
xlu@948 | 132 | fprintf(_log_fp, "%6.1f,%5d,%5d," UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) "," |
xlu@948 | 133 | UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",", |
xlu@948 | 134 | os::elapsedTime(), |
xlu@948 | 135 | Threads::number_of_threads(), |
xlu@948 | 136 | SystemDictionary::number_of_classes(), |
xlu@948 | 137 | Universe::heap()->used() / K, |
xlu@948 | 138 | Universe::heap()->capacity() / K, |
xlu@948 | 139 | Universe::heap()->permanent_used() / HWperKB, |
xlu@948 | 140 | Universe::heap()->permanent_capacity() / HWperKB); |
duke@435 | 141 | |
xlu@948 | 142 | fprintf(_log_fp, UINTX_FORMAT_W(6) ",", CodeCache::capacity() / K); |
duke@435 | 143 | |
xlu@948 | 144 | fprintf(_log_fp, UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",%6ld\n", |
xlu@948 | 145 | handles_memory_usage / K, |
xlu@948 | 146 | resource_memory_usage / K, |
xlu@948 | 147 | OopMapCache::memory_usage() / K); |
duke@435 | 148 | fflush(_log_fp); |
duke@435 | 149 | } |
duke@435 | 150 | |
duke@435 | 151 | #endif |