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