Skip to content

Commit 78d39b1

Browse files
committed
8317240: Promptly free OopMapEntry after fail to insert the entry to OopMapCache
Backport-of: a8eacb31ab8466f50a939d6748dbdd1560516878
1 parent eee3b42 commit 78d39b1

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
@@ -53,6 +53,8 @@ class OopMapCacheEntry: private InterpreterOopMap {
5353
// Deallocate bit masks and initialize fields
5454
void flush();
5555

56+
static void deallocate(OopMapCacheEntry* const entry);
57+
5658
private:
5759
void allocate_bit_mask(); // allocates the bit mask on C heap f necessary
5860
void deallocate_bit_mask(); // allocates the bit mask on C heap f necessary
@@ -399,6 +401,10 @@ void OopMapCacheEntry::flush() {
399401
initialize();
400402
}
401403

404+
void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
405+
entry->flush();
406+
FREE_C_HEAP_OBJ(entry);
407+
}
402408

403409
// Implementation of OopMapCache
404410

@@ -472,8 +478,7 @@ void OopMapCache::flush() {
472478
OopMapCacheEntry* entry = _array[i];
473479
if (entry != nullptr) {
474480
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
475-
entry->flush();
476-
FREE_C_HEAP_OBJ(entry);
481+
OopMapCacheEntry::deallocate(entry);
477482
}
478483
}
479484
}
@@ -492,8 +497,7 @@ void OopMapCache::flush_obsolete_entries() {
492497
entry->method()->name()->as_C_string(), entry->method()->signature()->as_C_string(), i);
493498
}
494499
_array[i] = nullptr;
495-
entry->flush();
496-
FREE_C_HEAP_OBJ(entry);
500+
OopMapCacheEntry::deallocate(entry);
497501
}
498502
}
499503
}
@@ -540,8 +544,7 @@ void OopMapCache::lookup(const methodHandle& method,
540544
// at this time. We give the caller of lookup() a copy of the
541545
// interesting info via parameter entry_for, but we don't add it to
542546
// the cache. See the gory details in Method*.cpp.
543-
tmp->flush();
544-
FREE_C_HEAP_OBJ(tmp);
547+
OopMapCacheEntry::deallocate(tmp);
545548
return;
546549
}
547550

@@ -564,7 +567,7 @@ void OopMapCache::lookup(const methodHandle& method,
564567
if (put_at(probe + 0, tmp, old)) {
565568
enqueue_for_cleanup(old);
566569
} else {
567-
enqueue_for_cleanup(tmp);
570+
OopMapCacheEntry::deallocate(tmp);
568571
}
569572

570573
assert(!entry_for->is_empty(), "A non-empty oop map should be returned");
@@ -599,8 +602,7 @@ void OopMapCache::cleanup_old_entries() {
599602
entry->method()->name_and_sig_as_C_string(), entry->bci());
600603
}
601604
OopMapCacheEntry* next = entry->_next;
602-
entry->flush();
603-
FREE_C_HEAP_OBJ(entry);
605+
OopMapCacheEntry::deallocate(entry);
604606
entry = next;
605607
}
606608
}
@@ -611,6 +613,5 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
611613
tmp->initialize();
612614
tmp->fill(method, bci);
613615
entry->resource_copy(tmp);
614-
tmp->flush();
615-
FREE_C_HEAP_OBJ(tmp);
616+
OopMapCacheEntry::deallocate(tmp);
616617
}

0 commit comments

Comments
 (0)