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