2943 |
2943 |
2944 void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { |
2944 void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { |
2945 if (SafepointSynchronize::is_at_safepoint()) { |
2945 if (SafepointSynchronize::is_at_safepoint()) { |
2946 assert(Thread::current()->is_VM_thread(), "should be the VM thread"); |
2946 assert(Thread::current()->is_VM_thread(), "should be the VM thread"); |
2947 // Don't take Heap_lock |
2947 // Don't take Heap_lock |
2948 MutexLocker ml(vsm()->lock()); |
2948 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
2949 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
2949 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
2950 // Dark matter. Too small for dictionary. |
2950 // Dark matter. Too small for dictionary. |
2951 #ifdef ASSERT |
2951 #ifdef ASSERT |
2952 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); |
2952 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); |
2953 #endif |
2953 #endif |
2957 class_vsm()->deallocate(ptr, word_size); |
2957 class_vsm()->deallocate(ptr, word_size); |
2958 } else { |
2958 } else { |
2959 vsm()->deallocate(ptr, word_size); |
2959 vsm()->deallocate(ptr, word_size); |
2960 } |
2960 } |
2961 } else { |
2961 } else { |
2962 MutexLocker ml(vsm()->lock()); |
2962 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
2963 |
2963 |
2964 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
2964 if (word_size < TreeChunk<Metablock, FreeList>::min_size()) { |
2965 // Dark matter. Too small for dictionary. |
2965 // Dark matter. Too small for dictionary. |
2966 #ifdef ASSERT |
2966 #ifdef ASSERT |
2967 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); |
2967 Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); |