Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp @ 20254:9fec19bb0659
8032379: Remove the is_scavenging flag to process_strong_roots
Summary: Refactor the strong root processing to avoid using a boolean in addition to the ScanOption enum.
Reviewed-by: stefank, tschatzl, ehelin, jmasa
author | mgerdin |
---|---|
date | Tue, 14 Jan 2014 16:40:33 +0100 |
parents | 828056cf311f |
children | 2c6ef90f030a |
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 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
26 #include "precompiled.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
27 #include "code/nmethod.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
28 #include "gc_implementation/g1/g1CodeCacheRemSet.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
29 #include "memory/iterator.hpp" |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
30 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17753
diff
changeset
|
31 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17753
diff
changeset
|
32 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
33 G1CodeRootChunk::G1CodeRootChunk() : _top(NULL), _next(NULL), _prev(NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
34 _top = bottom(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
35 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
36 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
37 void G1CodeRootChunk::reset() { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
38 _next = _prev = NULL; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
39 _top = bottom(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
40 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
41 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
42 void G1CodeRootChunk::nmethods_do(CodeBlobClosure* cl) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
43 nmethod** cur = bottom(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
44 while (cur != _top) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
45 cl->do_code_blob(*cur); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
46 cur++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
47 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
48 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
49 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
50 G1CodeRootChunkManager::G1CodeRootChunkManager() : _free_list(), _num_chunks_handed_out(0) { |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
51 _free_list.initialize(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
52 _free_list.set_size(G1CodeRootChunk::word_size()); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
53 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
54 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
55 size_t G1CodeRootChunkManager::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:
17937
diff
changeset
|
56 return _free_list.count() * _free_list.size(); |
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 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
59 void G1CodeRootChunkManager::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:
17937
diff
changeset
|
60 _num_chunks_handed_out -= list->count(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
61 _free_list.prepend(list); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
62 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
63 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
64 void G1CodeRootChunkManager::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:
17937
diff
changeset
|
65 _free_list.return_chunk_at_head(chunk); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
66 _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:
17937
diff
changeset
|
67 } |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
68 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
69 void G1CodeRootChunkManager::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:
17937
diff
changeset
|
70 size_t keep = _num_chunks_handed_out * keep_ratio / 100; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
71 if (keep >= (size_t)_free_list.count()) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
72 return; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
73 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
74 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
75 FreeList<G1CodeRootChunk> temp; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
76 temp.initialize(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
77 temp.set_size(G1CodeRootChunk::word_size()); |
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 _free_list.getFirstNChunksFromList((size_t)_free_list.count() - keep, &temp); |
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* cur = temp.get_chunk_at_head(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
82 while (cur != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
83 delete cur; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
84 cur = temp.get_chunk_at_head(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
85 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
86 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
87 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
88 size_t G1CodeRootChunkManager::static_mem_size() { |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
89 return sizeof(G1CodeRootChunkManager); |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
90 } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
91 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
92 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
93 G1CodeRootChunk* G1CodeRootChunkManager::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:
17937
diff
changeset
|
94 G1CodeRootChunk* result = _free_list.get_chunk_at_head(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
95 if (result == NULL) { |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
96 result = new G1CodeRootChunk(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
97 } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
98 _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:
17937
diff
changeset
|
99 result->reset(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
100 return result; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
101 } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
102 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
103 #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:
17937
diff
changeset
|
104 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
105 size_t G1CodeRootChunkManager::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:
17937
diff
changeset
|
106 return _num_chunks_handed_out; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
107 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
108 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
109 size_t G1CodeRootChunkManager::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:
17937
diff
changeset
|
110 return (size_t)_free_list.count(); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
111 } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
112 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
113 #endif |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
114 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
115 G1CodeRootChunkManager G1CodeRootSet::_default_chunk_manager; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
116 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
117 void G1CodeRootSet::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:
17937
diff
changeset
|
118 _default_chunk_manager.purge_chunks(keep_ratio); |
17753
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 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
121 size_t G1CodeRootSet::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:
17937
diff
changeset
|
122 return _default_chunk_manager.static_mem_size(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
123 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
124 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
125 size_t G1CodeRootSet::free_chunks_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:
17937
diff
changeset
|
126 return _default_chunk_manager.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:
17937
diff
changeset
|
127 } |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
128 |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
129 G1CodeRootSet::G1CodeRootSet(G1CodeRootChunkManager* manager) : _manager(manager), _list(), _length(0) { |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
130 if (_manager == NULL) { |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
131 _manager = &_default_chunk_manager; |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
132 } |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
133 _list.initialize(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
134 _list.set_size(G1CodeRootChunk::word_size()); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
135 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
136 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
137 G1CodeRootSet::~G1CodeRootSet() { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
138 clear(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
139 } |
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 G1CodeRootSet::add(nmethod* method) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
142 if (!contains(method)) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
143 // Try to add the nmethod. If there is not enough space, get a new chunk. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
144 if (_list.head() == NULL || _list.head()->is_full()) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
145 G1CodeRootChunk* cur = new_chunk(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
146 _list.return_chunk_at_head(cur); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
147 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
148 bool result = _list.head()->add(method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
149 guarantee(result, err_msg("Not able to add nmethod "PTR_FORMAT" to newly allocated chunk.", method)); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
150 _length++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
151 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
152 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
153 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
154 void G1CodeRootSet::remove(nmethod* method) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
155 G1CodeRootChunk* found = find(method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
156 if (found != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
157 bool result = found->remove(method); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
158 guarantee(result, err_msg("could not find nmethod "PTR_FORMAT" during removal although we previously found it", method)); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
159 // eventually free completely emptied chunk |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
160 if (found->is_empty()) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
161 _list.remove_chunk(found); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
162 free(found); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
163 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
164 _length--; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
165 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
166 assert(!contains(method), err_msg(PTR_FORMAT" still contains nmethod "PTR_FORMAT, this, method)); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
167 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
168 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
169 nmethod* G1CodeRootSet::pop() { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
170 do { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
171 G1CodeRootChunk* cur = _list.head(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
172 if (cur == NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
173 assert(_length == 0, "when there are no chunks, there should be no elements"); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
174 return NULL; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
175 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
176 nmethod* result = cur->pop(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
177 if (result != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
178 _length--; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
179 return result; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
180 } else { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
181 free(_list.get_chunk_at_head()); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
182 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
183 } while (true); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
184 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
185 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
186 G1CodeRootChunk* G1CodeRootSet::find(nmethod* method) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
187 G1CodeRootChunk* cur = _list.head(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
188 while (cur != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
189 if (cur->contains(method)) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
190 return cur; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
191 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
192 cur = (G1CodeRootChunk*)cur->next(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
193 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
194 return NULL; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
195 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
196 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
197 void G1CodeRootSet::free(G1CodeRootChunk* chunk) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
198 free_chunk(chunk); |
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 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
201 bool G1CodeRootSet::contains(nmethod* method) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
202 return find(method) != NULL; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
203 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
204 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
205 void G1CodeRootSet::clear() { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
206 free_all_chunks(&_list); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
207 _length = 0; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
208 } |
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 void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
211 G1CodeRootChunk* cur = _list.head(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
212 while (cur != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
213 cur->nmethods_do(blk); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
214 cur = (G1CodeRootChunk*)cur->next(); |
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 } |
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 size_t G1CodeRootSet::static_mem_size() { |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
219 return sizeof(G1CodeRootSet); |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
220 } |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
221 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
222 size_t G1CodeRootSet::mem_size() { |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
223 return G1CodeRootSet::static_mem_size() + _list.count() * _list.size(); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
224 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
225 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
226 #ifndef PRODUCT |
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 void G1CodeRootSet::test() { |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
229 G1CodeRootChunkManager mgr; |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
230 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
231 assert(mgr.num_chunks_handed_out() == 0, "Must not have handed out chunks yet"); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
232 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
233 assert(G1CodeRootChunkManager::static_mem_size() > sizeof(void*), |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
234 err_msg("The chunk manager's static memory usage seems too small, is only "SIZE_FORMAT" bytes.", G1CodeRootChunkManager::static_mem_size())); |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
235 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
236 // The number of chunks that we allocate for purge testing. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
237 size_t const num_chunks = 10; |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
238 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
239 { |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
240 G1CodeRootSet set1(&mgr); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
241 assert(set1.is_empty(), "Code root set must be initially empty but is not."); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
242 |
20218
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
243 assert(G1CodeRootSet::static_mem_size() > sizeof(void*), |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
244 err_msg("The code root set's static memory usage seems too small, is only "SIZE_FORMAT" bytes", G1CodeRootSet::static_mem_size())); |
828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
20211
diff
changeset
|
245 |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
246 set1.add((nmethod*)1); |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
247 assert(mgr.num_chunks_handed_out() == 1, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
248 err_msg("Must have allocated and handed out one chunk, but handed out " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
249 SIZE_FORMAT" chunks", mgr.num_chunks_handed_out())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
250 assert(set1.length() == 1, err_msg("Added exactly one element, but set contains " |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
251 SIZE_FORMAT" elements", set1.length())); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
252 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
253 // G1CodeRootChunk::word_size() is larger than G1CodeRootChunk::num_entries which |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
254 // we cannot access. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
255 for (uint i = 0; i < G1CodeRootChunk::word_size() + 1; i++) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
256 set1.add((nmethod*)1); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
257 } |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
258 assert(mgr.num_chunks_handed_out() == 1, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
259 err_msg("Duplicate detection must have prevented allocation of further " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
260 "chunks but allocated "SIZE_FORMAT, mgr.num_chunks_handed_out())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
261 assert(set1.length() == 1, |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
262 err_msg("Duplicate detection should not have increased the set size but " |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
263 "is "SIZE_FORMAT, set1.length())); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
264 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
265 size_t num_total_after_add = G1CodeRootChunk::word_size() + 1; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
266 for (size_t i = 0; i < num_total_after_add - 1; i++) { |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
267 set1.add((nmethod*)(uintptr_t)(2 + i)); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
268 } |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
269 assert(mgr.num_chunks_handed_out() > 1, |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
270 "After adding more code roots, more than one additional chunk should have been handed out"); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
271 assert(set1.length() == num_total_after_add, |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
272 err_msg("After adding in total "SIZE_FORMAT" distinct code roots, they " |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
273 "need to be in the set, but there are only "SIZE_FORMAT, |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
274 num_total_after_add, set1.length())); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
275 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
276 size_t num_popped = 0; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
277 while (set1.pop() != NULL) { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
278 num_popped++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
279 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
280 assert(num_popped == num_total_after_add, |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
281 err_msg("Managed to pop "SIZE_FORMAT" code roots, but only "SIZE_FORMAT" " |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
282 "were added", num_popped, num_total_after_add)); |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
283 assert(mgr.num_chunks_handed_out() == 0, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
284 err_msg("After popping all elements, all chunks must have been returned " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
285 "but there are still "SIZE_FORMAT" additional", mgr.num_chunks_handed_out())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
286 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
287 mgr.purge_chunks(0); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
288 assert(mgr.num_free_chunks() == 0, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
289 err_msg("After purging everything, the free list must be empty but still " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
290 "contains "SIZE_FORMAT" chunks", mgr.num_free_chunks())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
291 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
292 // Add some more handed out chunks. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
293 size_t i = 0; |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
294 while (mgr.num_chunks_handed_out() < num_chunks) { |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
295 set1.add((nmethod*)i); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
296 i++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
297 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
298 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
299 { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
300 // Generate chunks on the free 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:
17937
diff
changeset
|
301 G1CodeRootSet set2(&mgr); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
302 size_t i = 0; |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
303 while (mgr.num_chunks_handed_out() < (num_chunks * 2)) { |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
304 set2.add((nmethod*)i); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
305 i++; |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
306 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
307 // Exit of the scope of the set2 object will call the destructor that generates |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
308 // num_chunks elements on the free list. |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
309 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
310 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
311 assert(mgr.num_chunks_handed_out() == num_chunks, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
312 err_msg("Deletion of the second set must have resulted in giving back " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
313 "those, but there are still "SIZE_FORMAT" additional handed out, expecting " |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
314 SIZE_FORMAT, mgr.num_chunks_handed_out(), num_chunks)); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
315 assert(mgr.num_free_chunks() == num_chunks, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
316 err_msg("After freeing "SIZE_FORMAT" chunks, they must be on the free 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:
17937
diff
changeset
|
317 "but there are only "SIZE_FORMAT, num_chunks, mgr.num_free_chunks())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
318 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
319 size_t const test_percentage = 50; |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
320 mgr.purge_chunks(test_percentage); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
321 assert(mgr.num_chunks_handed_out() == num_chunks, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
322 err_msg("Purging must not hand out chunks but there are "SIZE_FORMAT, |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
323 mgr.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:
17937
diff
changeset
|
324 assert(mgr.num_free_chunks() == (size_t)(mgr.num_chunks_handed_out() * test_percentage / 100), |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
325 err_msg("Must have purged "SIZE_FORMAT" percent of "SIZE_FORMAT" chunks" |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
326 "but there are "SIZE_FORMAT, test_percentage, num_chunks, |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
327 mgr.num_free_chunks())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
328 // Purge the remainder of the chunks on the free 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:
17937
diff
changeset
|
329 mgr.purge_chunks(0); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
330 assert(mgr.num_free_chunks() == 0, "Free List must be empty"); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
331 assert(mgr.num_chunks_handed_out() == num_chunks, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
332 err_msg("Expected to be "SIZE_FORMAT" chunks handed out from the first set " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
333 "but there are "SIZE_FORMAT, num_chunks, mgr.num_chunks_handed_out())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
334 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
335 // Exit of the scope of the set1 object will call the destructor that generates |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
336 // num_chunks additional elements on the free 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:
17937
diff
changeset
|
337 } |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
338 |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
339 assert(mgr.num_chunks_handed_out() == 0, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
340 err_msg("Deletion of the only set must have resulted in no chunks handed " |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
341 "out, but there is still "SIZE_FORMAT" handed out", mgr.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:
17937
diff
changeset
|
342 assert(mgr.num_free_chunks() == num_chunks, |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
343 err_msg("After freeing "SIZE_FORMAT" chunks, they must be on the free 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:
17937
diff
changeset
|
344 "but there are only "SIZE_FORMAT, num_chunks, mgr.num_free_chunks())); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
345 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
346 // Restore initial state. |
20211
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
347 mgr.purge_chunks(0); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
348 assert(mgr.num_free_chunks() == 0, "Free List must be empty"); |
82693fb204a5
8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents:
17937
diff
changeset
|
349 assert(mgr.num_chunks_handed_out() == 0, "No additional elements must have been handed out yet"); |
17753
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
350 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
351 |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
352 void TestCodeCacheRemSet_test() { |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
353 G1CodeRootSet::test(); |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
354 } |
191174b49bec
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff
changeset
|
355 #endif |