mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8207359: Make SymbolTable increment_refcount disallow zero
Use cmpxchg for non permanent symbol refcounting, and pack refcount and length into an int. Reviewed-by: gziemski, kbarrett, iklam
This commit is contained in:
parent
6cbef1de5d
commit
39dd04b953
14 changed files with 206 additions and 64 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -190,6 +190,7 @@ void SymbolTable::rehash_table() {
|
|||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
// This should never happen with -Xshare:dump but it might in testing mode.
|
||||
if (DumpSharedSpaces) return;
|
||||
|
||||
// Create a new symbol table
|
||||
SymbolTable* new_table = new SymbolTable();
|
||||
|
||||
|
@ -212,10 +213,16 @@ Symbol* SymbolTable::lookup_dynamic(int index, const char* name,
|
|||
count++; // count all entries in this bucket, not just ones with same hash
|
||||
if (e->hash() == hash) {
|
||||
Symbol* sym = e->literal();
|
||||
if (sym->equals(name, len)) {
|
||||
// something is referencing this symbol now.
|
||||
sym->increment_refcount();
|
||||
return sym;
|
||||
// Skip checking already dead symbols in the bucket.
|
||||
if (sym->refcount() == 0) {
|
||||
count--; // Don't count this symbol towards rehashing.
|
||||
} else if (sym->equals(name, len)) {
|
||||
if (sym->try_increment_refcount()) {
|
||||
// something is referencing this symbol now.
|
||||
return sym;
|
||||
} else {
|
||||
count--; // don't count this symbol.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue