author | vlivanov |
Fri, 19 Feb 2016 20:40:20 +0300 | |
changeset 36300 | 5b47f168b948 |
parent 35123 | b0b89d83bcf5 |
child 36593 | 5ef494d5c3e8 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
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 |
#ifndef SHARE_VM_CODE_CODECACHE_HPP |
26 |
#define SHARE_VM_CODE_CODECACHE_HPP |
|
27 |
||
28 |
#include "code/codeBlob.hpp" |
|
26796 | 29 |
#include "code/nmethod.hpp" |
7397 | 30 |
#include "memory/allocation.hpp" |
31 |
#include "memory/heap.hpp" |
|
32 |
#include "oops/instanceKlass.hpp" |
|
33 |
#include "oops/oopsHierarchy.hpp" |
|
26796 | 34 |
#include "runtime/mutexLocker.hpp" |
7397 | 35 |
|
1 | 36 |
// The CodeCache implements the code cache for various pieces of generated |
37 |
// code, e.g., compiled java methods, runtime stubs, transition frames, etc. |
|
38 |
// The entries in the CodeCache are all CodeBlob's. |
|
39 |
||
26796 | 40 |
// -- Implementation -- |
41 |
// The CodeCache consists of one or more CodeHeaps, each of which contains |
|
42 |
// CodeBlobs of a specific CodeBlobType. Currently heaps for the following |
|
43 |
// types are available: |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
44 |
// - Non-nmethods: Non-nmethods like Buffers, Adapters and Runtime Stubs |
26796 | 45 |
// - Profiled nmethods: nmethods that are profiled, i.e., those |
46 |
// executed at level 2 or 3 |
|
47 |
// - Non-Profiled nmethods: nmethods that are not profiled, i.e., those |
|
48 |
// executed at level 1 or 4 and native methods |
|
49 |
// - All: Used for code of all types if code cache segmentation is disabled. |
|
50 |
// |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
51 |
// In the rare case of the non-nmethod code heap getting full, non-nmethod code |
26796 | 52 |
// will be stored in the non-profiled code heap as a fallback solution. |
53 |
// |
|
54 |
// Depending on the availability of compilers and TieredCompilation there |
|
55 |
// may be fewer heaps. The size of the code heaps depends on the values of |
|
56 |
// ReservedCodeCacheSize, NonProfiledCodeHeapSize and ProfiledCodeHeapSize |
|
57 |
// (see CodeCache::heap_available(..) and CodeCache::initialize_heaps(..) |
|
58 |
// for details). |
|
59 |
// |
|
60 |
// Code cache segmentation is controlled by the flag SegmentedCodeCache. |
|
61 |
// If turned off, all code types are stored in a single code heap. By default |
|
62 |
// code cache segmentation is turned on if TieredCompilation is enabled and |
|
63 |
// ReservedCodeCacheSize >= 240 MB. |
|
64 |
// |
|
65 |
// All methods of the CodeCache accepting a CodeBlobType only apply to |
|
66 |
// CodeBlobs of the given type. For example, iteration over the |
|
67 |
// CodeBlobs of a specific type can be done by using CodeCache::first_blob(..) |
|
68 |
// and CodeCache::next_blob(..) and providing the corresponding CodeBlobType. |
|
69 |
// |
|
70 |
// IMPORTANT: If you add new CodeHeaps to the code cache or change the |
|
71 |
// existing ones, make sure to adapt the dtrace scripts (jhelper.d) for |
|
72 |
// Solaris and BSD. |
|
1 | 73 |
|
74 |
class OopClosure; |
|
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35123
diff
changeset
|
75 |
class KlassDepChange; |
1 | 76 |
|
77 |
class CodeCache : AllStatic { |
|
78 |
friend class VMStructs; |
|
35123
b0b89d83bcf5
8134994: use separate VMStructs databases for SA and JVMCI
twisti
parents:
34182
diff
changeset
|
79 |
friend class JVMCIVMStructs; |
26796 | 80 |
friend class NMethodIterator; |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
27420
diff
changeset
|
81 |
friend class WhiteBox; |
31620
53be635ad49c
8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents:
31348
diff
changeset
|
82 |
friend class CodeCacheLoader; |
1 | 83 |
private: |
26796 | 84 |
// CodeHeaps of the cache |
85 |
static GrowableArray<CodeHeap*>* _heaps; |
|
86 |
||
87 |
static address _low_bound; // Lower bound of CodeHeap addresses |
|
88 |
static address _high_bound; // Upper bound of CodeHeap addresses |
|
89 |
static int _number_of_nmethods_with_dependencies; // Total number of nmethods with dependencies |
|
90 |
static bool _needs_cache_clean; // True if inline caches of the nmethods needs to be flushed |
|
91 |
static nmethod* _scavenge_root_nmethods; // linked via nm->scavenge_root_link() |
|
1 | 92 |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
93 |
static void mark_scavenge_root_nmethods() PRODUCT_RETURN; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
94 |
static void verify_perm_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
95 |
|
26796 | 96 |
// CodeHeap management |
97 |
static void initialize_heaps(); // Initializes the CodeHeaps |
|
34182
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34158
diff
changeset
|
98 |
// Check the code heap sizes set by the user via command line |
82d1b1696016
8061436: Processing of options related to segmented code cache should be enhanced
thartmann
parents:
34158
diff
changeset
|
99 |
static void check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set); |
26796 | 100 |
// Creates a new heap with the given name and size, containing CodeBlobs of the given type |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28374
diff
changeset
|
101 |
static void add_heap(ReservedSpace rs, const char* name, int code_blob_type); |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
27420
diff
changeset
|
102 |
static CodeHeap* get_code_heap(const CodeBlob* cb); // Returns the CodeHeap for the given CodeBlob |
26796 | 103 |
static CodeHeap* get_code_heap(int code_blob_type); // Returns the CodeHeap for the given CodeBlobType |
27410
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
26942
diff
changeset
|
104 |
// Returns the name of the VM option to set the size of the corresponding CodeHeap |
dd80df7cfa2b
8060196: 'CodeHeap is full' warning suggests to increase wrong code heap size
thartmann
parents:
26942
diff
changeset
|
105 |
static const char* get_code_heap_flag_name(int code_blob_type); |
28730
106944a21769
8064940: JMH javac performance regressions on solaris-sparcv9 in 9-b34
thartmann
parents:
28374
diff
changeset
|
106 |
static size_t heap_alignment(); // Returns the alignment of the CodeHeaps in bytes |
26796 | 107 |
static ReservedCodeSpace reserve_heap_memory(size_t size); // Reserves one continuous chunk of memory for the CodeHeaps |
108 |
||
109 |
// Iteration |
|
110 |
static CodeBlob* first_blob(CodeHeap* heap); // Returns the first CodeBlob on the given CodeHeap |
|
111 |
static CodeBlob* first_blob(int code_blob_type); // Returns the first CodeBlob of the given type |
|
112 |
static CodeBlob* next_blob(CodeHeap* heap, CodeBlob* cb); // Returns the first alive CodeBlob on the given CodeHeap |
|
113 |
static CodeBlob* next_blob(CodeBlob* cb); // Returns the next CodeBlob of the given type succeeding the given CodeBlob |
|
114 |
||
115 |
static size_t bytes_allocated_in_freelists(); |
|
116 |
static int allocated_segments(); |
|
117 |
static size_t freelists_length(); |
|
18025 | 118 |
|
1 | 119 |
public: |
120 |
// Initialization |
|
121 |
static void initialize(); |
|
122 |
||
123 |
// Allocation/administration |
|
29338
92297a8bd48e
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents:
28730
diff
changeset
|
124 |
static CodeBlob* allocate(int size, int code_blob_type, bool strict = false); // allocates a new CodeBlob |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
125 |
static void commit(CodeBlob* cb); // called when the allocated CodeBlob has been filled |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
126 |
static int alignment_unit(); // guaranteed alignment of all CodeBlobs |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
127 |
static int alignment_offset(); // guaranteed offset of first CodeBlob byte within alignment unit (i.e., allocation header) |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
128 |
static void free(CodeBlob* cb); // frees a CodeBlob |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
129 |
static bool contains(void *p); // returns whether p is included |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
130 |
static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
131 |
static void blobs_do(CodeBlobClosure* f); // iterates over all CodeBlobs |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
132 |
static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods |
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
27410
diff
changeset
|
133 |
static void alive_nmethods_do(void f(nmethod* nm)); // iterates over all alive nmethods |
1 | 134 |
|
135 |
// Lookup |
|
26796 | 136 |
static CodeBlob* find_blob(void* start); // Returns the CodeBlob containing the given address |
137 |
static CodeBlob* find_blob_unsafe(void* start); // Same as find_blob but does not fail if looking up a zombie method |
|
138 |
static nmethod* find_nmethod(void* start); // Returns the nmethod containing the given address |
|
13195 | 139 |
|
34158
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
140 |
static int blob_count(); // Returns the total number of CodeBlobs in the cache |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
141 |
static int blob_count(int code_blob_type); |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
142 |
static int adapter_count(); // Returns the total number of Adapters in the cache |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
143 |
static int adapter_count(int code_blob_type); |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
144 |
static int nmethod_count(); // Returns the total number of nmethods in the cache |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
145 |
static int nmethod_count(int code_blob_type); |
1 | 146 |
|
147 |
// GC support |
|
148 |
static void gc_epilogue(); |
|
149 |
static void gc_prologue(); |
|
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8672
diff
changeset
|
150 |
static void verify_oops(); |
1 | 151 |
// If "unloading_occurred" is true, then unloads (i.e., breaks root links |
152 |
// to) any unmarked codeBlobs in the cache. Sets "marked_for_unloading" |
|
153 |
// to "true" iff some code got unloaded. |
|
13878
6e6a462a6cff
7200470: KeepAliveClosure not needed in CodeCache::do_unloading
brutisso
parents:
13728
diff
changeset
|
154 |
static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
155 |
static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
156 |
static void scavenge_root_nmethods_do(CodeBlobClosure* f); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
157 |
|
26796 | 158 |
static nmethod* scavenge_root_nmethods() { return _scavenge_root_nmethods; } |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
159 |
static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
160 |
static void add_scavenge_root_nmethod(nmethod* nm); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
161 |
static void drop_scavenge_root_nmethod(nmethod* nm); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
162 |
static void prune_scavenge_root_nmethods(); |
1 | 163 |
|
164 |
// Printing/debugging |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
165 |
static void print(); // prints summary |
1 | 166 |
static void print_internals(); |
23214
b6426873cb37
8029799: vm/mlvm/anonloader/stress/oome prints warning: CodeHeap: # of free blocks > 10000
anoll
parents:
20290
diff
changeset
|
167 |
static void print_memory_overhead(); |
1 | 168 |
static void verify(); // verifies the code cache |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
169 |
static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN; |
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
13878
diff
changeset
|
170 |
static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage |
8672
26a427ab6f32
7025742: Can not use CodeCache::unallocated_capacity() with fragmented CodeCache
kvn
parents:
7715
diff
changeset
|
171 |
static void log_state(outputStream* st); |
26796 | 172 |
static const char* get_code_heap_name(int code_blob_type) { return (heap_available(code_blob_type) ? get_code_heap(code_blob_type)->name() : "Unused"); } |
173 |
static void report_codemem_full(int code_blob_type, bool print); |
|
1 | 174 |
|
26587 | 175 |
// Dcmd (Diagnostic commands) |
176 |
static void print_codelist(outputStream* st); |
|
177 |
static void print_layout(outputStream* st); |
|
178 |
||
1 | 179 |
// The full limits of the codeCache |
26796 | 180 |
static address low_bound() { return _low_bound; } |
34158
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
181 |
static address low_bound(int code_blob_type); |
26796 | 182 |
static address high_bound() { return _high_bound; } |
34158
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
183 |
static address high_bound(int code_blob_type); |
1 | 184 |
|
185 |
// Profiling |
|
26796 | 186 |
static size_t capacity(); |
26942
fa5ea7ff078d
8059390: code cache fills up for bigapps/Weblogic+medrec/nowarnings
zmajo
parents:
26919
diff
changeset
|
187 |
static size_t unallocated_capacity(int code_blob_type); |
26796 | 188 |
static size_t unallocated_capacity(); |
189 |
static size_t max_capacity(); |
|
190 |
||
191 |
static double reverse_free_ratio(int code_blob_type); |
|
192 |
||
193 |
static bool needs_cache_clean() { return _needs_cache_clean; } |
|
194 |
static void set_needs_cache_clean(bool v) { _needs_cache_clean = v; } |
|
195 |
static void clear_inline_caches(); // clear all inline caches |
|
1 | 196 |
|
34158
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
197 |
// Returns true if an own CodeHeap for the given CodeBlobType is available |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
198 |
static bool heap_available(int code_blob_type); |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
199 |
|
31348
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
200 |
// Returns the CodeBlobType for the given nmethod |
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
201 |
static int get_code_blob_type(nmethod* nm) { |
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
202 |
return get_code_heap(nm)->code_blob_type(); |
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
203 |
} |
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
204 |
|
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
205 |
// Returns the CodeBlobType for the given compilation level |
26796 | 206 |
static int get_code_blob_type(int comp_level) { |
207 |
if (comp_level == CompLevel_none || |
|
208 |
comp_level == CompLevel_simple || |
|
209 |
comp_level == CompLevel_full_optimization) { |
|
210 |
// Non profiled methods |
|
211 |
return CodeBlobType::MethodNonProfiled; |
|
212 |
} else if (comp_level == CompLevel_limited_profile || |
|
213 |
comp_level == CompLevel_full_profile) { |
|
214 |
// Profiled methods |
|
215 |
return CodeBlobType::MethodProfiled; |
|
216 |
} |
|
217 |
ShouldNotReachHere(); |
|
218 |
return 0; |
|
219 |
} |
|
1 | 220 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
221 |
static void verify_clean_inline_caches(); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
222 |
static void verify_icholder_relocations(); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
223 |
|
1 | 224 |
// Deoptimization |
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
225 |
private: |
36300
5b47f168b948
7177745: JSR292: Many Callsite relinkages cause target method to always run in interpreter mode
vlivanov
parents:
35123
diff
changeset
|
226 |
static int mark_for_deoptimization(KlassDepChange& changes); |
1 | 227 |
#ifdef HOTSWAP |
228 |
static int mark_for_evol_deoptimization(instanceKlassHandle dependee); |
|
229 |
#endif // HOTSWAP |
|
230 |
||
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
231 |
public: |
1 | 232 |
static void mark_all_nmethods_for_deoptimization(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
233 |
static int mark_for_deoptimization(Method* dependee); |
1 | 234 |
static void make_marked_nmethods_not_entrant(); |
235 |
||
28374
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
236 |
// Flushing and deoptimization |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
237 |
static void flush_dependents_on(instanceKlassHandle dependee); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
238 |
#ifdef HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
239 |
// Flushing and deoptimization in case of evolution |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
240 |
static void flush_evol_dependents_on(instanceKlassHandle dependee); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
241 |
#endif // HOTSWAP |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
242 |
// Support for fullspeed debugging |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
243 |
static void flush_dependents_on_method(methodHandle dependee); |
0558e321c027
8067836: The Universe::flush_foo methods belong in CodeCache.
coleenp
parents:
27642
diff
changeset
|
244 |
|
26796 | 245 |
// tells how many nmethods have dependencies |
1 | 246 |
static int number_of_nmethods_with_dependencies(); |
18025 | 247 |
|
34158
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
248 |
static int get_codemem_full_count(int code_blob_type) { |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
249 |
CodeHeap* heap = get_code_heap(code_blob_type); |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
250 |
return (heap != NULL) ? heap->full_count() : 0; |
1f8d643b02d5
8067378: Add segmented code heaps info into jfr events: vm/code_cache/stats and vm/code_cache/config
thartmann
parents:
32401
diff
changeset
|
251 |
} |
1 | 252 |
}; |
7397 | 253 |
|
26796 | 254 |
|
255 |
// Iterator to iterate over nmethods in the CodeCache. |
|
256 |
class NMethodIterator : public StackObj { |
|
257 |
private: |
|
258 |
CodeBlob* _code_blob; // Current CodeBlob |
|
259 |
int _code_blob_type; // Refers to current CodeHeap |
|
260 |
||
261 |
public: |
|
262 |
NMethodIterator() { |
|
263 |
initialize(NULL); // Set to NULL, initialized by first call to next() |
|
264 |
} |
|
265 |
||
266 |
NMethodIterator(nmethod* nm) { |
|
267 |
initialize(nm); |
|
268 |
} |
|
269 |
||
270 |
// Advance iterator to next nmethod |
|
271 |
bool next() { |
|
272 |
assert_locked_or_safepoint(CodeCache_lock); |
|
273 |
assert(_code_blob_type < CodeBlobType::NumTypes, "end reached"); |
|
274 |
||
275 |
bool result = next_nmethod(); |
|
276 |
while (!result && (_code_blob_type < CodeBlobType::MethodProfiled)) { |
|
277 |
// Advance to next code heap if segmented code cache |
|
278 |
_code_blob_type++; |
|
279 |
result = next_nmethod(); |
|
280 |
} |
|
281 |
return result; |
|
282 |
} |
|
283 |
||
284 |
// Advance iterator to next alive nmethod |
|
285 |
bool next_alive() { |
|
286 |
bool result = next(); |
|
287 |
while(result && !_code_blob->is_alive()) { |
|
288 |
result = next(); |
|
289 |
} |
|
290 |
return result; |
|
291 |
} |
|
292 |
||
293 |
bool end() const { return _code_blob == NULL; } |
|
294 |
nmethod* method() const { return (nmethod*)_code_blob; } |
|
295 |
||
296 |
private: |
|
297 |
// Initialize iterator to given nmethod |
|
298 |
void initialize(nmethod* nm) { |
|
299 |
_code_blob = (CodeBlob*)nm; |
|
300 |
if (!SegmentedCodeCache) { |
|
301 |
// Iterate over all CodeBlobs |
|
302 |
_code_blob_type = CodeBlobType::All; |
|
303 |
} else if (nm != NULL) { |
|
31348
c28f02c7abb5
8077279: assert(ic->is_clean()) failed: IC should be clean
sjohanss
parents:
31037
diff
changeset
|
304 |
_code_blob_type = CodeCache::get_code_blob_type(nm); |
26796 | 305 |
} else { |
306 |
// Only iterate over method code heaps, starting with non-profiled |
|
307 |
_code_blob_type = CodeBlobType::MethodNonProfiled; |
|
308 |
} |
|
309 |
} |
|
310 |
||
311 |
// Advance iterator to the next nmethod in the current code heap |
|
312 |
bool next_nmethod() { |
|
313 |
// Get first method CodeBlob |
|
314 |
if (_code_blob == NULL) { |
|
315 |
_code_blob = CodeCache::first_blob(_code_blob_type); |
|
316 |
if (_code_blob == NULL) { |
|
317 |
return false; |
|
318 |
} else if (_code_blob->is_nmethod()) { |
|
319 |
return true; |
|
320 |
} |
|
321 |
} |
|
322 |
// Search for next method CodeBlob |
|
323 |
_code_blob = CodeCache::next_blob(_code_blob); |
|
324 |
while (_code_blob != NULL && !_code_blob->is_nmethod()) { |
|
325 |
_code_blob = CodeCache::next_blob(_code_blob); |
|
326 |
} |
|
327 |
return _code_blob != NULL; |
|
328 |
} |
|
329 |
}; |
|
330 |
||
7397 | 331 |
#endif // SHARE_VM_CODE_CODECACHE_HPP |