author | coleenp |
Wed, 02 May 2018 11:28:49 -0400 | |
changeset 50416 | ef980b9ac191 |
parent 50113 | caf115bb98ad |
child 50515 | 1ce463f497ad |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49611 | 2 |
* Copyright (c) 1997, 2018, 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" |
42650 | 26 |
#include "aot/aotLoader.hpp" |
7397 | 27 |
#include "code/codeBlob.hpp" |
28 |
#include "code/codeCache.hpp" |
|
49611 | 29 |
#include "code/codeHeapState.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
30 |
#include "code/compiledIC.hpp" |
7397 | 31 |
#include "code/dependencies.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
32 |
#include "code/icBuffer.hpp" |
7397 | 33 |
#include "code/nmethod.hpp" |
34 |
#include "code/pcDesc.hpp" |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
35 |
#include "compiler/compileBroker.hpp" |
50113 | 36 |
#include "jfr/jfrEvents.hpp" |
49611 | 37 |
#include "logging/log.hpp" |
38 |
#include "logging/logStream.hpp" |
|
7397 | 39 |
#include "memory/allocation.inline.hpp" |
40 |
#include "memory/iterator.hpp" |
|
41 |
#include "memory/resourceArea.hpp" |
|
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48119
diff
changeset
|
42 |
#include "oops/method.inline.hpp" |
7397 | 43 |
#include "oops/objArrayOop.hpp" |
44 |
#include "oops/oop.inline.hpp" |
|
29084
1b732f2836ce
8073387: Move VerifyOopClosures out from genOopClosures.hpp
stefank
parents:
28730
diff
changeset
|
45 |
#include "oops/verifyOopClosure.hpp" |
30764 | 46 |
#include "runtime/arguments.hpp" |
47 |
#include "runtime/compilationPolicy.hpp" |
|
48 |
#include "runtime/deoptimization.hpp" |
|
7397 | 49 |
#include "runtime/handles.inline.hpp" |
50 |
#include "runtime/icache.hpp" |
|
51 |
#include "runtime/java.hpp" |
|
52 |
#include "runtime/mutexLocker.hpp" |
|
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49340
diff
changeset
|
53 |
#include "runtime/safepointVerifiers.hpp" |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
54 |
#include "runtime/sweeper.hpp" |
49746 | 55 |
#include "runtime/vmThread.hpp" |
7397 | 56 |
#include "services/memoryService.hpp" |
46625 | 57 |
#include "utilities/align.hpp" |
46589 | 58 |
#include "utilities/vmError.hpp" |
7397 | 59 |
#include "utilities/xmlstream.hpp" |
26796 | 60 |
#ifdef COMPILER1 |
61 |
#include "c1/c1_Compilation.hpp" |
|
62 |
#include "c1/c1_Compiler.hpp" |
|
63 |
#endif |
|
64 |
#ifdef COMPILER2 |
|
65 |
#include "opto/c2compiler.hpp" |
|
66 |
#include "opto/compile.hpp" |
|
26805 | 67 |
#include "opto/node.hpp" |
26796 | 68 |
#endif |
1 | 69 |
|
70 |
// Helper class for printing in CodeCache |
|
71 |
class CodeBlob_sizes { |
|
72 |
private: |
|
73 |
int count; |
|
74 |
int total_size; |
|
75 |
int header_size; |
|
76 |
int code_size; |
|
77 |
int stub_size; |
|
78 |
int relocation_size; |
|
79 |
int scopes_oop_size; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
80 |
int scopes_metadata_size; |
1 | 81 |
int scopes_data_size; |
82 |
int scopes_pcs_size; |
|
83 |
||
84 |
public: |
|
85 |
CodeBlob_sizes() { |
|
86 |
count = 0; |
|
87 |
total_size = 0; |
|
88 |
header_size = 0; |
|
89 |
code_size = 0; |
|
90 |
stub_size = 0; |
|
91 |
relocation_size = 0; |
|
92 |
scopes_oop_size = 0; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
93 |
scopes_metadata_size = 0; |
1 | 94 |
scopes_data_size = 0; |
95 |
scopes_pcs_size = 0; |
|
96 |
} |
|
97 |
||
98 |
int total() { return total_size; } |
|
99 |
bool is_empty() { return count == 0; } |
|
100 |
||
101 |
void print(const char* title) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
102 |
tty->print_cr(" #%d %s = %dK (hdr %d%%, loc %d%%, code %d%%, stub %d%%, [oops %d%%, metadata %d%%, data %d%%, pcs %d%%])", |
1 | 103 |
count, |
104 |
title, |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
105 |
(int)(total() / K), |
1 | 106 |
header_size * 100 / total_size, |
107 |
relocation_size * 100 / total_size, |
|
108 |
code_size * 100 / total_size, |
|
109 |
stub_size * 100 / total_size, |
|
110 |
scopes_oop_size * 100 / total_size, |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
111 |
scopes_metadata_size * 100 / total_size, |
1 | 112 |
scopes_data_size * 100 / total_size, |
113 |
scopes_pcs_size * 100 / total_size); |
|
114 |
} |
|
115 |
||
116 |
void add(CodeBlob* cb) { |
|
117 |
count++; |
|
118 |
total_size += cb->size(); |
|
119 |
header_size += cb->header_size(); |
|
120 |
relocation_size += cb->relocation_size(); |
|
121 |
if (cb->is_nmethod()) { |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
5533
diff
changeset
|
122 |
nmethod* nm = cb->as_nmethod_or_null(); |
6418 | 123 |
code_size += nm->insts_size(); |
1 | 124 |
stub_size += nm->stub_size(); |
125 |
||
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
5533
diff
changeset
|
126 |
scopes_oop_size += nm->oops_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
127 |
scopes_metadata_size += nm->metadata_size(); |
1 | 128 |
scopes_data_size += nm->scopes_data_size(); |
129 |
scopes_pcs_size += nm->scopes_pcs_size(); |
|
130 |
} else { |
|
6418 | 131 |
code_size += cb->code_size(); |
1 | 132 |
} |
133 |
} |
|
134 |
}; |
|
135 |
||
26796 | 136 |
// Iterate over all CodeHeaps |
137 |
#define FOR_ALL_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _heaps->begin(); heap != _heaps->end(); ++heap) |
|
42650 | 138 |
#define FOR_ALL_NMETHOD_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap) |
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
139 |
#define FOR_ALL_ALLOCABLE_HEAPS(heap) for (GrowableArrayIterator<CodeHeap*> heap = _allocable_heaps->begin(); heap != _allocable_heaps->end(); ++heap) |
42650 | 140 |
|
26796 | 141 |
// Iterate over all CodeBlobs (cb) on the given CodeHeap |
142 |
#define FOR_ALL_BLOBS(cb, heap) for (CodeBlob* cb = first_blob(heap); cb != NULL; cb = next_blob(heap, cb)) |
|
1 | 143 |
|
26796 | 144 |
address CodeCache::_low_bound = 0; |
145 |
address CodeCache::_high_bound = 0; |
|
1 | 146 |
int CodeCache::_number_of_nmethods_with_dependencies = 0; |
147 |
bool CodeCache::_needs_cache_clean = false; |
|
3908 | 148 |
nmethod* CodeCache::_scavenge_root_nmethods = NULL; |
1 | 149 |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
150 |
// Initialize arrays of CodeHeap subsets |
26796 | 151 |
GrowableArray<CodeHeap*>* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); |
42650 | 152 |
GrowableArray<CodeHeap*>* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); |
153 |
GrowableArray<CodeHeap*>* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
154 |
GrowableArray<CodeHeap*>* CodeCache::_allocable_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<CodeHeap*> (CodeBlobType::All, true); |
26796 | 155 |
|
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
156 |
void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
157 |
size_t total_size = non_nmethod_size + profiled_size + non_profiled_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
158 |
// Prepare error message |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
159 |
const char* error = "Invalid code heap sizes"; |
43407 | 160 |
err_msg message("NonNMethodCodeHeapSize (" SIZE_FORMAT "K) + ProfiledCodeHeapSize (" SIZE_FORMAT "K)" |
161 |
" + NonProfiledCodeHeapSize (" SIZE_FORMAT "K) = " SIZE_FORMAT "K", |
|
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
162 |
non_nmethod_size/K, profiled_size/K, non_profiled_size/K, total_size/K); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
163 |
|
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
164 |
if (total_size > cache_size) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
165 |
// Some code heap sizes were explicitly set: total_size must be <= cache_size |
43407 | 166 |
message.append(" is greater than ReservedCodeCacheSize (" SIZE_FORMAT "K).", cache_size/K); |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
167 |
vm_exit_during_initialization(error, message); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
168 |
} else if (all_set && total_size != cache_size) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
169 |
// All code heap sizes were explicitly set: total_size must equal cache_size |
43407 | 170 |
message.append(" is not equal to ReservedCodeCacheSize (" SIZE_FORMAT "K).", cache_size/K); |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
171 |
vm_exit_during_initialization(error, message); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
172 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
173 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
174 |
|
26796 | 175 |
void CodeCache::initialize_heaps() { |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
176 |
bool non_nmethod_set = FLAG_IS_CMDLINE(NonNMethodCodeHeapSize); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
177 |
bool profiled_set = FLAG_IS_CMDLINE(ProfiledCodeHeapSize); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
178 |
bool non_profiled_set = FLAG_IS_CMDLINE(NonProfiledCodeHeapSize); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
179 |
size_t min_size = os::vm_page_size(); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
180 |
size_t cache_size = ReservedCodeCacheSize; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
181 |
size_t non_nmethod_size = NonNMethodCodeHeapSize; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
182 |
size_t profiled_size = ProfiledCodeHeapSize; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
183 |
size_t non_profiled_size = NonProfiledCodeHeapSize; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
184 |
// Check if total size set via command line flags exceeds the reserved size |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
185 |
check_heap_sizes((non_nmethod_set ? non_nmethod_size : min_size), |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
186 |
(profiled_set ? profiled_size : min_size), |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
187 |
(non_profiled_set ? non_profiled_size : min_size), |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
188 |
cache_size, |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
189 |
non_nmethod_set && profiled_set && non_profiled_set); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
190 |
|
26796 | 191 |
// Determine size of compiler buffers |
192 |
size_t code_buffers_size = 0; |
|
193 |
#ifdef COMPILER1 |
|
194 |
// C1 temporary code buffers (see Compiler::init_buffer_blob()) |
|
195 |
const int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); |
|
196 |
code_buffers_size += c1_count * Compiler::code_buffer_size(); |
|
197 |
#endif |
|
198 |
#ifdef COMPILER2 |
|
199 |
// C2 scratch buffers (see Compile::init_scratch_buffer_blob()) |
|
200 |
const int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); |
|
201 |
// Initial size of constant table (this may be increased if a compiled method needs more space) |
|
202 |
code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size(); |
|
203 |
#endif |
|
1 | 204 |
|
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
205 |
// Increase default non_nmethod_size to account for compiler buffers |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
206 |
if (!non_nmethod_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
207 |
non_nmethod_size += code_buffers_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
208 |
} |
26796 | 209 |
// Calculate default CodeHeap sizes if not set by user |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
210 |
if (!non_nmethod_set && !profiled_set && !non_profiled_set) { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
211 |
// Check if we have enough space for the non-nmethod code heap |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
212 |
if (cache_size > non_nmethod_size) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
213 |
// Use the default value for non_nmethod_size and one half of the |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
214 |
// remaining size for non-profiled and one half for profiled methods |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
215 |
size_t remaining_size = cache_size - non_nmethod_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
216 |
profiled_size = remaining_size / 2; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
217 |
non_profiled_size = remaining_size - profiled_size; |
26796 | 218 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
219 |
// Use all space for the non-nmethod heap and set other heaps to minimal size |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
220 |
non_nmethod_size = cache_size - 2 * min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
221 |
profiled_size = min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
222 |
non_profiled_size = min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
223 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
224 |
} else if (!non_nmethod_set || !profiled_set || !non_profiled_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
225 |
// The user explicitly set some code heap sizes. Increase or decrease the (default) |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
226 |
// sizes of the other code heaps accordingly. First adapt non-profiled and profiled |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
227 |
// code heap sizes and then only change non-nmethod code heap size if still necessary. |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
228 |
intx diff_size = cache_size - (non_nmethod_size + profiled_size + non_profiled_size); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
229 |
if (non_profiled_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
230 |
if (!profiled_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
231 |
// Adapt size of profiled code heap |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
232 |
if (diff_size < 0 && ((intx)profiled_size + diff_size) <= 0) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
233 |
// Not enough space available, set to minimum size |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
234 |
diff_size += profiled_size - min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
235 |
profiled_size = min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
236 |
} else { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
237 |
profiled_size += diff_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
238 |
diff_size = 0; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
239 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
240 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
241 |
} else if (profiled_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
242 |
// Adapt size of non-profiled code heap |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
243 |
if (diff_size < 0 && ((intx)non_profiled_size + diff_size) <= 0) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
244 |
// Not enough space available, set to minimum size |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
245 |
diff_size += non_profiled_size - min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
246 |
non_profiled_size = min_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
247 |
} else { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
248 |
non_profiled_size += diff_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
249 |
diff_size = 0; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
250 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
251 |
} else if (non_nmethod_set) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
252 |
// Distribute remaining size between profiled and non-profiled code heaps |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
253 |
diff_size = cache_size - non_nmethod_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
254 |
profiled_size = diff_size / 2; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
255 |
non_profiled_size = diff_size - profiled_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
256 |
diff_size = 0; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
257 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
258 |
if (diff_size != 0) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
259 |
// Use non-nmethod code heap for remaining space requirements |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
260 |
assert(!non_nmethod_set && ((intx)non_nmethod_size + diff_size) > 0, "sanity"); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
261 |
non_nmethod_size += diff_size; |
26796 | 262 |
} |
263 |
} |
|
1 | 264 |
|
26796 | 265 |
// We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap |
48118
7f40c1cdde28
8179026: Remove explicit code cache options processing
thartmann
parents:
47688
diff
changeset
|
266 |
if (!heap_available(CodeBlobType::MethodProfiled)) { |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
267 |
non_profiled_size += profiled_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
268 |
profiled_size = 0; |
26796 | 269 |
} |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
270 |
// We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap |
48118
7f40c1cdde28
8179026: Remove explicit code cache options processing
thartmann
parents:
47688
diff
changeset
|
271 |
if (!heap_available(CodeBlobType::MethodNonProfiled)) { |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
272 |
non_nmethod_size += non_profiled_size; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
273 |
non_profiled_size = 0; |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
274 |
} |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
275 |
// Make sure we have enough space for VM internal code |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
276 |
uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
277 |
if (non_nmethod_size < (min_code_cache_size + code_buffers_size)) { |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
278 |
vm_exit_during_initialization(err_msg( |
43407 | 279 |
"Not enough space in non-nmethod code heap to run VM: " SIZE_FORMAT "K < " SIZE_FORMAT "K", |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
280 |
non_nmethod_size/K, (min_code_cache_size + code_buffers_size)/K)); |
26796 | 281 |
} |
282 |
||
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
283 |
// Verify sizes and update flag values |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
284 |
assert(non_profiled_size + profiled_size + non_nmethod_size == cache_size, "Invalid code heap sizes"); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
285 |
FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, non_nmethod_size); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
286 |
FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
287 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size); |
26796 | 288 |
|
48119
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
289 |
// If large page support is enabled, align code heaps according to large |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
290 |
// page size to make sure that code cache is covered by large pages. |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
291 |
const size_t alignment = MAX2(page_size(false), (size_t) os::vm_allocation_granularity()); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46589
diff
changeset
|
292 |
non_nmethod_size = align_up(non_nmethod_size, alignment); |
48119
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
293 |
profiled_size = align_down(profiled_size, alignment); |
1 | 294 |
|
26796 | 295 |
// Reserve one continuous chunk of memory for CodeHeaps and split it into |
296 |
// parts for the individual heaps. The memory layout looks like this: |
|
297 |
// ---------- high ----------- |
|
298 |
// Non-profiled nmethods |
|
299 |
// Profiled nmethods |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
300 |
// Non-nmethods |
26796 | 301 |
// ---------- low ------------ |
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
302 |
ReservedCodeSpace rs = reserve_heap_memory(cache_size); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
303 |
ReservedSpace non_method_space = rs.first_part(non_nmethod_size); |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34174
diff
changeset
|
304 |
ReservedSpace rest = rs.last_part(non_nmethod_size); |
26796 | 305 |
ReservedSpace profiled_space = rest.first_part(profiled_size); |
306 |
ReservedSpace non_profiled_space = rest.last_part(profiled_size); |
|
307 |
||
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
308 |
// Non-nmethods (stubs, adapters, ...) |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
309 |
add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod); |
26796 | 310 |
// 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
|
311 |
add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled); |
26796 | 312 |
// 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
|
313 |
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
|
314 |
} |
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
315 |
|
48119
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
316 |
size_t CodeCache::page_size(bool aligned) { |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
317 |
if (os::can_execute_large_page_memory()) { |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
318 |
return aligned ? os::page_size_for_region_aligned(ReservedCodeCacheSize, 8) : |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
319 |
os::page_size_for_region_unaligned(ReservedCodeCacheSize, 8); |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
320 |
} else { |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
321 |
return os::vm_page_size(); |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
322 |
} |
1 | 323 |
} |
324 |
||
26796 | 325 |
ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) { |
48119
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
326 |
// Align and reserve space for code cache |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
327 |
const size_t rs_ps = page_size(); |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
328 |
const size_t rs_align = MAX2(rs_ps, (size_t) os::vm_allocation_granularity()); |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
329 |
const size_t rs_size = align_up(size, rs_align); |
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
330 |
ReservedCodeSpace rs(rs_size, rs_align, rs_ps > (size_t) os::vm_page_size()); |
35203
3e70c7dc0772
8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents:
34182
diff
changeset
|
331 |
if (!rs.is_reserved()) { |
48118
7f40c1cdde28
8179026: Remove explicit code cache options processing
thartmann
parents:
47688
diff
changeset
|
332 |
vm_exit_during_initialization(err_msg("Could not reserve enough space for code cache (" SIZE_FORMAT "K)", |
48119
c1b46afab3ba
8087339: The code heap might use different alignment for committed size and reserved size
thartmann
parents:
48118
diff
changeset
|
333 |
rs_size/K)); |
35203
3e70c7dc0772
8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents:
34182
diff
changeset
|
334 |
} |
3e70c7dc0772
8144949: TestOptionsWithRanges -XX:NUMAInterleaveGranularity=2147483648 crashes VM
sangheki
parents:
34182
diff
changeset
|
335 |
|
26796 | 336 |
// Initialize bounds |
337 |
_low_bound = (address)rs.base(); |
|
338 |
_high_bound = _low_bound + rs.size(); |
|
339 |
return rs; |
|
340 |
} |
|
341 |
||
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
342 |
// Heaps available for allocation |
26796 | 343 |
bool CodeCache::heap_available(int code_blob_type) { |
344 |
if (!SegmentedCodeCache) { |
|
345 |
// No segmentation: use a single code heap |
|
346 |
return (code_blob_type == CodeBlobType::All); |
|
38055
9dddf9056918
8086068: VM crashes with "-Xint -XX:+UseCompiler" options
thartmann
parents:
37289
diff
changeset
|
347 |
} else if (Arguments::is_interpreter_only()) { |
26796 | 348 |
// 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
|
349 |
return (code_blob_type == CodeBlobType::NonNMethod); |
26796 | 350 |
} else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) { |
351 |
// Tiered compilation: use all code heaps |
|
352 |
return (code_blob_type < CodeBlobType::All); |
|
353 |
} else { |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
354 |
// 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
|
355 |
return (code_blob_type == CodeBlobType::NonNMethod) || |
26796 | 356 |
(code_blob_type == CodeBlobType::MethodNonProfiled); |
357 |
} |
|
1 | 358 |
} |
359 |
||
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
360 |
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
|
361 |
switch(code_blob_type) { |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
362 |
case CodeBlobType::NonNMethod: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
363 |
return "NonNMethodCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
364 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
365 |
case CodeBlobType::MethodNonProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
366 |
return "NonProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
367 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
368 |
case CodeBlobType::MethodProfiled: |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
369 |
return "ProfiledCodeHeapSize"; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
370 |
break; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
371 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
372 |
ShouldNotReachHere(); |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
373 |
return NULL; |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
374 |
} |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
27015
diff
changeset
|
375 |
|
42650 | 376 |
int CodeCache::code_heap_compare(CodeHeap* const &lhs, CodeHeap* const &rhs) { |
377 |
if (lhs->code_blob_type() == rhs->code_blob_type()) { |
|
378 |
return (lhs > rhs) ? 1 : ((lhs < rhs) ? -1 : 0); |
|
379 |
} else { |
|
380 |
return lhs->code_blob_type() - rhs->code_blob_type(); |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
void CodeCache::add_heap(CodeHeap* heap) { |
|
385 |
assert(!Universe::is_fully_initialized(), "late heap addition?"); |
|
386 |
||
387 |
_heaps->insert_sorted<code_heap_compare>(heap); |
|
388 |
||
389 |
int type = heap->code_blob_type(); |
|
390 |
if (code_blob_type_accepts_compiled(type)) { |
|
391 |
_compiled_heaps->insert_sorted<code_heap_compare>(heap); |
|
392 |
} |
|
393 |
if (code_blob_type_accepts_nmethod(type)) { |
|
394 |
_nmethod_heaps->insert_sorted<code_heap_compare>(heap); |
|
395 |
} |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
396 |
if (code_blob_type_accepts_allocable(type)) { |
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
397 |
_allocable_heaps->insert_sorted<code_heap_compare>(heap); |
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
398 |
} |
42650 | 399 |
} |
400 |
||
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
401 |
void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) { |
26796 | 402 |
// Check if heap is needed |
403 |
if (!heap_available(code_blob_type)) { |
|
404 |
return; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
405 |
} |
26796 | 406 |
|
407 |
// Create CodeHeap |
|
408 |
CodeHeap* heap = new CodeHeap(name, code_blob_type); |
|
42650 | 409 |
add_heap(heap); |
26796 | 410 |
|
411 |
// Reserve Space |
|
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
412 |
size_t size_initial = MIN2(InitialCodeCacheSize, rs.size()); |
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
413 |
size_initial = align_up(size_initial, os::vm_page_size()); |
26796 | 414 |
if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) { |
48118
7f40c1cdde28
8179026: Remove explicit code cache options processing
thartmann
parents:
47688
diff
changeset
|
415 |
vm_exit_during_initialization(err_msg("Could not reserve enough space in %s (" SIZE_FORMAT "K)", |
7f40c1cdde28
8179026: Remove explicit code cache options processing
thartmann
parents:
47688
diff
changeset
|
416 |
heap->name(), size_initial/K)); |
26796 | 417 |
} |
418 |
||
419 |
// Register the CodeHeap |
|
420 |
MemoryService::add_code_heap_memory_pool(heap, name); |
|
421 |
} |
|
422 |
||
46647
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
423 |
CodeHeap* CodeCache::get_code_heap_containing(void* start) { |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
424 |
FOR_ALL_HEAPS(heap) { |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
425 |
if ((*heap)->contains(start)) { |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
426 |
return *heap; |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
427 |
} |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
428 |
} |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
429 |
return NULL; |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
430 |
} |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
431 |
|
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
27420
diff
changeset
|
432 |
CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) { |
26796 | 433 |
assert(cb != NULL, "CodeBlob is null"); |
434 |
FOR_ALL_HEAPS(heap) { |
|
43945
e7f2e49d2274
8173151: Code heap corruption due to incorrect inclusion test
zmajo
parents:
43675
diff
changeset
|
435 |
if ((*heap)->contains_blob(cb)) { |
26796 | 436 |
return *heap; |
437 |
} |
|
438 |
} |
|
439 |
ShouldNotReachHere(); |
|
440 |
return NULL; |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
441 |
} |
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
442 |
|
26796 | 443 |
CodeHeap* CodeCache::get_code_heap(int code_blob_type) { |
444 |
FOR_ALL_HEAPS(heap) { |
|
445 |
if ((*heap)->accepts(code_blob_type)) { |
|
446 |
return *heap; |
|
447 |
} |
|
448 |
} |
|
449 |
return NULL; |
|
450 |
} |
|
451 |
||
452 |
CodeBlob* CodeCache::first_blob(CodeHeap* heap) { |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
453 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 454 |
assert(heap != NULL, "heap is null"); |
455 |
return (CodeBlob*)heap->first(); |
|
5533
e8d9ff82ec62
6950075: nmethod sweeper should operate concurrently
never
parents:
5247
diff
changeset
|
456 |
} |
1 | 457 |
|
26796 | 458 |
CodeBlob* CodeCache::first_blob(int code_blob_type) { |
459 |
if (heap_available(code_blob_type)) { |
|
460 |
return first_blob(get_code_heap(code_blob_type)); |
|
461 |
} else { |
|
462 |
return NULL; |
|
463 |
} |
|
464 |
} |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
465 |
|
26796 | 466 |
CodeBlob* CodeCache::next_blob(CodeHeap* heap, CodeBlob* cb) { |
467 |
assert_locked_or_safepoint(CodeCache_lock); |
|
468 |
assert(heap != NULL, "heap is null"); |
|
469 |
return (CodeBlob*)heap->next(cb); |
|
470 |
} |
|
471 |
||
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
472 |
/** |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
473 |
* 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
|
474 |
* 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
|
475 |
* 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
|
476 |
* 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
|
477 |
* instantiating. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
478 |
*/ |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
479 |
CodeBlob* CodeCache::allocate(int size, int code_blob_type, int orig_code_blob_type) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
480 |
// Possibly wakes up the sweeper thread. |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
481 |
NMethodSweeper::notify(code_blob_type); |
1 | 482 |
assert_locked_or_safepoint(CodeCache_lock); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32466
diff
changeset
|
483 |
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
|
484 |
if (size <= 0) { |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
485 |
return NULL; |
252c634b2e1c
8029343: CodeCache::allocate increments '_number_of_blobs' even if allocation fails.
anoll
parents:
23214
diff
changeset
|
486 |
} |
1 | 487 |
CodeBlob* cb = NULL; |
26796 | 488 |
|
489 |
// Get CodeHeap for the given CodeBlobType |
|
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
490 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
491 |
assert(heap != NULL, "heap is null"); |
26796 | 492 |
|
1 | 493 |
while (true) { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
494 |
cb = (CodeBlob*)heap->allocate(size); |
1 | 495 |
if (cb != NULL) break; |
26796 | 496 |
if (!heap->expand_by(CodeCacheExpansionSize)) { |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
497 |
// Save original type for error reporting |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
498 |
if (orig_code_blob_type == CodeBlobType::All) { |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
499 |
orig_code_blob_type = code_blob_type; |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
500 |
} |
1 | 501 |
// Expansion failed |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
502 |
if (SegmentedCodeCache) { |
29338
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
503 |
// Fallback solution: Try to store code in another code heap. |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
504 |
// NonNMethod -> MethodNonProfiled -> MethodProfiled (-> MethodNonProfiled) |
29338
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
505 |
// 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
|
506 |
// 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
|
507 |
int type = code_blob_type; |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
508 |
switch (type) { |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
509 |
case CodeBlobType::NonNMethod: |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
510 |
type = CodeBlobType::MethodNonProfiled; |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
511 |
break; |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
512 |
case CodeBlobType::MethodNonProfiled: |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
513 |
type = CodeBlobType::MethodProfiled; |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
514 |
break; |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
515 |
case CodeBlobType::MethodProfiled: |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
516 |
// Avoid loop if we already tried that code heap |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
517 |
if (type == orig_code_blob_type) { |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
518 |
type = CodeBlobType::MethodNonProfiled; |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
519 |
} |
29338
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
520 |
break; |
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
521 |
} |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
522 |
if (type != code_blob_type && type != orig_code_blob_type && heap_available(type)) { |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
523 |
if (PrintCodeCacheExtension) { |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
524 |
tty->print_cr("Extension of %s failed. Trying to allocate in %s.", |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
525 |
heap->name(), get_code_heap(type)->name()); |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
526 |
} |
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
527 |
return allocate(size, type, orig_code_blob_type); |
29338
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
528 |
} |
26796 | 529 |
} |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
530 |
MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
40863
f5fec6a2dc9e
8064892: Non-methods code cache overflow is not handled correctly
thartmann
parents:
38133
diff
changeset
|
531 |
CompileBroker::handle_full_code_cache(orig_code_blob_type); |
1 | 532 |
return NULL; |
533 |
} |
|
534 |
if (PrintCodeCacheExtension) { |
|
535 |
ResourceMark rm; |
|
42650 | 536 |
if (_nmethod_heaps->length() >= 1) { |
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
537 |
tty->print("%s", heap->name()); |
26796 | 538 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
539 |
tty->print("CodeCache"); |
26796 | 540 |
} |
541 |
tty->print_cr(" extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (" SSIZE_FORMAT " bytes)", |
|
542 |
(intptr_t)heap->low_boundary(), (intptr_t)heap->high(), |
|
543 |
(address)heap->high() - (address)heap->low_boundary()); |
|
1 | 544 |
} |
545 |
} |
|
3908 | 546 |
print_trace("allocation", cb, size); |
1 | 547 |
return cb; |
548 |
} |
|
549 |
||
550 |
void CodeCache::free(CodeBlob* cb) { |
|
551 |
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
|
552 |
CodeHeap* heap = get_code_heap(cb); |
3908 | 553 |
print_trace("free", cb); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
554 |
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
|
555 |
heap->set_nmethod_count(heap->nmethod_count() - 1); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
556 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
557 |
_number_of_nmethods_with_dependencies--; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
558 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
559 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
560 |
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
|
561 |
heap->set_adapter_count(heap->adapter_count() - 1); |
1 | 562 |
} |
563 |
||
26796 | 564 |
// Get heap for given CodeBlob and deallocate |
565 |
get_code_heap(cb)->deallocate(cb); |
|
1 | 566 |
|
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
|
567 |
assert(heap->blob_count() >= 0, "sanity check"); |
1 | 568 |
} |
569 |
||
47688 | 570 |
void CodeCache::free_unused_tail(CodeBlob* cb, size_t used) { |
571 |
assert_locked_or_safepoint(CodeCache_lock); |
|
572 |
guarantee(cb->is_buffer_blob() && strncmp("Interpreter", cb->name(), 11) == 0, "Only possible for interpreter!"); |
|
573 |
print_trace("free_unused_tail", cb); |
|
574 |
||
575 |
// We also have to account for the extra space (i.e. header) used by the CodeBlob |
|
576 |
// which provides the memory (see BufferBlob::create() in codeBlob.cpp). |
|
577 |
used += CodeBlob::align_code_offset(cb->header_size()); |
|
578 |
||
579 |
// Get heap for given CodeBlob and deallocate its unused tail |
|
580 |
get_code_heap(cb)->deallocate_tail(cb, used); |
|
581 |
// Adjust the sizes of the CodeBlob |
|
582 |
cb->adjust_size(used); |
|
583 |
} |
|
584 |
||
1 | 585 |
void CodeCache::commit(CodeBlob* cb) { |
586 |
// this is called by nmethod::nmethod, which must already own CodeCache_lock |
|
587 |
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
|
588 |
CodeHeap* heap = get_code_heap(cb); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
589 |
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
|
590 |
heap->set_nmethod_count(heap->nmethod_count() + 1); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
591 |
if (((nmethod *)cb)->has_dependencies()) { |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
592 |
_number_of_nmethods_with_dependencies++; |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
593 |
} |
1 | 594 |
} |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
595 |
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
|
596 |
heap->set_adapter_count(heap->adapter_count() + 1); |
5924
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
597 |
} |
dc9d04930c82
6965184: possible races in make_not_entrant_or_zombie
never
parents:
5702
diff
changeset
|
598 |
|
1 | 599 |
// flush the hardware I-cache |
6418 | 600 |
ICache::invalidate_range(cb->content_begin(), cb->content_size()); |
1 | 601 |
} |
602 |
||
603 |
bool CodeCache::contains(void *p) { |
|
42062 | 604 |
// S390 uses contains() in current_frame(), which is used before |
605 |
// code cache initialization if NativeMemoryTracking=detail is set. |
|
606 |
S390_ONLY(if (_heaps == NULL) return false;) |
|
607 |
// It should be ok to call contains without holding a lock. |
|
26796 | 608 |
FOR_ALL_HEAPS(heap) { |
609 |
if ((*heap)->contains(p)) { |
|
610 |
return true; |
|
611 |
} |
|
612 |
} |
|
613 |
return false; |
|
1 | 614 |
} |
615 |
||
42650 | 616 |
bool CodeCache::contains(nmethod *nm) { |
617 |
return contains((void *)nm); |
|
618 |
} |
|
619 |
||
26796 | 620 |
// This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not |
621 |
// looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain |
|
1 | 622 |
// valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled. |
623 |
CodeBlob* CodeCache::find_blob(void* start) { |
|
624 |
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
|
625 |
// We could potentially look up non_entrant methods |
46589 | 626 |
guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || VMError::is_error_reported(), "unsafe access to zombie method"); |
1 | 627 |
return result; |
628 |
} |
|
629 |
||
26796 | 630 |
// Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know |
631 |
// what you are doing) |
|
632 |
CodeBlob* CodeCache::find_blob_unsafe(void* start) { |
|
633 |
// NMT can walk the stack before code cache is created |
|
46647
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
634 |
if (_heaps != NULL) { |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
635 |
CodeHeap* heap = get_code_heap_containing(start); |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
636 |
if (heap != NULL) { |
634dc786bf96
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents:
46637
diff
changeset
|
637 |
return heap->find_blob_unsafe(start); |
26796 | 638 |
} |
639 |
} |
|
640 |
return NULL; |
|
641 |
} |
|
642 |
||
1 | 643 |
nmethod* CodeCache::find_nmethod(void* start) { |
26796 | 644 |
CodeBlob* cb = find_blob(start); |
645 |
assert(cb->is_nmethod(), "did not find an nmethod"); |
|
1 | 646 |
return (nmethod*)cb; |
647 |
} |
|
648 |
||
649 |
void CodeCache::blobs_do(void f(CodeBlob* nm)) { |
|
650 |
assert_locked_or_safepoint(CodeCache_lock); |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
651 |
FOR_ALL_HEAPS(heap) { |
26796 | 652 |
FOR_ALL_BLOBS(cb, *heap) { |
653 |
f(cb); |
|
654 |
} |
|
1 | 655 |
} |
656 |
} |
|
657 |
||
658 |
void CodeCache::nmethods_do(void f(nmethod* nm)) { |
|
659 |
assert_locked_or_safepoint(CodeCache_lock); |
|
26796 | 660 |
NMethodIterator iter; |
661 |
while(iter.next()) { |
|
662 |
f(iter.method()); |
|
1 | 663 |
} |
664 |
} |
|
665 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
666 |
void CodeCache::metadata_do(void f(Metadata* m)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
667 |
assert_locked_or_safepoint(CodeCache_lock); |
26796 | 668 |
NMethodIterator iter; |
669 |
while(iter.next_alive()) { |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
670 |
iter.method()->metadata_do(f); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
671 |
} |
42650 | 672 |
AOTLoader::metadata_do(f); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
673 |
} |
1 | 674 |
|
675 |
int CodeCache::alignment_unit() { |
|
26796 | 676 |
return (int)_heaps->first()->alignment_unit(); |
1 | 677 |
} |
678 |
||
679 |
int CodeCache::alignment_offset() { |
|
26796 | 680 |
return (int)_heaps->first()->alignment_offset(); |
1 | 681 |
} |
682 |
||
26796 | 683 |
// 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
|
684 |
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { |
1 | 685 |
assert_locked_or_safepoint(CodeCache_lock); |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
686 |
CompiledMethodIterator iter; |
26796 | 687 |
while(iter.next_alive()) { |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
688 |
iter.method()->do_unloading(is_alive); |
1 | 689 |
} |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
690 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
691 |
// Now that all the unloaded nmethods are known, cleanup caches |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
692 |
// before CLDG is purged. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
693 |
// This is another code cache walk but it is moved from gc_epilogue. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
694 |
// G1 does a parallel walk of the nmethods so cleans them up |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
695 |
// as it goes and doesn't call this. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
696 |
do_unloading_nmethod_caches(unloading_occurred); |
1 | 697 |
} |
698 |
||
3908 | 699 |
void CodeCache::blobs_do(CodeBlobClosure* f) { |
1 | 700 |
assert_locked_or_safepoint(CodeCache_lock); |
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
701 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 702 |
FOR_ALL_BLOBS(cb, *heap) { |
703 |
if (cb->is_alive()) { |
|
704 |
f->do_code_blob(cb); |
|
3908 | 705 |
#ifdef ASSERT |
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
706 |
if (cb->is_nmethod()) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
707 |
Universe::heap()->verify_nmethod((nmethod*)cb); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
708 |
} |
3908 | 709 |
#endif //ASSERT |
26796 | 710 |
} |
711 |
} |
|
1 | 712 |
} |
713 |
} |
|
714 |
||
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
715 |
// Walk the list of methods which might contain oops to the java heap. |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
716 |
void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) { |
3908 | 717 |
assert_locked_or_safepoint(CodeCache_lock); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
718 |
|
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
719 |
const bool fix_relocations = f->fix_relocations(); |
3908 | 720 |
debug_only(mark_scavenge_root_nmethods()); |
721 |
||
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
722 |
nmethod* prev = NULL; |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
723 |
nmethod* cur = scavenge_root_nmethods(); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
724 |
while (cur != NULL) { |
3908 | 725 |
debug_only(cur->clear_scavenge_root_marked()); |
726 |
assert(cur->scavenge_root_not_marked(), ""); |
|
727 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
728 |
||
729 |
bool is_live = (!cur->is_zombie() && !cur->is_unloaded()); |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
730 |
LogTarget(Trace, gc, nmethod) lt; |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
731 |
if (lt.is_enabled()) { |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
732 |
LogStream ls(lt); |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
733 |
CompileTask::print(&ls, cur, |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
734 |
is_live ? "scavenge root " : "dead scavenge root", /*short_form:*/ true); |
3908 | 735 |
} |
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
736 |
if (is_live) { |
3908 | 737 |
// Perform cur->oops_do(f), maybe just once per nmethod. |
738 |
f->do_code_blob(cur); |
|
5247
c2b4e525b3e5
6940520: CodeCache::scavenge_root_nmethods_do must fix oop relocations
twisti
parents:
4750
diff
changeset
|
739 |
} |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
740 |
nmethod* const next = cur->scavenge_root_link(); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
741 |
// The scavengable nmethod list must contain all methods with scavengable |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
742 |
// oops. It is safe to include more nmethod on the list, but we do not |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
743 |
// expect any live non-scavengable nmethods on the list. |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
744 |
if (fix_relocations) { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
745 |
if (!is_live || !cur->detect_scavenge_root_oops()) { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
746 |
unlink_scavenge_root_nmethod(cur, prev); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
747 |
} else { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
748 |
prev = cur; |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
749 |
} |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
750 |
} |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
751 |
cur = next; |
3908 | 752 |
} |
753 |
||
754 |
// Check for stray marks. |
|
755 |
debug_only(verify_perm_nmethods(NULL)); |
|
756 |
} |
|
757 |
||
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
758 |
void CodeCache::register_scavenge_root_nmethod(nmethod* nm) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
759 |
assert_locked_or_safepoint(CodeCache_lock); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
760 |
if (!nm->on_scavenge_root_list() && nm->detect_scavenge_root_oops()) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
761 |
add_scavenge_root_nmethod(nm); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
762 |
} |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
763 |
} |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
764 |
|
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
765 |
void CodeCache::verify_scavenge_root_nmethod(nmethod* nm) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
766 |
nm->verify_scavenge_root_oops(); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
767 |
} |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
768 |
|
3908 | 769 |
void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
770 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
771 |
|
3908 | 772 |
nm->set_on_scavenge_root_list(); |
773 |
nm->set_scavenge_root_link(_scavenge_root_nmethods); |
|
774 |
set_scavenge_root_nmethods(nm); |
|
775 |
print_trace("add_scavenge_root", nm); |
|
776 |
} |
|
777 |
||
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
778 |
void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
779 |
assert_locked_or_safepoint(CodeCache_lock); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
780 |
|
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
781 |
assert((prev == NULL && scavenge_root_nmethods() == nm) || |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
782 |
(prev != NULL && prev->scavenge_root_link() == nm), "precondition"); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
783 |
|
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
784 |
print_trace("unlink_scavenge_root", nm); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
785 |
if (prev == NULL) { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
786 |
set_scavenge_root_nmethods(nm->scavenge_root_link()); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
787 |
} else { |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
788 |
prev->set_scavenge_root_link(nm->scavenge_root_link()); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
789 |
} |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
790 |
nm->set_scavenge_root_link(NULL); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
791 |
nm->clear_on_scavenge_root_list(); |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
792 |
} |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
793 |
|
3908 | 794 |
void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
795 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
796 |
|
3908 | 797 |
print_trace("drop_scavenge_root", nm); |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
798 |
nmethod* prev = NULL; |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
799 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
3908 | 800 |
if (cur == nm) { |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
801 |
unlink_scavenge_root_nmethod(cur, prev); |
3908 | 802 |
return; |
803 |
} |
|
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
804 |
prev = cur; |
3908 | 805 |
} |
806 |
assert(false, "should have been on list"); |
|
807 |
} |
|
808 |
||
809 |
void CodeCache::prune_scavenge_root_nmethods() { |
|
810 |
assert_locked_or_safepoint(CodeCache_lock); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
811 |
|
3908 | 812 |
debug_only(mark_scavenge_root_nmethods()); |
813 |
||
814 |
nmethod* last = NULL; |
|
815 |
nmethod* cur = scavenge_root_nmethods(); |
|
816 |
while (cur != NULL) { |
|
817 |
nmethod* next = cur->scavenge_root_link(); |
|
818 |
debug_only(cur->clear_scavenge_root_marked()); |
|
819 |
assert(cur->scavenge_root_not_marked(), ""); |
|
820 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
821 |
||
822 |
if (!cur->is_zombie() && !cur->is_unloaded() |
|
823 |
&& cur->detect_scavenge_root_oops()) { |
|
824 |
// Keep it. Advance 'last' to prevent deletion. |
|
825 |
last = cur; |
|
826 |
} else { |
|
827 |
// Prune it from the list, so we don't have to look at it any more. |
|
828 |
print_trace("prune_scavenge_root", cur); |
|
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35825
diff
changeset
|
829 |
unlink_scavenge_root_nmethod(cur, last); |
3908 | 830 |
} |
831 |
cur = next; |
|
832 |
} |
|
833 |
||
834 |
// Check for stray marks. |
|
835 |
debug_only(verify_perm_nmethods(NULL)); |
|
836 |
} |
|
837 |
||
838 |
#ifndef PRODUCT |
|
839 |
void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { |
|
840 |
// While we are here, verify the integrity of the list. |
|
841 |
mark_scavenge_root_nmethods(); |
|
842 |
for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
|
843 |
assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
|
844 |
cur->clear_scavenge_root_marked(); |
|
845 |
} |
|
846 |
verify_perm_nmethods(f); |
|
847 |
} |
|
848 |
||
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
849 |
// Temporarily mark nmethods that are claimed to be on the scavenge list. |
3908 | 850 |
void CodeCache::mark_scavenge_root_nmethods() { |
26796 | 851 |
NMethodIterator iter; |
852 |
while(iter.next_alive()) { |
|
853 |
nmethod* nm = iter.method(); |
|
854 |
assert(nm->scavenge_root_not_marked(), "clean state"); |
|
855 |
if (nm->on_scavenge_root_list()) |
|
856 |
nm->set_scavenge_root_marked(); |
|
3908 | 857 |
} |
858 |
} |
|
859 |
||
860 |
// If the closure is given, run it on the unlisted nmethods. |
|
861 |
// Also make sure that the effects of mark_scavenge_root_nmethods is gone. |
|
862 |
void CodeCache::verify_perm_nmethods(CodeBlobClosure* f_or_null) { |
|
26796 | 863 |
NMethodIterator iter; |
864 |
while(iter.next_alive()) { |
|
865 |
nmethod* nm = iter.method(); |
|
3908 | 866 |
bool call_f = (f_or_null != NULL); |
26796 | 867 |
assert(nm->scavenge_root_not_marked(), "must be already processed"); |
868 |
if (nm->on_scavenge_root_list()) |
|
869 |
call_f = false; // don't show this one to the client |
|
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47216
diff
changeset
|
870 |
Universe::heap()->verify_nmethod(nm); |
26796 | 871 |
if (call_f) f_or_null->do_code_blob(nm); |
3908 | 872 |
} |
873 |
} |
|
874 |
#endif //PRODUCT |
|
875 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
876 |
void CodeCache::verify_clean_inline_caches() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
877 |
#ifdef ASSERT |
26796 | 878 |
NMethodIterator iter; |
879 |
while(iter.next_alive()) { |
|
880 |
nmethod* nm = iter.method(); |
|
881 |
assert(!nm->is_unloaded(), "Tautology"); |
|
882 |
nm->verify_clean_inline_caches(); |
|
883 |
nm->verify(); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
884 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
885 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
886 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
887 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
888 |
void CodeCache::verify_icholder_relocations() { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
889 |
#ifdef ASSERT |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
890 |
// make sure that we aren't leaking icholders |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
891 |
int count = 0; |
26796 | 892 |
FOR_ALL_HEAPS(heap) { |
893 |
FOR_ALL_BLOBS(cb, *heap) { |
|
42650 | 894 |
CompiledMethod *nm = cb->as_compiled_method_or_null(); |
895 |
if (nm != NULL) { |
|
26796 | 896 |
count += nm->verify_icholder_relocations(); |
897 |
} |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
898 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
899 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
900 |
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
|
901 |
CompiledICHolder::live_count(), "must agree"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
902 |
#endif |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
903 |
} |
4750 | 904 |
|
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
905 |
void CodeCache::gc_prologue() { } |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
906 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
907 |
void CodeCache::gc_epilogue() { |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
908 |
prune_scavenge_root_nmethods(); |
1 | 909 |
} |
910 |
||
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
911 |
|
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
912 |
void CodeCache::do_unloading_nmethod_caches(bool class_unloading_occurred) { |
1 | 913 |
assert_locked_or_safepoint(CodeCache_lock); |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
914 |
// Even if classes are not unloaded, there may have been some nmethods that are |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
915 |
// unloaded because oops in them are no longer reachable. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
916 |
NOT_DEBUG(if (needs_cache_clean() || class_unloading_occurred)) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
917 |
CompiledMethodIterator iter; |
32466
915d0c3d25aa
8134493: Cleaning inline caches of unloaded nmethods should be done in sweeper
thartmann
parents:
32401
diff
changeset
|
918 |
while(iter.next_alive()) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
919 |
CompiledMethod* cm = iter.method(); |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
920 |
assert(!cm->is_unloaded(), "Tautology"); |
50416
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
921 |
DEBUG_ONLY(if (needs_cache_clean() || class_unloading_occurred)) { |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
922 |
// Clean up both unloaded klasses from nmethods and unloaded nmethods |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
923 |
// from inline caches. |
ef980b9ac191
8203837: Split nmethod unloading from inline cache cleaning
coleenp
parents:
50113
diff
changeset
|
924 |
cm->unload_nmethod_caches(/*parallel*/false, class_unloading_occurred); |
32401
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31620
diff
changeset
|
925 |
} |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
926 |
DEBUG_ONLY(cm->verify()); |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
927 |
DEBUG_ONLY(cm->verify_oop_relocations()); |
1 | 928 |
} |
929 |
} |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
930 |
|
1 | 931 |
set_needs_cache_clean(false); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
932 |
verify_icholder_relocations(); |
1 | 933 |
} |
934 |
||
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
935 |
void CodeCache::verify_oops() { |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
936 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
937 |
VerifyOopClosure voc; |
26796 | 938 |
NMethodIterator iter; |
939 |
while(iter.next_alive()) { |
|
940 |
nmethod* nm = iter.method(); |
|
941 |
nm->oops_do(&voc); |
|
942 |
nm->verify_oop_relocations(); |
|
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
943 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
944 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
945 |
|
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
|
946 |
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
|
947 |
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
|
948 |
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
|
949 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
950 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
951 |
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
|
952 |
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
|
953 |
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
|
954 |
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
|
955 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
956 |
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
|
957 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
958 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
959 |
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
|
960 |
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
|
961 |
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
|
962 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
963 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
964 |
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
|
965 |
int count = 0; |
42650 | 966 |
FOR_ALL_NMETHOD_HEAPS(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
|
967 |
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
|
968 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
969 |
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
|
970 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
971 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
972 |
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
|
973 |
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
|
974 |
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
|
975 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
976 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
977 |
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
|
978 |
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
|
979 |
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
|
980 |
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
|
981 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
982 |
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
|
983 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
984 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
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
|
988 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
989 |
|
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
990 |
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
|
991 |
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
|
992 |
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
|
993 |
} |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
33105
diff
changeset
|
994 |
|
26796 | 995 |
size_t CodeCache::capacity() { |
996 |
size_t cap = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
997 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 998 |
cap += (*heap)->capacity(); |
999 |
} |
|
1000 |
return cap; |
|
1 | 1001 |
} |
1002 |
||
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1003 |
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
|
1004 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1005 |
return (heap != NULL) ? heap->unallocated_capacity() : 0; |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1006 |
} |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1007 |
|
26796 | 1008 |
size_t CodeCache::unallocated_capacity() { |
1009 |
size_t unallocated_cap = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1010 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1011 |
unallocated_cap += (*heap)->unallocated_capacity(); |
1012 |
} |
|
1013 |
return unallocated_cap; |
|
1014 |
} |
|
1 | 1015 |
|
26796 | 1016 |
size_t CodeCache::max_capacity() { |
1017 |
size_t max_cap = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1018 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1019 |
max_cap += (*heap)->max_capacity(); |
1020 |
} |
|
1021 |
return max_cap; |
|
1 | 1022 |
} |
1023 |
||
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
1024 |
/** |
26796 | 1025 |
* 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
|
1026 |
* 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
|
1027 |
*/ |
26796 | 1028 |
double CodeCache::reverse_free_ratio(int code_blob_type) { |
1029 |
CodeHeap* heap = get_code_heap(code_blob_type); |
|
1030 |
if (heap == NULL) { |
|
1031 |
return 0; |
|
1032 |
} |
|
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
1033 |
|
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
1034 |
double unallocated_capacity = MAX2((double)heap->unallocated_capacity(), 1.0); // Avoid division by 0; |
26796 | 1035 |
double max_capacity = (double)heap->max_capacity(); |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
1036 |
double result = max_capacity / unallocated_capacity; |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
1037 |
assert (max_capacity >= unallocated_capacity, "Must be"); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32466
diff
changeset
|
1038 |
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
|
1039 |
return result; |
17617
4e330bce1812
8012371: Adjust Tiered compile threshold according to available space in code cache
anoll
parents:
17132
diff
changeset
|
1040 |
} |
1 | 1041 |
|
26796 | 1042 |
size_t CodeCache::bytes_allocated_in_freelists() { |
1043 |
size_t allocated_bytes = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1044 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1045 |
allocated_bytes += (*heap)->allocated_in_freelist(); |
1046 |
} |
|
1047 |
return allocated_bytes; |
|
1048 |
} |
|
1049 |
||
1050 |
int CodeCache::allocated_segments() { |
|
1051 |
int number_of_segments = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1052 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1053 |
number_of_segments += (*heap)->allocated_segments(); |
1054 |
} |
|
1055 |
return number_of_segments; |
|
1056 |
} |
|
1057 |
||
1058 |
size_t CodeCache::freelists_length() { |
|
1059 |
size_t length = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1060 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1061 |
length += (*heap)->freelist_length(); |
1062 |
} |
|
1063 |
return length; |
|
1064 |
} |
|
1065 |
||
1 | 1066 |
void icache_init(); |
1067 |
||
1068 |
void CodeCache::initialize() { |
|
1069 |
assert(CodeCacheSegmentSize >= (uintx)CodeEntryAlignment, "CodeCacheSegmentSize must be large enough to align entry points"); |
|
1070 |
#ifdef COMPILER2 |
|
1071 |
assert(CodeCacheSegmentSize >= (uintx)OptoLoopAlignment, "CodeCacheSegmentSize must be large enough to align inner loops"); |
|
1072 |
#endif |
|
1073 |
assert(CodeCacheSegmentSize >= sizeof(jdouble), "CodeCacheSegmentSize must be large enough to align constants"); |
|
1074 |
// This was originally just a check of the alignment, causing failure, instead, round |
|
1075 |
// the code cache to the page size. In particular, Solaris is moving to a larger |
|
1076 |
// default page size. |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46619
diff
changeset
|
1077 |
CodeCacheExpansionSize = align_up(CodeCacheExpansionSize, os::vm_page_size()); |
26796 | 1078 |
|
1079 |
if (SegmentedCodeCache) { |
|
1080 |
// Use multiple code heaps |
|
1081 |
initialize_heaps(); |
|
1082 |
} else { |
|
1083 |
// 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
|
1084 |
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
|
1085 |
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
|
1086 |
FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 0); |
26796 | 1087 |
ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28631
diff
changeset
|
1088 |
add_heap(rs, "CodeCache", CodeBlobType::All); |
1 | 1089 |
} |
1090 |
||
1091 |
// Initialize ICache flush mechanism |
|
1092 |
// This service is needed for os::register_code_area |
|
1093 |
icache_init(); |
|
1094 |
||
1095 |
// Give OS a chance to register generated code area. |
|
1096 |
// This is used on Windows 64 bit platforms to register |
|
1097 |
// Structured Exception Handlers for our generated code. |
|
26796 | 1098 |
os::register_code_area((char*)low_bound(), (char*)high_bound()); |
1 | 1099 |
} |
1100 |
||
1101 |
void codeCache_init() { |
|
1102 |
CodeCache::initialize(); |
|
42650 | 1103 |
// Load AOT libraries and add AOT code heaps. |
1104 |
AOTLoader::initialize(); |
|
1 | 1105 |
} |
1106 |
||
1107 |
//------------------------------------------------------------------------------------------------ |
|
1108 |
||
1109 |
int CodeCache::number_of_nmethods_with_dependencies() { |
|
1110 |
return _number_of_nmethods_with_dependencies; |
|
1111 |
} |
|
1112 |
||
1113 |
void CodeCache::clear_inline_caches() { |
|
1114 |
assert_locked_or_safepoint(CodeCache_lock); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1115 |
CompiledMethodIterator iter; |
26796 | 1116 |
while(iter.next_alive()) { |
1117 |
iter.method()->clear_inline_caches(); |
|
1 | 1118 |
} |
1119 |
} |
|
1120 |
||
37289
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1121 |
void CodeCache::cleanup_inline_caches() { |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1122 |
assert_locked_or_safepoint(CodeCache_lock); |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1123 |
NMethodIterator iter; |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1124 |
while(iter.next_alive()) { |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1125 |
iter.method()->cleanup_inline_caches(/*clean_all=*/true); |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1126 |
} |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1127 |
} |
9989add27bf4
8067247: Crash: assert(method_holder->data() == 0 ...) failed: a) MT-unsafe modification of inline cache
jcm
parents:
36593
diff
changeset
|
1128 |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1129 |
// Keeps track of time spent for checking dependencies |
22921
ee35d5c0b1dc
8034839: jvm hangs with gc/gctests/LoadUnloadGC test
anoll
parents:
22506
diff
changeset
|
1130 |
NOT_PRODUCT(static elapsedTimer dependentCheckTime;) |
1 | 1131 |
|
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35825
diff
changeset
|
1132 |
int CodeCache::mark_for_deoptimization(KlassDepChange& changes) { |
1 | 1133 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1134 |
int number_of_marked_CodeBlobs = 0; |
|
1135 |
||
1136 |
// search the hierarchy looking for nmethods which are affected by the loading of this class |
|
1137 |
||
1138 |
// then search the interfaces this class implements looking for nmethods |
|
1139 |
// which might be dependent of the fact that an interface only had one |
|
1140 |
// implementor. |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1141 |
// 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
|
1142 |
// can happen |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
35203
diff
changeset
|
1143 |
NoSafepointVerifier nsv; |
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1144 |
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
|
1145 |
Klass* d = str.klass(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1146 |
number_of_marked_CodeBlobs += InstanceKlass::cast(d)->mark_dependent_nmethods(changes); |
1 | 1147 |
} |
1148 |
||
1149 |
#ifndef PRODUCT |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1150 |
if (VerifyDependencies) { |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1151 |
// 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
|
1152 |
// 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
|
1153 |
dependentCheckTime.start(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1154 |
nmethod::check_all_dependencies(changes); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1155 |
dependentCheckTime.stop(); |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1156 |
} |
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1157 |
#endif |
1 | 1158 |
|
1159 |
return number_of_marked_CodeBlobs; |
|
1160 |
} |
|
1161 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1162 |
CompiledMethod* CodeCache::find_compiled(void* start) { |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1163 |
CodeBlob *cb = find_blob(start); |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1164 |
assert(cb == NULL || cb->is_compiled(), "did not find an compiled_method"); |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1165 |
return (CompiledMethod*)cb; |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1166 |
} |
1 | 1167 |
|
42650 | 1168 |
bool CodeCache::is_far_target(address target) { |
1169 |
#if INCLUDE_AOT |
|
1170 |
return NativeCall::is_far_call(_low_bound, target) || |
|
1171 |
NativeCall::is_far_call(_high_bound, target); |
|
1172 |
#else |
|
1173 |
return false; |
|
1174 |
#endif |
|
1175 |
} |
|
1176 |
||
1 | 1177 |
#ifdef HOTSWAP |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
1178 |
int CodeCache::mark_for_evol_deoptimization(InstanceKlass* dependee) { |
1 | 1179 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1180 |
int number_of_marked_CodeBlobs = 0; |
|
1181 |
||
1182 |
// 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
|
1183 |
Array<Method*>* old_methods = dependee->methods(); |
1 | 1184 |
for (int i = 0; i < old_methods->length(); i++) { |
1185 |
ResourceMark rm; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1186 |
Method* old_method = old_methods->at(i); |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1187 |
CompiledMethod* nm = old_method->code(); |
1 | 1188 |
if (nm != NULL) { |
1189 |
nm->mark_for_deoptimization(); |
|
1190 |
number_of_marked_CodeBlobs++; |
|
1191 |
} |
|
1192 |
} |
|
1193 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1194 |
CompiledMethodIterator iter; |
26796 | 1195 |
while(iter.next_alive()) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1196 |
CompiledMethod* nm = iter.method(); |
1 | 1197 |
if (nm->is_marked_for_deoptimization()) { |
1198 |
// ...Already marked in the previous pass; don't count it again. |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
1199 |
} else if (nm->is_evol_dependent_on(dependee)) { |
1 | 1200 |
ResourceMark rm; |
1201 |
nm->mark_for_deoptimization(); |
|
1202 |
number_of_marked_CodeBlobs++; |
|
1203 |
} else { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1204 |
// flush caches in case they refer to a redefined Method* |
1 | 1205 |
nm->clear_inline_caches(); |
1206 |
} |
|
1207 |
} |
|
1208 |
||
1209 |
return number_of_marked_CodeBlobs; |
|
1210 |
} |
|
1211 |
#endif // HOTSWAP |
|
1212 |
||
1213 |
||
1214 |
// Deoptimize all methods |
|
1215 |
void CodeCache::mark_all_nmethods_for_deoptimization() { |
|
1216 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1217 |
CompiledMethodIterator iter; |
26796 | 1218 |
while(iter.next_alive()) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1219 |
CompiledMethod* nm = iter.method(); |
26580
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
1220 |
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
|
1221 |
nm->mark_for_deoptimization(); |
8cca7fbe77b8
8056154: JVM crash with EXCEPTION_ACCESS_VIOLATION when there are many threads running
iveresov
parents:
25492
diff
changeset
|
1222 |
} |
1 | 1223 |
} |
1224 |
} |
|
1225 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
1226 |
int CodeCache::mark_for_deoptimization(Method* dependee) { |
1 | 1227 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1228 |
int number_of_marked_CodeBlobs = 0; |
|
1229 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1230 |
CompiledMethodIterator iter; |
26796 | 1231 |
while(iter.next_alive()) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1232 |
CompiledMethod* nm = iter.method(); |
1 | 1233 |
if (nm->is_dependent_on_method(dependee)) { |
1234 |
ResourceMark rm; |
|
1235 |
nm->mark_for_deoptimization(); |
|
1236 |
number_of_marked_CodeBlobs++; |
|
1237 |
} |
|
1238 |
} |
|
1239 |
||
1240 |
return number_of_marked_CodeBlobs; |
|
1241 |
} |
|
1242 |
||
1243 |
void CodeCache::make_marked_nmethods_not_entrant() { |
|
1244 |
assert_locked_or_safepoint(CodeCache_lock); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1245 |
CompiledMethodIterator iter; |
26796 | 1246 |
while(iter.next_alive()) { |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
38055
diff
changeset
|
1247 |
CompiledMethod* nm = iter.method(); |
43675
a2b322083029
8173338: C2: continuous CallSite relinkage eventually disables compilation for a method
vlivanov
parents:
43407
diff
changeset
|
1248 |
if (nm->is_marked_for_deoptimization() && !nm->is_not_entrant()) { |
1 | 1249 |
nm->make_not_entrant(); |
1250 |
} |
|
1251 |
} |
|
1252 |
} |
|
1253 |
||
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1254 |
// Flushes compiled methods dependent on dependee. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
1255 |
void CodeCache::flush_dependents_on(InstanceKlass* dependee) { |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1256 |
assert_lock_strong(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1257 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1258 |
if (number_of_nmethods_with_dependencies() == 0) return; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1259 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1260 |
// 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
|
1261 |
// 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
|
1262 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1263 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1264 |
KlassDepChange changes(dependee); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1265 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1266 |
// Compute the dependent nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1267 |
if (mark_for_deoptimization(changes) > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1268 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1269 |
VM_Deoptimize op; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1270 |
VMThread::execute(&op); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1271 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1272 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1273 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1274 |
#ifdef HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1275 |
// Flushes compiled methods dependent on dependee in the evolutionary sense |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
1276 |
void CodeCache::flush_evol_dependents_on(InstanceKlass* ev_k) { |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1277 |
// --- 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
|
1278 |
assert_locked_or_safepoint(Compile_lock); |
42650 | 1279 |
if (number_of_nmethods_with_dependencies() == 0 && !UseAOT) return; |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1280 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1281 |
// 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
|
1282 |
// 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
|
1283 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1284 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1285 |
// Compute the dependent nmethods |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
1286 |
if (mark_for_evol_deoptimization(ev_k) > 0) { |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1287 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1288 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1289 |
// 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
|
1290 |
// Stuff copied from VM_Deoptimize and modified slightly. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1291 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1292 |
// 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
|
1293 |
ResourceMark rm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1294 |
DeoptimizationMarker dm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1295 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1296 |
// Deoptimize all activations depending on marked nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1297 |
Deoptimization::deoptimize_dependents(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1298 |
|
32401
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31620
diff
changeset
|
1299 |
// Make the dependent methods not entrant |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1300 |
make_marked_nmethods_not_entrant(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1301 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1302 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1303 |
#endif // HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1304 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1305 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1306 |
// Flushes compiled methods dependent on dependee |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46661
diff
changeset
|
1307 |
void CodeCache::flush_dependents_on_method(const methodHandle& m_h) { |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1308 |
// --- 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
|
1309 |
assert_locked_or_safepoint(Compile_lock); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1310 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1311 |
// 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
|
1312 |
// 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
|
1313 |
// holding the CodeCache_lock. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1314 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1315 |
// Compute the dependent nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1316 |
if (mark_for_deoptimization(m_h()) > 0) { |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1317 |
// At least one nmethod has been marked for deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1318 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1319 |
// 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
|
1320 |
// Stuff copied from VM_Deoptimize and modified slightly. |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1321 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1322 |
// 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
|
1323 |
ResourceMark rm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1324 |
DeoptimizationMarker dm; |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1325 |
|
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1326 |
// Deoptimize all activations depending on marked nmethods |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1327 |
Deoptimization::deoptimize_dependents(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1328 |
|
32401
cc58aeaec340
8075805: Crash while trying to release CompiledICHolder
thartmann
parents:
31620
diff
changeset
|
1329 |
// Make the dependent methods not entrant |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1330 |
make_marked_nmethods_not_entrant(); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1331 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1332 |
} |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27880
diff
changeset
|
1333 |
|
1 | 1334 |
void CodeCache::verify() { |
26796 | 1335 |
assert_locked_or_safepoint(CodeCache_lock); |
1336 |
FOR_ALL_HEAPS(heap) { |
|
1337 |
(*heap)->verify(); |
|
1338 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1339 |
if (cb->is_alive()) { |
|
1340 |
cb->verify(); |
|
1341 |
} |
|
1342 |
} |
|
1 | 1343 |
} |
1344 |
} |
|
1345 |
||
26796 | 1346 |
// A CodeHeap is full. Print out warning and report event. |
46269
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1347 |
PRAGMA_DIAG_PUSH |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1348 |
PRAGMA_FORMAT_NONLITERAL_IGNORED |
26796 | 1349 |
void CodeCache::report_codemem_full(int code_blob_type, bool print) { |
1350 |
// 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
|
1351 |
CodeHeap* heap = get_code_heap(code_blob_type); |
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
1352 |
assert(heap != NULL, "heap is null"); |
26796 | 1353 |
|
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
|
1354 |
if ((heap->full_count() == 0) || print) { |
26796 | 1355 |
// Not yet reported for this heap, report |
1356 |
if (SegmentedCodeCache) { |
|
46269
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1357 |
ResourceMark rm; |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1358 |
stringStream msg1_stream, msg2_stream; |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1359 |
msg1_stream.print("%s is full. Compiler has been disabled.", |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1360 |
get_code_heap_name(code_blob_type)); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1361 |
msg2_stream.print("Try increasing the code heap size using -XX:%s=", |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1362 |
get_code_heap_flag_name(code_blob_type)); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1363 |
const char *msg1 = msg1_stream.as_string(); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1364 |
const char *msg2 = msg2_stream.as_string(); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1365 |
|
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1366 |
log_warning(codecache)(msg1); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1367 |
log_warning(codecache)(msg2); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1368 |
warning(msg1); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1369 |
warning(msg2); |
26796 | 1370 |
} else { |
46269
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1371 |
const char *msg1 = "CodeCache is full. Compiler has been disabled."; |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1372 |
const char *msg2 = "Try increasing the code cache size using -XX:ReservedCodeCacheSize="; |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1373 |
|
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1374 |
log_warning(codecache)(msg1); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1375 |
log_warning(codecache)(msg2); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1376 |
warning(msg1); |
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1377 |
warning(msg2); |
26796 | 1378 |
} |
1379 |
ResourceMark rm; |
|
1380 |
stringStream s; |
|
1381 |
// Dump code cache into a buffer before locking the tty, |
|
1382 |
{ |
|
1383 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
1384 |
print_summary(&s); |
|
1385 |
} |
|
49611 | 1386 |
{ |
1387 |
ttyLocker ttyl; |
|
1388 |
tty->print("%s", s.as_string()); |
|
1389 |
} |
|
1390 |
||
1391 |
if (heap->full_count() == 0) { |
|
1392 |
LogTarget(Debug, codecache) lt; |
|
1393 |
if (lt.is_enabled()) { |
|
1394 |
CompileBroker::print_heapinfo(tty, "all", "4096"); // details, may be a lot! |
|
1395 |
} |
|
1396 |
} |
|
26796 | 1397 |
} |
1398 |
||
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
|
1399 |
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
|
1400 |
|
18025 | 1401 |
EventCodeCacheFull event; |
1402 |
if (event.should_commit()) { |
|
26796 | 1403 |
event.set_codeBlobType((u1)code_blob_type); |
1404 |
event.set_startAddress((u8)heap->low_boundary()); |
|
1405 |
event.set_commitedTopAddress((u8)heap->high()); |
|
1406 |
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
|
1407 |
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
|
1408 |
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
|
1409 |
event.set_adaptorCount(heap->adapter_count()); |
41056
8b4c1a429e5d
8157024: CodeCache JFR events reporting wrong data
neliasso
parents:
40863
diff
changeset
|
1410 |
event.set_unallocatedCapacity(heap->unallocated_capacity()); |
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
|
1411 |
event.set_fullCount(heap->full_count()); |
18025 | 1412 |
event.commit(); |
1413 |
} |
|
1414 |
} |
|
46269
7e725659ea12
8172286: CodeCacheFlushing message should be shown in UL
ysuenaga
parents:
42650
diff
changeset
|
1415 |
PRAGMA_DIAG_POP |
18025 | 1416 |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1417 |
void CodeCache::print_memory_overhead() { |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1418 |
size_t wasted_bytes = 0; |
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1419 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1420 |
CodeHeap* curr_heap = *heap; |
1421 |
for (CodeBlob* cb = (CodeBlob*)curr_heap->first(); cb != NULL; cb = (CodeBlob*)curr_heap->next(cb)) { |
|
1422 |
HeapBlock* heap_block = ((HeapBlock*)cb) - 1; |
|
1423 |
wasted_bytes += heap_block->length() * CodeCacheSegmentSize - cb->size(); |
|
1424 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1425 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1426 |
// 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
|
1427 |
ttyLocker ttl; |
26796 | 1428 |
tty->print_cr("Number of elements in freelist: " SSIZE_FORMAT, freelists_length()); |
1429 |
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
|
1430 |
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
|
1431 |
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
|
1432 |
} |
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1433 |
|
1 | 1434 |
//------------------------------------------------------------------------------------------------ |
1435 |
// Non-product version |
|
1436 |
||
1437 |
#ifndef PRODUCT |
|
1438 |
||
3908 | 1439 |
void CodeCache::print_trace(const char* event, CodeBlob* cb, int size) { |
1440 |
if (PrintCodeCache2) { // Need to add a new flag |
|
1441 |
ResourceMark rm; |
|
1442 |
if (size == 0) size = cb->size(); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23214
diff
changeset
|
1443 |
tty->print_cr("CodeCache %s: addr: " INTPTR_FORMAT ", size: 0x%x", event, p2i(cb), size); |
3908 | 1444 |
} |
1445 |
} |
|
1446 |
||
1 | 1447 |
void CodeCache::print_internals() { |
1448 |
int nmethodCount = 0; |
|
1449 |
int runtimeStubCount = 0; |
|
1450 |
int adapterCount = 0; |
|
1451 |
int deoptimizationStubCount = 0; |
|
1452 |
int uncommonTrapStubCount = 0; |
|
1453 |
int bufferBlobCount = 0; |
|
1454 |
int total = 0; |
|
1455 |
int nmethodAlive = 0; |
|
1456 |
int nmethodNotEntrant = 0; |
|
1457 |
int nmethodZombie = 0; |
|
1458 |
int nmethodUnloaded = 0; |
|
1459 |
int nmethodJava = 0; |
|
1460 |
int nmethodNative = 0; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1461 |
int max_nm_size = 0; |
1 | 1462 |
ResourceMark rm; |
1463 |
||
26796 | 1464 |
int i = 0; |
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1465 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
42650 | 1466 |
if ((_nmethod_heaps->length() >= 1) && Verbose) { |
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1467 |
tty->print_cr("-- %s --", (*heap)->name()); |
26796 | 1468 |
} |
1469 |
FOR_ALL_BLOBS(cb, *heap) { |
|
1470 |
total++; |
|
1471 |
if (cb->is_nmethod()) { |
|
1472 |
nmethod* nm = (nmethod*)cb; |
|
1 | 1473 |
|
26796 | 1474 |
if (Verbose && nm->method() != NULL) { |
1475 |
ResourceMark rm; |
|
1476 |
char *method_name = nm->method()->name_and_sig_as_C_string(); |
|
1477 |
tty->print("%s", method_name); |
|
1478 |
if(nm->is_alive()) { tty->print_cr(" alive"); } |
|
1479 |
if(nm->is_not_entrant()) { tty->print_cr(" not-entrant"); } |
|
1480 |
if(nm->is_zombie()) { tty->print_cr(" zombie"); } |
|
1481 |
} |
|
1 | 1482 |
|
26796 | 1483 |
nmethodCount++; |
1 | 1484 |
|
26796 | 1485 |
if(nm->is_alive()) { nmethodAlive++; } |
1486 |
if(nm->is_not_entrant()) { nmethodNotEntrant++; } |
|
1487 |
if(nm->is_zombie()) { nmethodZombie++; } |
|
1488 |
if(nm->is_unloaded()) { nmethodUnloaded++; } |
|
1489 |
if(nm->method() != NULL && nm->is_native_method()) { nmethodNative++; } |
|
1 | 1490 |
|
26796 | 1491 |
if(nm->method() != NULL && nm->is_java_method()) { |
1492 |
nmethodJava++; |
|
1493 |
max_nm_size = MAX2(max_nm_size, nm->size()); |
|
1494 |
} |
|
1495 |
} else if (cb->is_runtime_stub()) { |
|
1496 |
runtimeStubCount++; |
|
1497 |
} else if (cb->is_deoptimization_stub()) { |
|
1498 |
deoptimizationStubCount++; |
|
1499 |
} else if (cb->is_uncommon_trap_stub()) { |
|
1500 |
uncommonTrapStubCount++; |
|
1501 |
} else if (cb->is_adapter_blob()) { |
|
1502 |
adapterCount++; |
|
1503 |
} else if (cb->is_buffer_blob()) { |
|
1504 |
bufferBlobCount++; |
|
1 | 1505 |
} |
1506 |
} |
|
1507 |
} |
|
1508 |
||
1509 |
int bucketSize = 512; |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1510 |
int bucketLimit = max_nm_size / bucketSize + 1; |
13195 | 1511 |
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
|
1512 |
memset(buckets, 0, sizeof(int) * bucketLimit); |
1 | 1513 |
|
26796 | 1514 |
NMethodIterator iter; |
1515 |
while(iter.next()) { |
|
1516 |
nmethod* nm = iter.method(); |
|
1517 |
if(nm->method() != NULL && nm->is_java_method()) { |
|
1518 |
buckets[nm->size() / bucketSize]++; |
|
1 | 1519 |
} |
1520 |
} |
|
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
22921
diff
changeset
|
1521 |
|
1 | 1522 |
tty->print_cr("Code Cache Entries (total of %d)",total); |
1523 |
tty->print_cr("-------------------------------------------------"); |
|
1524 |
tty->print_cr("nmethods: %d",nmethodCount); |
|
1525 |
tty->print_cr("\talive: %d",nmethodAlive); |
|
1526 |
tty->print_cr("\tnot_entrant: %d",nmethodNotEntrant); |
|
1527 |
tty->print_cr("\tzombie: %d",nmethodZombie); |
|
1528 |
tty->print_cr("\tunloaded: %d",nmethodUnloaded); |
|
1529 |
tty->print_cr("\tjava: %d",nmethodJava); |
|
1530 |
tty->print_cr("\tnative: %d",nmethodNative); |
|
1531 |
tty->print_cr("runtime_stubs: %d",runtimeStubCount); |
|
1532 |
tty->print_cr("adapters: %d",adapterCount); |
|
1533 |
tty->print_cr("buffer blobs: %d",bufferBlobCount); |
|
1534 |
tty->print_cr("deoptimization_stubs: %d",deoptimizationStubCount); |
|
1535 |
tty->print_cr("uncommon_traps: %d",uncommonTrapStubCount); |
|
1536 |
tty->print_cr("\nnmethod size distribution (non-zombie java)"); |
|
1537 |
tty->print_cr("-------------------------------------------------"); |
|
1538 |
||
1539 |
for(int i=0; i<bucketLimit; i++) { |
|
1540 |
if(buckets[i] != 0) { |
|
1541 |
tty->print("%d - %d bytes",i*bucketSize,(i+1)*bucketSize); |
|
1542 |
tty->fill_to(40); |
|
1543 |
tty->print_cr("%d",buckets[i]); |
|
1544 |
} |
|
1545 |
} |
|
1546 |
||
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27642
diff
changeset
|
1547 |
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
|
1548 |
print_memory_overhead(); |
1 | 1549 |
} |
1550 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1551 |
#endif // !PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1552 |
|
1 | 1553 |
void CodeCache::print() { |
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1554 |
print_summary(tty); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1555 |
|
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1556 |
#ifndef PRODUCT |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1557 |
if (!Verbose) return; |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1558 |
|
1 | 1559 |
CodeBlob_sizes live; |
1560 |
CodeBlob_sizes dead; |
|
1561 |
||
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1562 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1563 |
FOR_ALL_BLOBS(cb, *heap) { |
1564 |
if (!cb->is_alive()) { |
|
1565 |
dead.add(cb); |
|
1566 |
} else { |
|
1567 |
live.add(cb); |
|
1568 |
} |
|
1 | 1569 |
} |
1570 |
} |
|
1571 |
||
1572 |
tty->print_cr("CodeCache:"); |
|
22506
0759c126204d
7194669: CodeCache::mark_for_deoptimization should avoid verifying dependencies multiple times
anoll
parents:
20290
diff
changeset
|
1573 |
tty->print_cr("nmethod dependency checking time %fs", dependentCheckTime.seconds()); |
1 | 1574 |
|
1575 |
if (!live.is_empty()) { |
|
1576 |
live.print("live"); |
|
1577 |
} |
|
1578 |
if (!dead.is_empty()) { |
|
1579 |
dead.print("dead"); |
|
1580 |
} |
|
1581 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1582 |
if (WizardMode) { |
1 | 1583 |
// print the oop_map usage |
1584 |
int code_size = 0; |
|
1585 |
int number_of_blobs = 0; |
|
1586 |
int number_of_oop_maps = 0; |
|
1587 |
int map_size = 0; |
|
45622
3e4f81c922de
8181757: NonNMethod heap in segmented CodeCache is not scanned in some cases
dlong
parents:
43945
diff
changeset
|
1588 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
26796 | 1589 |
FOR_ALL_BLOBS(cb, *heap) { |
1590 |
if (cb->is_alive()) { |
|
1591 |
number_of_blobs++; |
|
1592 |
code_size += cb->code_size(); |
|
30590 | 1593 |
ImmutableOopMapSet* set = cb->oop_maps(); |
26796 | 1594 |
if (set != NULL) { |
30590 | 1595 |
number_of_oop_maps += set->count(); |
30628
3c15b4a3bf4d
8079797: assert(index >= 0 && index < _count) failed: check
rbackman
parents:
30590
diff
changeset
|
1596 |
map_size += set->nr_of_bytes(); |
26796 | 1597 |
} |
1 | 1598 |
} |
1599 |
} |
|
1600 |
} |
|
1601 |
tty->print_cr("OopMaps"); |
|
1602 |
tty->print_cr(" #blobs = %d", number_of_blobs); |
|
1603 |
tty->print_cr(" code size = %d", code_size); |
|
1604 |
tty->print_cr(" #oop_maps = %d", number_of_oop_maps); |
|
1605 |
tty->print_cr(" map size = %d", map_size); |
|
1606 |
} |
|
1607 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1608 |
#endif // !PRODUCT |
1 | 1609 |
} |
1610 |
||
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1611 |
void CodeCache::print_summary(outputStream* st, bool detailed) { |
26796 | 1612 |
FOR_ALL_HEAPS(heap_iterator) { |
1613 |
CodeHeap* heap = (*heap_iterator); |
|
1614 |
size_t total = (heap->high_boundary() - heap->low_boundary()); |
|
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
31592
diff
changeset
|
1615 |
if (_heaps->length() >= 1) { |
26918
4e1761669426
8059137: MemoryPoolMXBeans for different code heaps should contain 'Code heap' in their names
thartmann
parents:
26809
diff
changeset
|
1616 |
st->print("%s:", heap->name()); |
26796 | 1617 |
} else { |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26918
diff
changeset
|
1618 |
st->print("CodeCache:"); |
26796 | 1619 |
} |
1620 |
st->print_cr(" size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT |
|
1621 |
"Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT "Kb", |
|
1622 |
total/K, (total - heap->unallocated_capacity())/K, |
|
1623 |
heap->max_allocated_capacity()/K, heap->unallocated_capacity()/K); |
|
1624 |
||
1625 |
if (detailed) { |
|
1626 |
st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]", |
|
1627 |
p2i(heap->low_boundary()), |
|
1628 |
p2i(heap->high()), |
|
1629 |
p2i(heap->high_boundary())); |
|
1630 |
} |
|
1631 |
} |
|
7108 | 1632 |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1633 |
if (detailed) { |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1634 |
st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT |
26796 | 1635 |
" 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
|
1636 |
blob_count(), nmethod_count(), adapter_count()); |
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1637 |
st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1638 |
"enabled" : Arguments::mode() == Arguments::_int ? |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1639 |
"disabled (interpreter mode)" : |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1640 |
"disabled (not enough contiguous free space left)"); |
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
1641 |
} |
7108 | 1642 |
} |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1643 |
|
26587 | 1644 |
void CodeCache::print_codelist(outputStream* st) { |
35825
7c7652ee137b
8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents:
35492
diff
changeset
|
1645 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
26587 | 1646 |
|
46637
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1647 |
CompiledMethodIterator iter; |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1648 |
while (iter.next_alive()) { |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1649 |
CompiledMethod* cm = iter.method(); |
26587 | 1650 |
ResourceMark rm; |
46637
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1651 |
char* method_name = cm->method()->name_and_sig_as_C_string(); |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1652 |
st->print_cr("%d %d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]", |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1653 |
cm->compile_id(), cm->comp_level(), cm->get_state(), |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1654 |
method_name, |
ad6940426976
8183151: DCmd Compiler.codelist should print all compiled methods
neliasso
parents:
46632
diff
changeset
|
1655 |
(intptr_t)cm->header_begin(), (intptr_t)cm->code_begin(), (intptr_t)cm->code_end()); |
26587 | 1656 |
} |
1657 |
} |
|
1658 |
||
1659 |
void CodeCache::print_layout(outputStream* st) { |
|
35825
7c7652ee137b
8063112: Compiler diagnostic commands should have locking instead of safepoint
neliasso
parents:
35492
diff
changeset
|
1660 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
26587 | 1661 |
ResourceMark rm; |
1662 |
print_summary(st, true); |
|
1663 |
} |
|
1664 |
||
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1665 |
void CodeCache::log_state(outputStream* st) { |
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1666 |
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
|
1667 |
" 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
|
1668 |
blob_count(), nmethod_count(), adapter_count(), |
17016
78b1c3670525
8006952: Slow VM due to excessive code cache freelist iteration
neliasso
parents:
15201
diff
changeset
|
1669 |
unallocated_capacity()); |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
1670 |
} |
49611 | 1671 |
|
1672 |
//---< BEGIN >--- CodeHeap State Analytics. |
|
1673 |
||
1674 |
void CodeCache::aggregate(outputStream *out, const char* granularity) { |
|
1675 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1676 |
CodeHeapState::aggregate(out, (*heap), granularity); |
|
1677 |
} |
|
1678 |
} |
|
1679 |
||
1680 |
void CodeCache::discard(outputStream *out) { |
|
1681 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1682 |
CodeHeapState::discard(out, (*heap)); |
|
1683 |
} |
|
1684 |
} |
|
1685 |
||
1686 |
void CodeCache::print_usedSpace(outputStream *out) { |
|
1687 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1688 |
CodeHeapState::print_usedSpace(out, (*heap)); |
|
1689 |
} |
|
1690 |
} |
|
1691 |
||
1692 |
void CodeCache::print_freeSpace(outputStream *out) { |
|
1693 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1694 |
CodeHeapState::print_freeSpace(out, (*heap)); |
|
1695 |
} |
|
1696 |
} |
|
1697 |
||
1698 |
void CodeCache::print_count(outputStream *out) { |
|
1699 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1700 |
CodeHeapState::print_count(out, (*heap)); |
|
1701 |
} |
|
1702 |
} |
|
1703 |
||
1704 |
void CodeCache::print_space(outputStream *out) { |
|
1705 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1706 |
CodeHeapState::print_space(out, (*heap)); |
|
1707 |
} |
|
1708 |
} |
|
1709 |
||
1710 |
void CodeCache::print_age(outputStream *out) { |
|
1711 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1712 |
CodeHeapState::print_age(out, (*heap)); |
|
1713 |
} |
|
1714 |
} |
|
1715 |
||
1716 |
void CodeCache::print_names(outputStream *out) { |
|
1717 |
FOR_ALL_ALLOCABLE_HEAPS(heap) { |
|
1718 |
CodeHeapState::print_names(out, (*heap)); |
|
1719 |
} |
|
1720 |
} |
|
1721 |
//---< END >--- CodeHeap State Analytics. |