annotate src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp @ 20494:7baf47cb97cb

8048268: G1 Code Root Migration performs poorly Summary: Replace G1CodeRootSet with a Hashtable based implementation, merge Code Root Migration phase into Code Root Scanning Reviewed-by: jmasa, brutisso, tschatzl
author mgerdin
date Fri, 29 Aug 2014 13:12:21 +0200
parents 870c03421152
children 58925d1f325e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #include "precompiled.hpp"
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
26 #include "code/codeCache.hpp"
17753
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"
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
29 #include "gc_implementation/g1/heapRegion.hpp"
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
30 #include "memory/heap.hpp"
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
31 #include "memory/iterator.hpp"
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
32 #include "oops/oop.inline.hpp"
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
33 #include "utilities/hashtable.inline.hpp"
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
34 #include "utilities/stack.inline.hpp"
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
35
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17753
diff changeset
36 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17753
diff changeset
37
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
38 class CodeRootSetTable : public Hashtable<nmethod*, mtGC> {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
39 friend class G1CodeRootSetTest;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
40 typedef HashtableEntry<nmethod*, mtGC> Entry;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
41
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
42 static CodeRootSetTable* volatile _purge_list;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
43
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
44 CodeRootSetTable* _purge_next;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
45
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
46 unsigned int compute_hash(nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
47 uintptr_t hash = (uintptr_t)nm;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
48 return hash ^ (hash >> 7); // code heap blocks are 128byte aligned
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
49 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
50
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
51 Entry* new_entry(nmethod* nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
52
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
53 public:
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
54 CodeRootSetTable(int size) : Hashtable<nmethod*, mtGC>(size, sizeof(Entry)), _purge_next(NULL) {}
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
55 ~CodeRootSetTable();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
56
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
57 // Needs to be protected locks
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
58 bool add(nmethod* nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
59 bool remove(nmethod* nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
60
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
61 // Can be called without locking
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
62 bool contains(nmethod* nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
63
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
64 int entry_size() const { return BasicHashtable<mtGC>::entry_size(); }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
65
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
66 void copy_to(CodeRootSetTable* new_table);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
67 void nmethods_do(CodeBlobClosure* blk);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
68
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
69 template<typename CB>
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
70 void remove_if(CB& should_remove);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
71
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
72 static void purge_list_append(CodeRootSetTable* tbl);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
73 static void purge();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
74
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
75 static size_t static_mem_size() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
76 return sizeof(_purge_list);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
77 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
78 };
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
79
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
80 CodeRootSetTable* volatile CodeRootSetTable::_purge_list = NULL;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
81
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
82 CodeRootSetTable::Entry* CodeRootSetTable::new_entry(nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
83 unsigned int hash = compute_hash(nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
84 Entry* entry = (Entry*) new_entry_free_list();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
85 if (entry == NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
86 entry = (Entry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtGC, CURRENT_PC);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
87 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
88 entry->set_next(NULL);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
89 entry->set_hash(hash);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
90 entry->set_literal(nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
91 return entry;
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
92 }
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
93
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
94 CodeRootSetTable::~CodeRootSetTable() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
95 for (int index = 0; index < table_size(); ++index) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
96 for (Entry* e = bucket(index); e != NULL; ) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
97 Entry* to_remove = e;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
98 // read next before freeing.
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
99 e = e->next();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
100 unlink_entry(to_remove);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
101 FREE_C_HEAP_ARRAY(char, to_remove, mtGC);
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
102 }
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
103 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
104 assert(number_of_entries() == 0, "should have removed all entries");
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
105 free_buckets();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
106 for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
107 FREE_C_HEAP_ARRAY(char, e, mtGC);
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
108 }
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
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
111 bool CodeRootSetTable::add(nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
112 if (!contains(nm)) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
113 Entry* e = new_entry(nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
114 int index = hash_to_index(e->hash());
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
115 add_entry(index, e);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
116 return true;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
117 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
118 return false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
119 }
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
120
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
121 bool CodeRootSetTable::contains(nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
122 int index = hash_to_index(compute_hash(nm));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
123 for (Entry* e = bucket(index); e != NULL; e = e->next()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
124 if (e->literal() == nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
125 return true;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
126 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
127 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
128 return false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
129 }
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
130
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
131 bool CodeRootSetTable::remove(nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
132 int index = hash_to_index(compute_hash(nm));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
133 Entry* previous = NULL;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
134 for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
135 if (e->literal() == nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
136 if (previous != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
137 previous->set_next(e->next());
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
138 } else {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
139 set_entry(index, e->next());
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
140 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
141 free_entry(e);
20278
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
142 return true;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
143 }
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
144 }
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
145 return false;
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
146 }
2c6ef90f030a 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 20218
diff changeset
147
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
148 void CodeRootSetTable::copy_to(CodeRootSetTable* new_table) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
149 for (int index = 0; index < table_size(); ++index) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
150 for (Entry* e = bucket(index); e != NULL; e = e->next()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
151 new_table->add(e->literal());
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
152 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
153 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
154 new_table->copy_freelist(this);
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
155 }
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
156
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
157 void CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
158 for (int index = 0; index < table_size(); ++index) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
159 for (Entry* e = bucket(index); e != NULL; e = e->next()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
160 blk->do_code_blob(e->literal());
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
161 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
162 }
17753
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
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
165 template<typename CB>
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
166 void CodeRootSetTable::remove_if(CB& should_remove) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
167 for (int index = 0; index < table_size(); ++index) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
168 Entry* previous = NULL;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
169 Entry* e = bucket(index);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
170 while (e != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
171 Entry* next = e->next();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
172 if (should_remove(e->literal())) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
173 if (previous != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
174 previous->set_next(next);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
175 } else {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
176 set_entry(index, next);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
177 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
178 free_entry(e);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
179 } else {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
180 previous = e;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
181 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
182 e = next;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
183 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
184 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
185 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
186
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
187 G1CodeRootSet::~G1CodeRootSet() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
188 delete _table;
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
189 }
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
190
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
191 CodeRootSetTable* G1CodeRootSet::load_acquire_table() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
192 return (CodeRootSetTable*) OrderAccess::load_ptr_acquire(&_table);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
193 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
194
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
195 void G1CodeRootSet::allocate_small_table() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
196 _table = new CodeRootSetTable(SmallSize);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
197 }
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
198
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
199 void CodeRootSetTable::purge_list_append(CodeRootSetTable* table) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
200 for (;;) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
201 table->_purge_next = _purge_list;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
202 CodeRootSetTable* old = (CodeRootSetTable*) Atomic::cmpxchg_ptr(table, &_purge_list, table->_purge_next);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
203 if (old == table->_purge_next) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
204 break;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
205 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
206 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
207 }
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
208
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
209 void CodeRootSetTable::purge() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
210 CodeRootSetTable* table = _purge_list;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
211 _purge_list = NULL;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
212 while (table != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
213 CodeRootSetTable* to_purge = table;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
214 table = table->_purge_next;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
215 delete to_purge;
17753
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 }
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
218
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
219 void G1CodeRootSet::move_to_large() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
220 CodeRootSetTable* temp = new CodeRootSetTable(LargeSize);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
221
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
222 _table->copy_to(temp);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
223
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
224 CodeRootSetTable::purge_list_append(_table);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
225
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
226 OrderAccess::release_store_ptr(&_table, temp);
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
227 }
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
228
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
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
230 void G1CodeRootSet::purge() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
231 CodeRootSetTable::purge();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
232 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
233
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
234 size_t G1CodeRootSet::static_mem_size() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
235 return CodeRootSetTable::static_mem_size();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
236 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
237
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
238 void G1CodeRootSet::add(nmethod* method) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
239 bool added = false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
240 if (is_empty()) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
241 allocate_small_table();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
242 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
243 added = _table->add(method);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
244 if (_length == Threshold) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
245 move_to_large();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
246 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
247 if (added) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
248 ++_length;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
249 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
250 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
251
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
252 bool G1CodeRootSet::remove(nmethod* method) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
253 bool removed = false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
254 if (_table != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
255 removed = _table->remove(method);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
256 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
257 if (removed) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
258 _length--;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
259 if (_length == 0) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
260 clear();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
261 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
262 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
263 return removed;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
264 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
265
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
266 bool G1CodeRootSet::contains(nmethod* method) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
267 CodeRootSetTable* table = load_acquire_table();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
268 if (table != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
269 return table->contains(method);
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
270 }
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
271 return false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
272 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
273
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
274 void G1CodeRootSet::clear() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
275 delete _table;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
276 _table = NULL;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
277 _length = 0;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
278 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
279
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
280 size_t G1CodeRootSet::mem_size() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
281 return sizeof(*this) +
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
282 (_table != NULL ? sizeof(CodeRootSetTable) + _table->entry_size() * _length : 0);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
283 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
284
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
285 void G1CodeRootSet::nmethods_do(CodeBlobClosure* blk) const {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
286 if (_table != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
287 _table->nmethods_do(blk);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
288 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
289 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
290
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
291 class CleanCallback : public StackObj {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
292 class PointsIntoHRDetectionClosure : public OopClosure {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
293 HeapRegion* _hr;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
294 public:
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
295 bool _points_into;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
296 PointsIntoHRDetectionClosure(HeapRegion* hr) : _hr(hr), _points_into(false) {}
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
297
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
298 void do_oop(narrowOop* o) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
299 do_oop_work(o);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
300 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
301
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
302 void do_oop(oop* o) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
303 do_oop_work(o);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
304 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
305
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
306 template <typename T>
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
307 void do_oop_work(T* p) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
308 if (_hr->is_in(oopDesc::load_decode_heap_oop(p))) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
309 _points_into = true;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
310 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
311 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
312 };
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
313
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
314 PointsIntoHRDetectionClosure _detector;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
315 CodeBlobToOopClosure _blobs;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
316
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
317 public:
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
318 CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {}
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
319
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
320 bool operator() (nmethod* nm) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
321 _detector._points_into = false;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
322 _blobs.do_code_blob(nm);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
323 return _detector._points_into;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
324 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
325 };
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
326
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
327 void G1CodeRootSet::clean(HeapRegion* owner) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
328 CleanCallback should_clean(owner);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
329 if (_table != NULL) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
330 _table->remove_if(should_clean);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
331 }
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
332 }
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
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
334 #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
335
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
336 class G1CodeRootSetTest {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
337 public:
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
338 static void test() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
339 {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
340 G1CodeRootSet set1;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
341 assert(set1.is_empty(), "Code root set must be initially empty but is not.");
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
342
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
343 assert(G1CodeRootSet::static_mem_size() == sizeof(void*),
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
344 err_msg("The code root set's static memory usage is incorrect, "SIZE_FORMAT" bytes", G1CodeRootSet::static_mem_size()));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
345
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
346 set1.add((nmethod*)1);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
347 assert(set1.length() == 1, err_msg("Added exactly one element, but set contains "
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
348 SIZE_FORMAT" elements", set1.length()));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
349
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
350 const size_t num_to_add = (size_t)G1CodeRootSet::Threshold + 1;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
351
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
352 for (size_t i = 1; i <= num_to_add; i++) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
353 set1.add((nmethod*)1);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
354 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
355 assert(set1.length() == 1,
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
356 err_msg("Duplicate detection should not have increased the set size but "
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
357 "is "SIZE_FORMAT, set1.length()));
17753
191174b49bec 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
358
20494
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
359 for (size_t i = 2; i <= num_to_add; i++) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
360 set1.add((nmethod*)(uintptr_t)(i));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
361 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
362 assert(set1.length() == num_to_add,
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
363 err_msg("After adding in total "SIZE_FORMAT" distinct code roots, they "
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
364 "need to be in the set, but there are only "SIZE_FORMAT,
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
365 num_to_add, set1.length()));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
366
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
367 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable");
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
368
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
369 size_t num_popped = 0;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
370 for (size_t i = 1; i <= num_to_add; i++) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
371 bool removed = set1.remove((nmethod*)i);
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
372 if (removed) {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
373 num_popped += 1;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
374 } else {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
375 break;
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
376 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
377 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
378 assert(num_popped == num_to_add,
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
379 err_msg("Managed to pop "SIZE_FORMAT" code roots, but only "SIZE_FORMAT" "
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
380 "were added", num_popped, num_to_add));
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
381 assert(CodeRootSetTable::_purge_list != NULL, "should have grown to large hashtable");
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
382
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
383 G1CodeRootSet::purge();
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
384
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
385 assert(CodeRootSetTable::_purge_list == NULL, "should have purged old small tables");
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
386
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
387 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
388
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
389 }
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
390 };
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
391
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
392 void TestCodeCacheRemSet_test() {
7baf47cb97cb 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 20279
diff changeset
393 G1CodeRootSetTest::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
394 }
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
395
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
396 #endif