author | anoll |
Fri, 24 Oct 2014 14:25:46 +0200 | |
changeset 27420 | 04e6f914cce1 |
parent 27410 | dd80df7cfa2b |
child 27642 | 8c9eff693145 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, 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 |
|
202 |
// Align reserved sizes of CodeHeaps |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
203 |
size_t non_method_size = ReservedCodeSpace::allocation_align_size_up(NonNMethodCodeHeapSize); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
204 |
size_t profiled_size = ReservedCodeSpace::allocation_align_size_up(ProfiledCodeHeapSize); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
205 |
size_t non_profiled_size = ReservedCodeSpace::allocation_align_size_up(NonProfiledCodeHeapSize); |
1 | 206 |
|
26796 | 207 |
// Compute initial sizes of CodeHeaps |
208 |
size_t init_non_method_size = MIN2(InitialCodeCacheSize, non_method_size); |
|
209 |
size_t init_profiled_size = MIN2(InitialCodeCacheSize, profiled_size); |
|
210 |
size_t init_non_profiled_size = MIN2(InitialCodeCacheSize, non_profiled_size); |
|
1 | 211 |
|
26796 | 212 |
// Reserve one continuous chunk of memory for CodeHeaps and split it into |
213 |
// parts for the individual heaps. The memory layout looks like this: |
|
214 |
// ---------- high ----------- |
|
215 |
// Non-profiled nmethods |
|
216 |
// Profiled nmethods |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
217 |
// Non-nmethods |
26796 | 218 |
// ---------- low ------------ |
219 |
ReservedCodeSpace rs = reserve_heap_memory(non_profiled_size + profiled_size + non_method_size); |
|
220 |
ReservedSpace non_method_space = rs.first_part(non_method_size); |
|
221 |
ReservedSpace rest = rs.last_part(non_method_size); |
|
222 |
ReservedSpace profiled_space = rest.first_part(profiled_size); |
|
223 |
ReservedSpace non_profiled_space = rest.last_part(profiled_size); |
|
224 |
||
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
225 |
// Non-nmethods (stubs, adapters, ...) |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
226 |
add_heap(non_method_space, "CodeHeap 'non-nmethods'", init_non_method_size, CodeBlobType::NonNMethod); |
26796 | 227 |
// Tier 2 and tier 3 (profiled) methods |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
228 |
add_heap(profiled_space, "CodeHeap 'profiled nmethods'", init_profiled_size, CodeBlobType::MethodProfiled); |
26796 | 229 |
// Tier 1 and tier 4 (non-profiled) methods and native methods |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
230 |
add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", init_non_profiled_size, CodeBlobType::MethodNonProfiled); |
1 | 231 |
} |
232 |
||
26796 | 233 |
ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) { |
234 |
// Determine alignment |
|
235 |
const size_t page_size = os::can_execute_large_page_memory() ? |
|
26809 | 236 |
MIN2(os::page_size_for_region(InitialCodeCacheSize, 8), |
237 |
os::page_size_for_region(size, 8)) : |
|
26796 | 238 |
os::vm_page_size(); |
239 |
const size_t granularity = os::vm_allocation_granularity(); |
|
240 |
const size_t r_align = MAX2(page_size, granularity); |
|
241 |
const size_t r_size = align_size_up(size, r_align); |
|
242 |
const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 : |
|
243 |
MAX2(page_size, granularity); |
|
1 | 244 |
|
26796 | 245 |
ReservedCodeSpace rs(r_size, rs_align, rs_align > 0); |
246 |
||
247 |
// Initialize bounds |
|
248 |
_low_bound = (address)rs.base(); |
|
249 |
_high_bound = _low_bound + rs.size(); |
|
250 |
||
251 |
return rs; |
|
252 |
} |
|
253 |
||
254 |
bool CodeCache::heap_available(int code_blob_type) { |
|
255 |
if (!SegmentedCodeCache) { |
|
256 |
// No segmentation: use a single code heap |
|
257 |
return (code_blob_type == CodeBlobType::All); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26942
diff
changeset
|
258 |
} else if (Arguments::mode() == Arguments::_int) { |
26796 | 259 |
// 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
|
260 |
return (code_blob_type == CodeBlobType::NonNMethod); |
26796 | 261 |
} else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) { |
262 |
// Tiered compilation: use all code heaps |
|
263 |
return (code_blob_type < CodeBlobType::All); |
|
264 |
} else { |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
265 |
// 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
|
266 |
return (code_blob_type == CodeBlobType::NonNMethod) || |
26796 | 267 |
(code_blob_type == CodeBlobType::MethodNonProfiled); |
268 |
} |
|
1 | 269 |
} |
270 |
||
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
271 |
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
|
272 |
switch(code_blob_type) { |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
273 |
case CodeBlobType::NonNMethod: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
274 |
return "NonNMethodCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
275 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
276 |
case CodeBlobType::MethodNonProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
277 |
return "NonProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
278 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
279 |
case CodeBlobType::MethodProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
280 |
return "ProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
281 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
282 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
283 |
ShouldNotReachHere(); |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
284 |
return NULL; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
285 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
286 |
|
26796 | 287 |
void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type) { |
288 |
// Check if heap is needed |
|
289 |
if (!heap_available(code_blob_type)) { |
|
290 |
return; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
291 |
} |
26796 | 292 |
|
293 |
// Create CodeHeap |
|
294 |
CodeHeap* heap = new CodeHeap(name, code_blob_type); |
|
295 |
_heaps->append(heap); |
|
296 |
||
297 |
// Reserve Space |
|
298 |
size_initial = round_to(size_initial, os::vm_page_size()); |
|
299 |
||
300 |
if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) { |
|
301 |
vm_exit_during_initialization("Could not reserve enough space for code cache"); |
|
302 |
} |
|
303 |
||
304 |
// Register the CodeHeap |
|
305 |
MemoryService::add_code_heap_memory_pool(heap, name); |
|
306 |
} |
|
307 |
||
308 |
CodeHeap* CodeCache::get_code_heap(CodeBlob* cb) { |
|
309 |
assert(cb != NULL, "CodeBlob is null"); |
|
310 |
FOR_ALL_HEAPS(heap) { |
|
311 |
if ((*heap)->contains(cb)) { |
|
312 |
return *heap; |
|
313 |
} |
|
314 |
} |
|
315 |
ShouldNotReachHere(); |
|
316 |
return NULL; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
317 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
318 |
|
26796 | 319 |
CodeHeap* CodeCache::get_code_heap(int code_blob_type) { |
320 |
FOR_ALL_HEAPS(heap) { |
|
321 |
if ((*heap)->accepts(code_blob_type)) { |
|
322 |
return *heap; |
|
323 |
} |
|
324 |
} |
|
325 |
return NULL; |
|
326 |
} |
|
327 |
||
328 |
CodeBlob* CodeCache::first_blob(CodeHeap* heap) { |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
329 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 330 |
assert(heap != NULL, "heap is null"); |
331 |
return (CodeBlob*)heap->first(); |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
332 |
} |
1 | 333 |
|
26796 | 334 |
CodeBlob* CodeCache::first_blob(int code_blob_type) { |
335 |
if (heap_available(code_blob_type)) { |
|
336 |
return first_blob(get_code_heap(code_blob_type)); |
|
337 |
} else { |
|
338 |
return NULL; |
|
339 |
} |
|
340 |
} |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
341 |
|
26796 | 342 |
CodeBlob* CodeCache::next_blob(CodeHeap* heap, CodeBlob* cb) { |
343 |
assert_locked_or_safepoint(CodeCache_lock); |
|
344 |
assert(heap != NULL, "heap is null"); |
|
345 |
return (CodeBlob*)heap->next(cb); |
|
346 |
} |
|
347 |
||
348 |
CodeBlob* CodeCache::next_blob(CodeBlob* cb) { |
|
349 |
return next_blob(get_code_heap(cb), cb); |
|
350 |
} |
|
351 |
||
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
352 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
353 |
* 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
|
354 |
* 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
|
355 |
* 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
|
356 |
* 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
|
357 |
* instantiating. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
358 |
*/ |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
359 |
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
|
360 |
// Possibly wakes up the sweeper thread. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
361 |
NMethodSweeper::notify(code_blob_type); |
1 | 362 |
assert_locked_or_safepoint(CodeCache_lock); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
363 |
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
|
364 |
if (size <= 0) { |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
365 |
return NULL; |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
366 |
} |
1 | 367 |
CodeBlob* cb = NULL; |
26796 | 368 |
|
369 |
// Get CodeHeap for the given CodeBlobType |
|
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
370 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
371 |
assert(heap != NULL, "heap is null"); |
26796 | 372 |
|
1 | 373 |
while (true) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
374 |
cb = (CodeBlob*)heap->allocate(size); |
1 | 375 |
if (cb != NULL) break; |
26796 | 376 |
if (!heap->expand_by(CodeCacheExpansionSize)) { |
1 | 377 |
// Expansion failed |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
378 |
if (SegmentedCodeCache && (code_blob_type == CodeBlobType::NonNMethod)) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
379 |
// 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
|
380 |
// 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
|
381 |
// 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
|
382 |
return allocate(size, CodeBlobType::MethodNonProfiled); |
26796 | 383 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
384 |
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
|
385 |
CompileBroker::handle_full_code_cache(code_blob_type); |
1 | 386 |
return NULL; |
387 |
} |
|
388 |
if (PrintCodeCacheExtension) { |
|
389 |
ResourceMark rm; |
|
26796 | 390 |
if (SegmentedCodeCache) { |
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
391 |
tty->print("%s", heap->name()); |
26796 | 392 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
393 |
tty->print("CodeCache"); |
26796 | 394 |
} |
395 |
tty->print_cr(" extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)", |
|
396 |
(intptr_t)heap->low_boundary(), (intptr_t)heap->high(), |
|
397 |
(address)heap->high() - (address)heap->low_boundary()); |
|
1 | 398 |
} |
399 |
} |
|
3908 | 400 |
print_trace("allocation", cb, size); |
24439
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
401 |
_number_of_blobs++; |
1 | 402 |
return cb; |
403 |
} |
|
404 |
||
405 |
void CodeCache::free(CodeBlob* cb) { |
|
406 |
assert_locked_or_safepoint(CodeCache_lock); |
|
407 |
||
3908 | 408 |
print_trace("free", cb); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
409 |
if (cb->is_nmethod()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
410 |
_number_of_nmethods--; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
411 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
412 |
_number_of_nmethods_with_dependencies--; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
413 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
414 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
415 |
if (cb->is_adapter_blob()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
416 |
_number_of_adapters--; |
1 | 417 |
} |
418 |
_number_of_blobs--; |
|
419 |
||
26796 | 420 |
// Get heap for given CodeBlob and deallocate |
421 |
get_code_heap(cb)->deallocate(cb); |
|
1 | 422 |
|
423 |
assert(_number_of_blobs >= 0, "sanity check"); |
|
424 |
} |
|
425 |
||
426 |
void CodeCache::commit(CodeBlob* cb) { |
|
427 |
// this is called by nmethod::nmethod, which must already own CodeCache_lock |
|
428 |
assert_locked_or_safepoint(CodeCache_lock); |
|
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
429 |
if (cb->is_nmethod()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
430 |
_number_of_nmethods++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
431 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
432 |
_number_of_nmethods_with_dependencies++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
433 |
} |
1 | 434 |
} |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
435 |
if (cb->is_adapter_blob()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
436 |
_number_of_adapters++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
437 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
438 |
|
1 | 439 |
// flush the hardware I-cache |
6418 | 440 |
ICache::invalidate_range(cb->content_begin(), cb->content_size()); |
1 | 441 |
} |
442 |
||
443 |
bool CodeCache::contains(void *p) { |
|
444 |
// It should be ok to call contains without holding a lock |
|
26796 | 445 |
FOR_ALL_HEAPS(heap) { |
446 |
if ((*heap)->contains(p)) { |
|
447 |
return true; |
|
448 |
} |
|
449 |
} |
|
450 |
return false; |
|
1 | 451 |
} |
452 |
||
26796 | 453 |
// This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not |
454 |
// looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain |
|
1 | 455 |
// valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled. |
456 |
CodeBlob* CodeCache::find_blob(void* start) { |
|
457 |
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
|
458 |
// We could potentially look up non_entrant methods |
26796 | 459 |
guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || is_error_reported(), "unsafe access to zombie method"); |
1 | 460 |
return result; |
461 |
} |
|
462 |
||
26796 | 463 |
// Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know |
464 |
// what you are doing) |
|
465 |
CodeBlob* CodeCache::find_blob_unsafe(void* start) { |
|
466 |
// NMT can walk the stack before code cache is created |
|
467 |
if (_heaps == NULL || _heaps->is_empty()) return NULL; |
|
468 |
||
469 |
FOR_ALL_HEAPS(heap) { |
|
470 |
CodeBlob* result = (CodeBlob*) (*heap)->find_start(start); |
|
471 |
if (result != NULL && result->blob_contains((address)start)) { |
|
472 |
return result; |
|
473 |
} |
|
474 |
} |
|
475 |
return NULL; |
|
476 |
} |
|
477 |
||
1 | 478 |
nmethod* CodeCache::find_nmethod(void* start) { |
26796 | 479 |
CodeBlob* cb = find_blob(start); |
480 |
assert(cb->is_nmethod(), "did not find an nmethod"); |
|
1 | 481 |
return (nmethod*)cb; |
482 |
} |
|
483 |
||
484 |
void CodeCache::blobs_do(void f(CodeBlob* nm)) { |
|
485 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 486 |
FOR_ALL_HEAPS(heap) { |
487 |
FOR_ALL_BLOBS(cb, *heap) { |
|
488 |
f(cb); |
|
489 |
} |
|
1 | 490 |
} |
491 |
} |
|
492 |
||
493 |
void CodeCache::nmethods_do(void f(nmethod* nm)) { |
|
494 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 495 |
NMethodIterator iter; |
496 |
while(iter.next()) { |
|
497 |
f(iter.method()); |
|
1 | 498 |
} |
499 |
} |
|
500 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
501 |
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
|
502 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 503 |
NMethodIterator iter; |
504 |
while(iter.next_alive()) { |
|
505 |
f(iter.method()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
506 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
507 |
} |
1 | 508 |
|
509 |
int CodeCache::alignment_unit() { |
|
26796 | 510 |
return (int)_heaps->first()->alignment_unit(); |
1 | 511 |
} |
512 |
||
513 |
int CodeCache::alignment_offset() { |
|
26796 | 514 |
return (int)_heaps->first()->alignment_offset(); |
1 | 515 |
} |
516 |
||
26796 | 517 |
// 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
|
518 |
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { |
1 | 519 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 520 |
NMethodIterator iter; |
521 |
while(iter.next_alive()) { |
|
522 |
iter.method()->do_unloading(is_alive, unloading_occurred); |
|
1 | 523 |
} |
524 |
} |
|
525 |
||
3908 | 526 |
void CodeCache::blobs_do(CodeBlobClosure* f) { |
1 | 527 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 528 |
FOR_ALL_HEAPS(heap) { |
529 |
FOR_ALL_BLOBS(cb, *heap) { |
|
530 |
if (cb->is_alive()) { |
|
531 |
f->do_code_blob(cb); |
|
3908 | 532 |
|
533 |
#ifdef ASSERT |
|
26796 | 534 |
if (cb->is_nmethod()) |
535 |
((nmethod*)cb)->verify_scavenge_root_oops(); |
|
3908 | 536 |
#endif //ASSERT |
26796 | 537 |
} |
538 |
} |
|
1 | 539 |
} |
540 |
} |
|
541 |
||
3908 | 542 |
// Walk the list of methods which might contain non-perm oops. |
543 |
void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) { |
|
544 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
545 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
546 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
547 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
548 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
549 |
|
3908 | 550 |
debug_only(mark_scavenge_root_nmethods()); |
551 |
||
552 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
|
553 |
debug_only(cur->clear_scavenge_root_marked()); |
|
554 |
assert(cur->scavenge_root_not_marked(), ""); |
|
555 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
556 |
||
557 |
bool is_live = (!cur->is_zombie() && !cur->is_unloaded()); |
|
558 |
#ifndef PRODUCT |
|
559 |
if (TraceScavenge) { |
|
560 |
cur->print_on(tty, is_live ? "scavenge root" : "dead scavenge root"); tty->cr(); |
|
561 |
} |
|
562 |
#endif //PRODUCT |
|
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
563 |
if (is_live) { |
3908 | 564 |
// Perform cur->oops_do(f), maybe just once per nmethod. |
565 |
f->do_code_blob(cur); |
|
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
566 |
} |
3908 | 567 |
} |
568 |
||
569 |
// Check for stray marks. |
|
570 |
debug_only(verify_perm_nmethods(NULL)); |
|
571 |
} |
|
572 |
||
573 |
void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
|
574 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
575 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
576 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
577 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
578 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
579 |
|
3908 | 580 |
nm->set_on_scavenge_root_list(); |
581 |
nm->set_scavenge_root_link(_scavenge_root_nmethods); |
|
582 |
set_scavenge_root_nmethods(nm); |
|
583 |
print_trace("add_scavenge_root", nm); |
|
584 |
} |
|
585 |
||
586 |
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
|
587 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
588 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
589 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
590 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
591 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
592 |
|
3908 | 593 |
print_trace("drop_scavenge_root", nm); |
594 |
nmethod* last = NULL; |
|
595 |
nmethod* cur = scavenge_root_nmethods(); |
|
596 |
while (cur != NULL) { |
|
597 |
nmethod* next = cur->scavenge_root_link(); |
|
598 |
if (cur == nm) { |
|
599 |
if (last != NULL) |
|
600 |
last->set_scavenge_root_link(next); |
|
601 |
else set_scavenge_root_nmethods(next); |
|
602 |
nm->set_scavenge_root_link(NULL); |
|
603 |
nm->clear_on_scavenge_root_list(); |
|
604 |
return; |
|
605 |
} |
|
606 |
last = cur; |
|
607 |
cur = next; |
|
608 |
} |
|
609 |
assert(false, "should have been on list"); |
|
610 |
} |
|
611 |
||
612 |
void CodeCache::prune_scavenge_root_nmethods() { |
|
613 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
614 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
615 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
616 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
617 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
618 |
|
3908 | 619 |
debug_only(mark_scavenge_root_nmethods()); |
620 |
||
621 |
nmethod* last = NULL; |
|
622 |
nmethod* cur = scavenge_root_nmethods(); |
|
623 |
while (cur != NULL) { |
|
624 |
nmethod* next = cur->scavenge_root_link(); |
|
625 |
debug_only(cur->clear_scavenge_root_marked()); |
|
626 |
assert(cur->scavenge_root_not_marked(), ""); |
|
627 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
628 |
||
629 |
if (!cur->is_zombie() && !cur->is_unloaded() |
|
630 |
&& cur->detect_scavenge_root_oops()) { |
|
631 |
// Keep it. Advance 'last' to prevent deletion. |
|
632 |
last = cur; |
|
633 |
} else { |
|
634 |
// Prune it from the list, so we don't have to look at it any more. |
|
635 |
print_trace("prune_scavenge_root", cur); |
|
636 |
cur->set_scavenge_root_link(NULL); |
|
637 |
cur->clear_on_scavenge_root_list(); |
|
638 |
if (last != NULL) |
|
639 |
last->set_scavenge_root_link(next); |
|
640 |
else set_scavenge_root_nmethods(next); |
|
641 |
} |
|
642 |
cur = next; |
|
643 |
} |
|
644 |
||
645 |
// Check for stray marks. |
|
646 |
debug_only(verify_perm_nmethods(NULL)); |
|
647 |
} |
|
648 |
||
649 |
#ifndef PRODUCT |
|
650 |
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
|
651 |
if (UseG1GC) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
652 |
return; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
653 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
654 |
|
3908 | 655 |
// While we are here, verify the integrity of the list. |
656 |
mark_scavenge_root_nmethods(); |
|
657 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
|
658 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
659 |
cur->clear_scavenge_root_marked(); |
|
660 |
} |
|
661 |
verify_perm_nmethods(f); |
|
662 |
} |
|
663 |
||
664 |
// Temporarily mark nmethods that are claimed to be on the non-perm list. |
|
665 |
void CodeCache::mark_scavenge_root_nmethods() { |
|
26796 | 666 |
NMethodIterator iter; |
667 |
while(iter.next_alive()) { |
|
668 |
nmethod* nm = iter.method(); |
|
669 |
assert(nm->scavenge_root_not_marked(), "clean state"); |
|
670 |
if (nm->on_scavenge_root_list()) |
|
671 |
nm->set_scavenge_root_marked(); |
|
3908 | 672 |
} |
673 |
} |
|
674 |
||
675 |
// If the closure is given, run it on the unlisted nmethods. |
|
676 |
// Also make sure that the effects of mark_scavenge_root_nmethods is gone. |
|
677 |
void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) { |
|
26796 | 678 |
NMethodIterator iter; |
679 |
while(iter.next_alive()) { |
|
680 |
nmethod* nm = iter.method(); |
|
3908 | 681 |
bool call_f = (f_or_null != NULL); |
26796 | 682 |
assert(nm->scavenge_root_not_marked(), "must be already processed"); |
683 |
if (nm->on_scavenge_root_list()) |
|
684 |
call_f = false; // don't show this one to the client |
|
685 |
nm->verify_scavenge_root_oops(); |
|
686 |
if (call_f) f_or_null->do_code_blob(nm); |
|
3908 | 687 |
} |
688 |
} |
|
689 |
#endif //PRODUCT |
|
690 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
691 |
void CodeCache::verify_clean_inline_caches() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
692 |
#ifdef ASSERT |
26796 | 693 |
NMethodIterator iter; |
694 |
while(iter.next_alive()) { |
|
695 |
nmethod* nm = iter.method(); |
|
696 |
assert(!nm->is_unloaded(), "Tautology"); |
|
697 |
nm->verify_clean_inline_caches(); |
|
698 |
nm->verify(); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
699 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
700 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
701 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
702 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
703 |
void CodeCache::verify_icholder_relocations() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
704 |
#ifdef ASSERT |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
705 |
// make sure that we aren't leaking icholders |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
706 |
int count = 0; |
26796 | 707 |
FOR_ALL_HEAPS(heap) { |
708 |
FOR_ALL_BLOBS(cb, *heap) { |
|
709 |
if (cb->is_nmethod()) { |
|
710 |
nmethod* nm = (nmethod*)cb; |
|
711 |
count += nm->verify_icholder_relocations(); |
|
712 |
} |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
713 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
714 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
715 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
716 |
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
|
717 |
CompiledICHolder::live_count(), "must agree"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
718 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
719 |
} |
4750 | 720 |
|
1 | 721 |
void CodeCache::gc_prologue() { |
722 |
} |
|
723 |
||
724 |
void CodeCache::gc_epilogue() { |
|
725 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 726 |
NMethodIterator iter; |
727 |
while(iter.next_alive()) { |
|
728 |
nmethod* nm = iter.method(); |
|
729 |
assert(!nm->is_unloaded(), "Tautology"); |
|
730 |
if (needs_cache_clean()) { |
|
731 |
nm->cleanup_inline_caches(); |
|
1 | 732 |
} |
26796 | 733 |
DEBUG_ONLY(nm->verify()); |
734 |
DEBUG_ONLY(nm->verify_oop_relocations()); |
|
1 | 735 |
} |
736 |
set_needs_cache_clean(false); |
|
3908 | 737 |
prune_scavenge_root_nmethods(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
738 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
739 |
verify_icholder_relocations(); |
1 | 740 |
} |
741 |
||
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
742 |
void CodeCache::verify_oops() { |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
743 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
744 |
VerifyOopClosure voc; |
26796 | 745 |
NMethodIterator iter; |
746 |
while(iter.next_alive()) { |
|
747 |
nmethod* nm = iter.method(); |
|
748 |
nm->oops_do(&voc); |
|
749 |
nm->verify_oop_relocations(); |
|
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
750 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
751 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
752 |
|
26796 | 753 |
size_t CodeCache::capacity() { |
754 |
size_t cap = 0; |
|
755 |
FOR_ALL_HEAPS(heap) { |
|
756 |
cap += (*heap)->capacity(); |
|
757 |
} |
|
758 |
return cap; |
|
1 | 759 |
} |
760 |
||
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
761 |
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
|
762 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
763 |
return (heap != NULL) ? heap->unallocated_capacity() : 0; |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
764 |
} |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
765 |
|
26796 | 766 |
size_t CodeCache::unallocated_capacity() { |
767 |
size_t unallocated_cap = 0; |
|
768 |
FOR_ALL_HEAPS(heap) { |
|
769 |
unallocated_cap += (*heap)->unallocated_capacity(); |
|
770 |
} |
|
771 |
return unallocated_cap; |
|
772 |
} |
|
1 | 773 |
|
26796 | 774 |
size_t CodeCache::max_capacity() { |
775 |
size_t max_cap = 0; |
|
776 |
FOR_ALL_HEAPS(heap) { |
|
777 |
max_cap += (*heap)->max_capacity(); |
|
778 |
} |
|
779 |
return max_cap; |
|
1 | 780 |
} |
781 |
||
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
782 |
/** |
26796 | 783 |
* 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
|
784 |
* 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
|
785 |
*/ |
26796 | 786 |
double CodeCache::reverse_free_ratio(int code_blob_type) { |
787 |
CodeHeap* heap = get_code_heap(code_blob_type); |
|
788 |
if (heap == NULL) { |
|
789 |
return 0; |
|
790 |
} |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
791 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
792 |
double unallocated_capacity = MAX2((double)heap->unallocated_capacity(), 1.0); // Avoid division by 0; |
26796 | 793 |
double max_capacity = (double)heap->max_capacity(); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
794 |
double result = max_capacity / unallocated_capacity; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
795 |
assert (max_capacity >= unallocated_capacity, "Must be"); |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
796 |
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
|
797 |
return result; |
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
798 |
} |
1 | 799 |
|
26796 | 800 |
size_t CodeCache::bytes_allocated_in_freelists() { |
801 |
size_t allocated_bytes = 0; |
|
802 |
FOR_ALL_HEAPS(heap) { |
|
803 |
allocated_bytes += (*heap)->allocated_in_freelist(); |
|
804 |
} |
|
805 |
return allocated_bytes; |
|
806 |
} |
|
807 |
||
808 |
int CodeCache::allocated_segments() { |
|
809 |
int number_of_segments = 0; |
|
810 |
FOR_ALL_HEAPS(heap) { |
|
811 |
number_of_segments += (*heap)->allocated_segments(); |
|
812 |
} |
|
813 |
return number_of_segments; |
|
814 |
} |
|
815 |
||
816 |
size_t CodeCache::freelists_length() { |
|
817 |
size_t length = 0; |
|
818 |
FOR_ALL_HEAPS(heap) { |
|
819 |
length += (*heap)->freelist_length(); |
|
820 |
} |
|
821 |
return length; |
|
822 |
} |
|
823 |
||
1 | 824 |
void icache_init(); |
825 |
||
826 |
void CodeCache::initialize() { |
|
827 |
assert(CodeCacheSegmentSize >= (uintx)CodeEntryAlignment, "CodeCacheSegmentSize must be large enough to align entry points"); |
|
828 |
#ifdef COMPILER2 |
|
829 |
assert(CodeCacheSegmentSize >= (uintx)OptoLoopAlignment, "CodeCacheSegmentSize must be large enough to align inner loops"); |
|
830 |
#endif |
|
831 |
assert(CodeCacheSegmentSize >= sizeof(jdouble), "CodeCacheSegmentSize must be large enough to align constants"); |
|
832 |
// This was originally just a check of the alignment, causing failure, instead, round |
|
833 |
// the code cache to the page size. In particular, Solaris is moving to a larger |
|
834 |
// default page size. |
|
835 |
CodeCacheExpansionSize = round_to(CodeCacheExpansionSize, os::vm_page_size()); |
|
26796 | 836 |
|
837 |
if (SegmentedCodeCache) { |
|
838 |
// Use multiple code heaps |
|
839 |
initialize_heaps(); |
|
840 |
} else { |
|
841 |
// Use a single code heap |
|
842 |
ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
843 |
add_heap(rs, "CodeCache", InitialCodeCacheSize, CodeBlobType::All); |
1 | 844 |
} |
845 |
||
846 |
// Initialize ICache flush mechanism |
|
847 |
// This service is needed for os::register_code_area |
|
848 |
icache_init(); |
|
849 |
||
850 |
// Give OS a chance to register generated code area. |
|
851 |
// This is used on Windows 64 bit platforms to register |
|
852 |
// Structured Exception Handlers for our generated code. |
|
26796 | 853 |
os::register_code_area((char*)low_bound(), (char*)high_bound()); |
1 | 854 |
} |
855 |
||
856 |
void codeCache_init() { |
|
857 |
CodeCache::initialize(); |
|
858 |
} |
|
859 |
||
860 |
//------------------------------------------------------------------------------------------------ |
|
861 |
||
862 |
int CodeCache::number_of_nmethods_with_dependencies() { |
|
863 |
return _number_of_nmethods_with_dependencies; |
|
864 |
} |
|
865 |
||
866 |
void CodeCache::clear_inline_caches() { |
|
867 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 868 |
NMethodIterator iter; |
869 |
while(iter.next_alive()) { |
|
870 |
iter.method()->clear_inline_caches(); |
|
1 | 871 |
} |
872 |
} |
|
873 |
||
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
874 |
// Keeps track of time spent for checking dependencies |
22921
ee35d5c0b1dc
8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents:
22506
diff
changeset
|
875 |
NOT_PRODUCT(static elapsedTimer dependentCheckTime;) |
1 | 876 |
|
877 |
int CodeCache::mark_for_deoptimization(DepChange& changes) { |
|
878 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
879 |
int number_of_marked_CodeBlobs = 0; |
|
880 |
||
881 |
// search the hierarchy looking for nmethods which are affected by the loading of this class |
|
882 |
||
883 |
// then search the interfaces this class implements looking for nmethods |
|
884 |
// which might be dependent of the fact that an interface only had one |
|
885 |
// implementor. |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
886 |
// 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
|
887 |
// can happen |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
888 |
No_Safepoint_Verifier nsv; |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
889 |
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
|
890 |
Klass* d = str.klass(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
891 |
number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes); |
1 | 892 |
} |
893 |
||
894 |
#ifndef PRODUCT |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
895 |
if (VerifyDependencies) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
896 |
// 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
|
897 |
// 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
|
898 |
dependentCheckTime.start(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
899 |
nmethod::check_all_dependencies(changes); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
900 |
dependentCheckTime.stop(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
901 |
} |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
902 |
#endif |
1 | 903 |
|
904 |
return number_of_marked_CodeBlobs; |
|
905 |
} |
|
906 |
||
907 |
||
908 |
#ifdef HOTSWAP |
|
909 |
int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { |
|
910 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
911 |
int number_of_marked_CodeBlobs = 0; |
|
912 |
||
913 |
// 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
|
914 |
Array<Method*>* old_methods = dependee->methods(); |
1 | 915 |
for (int i = 0; i < old_methods->length(); i++) { |
916 |
ResourceMark rm; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
917 |
Method* old_method = old_methods->at(i); |
1 | 918 |
nmethod *nm = old_method->code(); |
919 |
if (nm != NULL) { |
|
920 |
nm->mark_for_deoptimization(); |
|
921 |
number_of_marked_CodeBlobs++; |
|
922 |
} |
|
923 |
} |
|
924 |
||
26796 | 925 |
NMethodIterator iter; |
926 |
while(iter.next_alive()) { |
|
927 |
nmethod* nm = iter.method(); |
|
1 | 928 |
if (nm->is_marked_for_deoptimization()) { |
929 |
// ...Already marked in the previous pass; don't count it again. |
|
930 |
} else if (nm->is_evol_dependent_on(dependee())) { |
|
931 |
ResourceMark rm; |
|
932 |
nm->mark_for_deoptimization(); |
|
933 |
number_of_marked_CodeBlobs++; |
|
934 |
} else { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
935 |
// flush caches in case they refer to a redefined Method* |
1 | 936 |
nm->clear_inline_caches(); |
937 |
} |
|
938 |
} |
|
939 |
||
940 |
return number_of_marked_CodeBlobs; |
|
941 |
} |
|
942 |
#endif // HOTSWAP |
|
943 |
||
944 |
||
945 |
// Deoptimize all methods |
|
946 |
void CodeCache::mark_all_nmethods_for_deoptimization() { |
|
947 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
26796 | 948 |
NMethodIterator iter; |
949 |
while(iter.next_alive()) { |
|
950 |
nmethod* nm = iter.method(); |
|
26580
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
951 |
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
|
952 |
nm->mark_for_deoptimization(); |
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
953 |
} |
1 | 954 |
} |
955 |
} |
|
956 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
957 |
int CodeCache::mark_for_deoptimization(Method* dependee) { |
1 | 958 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
959 |
int number_of_marked_CodeBlobs = 0; |
|
960 |
||
26796 | 961 |
NMethodIterator iter; |
962 |
while(iter.next_alive()) { |
|
963 |
nmethod* nm = iter.method(); |
|
1 | 964 |
if (nm->is_dependent_on_method(dependee)) { |
965 |
ResourceMark rm; |
|
966 |
nm->mark_for_deoptimization(); |
|
967 |
number_of_marked_CodeBlobs++; |
|
968 |
} |
|
969 |
} |
|
970 |
||
971 |
return number_of_marked_CodeBlobs; |
|
972 |
} |
|
973 |
||
974 |
void CodeCache::make_marked_nmethods_zombies() { |
|
975 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); |
|
26796 | 976 |
NMethodIterator iter; |
977 |
while(iter.next_alive()) { |
|
978 |
nmethod* nm = iter.method(); |
|
1 | 979 |
if (nm->is_marked_for_deoptimization()) { |
980 |
||
981 |
// If the nmethod has already been made non-entrant and it can be converted |
|
982 |
// then zombie it now. Otherwise make it non-entrant and it will eventually |
|
983 |
// be zombied when it is no longer seen on the stack. Note that the nmethod |
|
984 |
// might be "entrant" and not on the stack and so could be zombied immediately |
|
985 |
// but we can't tell because we don't track it on stack until it becomes |
|
986 |
// non-entrant. |
|
987 |
||
988 |
if (nm->is_not_entrant() && nm->can_not_entrant_be_converted()) { |
|
989 |
nm->make_zombie(); |
|
990 |
} else { |
|
991 |
nm->make_not_entrant(); |
|
992 |
} |
|
993 |
} |
|
994 |
} |
|
995 |
} |
|
996 |
||
997 |
void CodeCache::make_marked_nmethods_not_entrant() { |
|
998 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 999 |
NMethodIterator iter; |
1000 |
while(iter.next_alive()) { |
|
1001 |
nmethod* nm = iter.method(); |
|
1 | 1002 |
if (nm->is_marked_for_deoptimization()) { |
1003 |
nm->make_not_entrant(); |
|
1004 |
} |
|
1005 |
} |
|
1006 |
} |
|
1007 |
||
1008 |
void CodeCache::verify() { |
|
26796 | 1009 |
assert_locked_or_safepoint(CodeCache_lock); |
1010 |
FOR_ALL_HEAPS(heap) { |
|
1011 |
(*heap)->verify(); |
|
1012 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1013 |
if (cb->is_alive()) { |
|
1014 |
cb->verify(); |
|
1015 |
} |
|
1016 |
} |
|
1 | 1017 |
} |
1018 |
} |
|
1019 |
||
26796 | 1020 |
// A CodeHeap is full. Print out warning and report event. |
1021 |
void CodeCache::report_codemem_full(int code_blob_type, bool print) { |
|
1022 |
// 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
|
1023 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1024 |
assert(heap != NULL, "heap is null"); |
26796 | 1025 |
|
1026 |
if (!heap->was_full() || print) { |
|
1027 |
// Not yet reported for this heap, report |
|
1028 |
heap->report_full(); |
|
1029 |
if (SegmentedCodeCache) { |
|
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
1030 |
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
|
1031 |
warning("Try increasing the code heap size using -XX:%s=", get_code_heap_flag_name(code_blob_type)); |
26796 | 1032 |
} else { |
1033 |
warning("CodeCache is full. Compiler has been disabled."); |
|
1034 |
warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize="); |
|
1035 |
} |
|
1036 |
ResourceMark rm; |
|
1037 |
stringStream s; |
|
1038 |
// Dump code cache into a buffer before locking the tty, |
|
1039 |
{ |
|
1040 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
1041 |
print_summary(&s); |
|
1042 |
} |
|
1043 |
ttyLocker ttyl; |
|
1044 |
tty->print("%s", s.as_string()); |
|
1045 |
} |
|
1046 |
||
18025 | 1047 |
_codemem_full_count++; |
1048 |
EventCodeCacheFull event; |
|
1049 |
if (event.should_commit()) { |
|
26796 | 1050 |
event.set_codeBlobType((u1)code_blob_type); |
1051 |
event.set_startAddress((u8)heap->low_boundary()); |
|
1052 |
event.set_commitedTopAddress((u8)heap->high()); |
|
1053 |
event.set_reservedTopAddress((u8)heap->high_boundary()); |
|
18025 | 1054 |
event.set_entryCount(nof_blobs()); |
1055 |
event.set_methodCount(nof_nmethods()); |
|
1056 |
event.set_adaptorCount(nof_adapters()); |
|
26796 | 1057 |
event.set_unallocatedCapacity(heap->unallocated_capacity()/K); |
18025 | 1058 |
event.set_fullCount(_codemem_full_count); |
1059 |
event.commit(); |
|
1060 |
} |
|
1061 |
} |
|
1062 |
||
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1063 |
void CodeCache::print_memory_overhead() { |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1064 |
size_t wasted_bytes = 0; |
26796 | 1065 |
FOR_ALL_HEAPS(heap) { |
1066 |
CodeHeap* curr_heap = *heap; |
|
1067 |
for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) { |
|
1068 |
HeapBlock* heap_block = ((HeapBlock*)cb) - 1; |
|
1069 |
wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size(); |
|
1070 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1071 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1072 |
// 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
|
1073 |
ttyLocker ttl; |
26796 | 1074 |
tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT, freelists_length()); |
1075 |
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
|
1076 |
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
|
1077 |
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
|
1078 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1079 |
|
1 | 1080 |
//------------------------------------------------------------------------------------------------ |
1081 |
// Non-product version |
|
1082 |
||
1083 |
#ifndef PRODUCT |
|
1084 |
||
3908 | 1085 |
void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) { |
1086 |
if (PrintCodeCache2) { // Need to add a new flag |
|
1087 |
ResourceMark rm; |
|
1088 |
if (size == 0) size = cb->size(); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
1089 |
tty->print_cr("CodeCache %s: addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size); |
3908 | 1090 |
} |
1091 |
} |
|
1092 |
||
1 | 1093 |
void CodeCache::print_internals() { |
1094 |
int nmethodCount = 0; |
|
1095 |
int runtimeStubCount = 0; |
|
1096 |
int adapterCount = 0; |
|
1097 |
int deoptimizationStubCount = 0; |
|
1098 |
int uncommonTrapStubCount = 0; |
|
1099 |
int bufferBlobCount = 0; |
|
1100 |
int total = 0; |
|
1101 |
int nmethodAlive = 0; |
|
1102 |
int nmethodNotEntrant = 0; |
|
1103 |
int nmethodZombie = 0; |
|
1104 |
int nmethodUnloaded = 0; |
|
1105 |
int nmethodJava = 0; |
|
1106 |
int nmethodNative = 0; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1107 |
int max_nm_size = 0; |
1 | 1108 |
ResourceMark rm; |
1109 |
||
26796 | 1110 |
int i = 0; |
1111 |
FOR_ALL_HEAPS(heap) { |
|
1112 |
if (SegmentedCodeCache && Verbose) { |
|
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1113 |
tty->print_cr("-- %s --", (*heap)->name()); |
26796 | 1114 |
} |
1115 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1116 |
total++; |
|
1117 |
if (cb->is_nmethod()) { |
|
1118 |
nmethod* nm = (nmethod*)cb; |
|
1 | 1119 |
|
26796 | 1120 |
if (Verbose && nm->method() != NULL) { |
1121 |
ResourceMark rm; |
|
1122 |
char *method_name = nm->method()->name_and_sig_as_C_string(); |
|
1123 |
tty->print("%s", method_name); |
|
1124 |
if(nm->is_alive()) { tty->print_cr(" alive"); } |
|
1125 |
if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); } |
|
1126 |
if(nm->is_zombie()) { tty->print_cr(" zombie"); } |
|
1127 |
} |
|
1 | 1128 |
|
26796 | 1129 |
nmethodCount++; |
1 | 1130 |
|
26796 | 1131 |
if(nm->is_alive()) { nmethodAlive++; } |
1132 |
if(nm->is_not_entrant()) { nmethodNotEntrant++; } |
|
1133 |
if(nm->is_zombie()) { nmethodZombie++; } |
|
1134 |
if(nm->is_unloaded()) { nmethodUnloaded++; } |
|
1135 |
if(nm->method() != NULL && nm->is_native_method()) { nmethodNative++; } |
|
1 | 1136 |
|
26796 | 1137 |
if(nm->method() != NULL && nm->is_java_method()) { |
1138 |
nmethodJava++; |
|
1139 |
max_nm_size = MAX2(max_nm_size, nm->size()); |
|
1140 |
} |
|
1141 |
} else if (cb->is_runtime_stub()) { |
|
1142 |
runtimeStubCount++; |
|
1143 |
} else if (cb->is_deoptimization_stub()) { |
|
1144 |
deoptimizationStubCount++; |
|
1145 |
} else if (cb->is_uncommon_trap_stub()) { |
|
1146 |
uncommonTrapStubCount++; |
|
1147 |
} else if (cb->is_adapter_blob()) { |
|
1148 |
adapterCount++; |
|
1149 |
} else if (cb->is_buffer_blob()) { |
|
1150 |
bufferBlobCount++; |
|
1 | 1151 |
} |
1152 |
} |
|
1153 |
} |
|
1154 |
||
1155 |
int bucketSize = 512; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1156 |
int bucketLimit = max_nm_size / bucketSize + 1; |
13195 | 1157 |
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
|
1158 |
memset(buckets, 0, sizeof(int) * bucketLimit); |
1 | 1159 |
|
26796 | 1160 |
NMethodIterator iter; |
1161 |
while(iter.next()) { |
|
1162 |
nmethod* nm = iter.method(); |
|
1163 |
if(nm->method() != NULL && nm->is_java_method()) { |
|
1164 |
buckets[nm->size() / bucketSize]++; |
|
1 | 1165 |
} |
1166 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1167 |
|
1 | 1168 |
tty->print_cr("Code Cache Entries (total of %d)",total); |
1169 |
tty->print_cr("-------------------------------------------------"); |
|
1170 |
tty->print_cr("nmethods: %d",nmethodCount); |
|
1171 |
tty->print_cr("\talive: %d",nmethodAlive); |
|
1172 |
tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant); |
|
1173 |
tty->print_cr("\tzombie: %d",nmethodZombie); |
|
1174 |
tty->print_cr("\tunloaded: %d",nmethodUnloaded); |
|
1175 |
tty->print_cr("\tjava: %d",nmethodJava); |
|
1176 |
tty->print_cr("\tnative: %d",nmethodNative); |
|
1177 |
tty->print_cr("runtime_stubs: %d",runtimeStubCount); |
|
1178 |
tty->print_cr("adapters: %d",adapterCount); |
|
1179 |
tty->print_cr("buffer blobs: %d",bufferBlobCount); |
|
1180 |
tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount); |
|
1181 |
tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount); |
|
1182 |
tty->print_cr("\nnmethod size distribution (non-zombie java)"); |
|
1183 |
tty->print_cr("-------------------------------------------------"); |
|
1184 |
||
1185 |
for(int i=0; i<bucketLimit; i++) { |
|
1186 |
if(buckets[i] != 0) { |
|
1187 |
tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize); |
|
1188 |
tty->fill_to(40); |
|
1189 |
tty->print_cr("%d",buckets[i]); |
|
1190 |
} |
|
1191 |
} |
|
1192 |
||
13195 | 1193 |
FREE_C_HEAP_ARRAY(int, buckets, mtCode); |
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1194 |
print_memory_overhead(); |
1 | 1195 |
} |
1196 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1197 |
#endif // !PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1198 |
|
1 | 1199 |
void CodeCache::print() { |
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1200 |
print_summary(tty); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1201 |
|
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1202 |
#ifndef PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1203 |
if (!Verbose) return; |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1204 |
|
1 | 1205 |
CodeBlob_sizes live; |
1206 |
CodeBlob_sizes dead; |
|
1207 |
||
26796 | 1208 |
FOR_ALL_HEAPS(heap) { |
1209 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1210 |
if (!cb->is_alive()) { |
|
1211 |
dead.add(cb); |
|
1212 |
} else { |
|
1213 |
live.add(cb); |
|
1214 |
} |
|
1 | 1215 |
} |
1216 |
} |
|
1217 |
||
1218 |
tty->print_cr("CodeCache:"); |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1219 |
tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds()); |
1 | 1220 |
|
1221 |
if (!live.is_empty()) { |
|
1222 |
live.print("live"); |
|
1223 |
} |
|
1224 |
if (!dead.is_empty()) { |
|
1225 |
dead.print("dead"); |
|
1226 |
} |
|
1227 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1228 |
if (WizardMode) { |
1 | 1229 |
// print the oop_map usage |
1230 |
int code_size = 0; |
|
1231 |
int number_of_blobs = 0; |
|
1232 |
int number_of_oop_maps = 0; |
|
1233 |
int map_size = 0; |
|
26796 | 1234 |
FOR_ALL_HEAPS(heap) { |
1235 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1236 |
if (cb->is_alive()) { |
|
1237 |
number_of_blobs++; |
|
1238 |
code_size += cb->code_size(); |
|
1239 |
OopMapSet* set = cb->oop_maps(); |
|
1240 |
if (set != NULL) { |
|
1241 |
number_of_oop_maps += set->size(); |
|
1242 |
map_size += set->heap_size(); |
|
1243 |
} |
|
1 | 1244 |
} |
1245 |
} |
|
1246 |
} |
|
1247 |
tty->print_cr("OopMaps"); |
|
1248 |
tty->print_cr(" #blobs = %d", number_of_blobs); |
|
1249 |
tty->print_cr(" code size = %d", code_size); |
|
1250 |
tty->print_cr(" #oop_maps = %d", number_of_oop_maps); |
|
1251 |
tty->print_cr(" map size = %d", map_size); |
|
1252 |
} |
|
1253 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1254 |
#endif // !PRODUCT |
1 | 1255 |
} |
1256 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1257 |
void CodeCache::print_summary(outputStream* st, bool detailed) { |
26796 | 1258 |
FOR_ALL_HEAPS(heap_iterator) { |
1259 |
CodeHeap* heap = (*heap_iterator); |
|
1260 |
size_t total = (heap->high_boundary() - heap->low_boundary()); |
|
1261 |
if (SegmentedCodeCache) { |
|
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1262 |
st->print("%s:", heap->name()); |
26796 | 1263 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
1264 |
st->print("CodeCache:"); |
26796 | 1265 |
} |
1266 |
st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT |
|
1267 |
"Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb", |
|
1268 |
total/K, (total - heap->unallocated_capacity())/K, |
|
1269 |
heap->max_allocated_capacity()/K, heap->unallocated_capacity()/K); |
|
1270 |
||
1271 |
if (detailed) { |
|
1272 |
st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]", |
|
1273 |
p2i(heap->low_boundary()), |
|
1274 |
p2i(heap->high()), |
|
1275 |
p2i(heap->high_boundary())); |
|
1276 |
} |
|
1277 |
} |
|
7108 | 1278 |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1279 |
if (detailed) { |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1280 |
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT |
26796 | 1281 |
" adapters=" UINT32_FORMAT, |
1282 |
nof_blobs(), nof_nmethods(), nof_adapters()); |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1283 |
st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1284 |
"enabled" : Arguments::mode() == Arguments::_int ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1285 |
"disabled (interpreter mode)" : |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1286 |
"disabled (not enough contiguous free space left)"); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1287 |
} |
7108 | 1288 |
} |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1289 |
|
26587 | 1290 |
void CodeCache::print_codelist(outputStream* st) { |
1291 |
assert_locked_or_safepoint(CodeCache_lock); |
|
1292 |
||
26796 | 1293 |
NMethodIterator iter; |
1294 |
while(iter.next_alive()) { |
|
1295 |
nmethod* nm = iter.method(); |
|
26587 | 1296 |
ResourceMark rm; |
26796 | 1297 |
char *method_name = nm->method()->name_and_sig_as_C_string(); |
26587 | 1298 |
st->print_cr("%d %d %s ["INTPTR_FORMAT", "INTPTR_FORMAT" - "INTPTR_FORMAT"]", |
26796 | 1299 |
nm->compile_id(), nm->comp_level(), method_name, (intptr_t)nm->header_begin(), |
1300 |
(intptr_t)nm->code_begin(), (intptr_t)nm->code_end()); |
|
26587 | 1301 |
} |
1302 |
} |
|
1303 |
||
1304 |
void CodeCache::print_layout(outputStream* st) { |
|
1305 |
assert_locked_or_safepoint(CodeCache_lock); |
|
1306 |
ResourceMark rm; |
|
1307 |
||
1308 |
print_summary(st, true); |
|
1309 |
} |
|
1310 |
||
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1311 |
void CodeCache::log_state(outputStream* st) { |
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1312 |
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
|
1313 |
" 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
|
1314 |
nof_blobs(), nof_nmethods(), nof_adapters(), |
17016
78b1c3670525
8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents:
15201
diff
changeset
|
1315 |
unallocated_capacity()); |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1316 |
} |