Skip to content

Commit

Permalink
8317240: Promptly free OopMapEntry after fail to insert the entry to …
Browse files Browse the repository at this point in the history
…OopMapCache

Reviewed-by: coleenp, fparain
  • Loading branch information
zhengyu123 committed Oct 5, 2023
1 parent 4c5b66d commit a8eacb3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/hotspot/share/interpreter/oopMapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class OopMapCacheEntry: private InterpreterOopMap {
// Deallocate bit masks and initialize fields
void flush();

static void deallocate(OopMapCacheEntry* const entry);

private:
void allocate_bit_mask(); // allocates the bit mask on C heap f necessary
void deallocate_bit_mask(); // allocates the bit mask on C heap f necessary
Expand Down Expand Up @@ -401,6 +403,10 @@ void OopMapCacheEntry::flush() {
initialize();
}

void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
entry->flush();
FREE_C_HEAP_OBJ(entry);
}

// Implementation of OopMapCache

Expand Down Expand Up @@ -476,8 +482,7 @@ void OopMapCache::flush() {
OopMapCacheEntry* entry = _array[i];
if (entry != nullptr) {
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
}
}
}
Expand All @@ -496,8 +501,7 @@ void OopMapCache::flush_obsolete_entries() {
entry->method()->name()->as_C_string(), entry->method()->signature()->as_C_string(), i);
}
_array[i] = nullptr;
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
}
}
}
Expand Down Expand Up @@ -544,8 +548,7 @@ void OopMapCache::lookup(const methodHandle& method,
// at this time. We give the caller of lookup() a copy of the
// interesting info via parameter entry_for, but we don't add it to
// the cache. See the gory details in Method*.cpp.
tmp->flush();
FREE_C_HEAP_OBJ(tmp);
OopMapCacheEntry::deallocate(tmp);
return;
}

Expand All @@ -568,7 +571,7 @@ void OopMapCache::lookup(const methodHandle& method,
if (put_at(probe + 0, tmp, old)) {
enqueue_for_cleanup(old);
} else {
enqueue_for_cleanup(tmp);
OopMapCacheEntry::deallocate(tmp);
}

assert(!entry_for->is_empty(), "A non-empty oop map should be returned");
Expand Down Expand Up @@ -603,8 +606,7 @@ void OopMapCache::cleanup_old_entries() {
entry->method()->name_and_sig_as_C_string(), entry->bci());
}
OopMapCacheEntry* next = entry->_next;
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
entry = next;
}
}
Expand All @@ -617,6 +619,5 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
if (tmp->has_valid_mask()) {
entry->resource_copy(tmp);
}
tmp->flush();
FREE_C_HEAP_OBJ(tmp);
OopMapCacheEntry::deallocate(tmp);
}

1 comment on commit a8eacb3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.