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