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