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