Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ public void share(String className, T info, int classLoaderKeyId) {
final SharedInfo[] shared = this.shared;
final int slotMask = this.slotMask;

// always wrap info in a new wrapper to avoid consistency issues
final SharedInfo update = new SharedInfo(className, info, classLoaderKeyId);

int oldestTick = Integer.MAX_VALUE;
int oldestSlot = -1;

Expand All @@ -192,7 +189,7 @@ public void share(String className, T info, int classLoaderKeyId) {
for (int i = 1, h = hash; true; i++, h = rehash(h)) {
int slot = slotMask & h;
SharedInfo existing = shared[slot];
if (existing != null && !existing.equals(update)) {
if (existing != null && !existing.className.equals(className)) {
// slot already used by a different class
int tick = existing.accessed;
if (i < MAX_HASH_ATTEMPTS) {
Expand All @@ -211,6 +208,8 @@ public void share(String className, T info, int classLoaderKeyId) {
// last hashed slot is least-recently-used, re-use it
}
}
// wrap info in a new wrapper (deferred to avoid allocation on early match)
SharedInfo update = new SharedInfo(className, info, classLoaderKeyId);
shared[slot] = update;
// increment global TICKS whenever info is shared
// avoid incrementing it in 'find' for performance reasons
Expand Down
Loading