8232788: Move biased locking initalization
Reviewed-by: pchilanomate, dholmes
This commit is contained in:
parent
31ab60e211
commit
9308d18580
@ -2132,26 +2132,6 @@ void SystemDictionary::update_dictionary(unsigned int d_hash,
|
||||
{
|
||||
MutexLocker mu1(SystemDictionary_lock, THREAD);
|
||||
|
||||
// See whether biased locking is enabled and if so set it for this
|
||||
// klass.
|
||||
// Note that this must be done past the last potential blocking
|
||||
// point / safepoint. We might enable biased locking lazily using a
|
||||
// VM_Operation to iterate the SystemDictionary and installing the
|
||||
// biasable mark word into each InstanceKlass's prototype header.
|
||||
// To avoid race conditions where we accidentally miss enabling the
|
||||
// optimization for one class in the process of being added to the
|
||||
// dictionary, we must not safepoint after the test of
|
||||
// BiasedLocking::enabled().
|
||||
if (UseBiasedLocking && BiasedLocking::enabled()) {
|
||||
// Set biased locking bit for all loaded classes; it will be
|
||||
// cleared if revocation occurs too often for this type
|
||||
// NOTE that we must only do this when the class is initally
|
||||
// defined, not each time it is referenced from a new class loader
|
||||
if (k->class_loader() == class_loader()) {
|
||||
k->set_prototype_header(markWord::biased_locking_prototype());
|
||||
}
|
||||
}
|
||||
|
||||
// Make a new dictionary entry.
|
||||
Dictionary* dictionary = loader_data->dictionary();
|
||||
InstanceKlass* sd_check = find_class(d_hash, name, dictionary);
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include "prims/jvmtiThreadState.hpp"
|
||||
#include "prims/methodComparator.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/biasedLocking.hpp"
|
||||
#include "runtime/fieldDescriptor.inline.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "runtime/javaCalls.hpp"
|
||||
@ -456,6 +457,12 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, Klass
|
||||
if (Arguments::is_dumping_archive()) {
|
||||
SystemDictionaryShared::init_dumptime_info(this);
|
||||
}
|
||||
|
||||
// Set biased locking bit for all instances of this class; it will be
|
||||
// cleared if revocation occurs too often for this type
|
||||
if (UseBiasedLocking && BiasedLocking::enabled()) {
|
||||
set_prototype_header(markWord::biased_locking_prototype());
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
|
||||
@ -2408,6 +2415,11 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
|
||||
// --> see ArrayKlass::complete_create_array_klass()
|
||||
array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK);
|
||||
}
|
||||
|
||||
// Initialize current biased locking state.
|
||||
if (UseBiasedLocking && BiasedLocking::enabled()) {
|
||||
set_prototype_header(markWord::biased_locking_prototype());
|
||||
}
|
||||
}
|
||||
|
||||
// returns true IFF is_in_error_state() has been changed as a result of this call.
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/biasedLocking.hpp"
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
@ -84,10 +85,14 @@ TEST_VM(markWord, printing) {
|
||||
ThreadInVMfromNative invm(THREAD);
|
||||
ResourceMark rm(THREAD);
|
||||
|
||||
if (!UseBiasedLocking || !BiasedLocking::enabled()) {
|
||||
// Can't test this with biased locking disabled.
|
||||
return;
|
||||
}
|
||||
|
||||
oop obj = SystemDictionary::Byte_klass()->allocate_instance(THREAD);
|
||||
|
||||
FlagSetting fs(WizardMode, true);
|
||||
FlagSetting bf(UseBiasedLocking, true);
|
||||
|
||||
HandleMark hm(THREAD);
|
||||
Handle h_obj(THREAD, obj);
|
Loading…
x
Reference in New Issue
Block a user