mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 12:04:39 +02:00
8037952: Remove code duplication in Metaspace::deallocate
Reviewed-by: tschatzl, pliden, coleenp
This commit is contained in:
parent
e3ebae0947
commit
8159b86e35
1 changed files with 13 additions and 28 deletions
|
@ -3343,23 +3343,9 @@ size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
|
void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
|
||||||
if (SafepointSynchronize::is_at_safepoint()) {
|
assert(!SafepointSynchronize::is_at_safepoint()
|
||||||
assert(Thread::current()->is_VM_thread(), "should be the VM thread");
|
|| Thread::current()->is_VM_thread(), "should be the VM thread");
|
||||||
// Don't take Heap_lock
|
|
||||||
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
|
|
||||||
if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
|
|
||||||
// Dark matter. Too small for dictionary.
|
|
||||||
#ifdef ASSERT
|
|
||||||
Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (is_class && using_class_space()) {
|
|
||||||
class_vsm()->deallocate(ptr, word_size);
|
|
||||||
} else {
|
|
||||||
vsm()->deallocate(ptr, word_size);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
|
MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
|
||||||
|
|
||||||
if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
|
if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
|
||||||
|
@ -3375,7 +3361,6 @@ void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
|
||||||
vsm()->deallocate(ptr, word_size);
|
vsm()->deallocate(ptr, word_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
|
MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue