void G1CodeRootSetTable::remove_entry(Entry* e, Entry* previous) { int index = hash_to_index(e->hash());
assert((e == bucket(index)) == (previous == NULL), "if e is the first entry then previous should be null");
G1CodeRootSetTable::~G1CodeRootSetTable() { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; ) {
Entry* to_remove = e; // read next before freeing.
e = e->next();
BasicHashtable<mtGC>::free_entry(to_remove);
}
}
assert(number_of_entries() == 0, "should have removed all entries");
}
bool G1CodeRootSetTable::add(nmethod* nm) { if (!contains(nm)) {
Entry* e = new_entry(nm); int index = hash_to_index(e->hash());
add_entry(index, e); returntrue;
} returnfalse;
}
bool G1CodeRootSetTable::contains(nmethod* nm) { int index = hash_to_index(compute_hash(nm)); for (Entry* e = bucket(index); e != NULL; e = e->next()) { if (e->literal() == nm) { returntrue;
}
} returnfalse;
}
bool G1CodeRootSetTable::remove(nmethod* nm) { int index = hash_to_index(compute_hash(nm));
Entry* previous = NULL; for (Entry* e = bucket(index); e != NULL; previous = e, e = e->next()) { if (e->literal() == nm) {
remove_entry(e, previous); returntrue;
}
} returnfalse;
}
void G1CodeRootSetTable::copy_to(G1CodeRootSetTable* new_table) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) {
new_table->add(e->literal());
}
}
}
void G1CodeRootSetTable::nmethods_do(CodeBlobClosure* blk) { for (int index = 0; index < table_size(); ++index) { for (Entry* e = bucket(index); e != NULL; e = e->next()) {
blk->do_code_blob(e->literal());
}
}
}
template<typename CB> int G1CodeRootSetTable::remove_if(CB& should_remove) { int num_removed = 0; for (int index = 0; index < table_size(); ++index) {
Entry* previous = NULL;
Entry* e = bucket(index); while (e != NULL) {
Entry* next = e->next(); if (should_remove(e->literal())) {
remove_entry(e, previous);
++num_removed;
} else {
previous = e;
}
e = next;
}
} return num_removed;
}
bool G1CodeRootSet::contains(nmethod* method) {
G1CodeRootSetTable* table = load_acquire_table(); // contains() may be called outside of lock, so ensure mem sync. if (table != NULL) { return table->contains(method);
} returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.