Skip to content

Commit a8eacb3

Browse files
committed
8317240: Promptly free OopMapEntry after fail to insert the entry to OopMapCache
Reviewed-by: coleenp, fparain
1 parent 4c5b66d commit a8eacb3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Diff for: src/hotspot/share/interpreter/oopMapCache.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class OopMapCacheEntry: private InterpreterOopMap {
5555
// Deallocate bit masks and initialize fields
5656
void flush();
5757

58+
static void deallocate(OopMapCacheEntry* const entry);
59+
5860
private:
5961
void allocate_bit_mask(); // allocates the bit mask on C heap f necessary
6062
void deallocate_bit_mask(); // allocates the bit mask on C heap f necessary
@@ -401,6 +403,10 @@ void OopMapCacheEntry::flush() {
401403
initialize();
402404
}
403405

406+
void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
407+
entry->flush();
408+
FREE_C_HEAP_OBJ(entry);
409+
}
404410

405411
// Implementation of OopMapCache
406412

@@ -476,8 +482,7 @@ void OopMapCache::flush() {
476482
OopMapCacheEntry* entry = _array[i];
477483
if (entry != nullptr) {
478484
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
479-
entry->flush();
480-
FREE_C_HEAP_OBJ(entry);
485+
OopMapCacheEntry::deallocate(entry);
481486
}
482487
}
483488
}
@@ -496,8 +501,7 @@ void OopMapCache::flush_obsolete_entries() {
496501
entry->method()->name()->as_C_string(), entry->method()->signature()->as_C_string(), i);
497502
}
498503
_array[i] = nullptr;
499-
entry->flush();
500-
FREE_C_HEAP_OBJ(entry);
504+
OopMapCacheEntry::deallocate(entry);
501505
}
502506
}
503507
}
@@ -544,8 +548,7 @@ void OopMapCache::lookup(const methodHandle& method,
544548
// at this time. We give the caller of lookup() a copy of the
545549
// interesting info via parameter entry_for, but we don't add it to
546550
// the cache. See the gory details in Method*.cpp.
547-
tmp->flush();
548-
FREE_C_HEAP_OBJ(tmp);
551+
OopMapCacheEntry::deallocate(tmp);
549552
return;
550553
}
551554

@@ -568,7 +571,7 @@ void OopMapCache::lookup(const methodHandle& method,
568571
if (put_at(probe + 0, tmp, old)) {
569572
enqueue_for_cleanup(old);
570573
} else {
571-
enqueue_for_cleanup(tmp);
574+
OopMapCacheEntry::deallocate(tmp);
572575
}
573576

574577
assert(!entry_for->is_empty(), "A non-empty oop map should be returned");
@@ -603,8 +606,7 @@ void OopMapCache::cleanup_old_entries() {
603606
entry->method()->name_and_sig_as_C_string(), entry->bci());
604607
}
605608
OopMapCacheEntry* next = entry->_next;
606-
entry->flush();
607-
FREE_C_HEAP_OBJ(entry);
609+
OopMapCacheEntry::deallocate(entry);
608610
entry = next;
609611
}
610612
}
@@ -617,6 +619,5 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
617619
if (tmp->has_valid_mask()) {
618620
entry->resource_copy(tmp);
619621
}
620-
tmp->flush();
621-
FREE_C_HEAP_OBJ(tmp);
622+
OopMapCacheEntry::deallocate(tmp);
622623
}

0 commit comments

Comments
 (0)