author | thartmann |
Wed, 28 Jan 2015 07:55:27 +0100 | |
changeset 28730 | 106944a21769 |
parent 28631 | a56cae1b428d |
child 29084 | 1b732f2836ce |
child 29338 | 92297a8bd48e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5533
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "code/codeBlob.hpp" |
|
27 |
#include "code/codeCache.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
28 |
#include "code/compiledIC.hpp" |
7397 | 29 |
#include "code/dependencies.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
30 |
#include "code/icBuffer.hpp" |
7397 | 31 |
#include "code/nmethod.hpp" |
32 |
#include "code/pcDesc.hpp" |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
33 |
#include "compiler/compileBroker.hpp" |
7397 | 34 |
#include "gc_implementation/shared/markSweep.hpp" |
35 |
#include "memory/allocation.inline.hpp" |
|
36 |
#include "memory/gcLocker.hpp" |
|
37 |
#include "memory/iterator.hpp" |
|
38 |
#include "memory/resourceArea.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
39 |
#include "oops/method.hpp" |
7397 | 40 |
#include "oops/objArrayOop.hpp" |
41 |
#include "oops/oop.inline.hpp" |
|
42 |
#include "runtime/handles.inline.hpp" |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
43 |
#include "runtime/arguments.hpp" |
7397 | 44 |
#include "runtime/icache.hpp" |
45 |
#include "runtime/java.hpp" |
|
46 |
#include "runtime/mutexLocker.hpp" |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
47 |
#include "runtime/sweeper.hpp" |
26796 | 48 |
#include "runtime/compilationPolicy.hpp" |
7397 | 49 |
#include "services/memoryService.hpp" |
18025 | 50 |
#include "trace/tracing.hpp" |
7397 | 51 |
#include "utilities/xmlstream.hpp" |
26796 | 52 |
#ifdef COMPILER1 |
53 |
#include "c1/c1_Compilation.hpp" |
|
54 |
#include "c1/c1_Compiler.hpp" |
|
55 |
#endif |
|
56 |
#ifdef COMPILER2 |
|
57 |
#include "opto/c2compiler.hpp" |
|
58 |
#include "opto/compile.hpp" |
|
26805 | 59 |
#include "opto/node.hpp" |
26796 | 60 |
#endif |
1 | 61 |
|
62 |
// Helper class for printing in CodeCache |
|
63 |
class CodeBlob_sizes { |
|
64 |
private: |
|
65 |
int count; |
|
66 |
int total_size; |
|
67 |
int header_size; |
|
68 |
int code_size; |
|
69 |
int stub_size; |
|
70 |
int relocation_size; |
|
71 |
int scopes_oop_size; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
72 |
int scopes_metadata_size; |
1 | 73 |
int scopes_data_size; |
74 |
int scopes_pcs_size; |
|
75 |
||
76 |
public: |
|
77 |
CodeBlob_sizes() { |
|
78 |
count = 0; |
|
79 |
total_size = 0; |
|
80 |
header_size = 0; |
|
81 |
code_size = 0; |
|
82 |
stub_size = 0; |
|
83 |
relocation_size = 0; |
|
84 |
scopes_oop_size = 0; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
85 |
scopes_metadata_size = 0; |
1 | 86 |
scopes_data_size = 0; |
87 |
scopes_pcs_size = 0; |
|
88 |
} |
|
89 |
||
90 |
int total() { return total_size; } |
|
91 |
bool is_empty() { return count == 0; } |
|
92 |
||
93 |
void print(const char* title) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
94 |
tty->print_cr(" #%d %s = %dK (hdr %d%%, loc %d%%, code %d%%, stub %d%%, [oops %d%%, metadata %d%%, data %d%%, pcs %d%%])", |
1 | 95 |
count, |
96 |
title, |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
97 |
(int)(total() / K), |
1 | 98 |
header_size * 100 / total_size, |
99 |
relocation_size * 100 / total_size, |
|
100 |
code_size * 100 / total_size, |
|
101 |
stub_size * 100 / total_size, |
|
102 |
scopes_oop_size * 100 / total_size, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
103 |
scopes_metadata_size * 100 / total_size, |
1 | 104 |
scopes_data_size * 100 / total_size, |
105 |
scopes_pcs_size * 100 / total_size); |
|
106 |
} |
|
107 |
||
108 |
void add(CodeBlob* cb) { |
|
109 |
count++; |
|
110 |
total_size += cb->size(); |
|
111 |
header_size += cb->header_size(); |
|
112 |
relocation_size += cb->relocation_size(); |
|
113 |
if (cb->is_nmethod()) { |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
5533
diff
changeset
|
114 |
nmethod* nm = cb->as_nmethod_or_null(); |
6418 | 115 |
code_size += nm->insts_size(); |
1 | 116 |
stub_size += nm->stub_size(); |
117 |
||
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
5533
diff
changeset
|
118 |
scopes_oop_size += nm->oops_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
119 |
scopes_metadata_size += nm->metadata_size(); |
1 | 120 |
scopes_data_size += nm->scopes_data_size(); |
121 |
scopes_pcs_size += nm->scopes_pcs_size(); |
|
122 |
} else { |
|
6418 | 123 |
code_size += cb->code_size(); |
1 | 124 |
} |
125 |
} |
|
126 |
}; |
|
127 |
||
26796 | 128 |
// Iterate over all CodeHeaps |
129 |
#define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap) |
|
130 |
// Iterate over all CodeBlobs (cb) on the given CodeHeap |
|
131 |
#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb)) |
|
1 | 132 |
|
26796 | 133 |
address CodeCache::_low_bound = 0; |
134 |
address CodeCache::_high_bound = 0; |
|
1 | 135 |
int CodeCache::_number_of_blobs = 0; |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
136 |
int CodeCache::_number_of_adapters = 0; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
137 |
int CodeCache::_number_of_nmethods = 0; |
1 | 138 |
int CodeCache::_number_of_nmethods_with_dependencies = 0; |
139 |
bool CodeCache::_needs_cache_clean = false; |
|
3908 | 140 |
nmethod* CodeCache::_scavenge_root_nmethods = NULL; |
18025 | 141 |
int CodeCache::_codemem_full_count = 0; |
1 | 142 |
|
26796 | 143 |
// Initialize array of CodeHeaps |
144 |
GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); |
|
145 |
||
146 |
void CodeCache::initialize_heaps() { |
|
147 |
// Determine size of compiler buffers |
|
148 |
size_t code_buffers_size = 0; |
|
149 |
#ifdef COMPILER1 |
|
150 |
// C1 temporary code buffers (see Compiler::init_buffer_blob()) |
|
151 |
const int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); |
|
152 |
code_buffers_size += c1_count * Compiler::code_buffer_size(); |
|
153 |
#endif |
|
154 |
#ifdef COMPILER2 |
|
155 |
// C2 scratch buffers (see Compile::init_scratch_buffer_blob()) |
|
156 |
const int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); |
|
157 |
// Initial size of constant table (this may be increased if a compiled method needs more space) |
|
158 |
code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size(); |
|
159 |
#endif |
|
1 | 160 |
|
26796 | 161 |
// Calculate default CodeHeap sizes if not set by user |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
162 |
if (!FLAG_IS_CMDLINE(NonNMethodCodeHeapSize) && !FLAG_IS_CMDLINE(ProfiledCodeHeapSize) |
26796 | 163 |
&& !FLAG_IS_CMDLINE(NonProfiledCodeHeapSize)) { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
164 |
// Increase default NonNMethodCodeHeapSize to account for compiler buffers |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
165 |
FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + code_buffers_size); |
26796 | 166 |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
167 |
// Check if we have enough space for the non-nmethod code heap |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
168 |
if (ReservedCodeCacheSize > NonNMethodCodeHeapSize) { |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
169 |
// Use the default value for NonNMethodCodeHeapSize and one half of the |
26796 | 170 |
// remaining size for non-profiled methods and one half for profiled methods |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
171 |
size_t remaining_size = ReservedCodeCacheSize - NonNMethodCodeHeapSize; |
26796 | 172 |
size_t profiled_size = remaining_size / 2; |
173 |
size_t non_profiled_size = remaining_size - profiled_size; |
|
174 |
FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size); |
|
175 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size); |
|
176 |
} else { |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
177 |
// Use all space for the non-nmethod heap and set other heaps to minimal size |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
178 |
FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, ReservedCodeCacheSize - os::vm_page_size() * 2); |
26796 | 179 |
FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, os::vm_page_size()); |
180 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, os::vm_page_size()); |
|
181 |
} |
|
182 |
} |
|
1 | 183 |
|
26796 | 184 |
// We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap |
185 |
if(!heap_available(CodeBlobType::MethodProfiled)) { |
|
186 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize + ProfiledCodeHeapSize); |
|
187 |
FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, 0); |
|
188 |
} |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
189 |
// We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap |
26796 | 190 |
if(!heap_available(CodeBlobType::MethodNonProfiled)) { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
191 |
FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + NonProfiledCodeHeapSize); |
26796 | 192 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 0); |
193 |
} |
|
194 |
||
195 |
// Make sure we have enough space for VM internal code |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
196 |
uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
197 |
if (NonNMethodCodeHeapSize < (min_code_cache_size + code_buffers_size)) { |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
198 |
vm_exit_during_initialization("Not enough space in non-nmethod code heap to run VM."); |
26796 | 199 |
} |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
200 |
guarantee(NonProfiledCodeHeapSize + ProfiledCodeHeapSize + NonNMethodCodeHeapSize <= ReservedCodeCacheSize, "Size check"); |
26796 | 201 |
|
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
202 |
// Align CodeHeaps |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
203 |
size_t alignment = heap_alignment(); |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
204 |
size_t non_method_size = align_size_up(NonNMethodCodeHeapSize, alignment); |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
205 |
size_t profiled_size = align_size_down(ProfiledCodeHeapSize, alignment); |
1 | 206 |
|
26796 | 207 |
// Reserve one continuous chunk of memory for CodeHeaps and split it into |
208 |
// parts for the individual heaps. The memory layout looks like this: |
|
209 |
// ---------- high ----------- |
|
210 |
// Non-profiled nmethods |
|
211 |
// Profiled nmethods |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
212 |
// Non-nmethods |
26796 | 213 |
// ---------- low ------------ |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
214 |
ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); |
26796 | 215 |
ReservedSpace non_method_space = rs.first_part(non_method_size); |
216 |
ReservedSpace rest = rs.last_part(non_method_size); |
|
217 |
ReservedSpace profiled_space = rest.first_part(profiled_size); |
|
218 |
ReservedSpace non_profiled_space = rest.last_part(profiled_size); |
|
219 |
||
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
220 |
// Non-nmethods (stubs, adapters, ...) |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
221 |
add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod); |
26796 | 222 |
// Tier 2 and tier 3 (profiled) methods |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
223 |
add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled); |
26796 | 224 |
// Tier 1 and tier 4 (non-profiled) methods and native methods |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
225 |
add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", CodeBlobType::MethodNonProfiled); |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
226 |
} |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
227 |
|
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
228 |
size_t CodeCache::heap_alignment() { |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
229 |
// If large page support is enabled, align code heaps according to large |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
230 |
// page size to make sure that code cache is covered by large pages. |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
231 |
const size_t page_size = os::can_execute_large_page_memory() ? |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
232 |
os::page_size_for_region_unaligned(ReservedCodeCacheSize, 8) : |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
233 |
os::vm_page_size(); |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
234 |
return MAX2(page_size, (size_t) os::vm_allocation_granularity()); |
1 | 235 |
} |
236 |
||
26796 | 237 |
ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) { |
238 |
// Determine alignment |
|
239 |
const size_t page_size = os::can_execute_large_page_memory() ? |
|
28631 | 240 |
MIN2(os::page_size_for_region_aligned(InitialCodeCacheSize, 8), |
241 |
os::page_size_for_region_aligned(size, 8)) : |
|
26796 | 242 |
os::vm_page_size(); |
243 |
const size_t granularity = os::vm_allocation_granularity(); |
|
244 |
const size_t r_align = MAX2(page_size, granularity); |
|
245 |
const size_t r_size = align_size_up(size, r_align); |
|
246 |
const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 : |
|
247 |
MAX2(page_size, granularity); |
|
1 | 248 |
|
26796 | 249 |
ReservedCodeSpace rs(r_size, rs_align, rs_align > 0); |
250 |
||
251 |
// Initialize bounds |
|
252 |
_low_bound = (address)rs.base(); |
|
253 |
_high_bound = _low_bound + rs.size(); |
|
254 |
||
255 |
return rs; |
|
256 |
} |
|
257 |
||
258 |
bool CodeCache::heap_available(int code_blob_type) { |
|
259 |
if (!SegmentedCodeCache) { |
|
260 |
// No segmentation: use a single code heap |
|
261 |
return (code_blob_type == CodeBlobType::All); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26942
diff
changeset
|
262 |
} else if (Arguments::mode() == Arguments::_int) { |
26796 | 263 |
// Interpreter only: we don't need any method code heaps |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
264 |
return (code_blob_type == CodeBlobType::NonNMethod); |
26796 | 265 |
} else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) { |
266 |
// Tiered compilation: use all code heaps |
|
267 |
return (code_blob_type < CodeBlobType::All); |
|
268 |
} else { |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
269 |
// No TieredCompilation: we only need the non-nmethod and non-profiled code heap |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
270 |
return (code_blob_type == CodeBlobType::NonNMethod) || |
26796 | 271 |
(code_blob_type == CodeBlobType::MethodNonProfiled); |
272 |
} |
|
1 | 273 |
} |
274 |
||
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
275 |
const char* CodeCache::get_code_heap_flag_name(int code_blob_type) { |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
276 |
switch(code_blob_type) { |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
277 |
case CodeBlobType::NonNMethod: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
278 |
return "NonNMethodCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
279 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
280 |
case CodeBlobType::MethodNonProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
281 |
return "NonProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
282 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
283 |
case CodeBlobType::MethodProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
284 |
return "ProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
285 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
286 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
287 |
ShouldNotReachHere(); |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
288 |
return NULL; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
289 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
290 |
|
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
291 |
void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) { |
26796 | 292 |
// Check if heap is needed |
293 |
if (!heap_available(code_blob_type)) { |
|
294 |
return; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
295 |
} |
26796 | 296 |
|
297 |
// Create CodeHeap |
|
298 |
CodeHeap* heap = new CodeHeap(name, code_blob_type); |
|
299 |
_heaps->append(heap); |
|
300 |
||
301 |
// Reserve Space |
|
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
302 |
size_t size_initial = MIN2(InitialCodeCacheSize, rs.size()); |
26796 | 303 |
size_initial = round_to(size_initial, os::vm_page_size()); |
304 |
if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) { |
|
305 |
vm_exit_during_initialization("Could not reserve enough space for code cache"); |
|
306 |
} |
|
307 |
||
308 |
// Register the CodeHeap |
|
309 |
MemoryService::add_code_heap_memory_pool(heap, name); |
|
310 |
} |
|
311 |
||
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
27420
diff
changeset
|
312 |
CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) { |
26796 | 313 |
assert(cb != NULL, "CodeBlob is null"); |
314 |
FOR_ALL_HEAPS(heap) { |
|
315 |
if ((*heap)->contains(cb)) { |
|
316 |
return *heap; |
|
317 |
} |
|
318 |
} |
|
319 |
ShouldNotReachHere(); |
|
320 |
return NULL; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
321 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
322 |
|
26796 | 323 |
CodeHeap* CodeCache::get_code_heap(int code_blob_type) { |
324 |
FOR_ALL_HEAPS(heap) { |
|
325 |
if ((*heap)->accepts(code_blob_type)) { |
|
326 |
return *heap; |
|
327 |
} |
|
328 |
} |
|
329 |
return NULL; |
|
330 |
} |
|
331 |
||
332 |
CodeBlob* CodeCache::first_blob(CodeHeap* heap) { |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
333 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 334 |
assert(heap != NULL, "heap is null"); |
335 |
return (CodeBlob*)heap->first(); |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
336 |
} |
1 | 337 |
|
26796 | 338 |
CodeBlob* CodeCache::first_blob(int code_blob_type) { |
339 |
if (heap_available(code_blob_type)) { |
|
340 |
return first_blob(get_code_heap(code_blob_type)); |
|
341 |
} else { |
|
342 |
return NULL; |
|
343 |
} |
|
344 |
} |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
345 |
|
26796 | 346 |
CodeBlob* CodeCache::next_blob(CodeHeap* heap, CodeBlob* cb) { |
347 |
assert_locked_or_safepoint(CodeCache_lock); |
|
348 |
assert(heap != NULL, "heap is null"); |
|
349 |
return (CodeBlob*)heap->next(cb); |
|
350 |
} |
|
351 |
||
352 |
CodeBlob* CodeCache::next_blob(CodeBlob* cb) { |
|
353 |
return next_blob(get_code_heap(cb), cb); |
|
354 |
} |
|
355 |
||
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
356 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
357 |
* Do not seize the CodeCache lock here--if the caller has not |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
358 |
* already done so, we are going to lose bigtime, since the code |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
359 |
* cache will contain a garbage CodeBlob until the caller can |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
360 |
* run the constructor for the CodeBlob subclass he is busy |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
361 |
* instantiating. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
362 |
*/ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
363 |
CodeBlob* CodeCache::allocate(int size, int code_blob_type) { |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
364 |
// Possibly wakes up the sweeper thread. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
365 |
NMethodSweeper::notify(code_blob_type); |
1 | 366 |
assert_locked_or_safepoint(CodeCache_lock); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
367 |
assert(size > 0, err_msg_res("Code cache allocation request must be > 0 but is %d", size)); |
24439
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
368 |
if (size <= 0) { |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
369 |
return NULL; |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
370 |
} |
1 | 371 |
CodeBlob* cb = NULL; |
26796 | 372 |
|
373 |
// Get CodeHeap for the given CodeBlobType |
|
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
374 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
375 |
assert(heap != NULL, "heap is null"); |
26796 | 376 |
|
1 | 377 |
while (true) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
378 |
cb = (CodeBlob*)heap->allocate(size); |
1 | 379 |
if (cb != NULL) break; |
26796 | 380 |
if (!heap->expand_by(CodeCacheExpansionSize)) { |
1 | 381 |
// Expansion failed |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
382 |
if (SegmentedCodeCache && (code_blob_type == CodeBlobType::NonNMethod)) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
383 |
// Fallback solution: Store non-nmethod code in the non-profiled code heap. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
384 |
// Note that at in the sweeper, we check the reverse_free_ratio of the non-profiled |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
385 |
// code heap and force stack scanning if less than 10% if the code heap are free. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
386 |
return allocate(size, CodeBlobType::MethodNonProfiled); |
26796 | 387 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
388 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
389 |
CompileBroker::handle_full_code_cache(code_blob_type); |
1 | 390 |
return NULL; |
391 |
} |
|
392 |
if (PrintCodeCacheExtension) { |
|
393 |
ResourceMark rm; |
|
26796 | 394 |
if (SegmentedCodeCache) { |
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
395 |
tty->print("%s", heap->name()); |
26796 | 396 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
397 |
tty->print("CodeCache"); |
26796 | 398 |
} |
399 |
tty->print_cr(" extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)", |
|
400 |
(intptr_t)heap->low_boundary(), (intptr_t)heap->high(), |
|
401 |
(address)heap->high() - (address)heap->low_boundary()); |
|
1 | 402 |
} |
403 |
} |
|
3908 | 404 |
print_trace("allocation", cb, size); |
24439
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
405 |
_number_of_blobs++; |
1 | 406 |
return cb; |
407 |
} |
|
408 |
||
409 |
void CodeCache::free(CodeBlob* cb) { |
|
410 |
assert_locked_or_safepoint(CodeCache_lock); |
|
411 |
||
3908 | 412 |
print_trace("free", cb); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
413 |
if (cb->is_nmethod()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
414 |
_number_of_nmethods--; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
415 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
416 |
_number_of_nmethods_with_dependencies--; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
417 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
418 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
419 |
if (cb->is_adapter_blob()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
420 |
_number_of_adapters--; |
1 | 421 |
} |
422 |
_number_of_blobs--; |
|
423 |
||
26796 | 424 |
// Get heap for given CodeBlob and deallocate |
425 |
get_code_heap(cb)->deallocate(cb); |
|
1 | 426 |
|
427 |
assert(_number_of_blobs >= 0, "sanity check"); |
|
428 |
} |
|
429 |
||
430 |
void CodeCache::commit(CodeBlob* cb) { |
|
431 |
// this is called by nmethod::nmethod, which must already own CodeCache_lock |
|
432 |
assert_locked_or_safepoint(CodeCache_lock); |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
433 |
if (cb->is_nmethod()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
434 |
_number_of_nmethods++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
435 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
436 |
_number_of_nmethods_with_dependencies++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
437 |
} |
1 | 438 |
} |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
439 |
if (cb->is_adapter_blob()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
440 |
_number_of_adapters++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
441 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
442 |
|
1 | 443 |
// flush the hardware I-cache |
6418 | 444 |
ICache::invalidate_range(cb->content_begin(), cb->content_size()); |
1 | 445 |
} |
446 |
||
447 |
bool CodeCache::contains(void *p) { |
|
448 |
// It should be ok to call contains without holding a lock |
|
26796 | 449 |
FOR_ALL_HEAPS(heap) { |
450 |
if ((*heap)->contains(p)) { |
|
451 |
return true; |
|
452 |
} |
|
453 |
} |
|
454 |
return false; |
|
1 | 455 |
} |
456 |
||
26796 | 457 |
// This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not |
458 |
// looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain |
|
1 | 459 |
// valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled. |
460 |
CodeBlob* CodeCache::find_blob(void* start) { |
|
461 |
CodeBlob* result = find_blob_unsafe(start); |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
462 |
// We could potentially look up non_entrant methods |
26796 | 463 |
guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || is_error_reported(), "unsafe access to zombie method"); |
1 | 464 |
return result; |
465 |
} |
|
466 |
||
26796 | 467 |
// Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know |
468 |
// what you are doing) |
|
469 |
CodeBlob* CodeCache::find_blob_unsafe(void* start) { |
|
470 |
// NMT can walk the stack before code cache is created |
|
471 |
if (_heaps == NULL || _heaps->is_empty()) return NULL; |
|
472 |
||
473 |
FOR_ALL_HEAPS(heap) { |
|
474 |
CodeBlob* result = (CodeBlob*) (*heap)->find_start(start); |
|
475 |
if (result != NULL && result->blob_contains((address)start)) { |
|
476 |
return result; |
|
477 |
} |
|
478 |
} |
|
479 |
return NULL; |
|
480 |
} |
|
481 |
||
1 | 482 |
nmethod* CodeCache::find_nmethod(void* start) { |
26796 | 483 |
CodeBlob* cb = find_blob(start); |
484 |
assert(cb->is_nmethod(), "did not find an nmethod"); |
|
1 | 485 |
return (nmethod*)cb; |
486 |
} |
|
487 |
||
488 |
void CodeCache::blobs_do(void f(CodeBlob* nm)) { |
|
489 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 490 |
FOR_ALL_HEAPS(heap) { |
491 |
FOR_ALL_BLOBS(cb, *heap) { |
|
492 |
f(cb); |
|
493 |
} |
|
1 | 494 |
} |
495 |
} |
|
496 |
||
497 |
void CodeCache::nmethods_do(void f(nmethod* nm)) { |
|
498 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 499 |
NMethodIterator iter; |
500 |
while(iter.next()) { |
|
501 |
f(iter.method()); |
|
1 | 502 |
} |
503 |
} |
|
504 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
505 |
void CodeCache::alive_nmethods_do(void f(nmethod* nm)) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
506 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 507 |
NMethodIterator iter; |
508 |
while(iter.next_alive()) { |
|
509 |
f(iter.method()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
510 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
511 |
} |
1 | 512 |
|
513 |
int CodeCache::alignment_unit() { |
|
26796 | 514 |
return (int)_heaps->first()->alignment_unit(); |
1 | 515 |
} |
516 |
||
517 |
int CodeCache::alignment_offset() { |
|
26796 | 518 |
return (int)_heaps->first()->alignment_offset(); |
1 | 519 |
} |
520 |
||
26796 | 521 |
// Mark nmethods for unloading if they contain otherwise unreachable oops. |
13878
6e6a462a6cff
7200470: KeepAliveClosure not needed in CodeCache::do_unloading
brutisso
parents:
13728
diff
changeset
|
522 |
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { |
1 | 523 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 524 |
NMethodIterator iter; |
525 |
while(iter.next_alive()) { |
|
526 |
iter.method()->do_unloading(is_alive, unloading_occurred); |
|
1 | 527 |
} |
528 |
} |
|
529 |
||
3908 | 530 |
void CodeCache::blobs_do(CodeBlobClosure* f) { |
1 | 531 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 532 |
FOR_ALL_HEAPS(heap) { |
533 |
FOR_ALL_BLOBS(cb, *heap) { |
|
534 |
if (cb->is_alive()) { |
|
535 |
f->do_code_blob(cb); |
|
3908 | 536 |
|
537 |
#ifdef ASSERT |
|
26796 | 538 |
if (cb->is_nmethod()) |
539 |
((nmethod*)cb)->verify_scavenge_root_oops(); |
|
3908 | 540 |
#endif //ASSERT |
26796 | 541 |
} |
542 |
} |
|
1 | 543 |
} |
544 |
} |
|
545 |
||
3908 | 546 |
// Walk the list of methods which might contain non-perm oops. |
547 |
void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { |
|
548 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
549 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
550 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
551 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
552 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
553 |
|
3908 | 554 |
debug_only(mark_scavenge_root_nmethods()); |
555 |
||
556 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
|
557 |
debug_only(cur->clear_scavenge_root_marked()); |
|
558 |
assert(cur->scavenge_root_not_marked(), ""); |
|
559 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
560 |
||
561 |
bool is_live = (!cur->is_zombie() && !cur->is_unloaded()); |
|
562 |
#ifndef PRODUCT |
|
563 |
if (TraceScavenge) { |
|
564 |
cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr(); |
|
565 |
} |
|
566 |
#endif //PRODUCT |
|
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
567 |
if (is_live) { |
3908 | 568 |
// Perform cur->oops_do(f), maybe just once per nmethod. |
569 |
f->do_code_blob(cur); |
|
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
570 |
} |
3908 | 571 |
} |
572 |
||
573 |
// Check for stray marks. |
|
574 |
debug_only(verify_perm_nmethods(NULL)); |
|
575 |
} |
|
576 |
||
577 |
void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
|
578 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
579 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
580 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
581 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
582 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
583 |
|
3908 | 584 |
nm->set_on_scavenge_root_list(); |
585 |
nm->set_scavenge_root_link(_scavenge_root_nmethods); |
|
586 |
set_scavenge_root_nmethods(nm); |
|
587 |
print_trace("add_scavenge_root", nm); |
|
588 |
} |
|
589 |
||
590 |
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
|
591 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
592 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
593 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
594 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
595 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
596 |
|
3908 | 597 |
print_trace("drop_scavenge_root", nm); |
598 |
nmethod* last = NULL; |
|
599 |
nmethod* cur = scavenge_root_nmethods(); |
|
600 |
while (cur != NULL) { |
|
601 |
nmethod* next = cur->scavenge_root_link(); |
|
602 |
if (cur == nm) { |
|
603 |
if (last != NULL) |
|
604 |
last->set_scavenge_root_link(next); |
|
605 |
else set_scavenge_root_nmethods(next); |
|
606 |
nm->set_scavenge_root_link(NULL); |
|
607 |
nm->clear_on_scavenge_root_list(); |
|
608 |
return; |
|
609 |
} |
|
610 |
last = cur; |
|
611 |
cur = next; |
|
612 |
} |
|
613 |
assert(false, "should have been on list"); |
|
614 |
} |
|
615 |
||
616 |
void CodeCache::prune_scavenge_root_nmethods() { |
|
617 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
618 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
619 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
620 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
621 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
622 |
|
3908 | 623 |
debug_only(mark_scavenge_root_nmethods()); |
624 |
||
625 |
nmethod* last = NULL; |
|
626 |
nmethod* cur = scavenge_root_nmethods(); |
|
627 |
while (cur != NULL) { |
|
628 |
nmethod* next = cur->scavenge_root_link(); |
|
629 |
debug_only(cur->clear_scavenge_root_marked()); |
|
630 |
assert(cur->scavenge_root_not_marked(), ""); |
|
631 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
632 |
||
633 |
if (!cur->is_zombie() && !cur->is_unloaded() |
|
634 |
&& cur->detect_scavenge_root_oops()) { |
|
635 |
// Keep it. Advance 'last' to prevent deletion. |
|
636 |
last = cur; |
|
637 |
} else { |
|
638 |
// Prune it from the list, so we don't have to look at it any more. |
|
639 |
print_trace("prune_scavenge_root", cur); |
|
640 |
cur->set_scavenge_root_link(NULL); |
|
641 |
cur->clear_on_scavenge_root_list(); |
|
642 |
if (last != NULL) |
|
643 |
last->set_scavenge_root_link(next); |
|
644 |
else set_scavenge_root_nmethods(next); |
|
645 |
} |
|
646 |
cur = next; |
|
647 |
} |
|
648 |
||
649 |
// Check for stray marks. |
|
650 |
debug_only(verify_perm_nmethods(NULL)); |
|
651 |
} |
|
652 |
||
653 |
#ifndef PRODUCT |
|
654 |
void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
655 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
656 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
657 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
658 |
|
3908 | 659 |
// While we are here, verify the integrity of the list. |
660 |
mark_scavenge_root_nmethods(); |
|
661 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
|
662 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
663 |
cur->clear_scavenge_root_marked(); |
|
664 |
} |
|
665 |
verify_perm_nmethods(f); |
|
666 |
} |
|
667 |
||
668 |
// Temporarily mark nmethods that are claimed to be on the non-perm list. |
|
669 |
void CodeCache::mark_scavenge_root_nmethods() { |
|
26796 | 670 |
NMethodIterator iter; |
671 |
while(iter.next_alive()) { |
|
672 |
nmethod* nm = iter.method(); |
|
673 |
assert(nm->scavenge_root_not_marked(), "clean state"); |
|
674 |
if (nm->on_scavenge_root_list()) |
|
675 |
nm->set_scavenge_root_marked(); |
|
3908 | 676 |
} |
677 |
} |
|
678 |
||
679 |
// If the closure is given, run it on the unlisted nmethods. |
|
680 |
// Also make sure that the effects of mark_scavenge_root_nmethods is gone. |
|
681 |
void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) { |
|
26796 | 682 |
NMethodIterator iter; |
683 |
while(iter.next_alive()) { |
|
684 |
nmethod* nm = iter.method(); |
|
3908 | 685 |
bool call_f = (f_or_null != NULL); |
26796 | 686 |
assert(nm->scavenge_root_not_marked(), "must be already processed"); |
687 |
if (nm->on_scavenge_root_list()) |
|
688 |
call_f = false; // don't show this one to the client |
|
689 |
nm->verify_scavenge_root_oops(); |
|
690 |
if (call_f) f_or_null->do_code_blob(nm); |
|
3908 | 691 |
} |
692 |
} |
|
693 |
#endif //PRODUCT |
|
694 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
695 |
void CodeCache::verify_clean_inline_caches() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
696 |
#ifdef ASSERT |
26796 | 697 |
NMethodIterator iter; |
698 |
while(iter.next_alive()) { |
|
699 |
nmethod* nm = iter.method(); |
|
700 |
assert(!nm->is_unloaded(), "Tautology"); |
|
701 |
nm->verify_clean_inline_caches(); |
|
702 |
nm->verify(); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
703 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
704 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
705 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
706 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
707 |
void CodeCache::verify_icholder_relocations() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
708 |
#ifdef ASSERT |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
709 |
// make sure that we aren't leaking icholders |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
710 |
int count = 0; |
26796 | 711 |
FOR_ALL_HEAPS(heap) { |
712 |
FOR_ALL_BLOBS(cb, *heap) { |
|
713 |
if (cb->is_nmethod()) { |
|
714 |
nmethod* nm = (nmethod*)cb; |
|
715 |
count += nm->verify_icholder_relocations(); |
|
716 |
} |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
717 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
718 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
719 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
720 |
assert(count + InlineCacheBuffer::pending_icholder_count() + CompiledICHolder::live_not_claimed_count() == |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
721 |
CompiledICHolder::live_count(), "must agree"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
722 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
723 |
} |
4750 | 724 |
|
1 | 725 |
void CodeCache::gc_prologue() { |
726 |
} |
|
727 |
||
728 |
void CodeCache::gc_epilogue() { |
|
729 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 730 |
NMethodIterator iter; |
731 |
while(iter.next_alive()) { |
|
732 |
nmethod* nm = iter.method(); |
|
733 |
assert(!nm->is_unloaded(), "Tautology"); |
|
734 |
if (needs_cache_clean()) { |
|
735 |
nm->cleanup_inline_caches(); |
|
1 | 736 |
} |
26796 | 737 |
DEBUG_ONLY(nm->verify()); |
738 |
DEBUG_ONLY(nm->verify_oop_relocations()); |
|
1 | 739 |
} |
740 |
set_needs_cache_clean(false); |
|
3908 | 741 |
prune_scavenge_root_nmethods(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
742 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
743 |
verify_icholder_relocations(); |
1 | 744 |
} |
745 |
||
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
746 |
void CodeCache::verify_oops() { |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
747 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
748 |
VerifyOopClosure voc; |
26796 | 749 |
NMethodIterator iter; |
750 |
while(iter.next_alive()) { |
|
751 |
nmethod* nm = iter.method(); |
|
752 |
nm->oops_do(&voc); |
|
753 |
nm->verify_oop_relocations(); |
|
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
754 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
755 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
756 |
|
26796 | 757 |
size_t CodeCache::capacity() { |
758 |
size_t cap = 0; |
|
759 |
FOR_ALL_HEAPS(heap) { |
|
760 |
cap += (*heap)->capacity(); |
|
761 |
} |
|
762 |
return cap; |
|
1 | 763 |
} |
764 |
||
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
765 |
size_t CodeCache::unallocated_capacity(int code_blob_type) { |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
766 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
767 |
return (heap != NULL) ? heap->unallocated_capacity() : 0; |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
768 |
} |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
769 |
|
26796 | 770 |
size_t CodeCache::unallocated_capacity() { |
771 |
size_t unallocated_cap = 0; |
|
772 |
FOR_ALL_HEAPS(heap) { |
|
773 |
unallocated_cap += (*heap)->unallocated_capacity(); |
|
774 |
} |
|
775 |
return unallocated_cap; |
|
776 |
} |
|
1 | 777 |
|
26796 | 778 |
size_t CodeCache::max_capacity() { |
779 |
size_t max_cap = 0; |
|
780 |
FOR_ALL_HEAPS(heap) { |
|
781 |
max_cap += (*heap)->max_capacity(); |
|
782 |
} |
|
783 |
return max_cap; |
|
1 | 784 |
} |
785 |
||
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
786 |
/** |
26796 | 787 |
* Returns the reverse free ratio. E.g., if 25% (1/4) of the code heap |
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
788 |
* is free, reverse_free_ratio() returns 4. |
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
789 |
*/ |
26796 | 790 |
double CodeCache::reverse_free_ratio(int code_blob_type) { |
791 |
CodeHeap* heap = get_code_heap(code_blob_type); |
|
792 |
if (heap == NULL) { |
|
793 |
return 0; |
|
794 |
} |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
795 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
796 |
double unallocated_capacity = MAX2((double)heap->unallocated_capacity(), 1.0); // Avoid division by 0; |
26796 | 797 |
double max_capacity = (double)heap->max_capacity(); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
798 |
double result = max_capacity / unallocated_capacity; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
799 |
assert (max_capacity >= unallocated_capacity, "Must be"); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
800 |
assert (result >= 1.0, err_msg_res("reverse_free_ratio must be at least 1. It is %f", result)); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
801 |
return result; |
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
802 |
} |
1 | 803 |
|
26796 | 804 |
size_t CodeCache::bytes_allocated_in_freelists() { |
805 |
size_t allocated_bytes = 0; |
|
806 |
FOR_ALL_HEAPS(heap) { |
|
807 |
allocated_bytes += (*heap)->allocated_in_freelist(); |
|
808 |
} |
|
809 |
return allocated_bytes; |
|
810 |
} |
|
811 |
||
812 |
int CodeCache::allocated_segments() { |
|
813 |
int number_of_segments = 0; |
|
814 |
FOR_ALL_HEAPS(heap) { |
|
815 |
number_of_segments += (*heap)->allocated_segments(); |
|
816 |
} |
|
817 |
return number_of_segments; |
|
818 |
} |
|
819 |
||
820 |
size_t CodeCache::freelists_length() { |
|
821 |
size_t length = 0; |
|
822 |
FOR_ALL_HEAPS(heap) { |
|
823 |
length += (*heap)->freelist_length(); |
|
824 |
} |
|
825 |
return length; |
|
826 |
} |
|
827 |
||
1 | 828 |
void icache_init(); |
829 |
||
830 |
void CodeCache::initialize() { |
|
831 |
assert(CodeCacheSegmentSize >= (uintx)CodeEntryAlignment, "CodeCacheSegmentSize must be large enough to align entry points"); |
|
832 |
#ifdef COMPILER2 |
|
833 |
assert(CodeCacheSegmentSize >= (uintx)OptoLoopAlignment, "CodeCacheSegmentSize must be large enough to align inner loops"); |
|
834 |
#endif |
|
835 |
assert(CodeCacheSegmentSize >= sizeof(jdouble), "CodeCacheSegmentSize must be large enough to align constants"); |
|
836 |
// This was originally just a check of the alignment, causing failure, instead, round |
|
837 |
// the code cache to the page size. In particular, Solaris is moving to a larger |
|
838 |
// default page size. |
|
839 |
CodeCacheExpansionSize = round_to(CodeCacheExpansionSize, os::vm_page_size()); |
|
26796 | 840 |
|
841 |
if (SegmentedCodeCache) { |
|
842 |
// Use multiple code heaps |
|
843 |
initialize_heaps(); |
|
844 |
} else { |
|
845 |
// Use a single code heap |
|
846 |
ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); |
|
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
847 |
add_heap(rs, "CodeCache", CodeBlobType::All); |
1 | 848 |
} |
849 |
||
850 |
// Initialize ICache flush mechanism |
|
851 |
// This service is needed for os::register_code_area |
|
852 |
icache_init(); |
|
853 |
||
854 |
// Give OS a chance to register generated code area. |
|
855 |
// This is used on Windows 64 bit platforms to register |
|
856 |
// Structured Exception Handlers for our generated code. |
|
26796 | 857 |
os::register_code_area((char*)low_bound(), (char*)high_bound()); |
1 | 858 |
} |
859 |
||
860 |
void codeCache_init() { |
|
861 |
CodeCache::initialize(); |
|
862 |
} |
|
863 |
||
864 |
//------------------------------------------------------------------------------------------------ |
|
865 |
||
866 |
int CodeCache::number_of_nmethods_with_dependencies() { |
|
867 |
return _number_of_nmethods_with_dependencies; |
|
868 |
} |
|
869 |
||
870 |
void CodeCache::clear_inline_caches() { |
|
871 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 872 |
NMethodIterator iter; |
873 |
while(iter.next_alive()) { |
|
874 |
iter.method()->clear_inline_caches(); |
|
1 | 875 |
} |
876 |
} |
|
877 |
||
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
878 |
// Keeps track of time spent for checking dependencies |
22921
ee35d5c0b1dc
8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents:
22506
diff
changeset
|
879 |
NOT_PRODUCT(static elapsedTimer dependentCheckTime;) |
1 | 880 |
|
881 |
int CodeCache::mark_for_deoptimization(DepChange& changes) { |
|
882 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
883 |
int number_of_marked_CodeBlobs = 0; |
|
884 |
||
885 |
// search the hierarchy looking for nmethods which are affected by the loading of this class |
|
886 |
||
887 |
// then search the interfaces this class implements looking for nmethods |
|
888 |
// which might be dependent of the fact that an interface only had one |
|
889 |
// implementor. |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
890 |
// nmethod::check_all_dependencies works only correctly, if no safepoint |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
891 |
// can happen |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
892 |
No_Safepoint_Verifier nsv; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
893 |
for (DepChange::ContextStream str(changes, nsv); str.next(); ) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
894 |
Klass* d = str.klass(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
895 |
number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes); |
1 | 896 |
} |
897 |
||
898 |
#ifndef PRODUCT |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
899 |
if (VerifyDependencies) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
900 |
// Object pointers are used as unique identifiers for dependency arguments. This |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
901 |
// is only possible if no safepoint, i.e., GC occurs during the verification code. |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
902 |
dependentCheckTime.start(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
903 |
nmethod::check_all_dependencies(changes); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
904 |
dependentCheckTime.stop(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
905 |
} |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
906 |
#endif |
1 | 907 |
|
908 |
return number_of_marked_CodeBlobs; |
|
909 |
} |
|
910 |
||
911 |
||
912 |
#ifdef HOTSWAP |
|
913 |
int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { |
|
914 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
915 |
int number_of_marked_CodeBlobs = 0; |
|
916 |
||
917 |
// Deoptimize all methods of the evolving class itself |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
918 |
Array<Method*>* old_methods = dependee->methods(); |
1 | 919 |
for (int i = 0; i < old_methods->length(); i++) { |
920 |
ResourceMark rm; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
921 |
Method* old_method = old_methods->at(i); |
1 | 922 |
nmethod *nm = old_method->code(); |
923 |
if (nm != NULL) { |
|
924 |
nm->mark_for_deoptimization(); |
|
925 |
number_of_marked_CodeBlobs++; |
|
926 |
} |
|
927 |
} |
|
928 |
||
26796 | 929 |
NMethodIterator iter; |
930 |
while(iter.next_alive()) { |
|
931 |
nmethod* nm = iter.method(); |
|
1 | 932 |
if (nm->is_marked_for_deoptimization()) { |
933 |
// ...Already marked in the previous pass; don't count it again. |
|
934 |
} else if (nm->is_evol_dependent_on(dependee())) { |
|
935 |
ResourceMark rm; |
|
936 |
nm->mark_for_deoptimization(); |
|
937 |
number_of_marked_CodeBlobs++; |
|
938 |
} else { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
939 |
// flush caches in case they refer to a redefined Method* |
1 | 940 |
nm->clear_inline_caches(); |
941 |
} |
|
942 |
} |
|
943 |
||
944 |
return number_of_marked_CodeBlobs; |
|
945 |
} |
|
946 |
#endif // HOTSWAP |
|
947 |
||
948 |
||
949 |
// Deoptimize all methods |
|
950 |
void CodeCache::mark_all_nmethods_for_deoptimization() { |
|
951 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
26796 | 952 |
NMethodIterator iter; |
953 |
while(iter.next_alive()) { |
|
954 |
nmethod* nm = iter.method(); |
|
26580
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
955 |
if (!nm->method()->is_method_handle_intrinsic()) { |
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
956 |
nm->mark_for_deoptimization(); |
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
957 |
} |
1 | 958 |
} |
959 |
} |
|
960 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
961 |
int CodeCache::mark_for_deoptimization(Method* dependee) { |
1 | 962 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
963 |
int number_of_marked_CodeBlobs = 0; |
|
964 |
||
26796 | 965 |
NMethodIterator iter; |
966 |
while(iter.next_alive()) { |
|
967 |
nmethod* nm = iter.method(); |
|
1 | 968 |
if (nm->is_dependent_on_method(dependee)) { |
969 |
ResourceMark rm; |
|
970 |
nm->mark_for_deoptimization(); |
|
971 |
number_of_marked_CodeBlobs++; |
|
972 |
} |
|
973 |
} |
|
974 |
||
975 |
return number_of_marked_CodeBlobs; |
|
976 |
} |
|
977 |
||
978 |
void CodeCache::make_marked_nmethods_zombies() { |
|
979 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); |
|
26796 | 980 |
NMethodIterator iter; |
981 |
while(iter.next_alive()) { |
|
982 |
nmethod* nm = iter.method(); |
|
1 | 983 |
if (nm->is_marked_for_deoptimization()) { |
984 |
||
985 |
// If the nmethod has already been made non-entrant and it can be converted |
|
986 |
// then zombie it now. Otherwise make it non-entrant and it will eventually |
|
987 |
// be zombied when it is no longer seen on the stack. Note that the nmethod |
|
988 |
// might be "entrant" and not on the stack and so could be zombied immediately |
|
989 |
// but we can't tell because we don't track it on stack until it becomes |
|
990 |
// non-entrant. |
|
991 |
||
992 |
if (nm->is_not_entrant() && nm->can_not_entrant_be_converted()) { |
|
993 |
nm->make_zombie(); |
|
994 |
} else { |
|
995 |
nm->make_not_entrant(); |
|
996 |
} |
|
997 |
} |
|
998 |
} |
|
999 |
} |
|
1000 |
||
1001 |
void CodeCache::make_marked_nmethods_not_entrant() { |
|
1002 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 1003 |
NMethodIterator iter; |
1004 |
while(iter.next_alive()) { |
|
1005 |
nmethod* nm = iter.method(); |
|
1 | 1006 |
if (nm->is_marked_for_deoptimization()) { |
1007 |
nm->make_not_entrant(); |
|
1008 |
} |
|
1009 |
} |
|
1010 |
} |
|
1011 |
||
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1012 |
// Flushes compiled methods dependent on dependee. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1013 |
void CodeCache::flush_dependents_on(instanceKlassHandle dependee) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1014 |
assert_lock_strong(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1015 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1016 |
if (number_of_nmethods_with_dependencies() == 0) return; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1017 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1018 |
// CodeCache can only be updated by a thread_in_VM and they will all be |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1019 |
// stopped during the safepoint so CodeCache will be safe to update without |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1020 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1021 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1022 |
KlassDepChange changes(dependee); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1023 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1024 |
// Compute the dependent nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1025 |
if (mark_for_deoptimization(changes) > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1026 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1027 |
VM_Deoptimize op; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1028 |
VMThread::execute(&op); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1029 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1030 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1031 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1032 |
// Flushes compiled methods dependent on a particular CallSite |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1033 |
// instance when its target is different than the given MethodHandle. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1034 |
void CodeCache::flush_dependents_on(Handle call_site, Handle method_handle) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1035 |
assert_lock_strong(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1036 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1037 |
if (number_of_nmethods_with_dependencies() == 0) return; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1038 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1039 |
// CodeCache can only be updated by a thread_in_VM and they will all be |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1040 |
// stopped during the safepoint so CodeCache will be safe to update without |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1041 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1042 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1043 |
CallSiteDepChange changes(call_site(), method_handle()); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1044 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1045 |
// Compute the dependent nmethods that have a reference to a |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1046 |
// CallSite object. We use InstanceKlass::mark_dependent_nmethod |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1047 |
// directly instead of CodeCache::mark_for_deoptimization because we |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1048 |
// want dependents on the call site class only not all classes in |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1049 |
// the ContextStream. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1050 |
int marked = 0; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1051 |
{ |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1052 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1053 |
InstanceKlass* call_site_klass = InstanceKlass::cast(call_site->klass()); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1054 |
marked = call_site_klass->mark_dependent_nmethods(changes); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1055 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1056 |
if (marked > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1057 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1058 |
VM_Deoptimize op; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1059 |
VMThread::execute(&op); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1060 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1061 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1062 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1063 |
#ifdef HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1064 |
// Flushes compiled methods dependent on dependee in the evolutionary sense |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1065 |
void CodeCache::flush_evol_dependents_on(instanceKlassHandle ev_k_h) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1066 |
// --- Compile_lock is not held. However we are at a safepoint. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1067 |
assert_locked_or_safepoint(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1068 |
if (number_of_nmethods_with_dependencies() == 0) return; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1069 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1070 |
// CodeCache can only be updated by a thread_in_VM and they will all be |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1071 |
// stopped during the safepoint so CodeCache will be safe to update without |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1072 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1073 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1074 |
// Compute the dependent nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1075 |
if (mark_for_evol_deoptimization(ev_k_h) > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1076 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1077 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1078 |
// All this already happens inside a VM_Operation, so we'll do all the work here. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1079 |
// Stuff copied from VM_Deoptimize and modified slightly. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1080 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1081 |
// We do not want any GCs to happen while we are in the middle of this VM operation |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1082 |
ResourceMark rm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1083 |
DeoptimizationMarker dm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1084 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1085 |
// Deoptimize all activations depending on marked nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1086 |
Deoptimization::deoptimize_dependents(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1087 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1088 |
// Make the dependent methods not entrant (in VM_Deoptimize they are made zombies) |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1089 |
make_marked_nmethods_not_entrant(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1090 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1091 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1092 |
#endif // HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1093 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1094 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1095 |
// Flushes compiled methods dependent on dependee |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1096 |
void CodeCache::flush_dependents_on_method(methodHandle m_h) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1097 |
// --- Compile_lock is not held. However we are at a safepoint. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1098 |
assert_locked_or_safepoint(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1099 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1100 |
// CodeCache can only be updated by a thread_in_VM and they will all be |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1101 |
// stopped dring the safepoint so CodeCache will be safe to update without |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1102 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1103 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1104 |
// Compute the dependent nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1105 |
if (mark_for_deoptimization(m_h()) > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1106 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1107 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1108 |
// All this already happens inside a VM_Operation, so we'll do all the work here. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1109 |
// Stuff copied from VM_Deoptimize and modified slightly. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1110 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1111 |
// We do not want any GCs to happen while we are in the middle of this VM operation |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1112 |
ResourceMark rm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1113 |
DeoptimizationMarker dm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1114 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1115 |
// Deoptimize all activations depending on marked nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1116 |
Deoptimization::deoptimize_dependents(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1117 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1118 |
// Make the dependent methods not entrant (in VM_Deoptimize they are made zombies) |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1119 |
make_marked_nmethods_not_entrant(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1120 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1121 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1122 |
|
1 | 1123 |
void CodeCache::verify() { |
26796 | 1124 |
assert_locked_or_safepoint(CodeCache_lock); |
1125 |
FOR_ALL_HEAPS(heap) { |
|
1126 |
(*heap)->verify(); |
|
1127 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1128 |
if (cb->is_alive()) { |
|
1129 |
cb->verify(); |
|
1130 |
} |
|
1131 |
} |
|
1 | 1132 |
} |
1133 |
} |
|
1134 |
||
26796 | 1135 |
// A CodeHeap is full. Print out warning and report event. |
1136 |
void CodeCache::report_codemem_full(int code_blob_type, bool print) { |
|
1137 |
// Get nmethod heap for the given CodeBlobType and build CodeCacheFull event |
|
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1138 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1139 |
assert(heap != NULL, "heap is null"); |
26796 | 1140 |
|
1141 |
if (!heap->was_full() || print) { |
|
1142 |
// Not yet reported for this heap, report |
|
1143 |
heap->report_full(); |
|
1144 |
if (SegmentedCodeCache) { |
|
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
1145 |
warning("%s is full. Compiler has been disabled.", get_code_heap_name(code_blob_type)); |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
1146 |
warning("Try increasing the code heap size using -XX:%s=", get_code_heap_flag_name(code_blob_type)); |
26796 | 1147 |
} else { |
1148 |
warning("CodeCache is full. Compiler has been disabled."); |
|
1149 |
warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); |
|
1150 |
} |
|
1151 |
ResourceMark rm; |
|
1152 |
stringStream s; |
|
1153 |
// Dump code cache into a buffer before locking the tty, |
|
1154 |
{ |
|
1155 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
1156 |
print_summary(&s); |
|
1157 |
} |
|
1158 |
ttyLocker ttyl; |
|
1159 |
tty->print("%s", s.as_string()); |
|
1160 |
} |
|
1161 |
||
18025 | 1162 |
_codemem_full_count++; |
1163 |
EventCodeCacheFull event; |
|
1164 |
if (event.should_commit()) { |
|
26796 | 1165 |
event.set_codeBlobType((u1)code_blob_type); |
1166 |
event.set_startAddress((u8)heap->low_boundary()); |
|
1167 |
event.set_commitedTopAddress((u8)heap->high()); |
|
1168 |
event.set_reservedTopAddress((u8)heap->high_boundary()); |
|
18025 | 1169 |
event.set_entryCount(nof_blobs()); |
1170 |
event.set_methodCount(nof_nmethods()); |
|
1171 |
event.set_adaptorCount(nof_adapters()); |
|
26796 | 1172 |
event.set_unallocatedCapacity(heap->unallocated_capacity()/K); |
18025 | 1173 |
event.set_fullCount(_codemem_full_count); |
1174 |
event.commit(); |
|
1175 |
} |
|
1176 |
} |
|
1177 |
||
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1178 |
void CodeCache::print_memory_overhead() { |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1179 |
size_t wasted_bytes = 0; |
26796 | 1180 |
FOR_ALL_HEAPS(heap) { |
1181 |
CodeHeap* curr_heap = *heap; |
|
1182 |
for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) { |
|
1183 |
HeapBlock* heap_block = ((HeapBlock*)cb) - 1; |
|
1184 |
wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size(); |
|
1185 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1186 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1187 |
// Print bytes that are allocated in the freelist |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1188 |
ttyLocker ttl; |
26796 | 1189 |
tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT, freelists_length()); |
1190 |
tty->print_cr("Allocated in freelist: " SSIZE_FORMAT "kB", bytes_allocated_in_freelists()/K); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
1191 |
tty->print_cr("Unused bytes in CodeBlobs: " SSIZE_FORMAT "kB", (wasted_bytes/K)); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
1192 |
tty->print_cr("Segment map size: " SSIZE_FORMAT "kB", allocated_segments()/K); // 1 byte per segment |
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1193 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1194 |
|
1 | 1195 |
//------------------------------------------------------------------------------------------------ |
1196 |
// Non-product version |
|
1197 |
||
1198 |
#ifndef PRODUCT |
|
1199 |
||
3908 | 1200 |
void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) { |
1201 |
if (PrintCodeCache2) { // Need to add a new flag |
|
1202 |
ResourceMark rm; |
|
1203 |
if (size == 0) size = cb->size(); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
1204 |
tty->print_cr("CodeCache %s: addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size); |
3908 | 1205 |
} |
1206 |
} |
|
1207 |
||
1 | 1208 |
void CodeCache::print_internals() { |
1209 |
int nmethodCount = 0; |
|
1210 |
int runtimeStubCount = 0; |
|
1211 |
int adapterCount = 0; |
|
1212 |
int deoptimizationStubCount = 0; |
|
1213 |
int uncommonTrapStubCount = 0; |
|
1214 |
int bufferBlobCount = 0; |
|
1215 |
int total = 0; |
|
1216 |
int nmethodAlive = 0; |
|
1217 |
int nmethodNotEntrant = 0; |
|
1218 |
int nmethodZombie = 0; |
|
1219 |
int nmethodUnloaded = 0; |
|
1220 |
int nmethodJava = 0; |
|
1221 |
int nmethodNative = 0; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1222 |
int max_nm_size = 0; |
1 | 1223 |
ResourceMark rm; |
1224 |
||
26796 | 1225 |
int i = 0; |
1226 |
FOR_ALL_HEAPS(heap) { |
|
1227 |
if (SegmentedCodeCache && Verbose) { |
|
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1228 |
tty->print_cr("-- %s --", (*heap)->name()); |
26796 | 1229 |
} |
1230 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1231 |
total++; |
|
1232 |
if (cb->is_nmethod()) { |
|
1233 |
nmethod* nm = (nmethod*)cb; |
|
1 | 1234 |
|
26796 | 1235 |
if (Verbose && nm->method() != NULL) { |
1236 |
ResourceMark rm; |
|
1237 |
char *method_name = nm->method()->name_and_sig_as_C_string(); |
|
1238 |
tty->print("%s", method_name); |
|
1239 |
if(nm->is_alive()) { tty->print_cr(" alive"); } |
|
1240 |
if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); } |
|
1241 |
if(nm->is_zombie()) { tty->print_cr(" zombie"); } |
|
1242 |
} |
|
1 | 1243 |
|
26796 | 1244 |
nmethodCount++; |
1 | 1245 |
|
26796 | 1246 |
if(nm->is_alive()) { nmethodAlive++; } |
1247 |
if(nm->is_not_entrant()) { nmethodNotEntrant++; } |
|
1248 |
if(nm->is_zombie()) { nmethodZombie++; } |
|
1249 |
if(nm->is_unloaded()) { nmethodUnloaded++; } |
|
1250 |
if(nm->method() != NULL && nm->is_native_method()) { nmethodNative++; } |
|
1 | 1251 |
|
26796 | 1252 |
if(nm->method() != NULL && nm->is_java_method()) { |
1253 |
nmethodJava++; |
|
1254 |
max_nm_size = MAX2(max_nm_size, nm->size()); |
|
1255 |
} |
|
1256 |
} else if (cb->is_runtime_stub()) { |
|
1257 |
runtimeStubCount++; |
|
1258 |
} else if (cb->is_deoptimization_stub()) { |
|
1259 |
deoptimizationStubCount++; |
|
1260 |
} else if (cb->is_uncommon_trap_stub()) { |
|
1261 |
uncommonTrapStubCount++; |
|
1262 |
} else if (cb->is_adapter_blob()) { |
|
1263 |
adapterCount++; |
|
1264 |
} else if (cb->is_buffer_blob()) { |
|
1265 |
bufferBlobCount++; |
|
1 | 1266 |
} |
1267 |
} |
|
1268 |
} |
|
1269 |
||
1270 |
int bucketSize = 512; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1271 |
int bucketLimit = max_nm_size / bucketSize + 1; |
13195 | 1272 |
int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode); |
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1273 |
memset(buckets, 0, sizeof(int) * bucketLimit); |
1 | 1274 |
|
26796 | 1275 |
NMethodIterator iter; |
1276 |
while(iter.next()) { |
|
1277 |
nmethod* nm = iter.method(); |
|
1278 |
if(nm->method() != NULL && nm->is_java_method()) { |
|
1279 |
buckets[nm->size() / bucketSize]++; |
|
1 | 1280 |
} |
1281 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1282 |
|
1 | 1283 |
tty->print_cr("Code Cache Entries (total of %d)",total); |
1284 |
tty->print_cr("-------------------------------------------------"); |
|
1285 |
tty->print_cr("nmethods: %d",nmethodCount); |
|
1286 |
tty->print_cr("\talive: %d",nmethodAlive); |
|
1287 |
tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant); |
|
1288 |
tty->print_cr("\tzombie: %d",nmethodZombie); |
|
1289 |
tty->print_cr("\tunloaded: %d",nmethodUnloaded); |
|
1290 |
tty->print_cr("\tjava: %d",nmethodJava); |
|
1291 |
tty->print_cr("\tnative: %d",nmethodNative); |
|
1292 |
tty->print_cr("runtime_stubs: %d",runtimeStubCount); |
|
1293 |
tty->print_cr("adapters: %d",adapterCount); |
|
1294 |
tty->print_cr("buffer blobs: %d",bufferBlobCount); |
|
1295 |
tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount); |
|
1296 |
tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount); |
|
1297 |
tty->print_cr("\nnmethod size distribution (non-zombie java)"); |
|
1298 |
tty->print_cr("-------------------------------------------------"); |
|
1299 |
||
1300 |
for(int i=0; i<bucketLimit; i++) { |
|
1301 |
if(buckets[i] != 0) { |
|
1302 |
tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize); |
|
1303 |
tty->fill_to(40); |
|
1304 |
tty->print_cr("%d",buckets[i]); |
|
1305 |
} |
|
1306 |
} |
|
1307 |
||
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27642
diff
changeset
|
1308 |
FREE_C_HEAP_ARRAY(int, buckets); |
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1309 |
print_memory_overhead(); |
1 | 1310 |
} |
1311 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1312 |
#endif // !PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1313 |
|
1 | 1314 |
void CodeCache::print() { |
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1315 |
print_summary(tty); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1316 |
|
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1317 |
#ifndef PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1318 |
if (!Verbose) return; |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1319 |
|
1 | 1320 |
CodeBlob_sizes live; |
1321 |
CodeBlob_sizes dead; |
|
1322 |
||
26796 | 1323 |
FOR_ALL_HEAPS(heap) { |
1324 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1325 |
if (!cb->is_alive()) { |
|
1326 |
dead.add(cb); |
|
1327 |
} else { |
|
1328 |
live.add(cb); |
|
1329 |
} |
|
1 | 1330 |
} |
1331 |
} |
|
1332 |
||
1333 |
tty->print_cr("CodeCache:"); |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1334 |
tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds()); |
1 | 1335 |
|
1336 |
if (!live.is_empty()) { |
|
1337 |
live.print("live"); |
|
1338 |
} |
|
1339 |
if (!dead.is_empty()) { |
|
1340 |
dead.print("dead"); |
|
1341 |
} |
|
1342 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1343 |
if (WizardMode) { |
1 | 1344 |
// print the oop_map usage |
1345 |
int code_size = 0; |
|
1346 |
int number_of_blobs = 0; |
|
1347 |
int number_of_oop_maps = 0; |
|
1348 |
int map_size = 0; |
|
26796 | 1349 |
FOR_ALL_HEAPS(heap) { |
1350 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1351 |
if (cb->is_alive()) { |
|
1352 |
number_of_blobs++; |
|
1353 |
code_size += cb->code_size(); |
|
1354 |
OopMapSet* set = cb->oop_maps(); |
|
1355 |
if (set != NULL) { |
|
1356 |
number_of_oop_maps += set->size(); |
|
1357 |
map_size += set->heap_size(); |
|
1358 |
} |
|
1 | 1359 |
} |
1360 |
} |
|
1361 |
} |
|
1362 |
tty->print_cr("OopMaps"); |
|
1363 |
tty->print_cr(" #blobs = %d", number_of_blobs); |
|
1364 |
tty->print_cr(" code size = %d", code_size); |
|
1365 |
tty->print_cr(" #oop_maps = %d", number_of_oop_maps); |
|
1366 |
tty->print_cr(" map size = %d", map_size); |
|
1367 |
} |
|
1368 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1369 |
#endif // !PRODUCT |
1 | 1370 |
} |
1371 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1372 |
void CodeCache::print_summary(outputStream* st, bool detailed) { |
26796 | 1373 |
FOR_ALL_HEAPS(heap_iterator) { |
1374 |
CodeHeap* heap = (*heap_iterator); |
|
1375 |
size_t total = (heap->high_boundary() - heap->low_boundary()); |
|
1376 |
if (SegmentedCodeCache) { |
|
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1377 |
st->print("%s:", heap->name()); |
26796 | 1378 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
1379 |
st->print("CodeCache:"); |
26796 | 1380 |
} |
1381 |
st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT |
|
1382 |
"Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb", |
|
1383 |
total/K, (total - heap->unallocated_capacity())/K, |
|
1384 |
heap->max_allocated_capacity()/K, heap->unallocated_capacity()/K); |
|
1385 |
||
1386 |
if (detailed) { |
|
1387 |
st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]", |
|
1388 |
p2i(heap->low_boundary()), |
|
1389 |
p2i(heap->high()), |
|
1390 |
p2i(heap->high_boundary())); |
|
1391 |
} |
|
1392 |
} |
|
7108 | 1393 |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1394 |
if (detailed) { |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1395 |
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT |
26796 | 1396 |
" adapters=" UINT32_FORMAT, |
1397 |
nof_blobs(), nof_nmethods(), nof_adapters()); |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1398 |
st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1399 |
"enabled" : Arguments::mode() == Arguments::_int ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1400 |
"disabled (interpreter mode)" : |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1401 |
"disabled (not enough contiguous free space left)"); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1402 |
} |
7108 | 1403 |
} |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1404 |
|
26587 | 1405 |
void CodeCache::print_codelist(outputStream* st) { |
1406 |
assert_locked_or_safepoint(CodeCache_lock); |
|
1407 |
||
26796 | 1408 |
NMethodIterator iter; |
1409 |
while(iter.next_alive()) { |
|
1410 |
nmethod* nm = iter.method(); |
|
26587 | 1411 |
ResourceMark rm; |
26796 | 1412 |
char *method_name = nm->method()->name_and_sig_as_C_string(); |
26587 | 1413 |
st->print_cr("%d %d %s ["INTPTR_FORMAT", "INTPTR_FORMAT" - "INTPTR_FORMAT"]", |
26796 | 1414 |
nm->compile_id(), nm->comp_level(), method_name, (intptr_t)nm->header_begin(), |
1415 |
(intptr_t)nm->code_begin(), (intptr_t)nm->code_end()); |
|
26587 | 1416 |
} |
1417 |
} |
|
1418 |
||
1419 |
void CodeCache::print_layout(outputStream* st) { |
|
1420 |
assert_locked_or_safepoint(CodeCache_lock); |
|
1421 |
ResourceMark rm; |
|
1422 |
||
1423 |
print_summary(st, true); |
|
1424 |
} |
|
1425 |
||
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1426 |
void CodeCache::log_state(outputStream* st) { |
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1427 |
st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" |
17016
78b1c3670525
8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents:
15201
diff
changeset
|
1428 |
" adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1429 |
nof_blobs(), nof_nmethods(), nof_adapters(), |
17016
78b1c3670525
8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents:
15201
diff
changeset
|
1430 |
unallocated_capacity()); |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1431 |
} |