Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp @ 20335:eec72fa4b108
8040722: G1: Clean up usages of heap_region_containing
Reviewed-by: tschatzl, jmasa
author | brutisso |
---|---|
date | Tue, 19 Aug 2014 12:39:06 +0200 |
parents | 2c6ef90f030a |
children | 7baf47cb97cb |
rev | line source |
---|---|
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
1 /* |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
4 * |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
8 * |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
13 * accompanied this code). |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
14 * |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
18 * |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
21 * questions. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
22 * |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
23 */ |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
24 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
27 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
28 #include "memory/allocation.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
29 #include "memory/freeList.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
30 #include "runtime/globals.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
31 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
32 class CodeBlobClosure; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
33 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
34 // The elements of the G1CodeRootChunk is either: |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
35 // 1) nmethod pointers |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
36 // 2) nodes in an internally chained free list |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
37 typedef union { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
38 nmethod* _nmethod; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
39 void* _link; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
40 } NmethodOrLink; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
41 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
42 class G1CodeRootChunk : public CHeapObj<mtGC> { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
43 private: |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
44 static const int NUM_ENTRIES = 32; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
45 public: |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
46 G1CodeRootChunk* _next; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
47 G1CodeRootChunk* _prev; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
48 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
49 NmethodOrLink* _top; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
50 // First free position within the chunk. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
51 volatile NmethodOrLink* _free; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
52 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
53 NmethodOrLink _data[NUM_ENTRIES]; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
54 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
55 NmethodOrLink* bottom() const { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
56 return (NmethodOrLink*) &(_data[0]); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
57 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
58 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
59 NmethodOrLink* end() const { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
60 return (NmethodOrLink*) &(_data[NUM_ENTRIES]); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
61 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
62 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
63 bool is_link(NmethodOrLink* nmethod_or_link) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
64 return nmethod_or_link->_link == NULL || |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
65 (bottom() <= nmethod_or_link->_link |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
66 && nmethod_or_link->_link < end()); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
67 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
68 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
69 bool is_nmethod(NmethodOrLink* nmethod_or_link) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
70 return !is_link(nmethod_or_link); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
71 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
72 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
73 public: |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
74 G1CodeRootChunk(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
75 ~G1CodeRootChunk() {} |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
76 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
77 static size_t word_size() { return (size_t)(align_size_up_(sizeof(G1CodeRootChunk), HeapWordSize) / HeapWordSize); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
78 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
79 // FreeList "interface" methods |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
80 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
81 G1CodeRootChunk* next() const { return _next; } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
82 G1CodeRootChunk* prev() const { return _prev; } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
83 void set_next(G1CodeRootChunk* v) { _next = v; assert(v != this, "Boom");} |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
84 void set_prev(G1CodeRootChunk* v) { _prev = v; assert(v != this, "Boom");} |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
85 void clear_next() { set_next(NULL); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
86 void clear_prev() { set_prev(NULL); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
87 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
88 size_t size() const { return word_size(); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
89 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
90 void link_next(G1CodeRootChunk* ptr) { set_next(ptr); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
91 void link_prev(G1CodeRootChunk* ptr) { set_prev(ptr); } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
92 void link_after(G1CodeRootChunk* ptr) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
93 link_next(ptr); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
94 if (ptr != NULL) ptr->link_prev((G1CodeRootChunk*)this); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
95 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
96 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
97 bool is_free() { return true; } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
98 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
99 // New G1CodeRootChunk routines |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
100 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
101 void reset(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
102 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
103 bool is_empty() const { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
104 return _top == bottom(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
105 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
106 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
107 bool is_full() const { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
108 return _top == end() && _free == NULL; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
109 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
110 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
111 bool contains(nmethod* method) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
112 NmethodOrLink* cur = bottom(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
113 while (cur != _top) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
114 if (cur->_nmethod == method) return true; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
115 cur++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
116 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
117 return false; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
118 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
119 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
120 bool add(nmethod* method) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
121 if (is_full()) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
122 return false; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
123 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
124 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
125 if (_free != NULL) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
126 // Take from internally chained free list |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
127 NmethodOrLink* first_free = (NmethodOrLink*)_free; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
128 _free = (NmethodOrLink*)_free->_link; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
129 first_free->_nmethod = method; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
130 } else { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
131 // Take from top. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
132 _top->_nmethod = method; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
133 _top++; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
134 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
135 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
136 return true; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
137 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
138 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
139 bool remove_lock_free(nmethod* method); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
140 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
141 void nmethods_do(CodeBlobClosure* blk); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
142 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
143 nmethod* pop() { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
144 if (_free != NULL) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
145 // Kill the free list. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
146 _free = NULL; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
147 } |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
148 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
149 while (!is_empty()) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
150 _top--; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
151 if (is_nmethod(_top)) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
152 return _top->_nmethod; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
153 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
154 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
155 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
156 return NULL; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
157 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
158 }; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
159 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
160 // Manages free chunks. |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
161 class G1CodeRootChunkManager VALUE_OBJ_CLASS_SPEC { |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
162 private: |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
163 // Global free chunk list management |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
164 FreeList<G1CodeRootChunk> _free_list; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
165 // Total number of chunks handed out |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
166 size_t _num_chunks_handed_out; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
167 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
168 public: |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
169 G1CodeRootChunkManager(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
170 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
171 G1CodeRootChunk* new_chunk(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
172 void free_chunk(G1CodeRootChunk* chunk); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
173 // Free all elements of the given list. |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
174 void free_all_chunks(FreeList<G1CodeRootChunk>* list); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
175 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
176 void initialize(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
177 void purge_chunks(size_t keep_ratio); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
178 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
179 static size_t static_mem_size(); |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
180 size_t fl_mem_size(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
181 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
182 #ifndef PRODUCT |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
183 size_t num_chunks_handed_out() const; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
184 size_t num_free_chunks() const; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
185 #endif |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
186 }; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
187 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
188 // Implements storage for a set of code roots. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
189 // All methods that modify the set are not thread-safe except if otherwise noted. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
190 class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
191 private: |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
192 // Global default free chunk manager instance. |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
193 static G1CodeRootChunkManager _default_chunk_manager; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
194 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
195 G1CodeRootChunk* new_chunk() { return _manager->new_chunk(); } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
196 void free_chunk(G1CodeRootChunk* chunk) { _manager->free_chunk(chunk); } |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
197 // Free all elements of the given list. |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
198 void free_all_chunks(FreeList<G1CodeRootChunk>* list) { _manager->free_all_chunks(list); } |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
199 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
200 // Return the chunk that contains the given nmethod, NULL otherwise. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
201 // Scans the list of chunks backwards, as this method is used to add new |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
202 // entries, which are typically added in bulk for a single nmethod. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
203 G1CodeRootChunk* find(nmethod* method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
204 void free(G1CodeRootChunk* chunk); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
205 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
206 size_t _length; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
207 FreeList<G1CodeRootChunk> _list; |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
208 G1CodeRootChunkManager* _manager; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
209 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
210 public: |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
211 // If an instance is initialized with a chunk manager of NULL, use the global |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
212 // default one. |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
213 G1CodeRootSet(G1CodeRootChunkManager* manager = NULL); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
214 ~G1CodeRootSet(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
215 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
216 static void purge_chunks(size_t keep_ratio); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
217 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
218 static size_t free_chunks_static_mem_size(); |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17753
diff
changeset
|
219 static size_t free_chunks_mem_size(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
220 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
221 // Search for the code blob from the recently allocated ones to find duplicates more quickly, as this |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
222 // method is likely to be repeatedly called with the same nmethod. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
223 void add(nmethod* method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
224 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20218
diff
changeset
|
225 void remove_lock_free(nmethod* method); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
226 nmethod* pop(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
227 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
228 bool contains(nmethod* method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
229 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
230 void clear(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
231 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
232 void nmethods_do(CodeBlobClosure* blk) const; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
233 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
234 bool is_empty() { return length() == 0; } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
235 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
236 // Length in elements |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
237 size_t length() const { return _length; } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
238 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
239 // Static data memory size in bytes of this set. |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
240 static size_t static_mem_size(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
241 // Memory size in bytes taken by this set. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
242 size_t mem_size(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
243 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
244 static void test() PRODUCT_RETURN; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
245 }; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
246 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
247 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP |