comparison src/share/vm/runtime/java.cpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents 957c266d8bc5 a1b8cf9cf970
children 291ffc492eb6
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
34 #include "graal/graalCompiler.hpp" 34 #include "graal/graalCompiler.hpp"
35 #endif 35 #endif
36 #include "memory/genCollectedHeap.hpp" 36 #include "memory/genCollectedHeap.hpp"
37 #include "memory/oopFactory.hpp" 37 #include "memory/oopFactory.hpp"
38 #include "memory/universe.hpp" 38 #include "memory/universe.hpp"
39 #include "oops/constantPoolOop.hpp" 39 #include "oops/constantPool.hpp"
40 #include "oops/generateOopMap.hpp" 40 #include "oops/generateOopMap.hpp"
41 #include "oops/instanceKlass.hpp" 41 #include "oops/instanceKlass.hpp"
42 #include "oops/instanceKlassKlass.hpp"
43 #include "oops/instanceOop.hpp" 42 #include "oops/instanceOop.hpp"
44 #include "oops/methodOop.hpp" 43 #include "oops/method.hpp"
45 #include "oops/objArrayOop.hpp" 44 #include "oops/objArrayOop.hpp"
46 #include "oops/oop.inline.hpp" 45 #include "oops/oop.inline.hpp"
47 #include "oops/symbol.hpp" 46 #include "oops/symbol.hpp"
48 #include "prims/jvmtiExport.hpp" 47 #include "prims/jvmtiExport.hpp"
49 #include "runtime/aprofiler.hpp" 48 #include "runtime/aprofiler.hpp"
58 #include "runtime/sharedRuntime.hpp" 57 #include "runtime/sharedRuntime.hpp"
59 #include "runtime/statSampler.hpp" 58 #include "runtime/statSampler.hpp"
60 #include "runtime/task.hpp" 59 #include "runtime/task.hpp"
61 #include "runtime/timer.hpp" 60 #include "runtime/timer.hpp"
62 #include "runtime/vm_operations.hpp" 61 #include "runtime/vm_operations.hpp"
62 #include "services/memReporter.hpp"
63 #include "services/memTracker.hpp"
63 #include "trace/tracing.hpp" 64 #include "trace/tracing.hpp"
64 #include "trace/traceEventTypes.hpp" 65 #include "trace/traceEventTypes.hpp"
65 #include "utilities/dtrace.hpp" 66 #include "utilities/dtrace.hpp"
66 #include "utilities/globalDefinitions.hpp" 67 #include "utilities/globalDefinitions.hpp"
67 #include "utilities/histogram.hpp" 68 #include "utilities/histogram.hpp"
116 117
117 #ifndef PRODUCT 118 #ifndef PRODUCT
118 119
119 // Statistics printing (method invocation histogram) 120 // Statistics printing (method invocation histogram)
120 121
121 GrowableArray<methodOop>* collected_invoked_methods; 122 GrowableArray<Method*>* collected_invoked_methods;
122 123
123 void collect_invoked_methods(methodOop m) { 124 void collect_invoked_methods(Method* m) {
124 if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) { 125 if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) {
125 collected_invoked_methods->push(m); 126 collected_invoked_methods->push(m);
126 } 127 }
127 } 128 }
128 129
129 130
130 GrowableArray<methodOop>* collected_profiled_methods; 131 GrowableArray<Method*>* collected_profiled_methods;
131 132
132 void collect_profiled_methods(methodOop m) { 133 void collect_profiled_methods(Method* m) {
133 methodHandle mh(Thread::current(), m); 134 Thread* thread = Thread::current();
135 // This HandleMark prevents a huge amount of handles from being added
136 // to the metadata_handles() array on the thread.
137 HandleMark hm(thread);
138 methodHandle mh(thread, m);
134 if ((m->method_data() != NULL) && 139 if ((m->method_data() != NULL) &&
135 (PrintMethodData || CompilerOracle::should_print(mh))) { 140 (PrintMethodData || CompilerOracle::should_print(mh))) {
136 collected_profiled_methods->push(m); 141 collected_profiled_methods->push(m);
137 } 142 }
138 } 143 }
139 144
140 145
141 int compare_methods(methodOop* a, methodOop* b) { 146 int compare_methods(Method** a, Method** b) {
142 // %%% there can be 32-bit overflow here 147 // %%% there can be 32-bit overflow here
143 return ((*b)->invocation_count() + (*b)->compiled_invocation_count()) 148 return ((*b)->invocation_count() + (*b)->compiled_invocation_count())
144 - ((*a)->invocation_count() + (*a)->compiled_invocation_count()); 149 - ((*a)->invocation_count() + (*a)->compiled_invocation_count());
145 } 150 }
146 151
147 152
148 void print_method_invocation_histogram() { 153 void print_method_invocation_histogram() {
149 ResourceMark rm; 154 ResourceMark rm;
150 HandleMark hm; 155 HandleMark hm;
151 collected_invoked_methods = new GrowableArray<methodOop>(1024); 156 collected_invoked_methods = new GrowableArray<Method*>(1024);
152 SystemDictionary::methods_do(collect_invoked_methods); 157 SystemDictionary::methods_do(collect_invoked_methods);
153 collected_invoked_methods->sort(&compare_methods); 158 collected_invoked_methods->sort(&compare_methods);
154 // 159 //
155 tty->cr(); 160 tty->cr();
156 tty->print_cr("Histogram Over MethodOop Invocation Counters (cutoff = %d):", MethodHistogramCutoff); 161 tty->print_cr("Histogram Over MethodOop Invocation Counters (cutoff = %d):", MethodHistogramCutoff);
157 tty->cr(); 162 tty->cr();
158 tty->print_cr("____Count_(I+C)____Method________________________Module_________________"); 163 tty->print_cr("____Count_(I+C)____Method________________________Module_________________");
159 unsigned total = 0, int_total = 0, comp_total = 0, static_total = 0, final_total = 0, 164 unsigned total = 0, int_total = 0, comp_total = 0, static_total = 0, final_total = 0,
160 synch_total = 0, nativ_total = 0, acces_total = 0; 165 synch_total = 0, nativ_total = 0, acces_total = 0;
161 for (int index = 0; index < collected_invoked_methods->length(); index++) { 166 for (int index = 0; index < collected_invoked_methods->length(); index++) {
162 methodOop m = collected_invoked_methods->at(index); 167 Method* m = collected_invoked_methods->at(index);
163 int c = m->invocation_count() + m->compiled_invocation_count(); 168 int c = m->invocation_count() + m->compiled_invocation_count();
164 if (c >= MethodHistogramCutoff) m->print_invocation_count(); 169 if (c >= MethodHistogramCutoff) m->print_invocation_count();
165 int_total += m->invocation_count(); 170 int_total += m->invocation_count();
166 comp_total += m->compiled_invocation_count(); 171 comp_total += m->compiled_invocation_count();
167 if (m->is_final()) final_total += c; 172 if (m->is_final()) final_total += c;
186 } 191 }
187 192
188 void print_method_profiling_data() { 193 void print_method_profiling_data() {
189 ResourceMark rm; 194 ResourceMark rm;
190 HandleMark hm; 195 HandleMark hm;
191 collected_profiled_methods = new GrowableArray<methodOop>(1024); 196 collected_profiled_methods = new GrowableArray<Method*>(1024);
192 SystemDictionary::methods_do(collect_profiled_methods); 197 SystemDictionary::methods_do(collect_profiled_methods);
193 collected_profiled_methods->sort(&compare_methods); 198 collected_profiled_methods->sort(&compare_methods);
194 199
195 int count = collected_profiled_methods->length(); 200 int count = collected_profiled_methods->length();
196 if (count > 0) { 201 if (count > 0) {
197 for (int index = 0; index < count; index++) { 202 for (int index = 0; index < count; index++) {
198 methodOop m = collected_profiled_methods->at(index); 203 Method* m = collected_profiled_methods->at(index);
199 ttyLocker ttyl; 204 ttyLocker ttyl;
200 tty->print_cr("------------------------------------------------------------------------"); 205 tty->print_cr("------------------------------------------------------------------------");
201 //m->print_name(tty); 206 //m->print_name(tty);
202 m->print_invocation_count(); 207 m->print_invocation_count();
203 tty->cr(); 208 tty->cr();
360 tty->print_cr("Compile::CompiledZap_count = %d", Compile::CompiledZap_count); 365 tty->print_cr("Compile::CompiledZap_count = %d", Compile::CompiledZap_count);
361 tty->print_cr("OptoRuntime::ZapDeadCompiledLocals_count = %d", OptoRuntime::ZapDeadCompiledLocals_count); 366 tty->print_cr("OptoRuntime::ZapDeadCompiledLocals_count = %d", OptoRuntime::ZapDeadCompiledLocals_count);
362 } 367 }
363 #endif // COMPILER2 368 #endif // COMPILER2
364 #endif // ENABLE_ZAP_DEAD_LOCALS 369 #endif // ENABLE_ZAP_DEAD_LOCALS
370 // Native memory tracking data
371 if (PrintNMTStatistics) {
372 if (MemTracker::is_on()) {
373 BaselineTTYOutputer outputer(tty);
374 MemTracker::print_memory_usage(outputer, K, false);
375 } else {
376 tty->print_cr(MemTracker::reason());
377 }
378 }
365 } 379 }
366 380
367 #else // PRODUCT MODE STATISTICS 381 #else // PRODUCT MODE STATISTICS
368 382
369 void print_statistics() { 383 void print_statistics() {
379 OptoRuntime::print_named_counters(); 393 OptoRuntime::print_named_counters();
380 } 394 }
381 #endif 395 #endif
382 if (PrintBiasedLockingStatistics) { 396 if (PrintBiasedLockingStatistics) {
383 BiasedLocking::print_counters(); 397 BiasedLocking::print_counters();
398 }
399
400 // Native memory tracking data
401 if (PrintNMTStatistics) {
402 if (MemTracker::is_on()) {
403 BaselineTTYOutputer outputer(tty);
404 MemTracker::print_memory_usage(outputer, K, false);
405 } else {
406 tty->print_cr(MemTracker::reason());
407 }
384 } 408 }
385 } 409 }
386 410
387 #endif 411 #endif
388 412
496 520
497 // Print GC/heap related information. 521 // Print GC/heap related information.
498 if (PrintGCDetails) { 522 if (PrintGCDetails) {
499 Universe::print(); 523 Universe::print();
500 AdaptiveSizePolicyOutput(0); 524 AdaptiveSizePolicyOutput(0);
525 if (Verbose) {
526 ClassLoaderDataGraph::dump_on(gclog_or_tty);
527 }
501 } 528 }
502 529
503 530
504 if (Arguments::has_alloc_profile()) { 531 if (Arguments::has_alloc_profile()) {
505 HandleMark hm; 532 HandleMark hm;
672 vm_shutdown(); 699 vm_shutdown();
673 } 700 }
674 701
675 JDK_Version JDK_Version::_current; 702 JDK_Version JDK_Version::_current;
676 const char* JDK_Version::_runtime_name; 703 const char* JDK_Version::_runtime_name;
704 const char* JDK_Version::_runtime_version;
677 705
678 void JDK_Version::initialize() { 706 void JDK_Version::initialize() {
679 jdk_version_info info; 707 jdk_version_info info;
680 assert(!_current.is_valid(), "Don't initialize twice"); 708 assert(!_current.is_valid(), "Don't initialize twice");
681 709