39 static bool _biased_locking_enabled = false; 40 BiasedLockingCounters BiasedLocking::_counters; 41 42 static GrowableArray<Handle>* _preserved_oop_stack = NULL; 43 static GrowableArray<markOop>* _preserved_mark_stack = NULL; 44 45 static void enable_biased_locking(InstanceKlass* k) { 46 k->set_prototype_header(markOopDesc::biased_locking_prototype()); 47 } 48 49 class VM_EnableBiasedLocking: public VM_Operation { 50 private: 51 bool _is_cheap_allocated; 52 public: 53 VM_EnableBiasedLocking(bool is_cheap_allocated) { _is_cheap_allocated = is_cheap_allocated; } 54 VMOp_Type type() const { return VMOp_EnableBiasedLocking; } 55 Mode evaluation_mode() const { return _is_cheap_allocated ? _async_safepoint : _safepoint; } 56 bool is_cheap_allocated() const { return _is_cheap_allocated; } 57 58 void doit() { 59 // Iterate the system dictionary enabling biased locking for all 60 // currently loaded classes 61 ClassLoaderDataGraph::dictionary_classes_do(enable_biased_locking); 62 // Indicate that future instances should enable it as well 63 _biased_locking_enabled = true; 64 65 log_info(biasedlocking)("Biased locking enabled"); 66 } 67 68 bool allow_nested_vm_operations() const { return false; } 69 }; 70 71 72 // One-shot PeriodicTask subclass for enabling biased locking 73 class EnableBiasedLockingTask : public PeriodicTask { 74 public: 75 EnableBiasedLockingTask(size_t interval_time) : PeriodicTask(interval_time) {} 76 77 virtual void task() { 78 // Use async VM operation to avoid blocking the Watcher thread. 79 // VM Thread will free C heap storage. 80 VM_EnableBiasedLocking *op = new VM_EnableBiasedLocking(true); | 39 static bool _biased_locking_enabled = false; 40 BiasedLockingCounters BiasedLocking::_counters; 41 42 static GrowableArray<Handle>* _preserved_oop_stack = NULL; 43 static GrowableArray<markOop>* _preserved_mark_stack = NULL; 44 45 static void enable_biased_locking(InstanceKlass* k) { 46 k->set_prototype_header(markOopDesc::biased_locking_prototype()); 47 } 48 49 class VM_EnableBiasedLocking: public VM_Operation { 50 private: 51 bool _is_cheap_allocated; 52 public: 53 VM_EnableBiasedLocking(bool is_cheap_allocated) { _is_cheap_allocated = is_cheap_allocated; } 54 VMOp_Type type() const { return VMOp_EnableBiasedLocking; } 55 Mode evaluation_mode() const { return _is_cheap_allocated ? _async_safepoint : _safepoint; } 56 bool is_cheap_allocated() const { return _is_cheap_allocated; } 57 58 void doit() { 59 // Iterate the class loader data dictionaries enabling biased locking for all 60 // currently loaded classes. 61 ClassLoaderDataGraph::dictionary_classes_do(enable_biased_locking); 62 // Indicate that future instances should enable it as well 63 _biased_locking_enabled = true; 64 65 log_info(biasedlocking)("Biased locking enabled"); 66 } 67 68 bool allow_nested_vm_operations() const { return false; } 69 }; 70 71 72 // One-shot PeriodicTask subclass for enabling biased locking 73 class EnableBiasedLockingTask : public PeriodicTask { 74 public: 75 EnableBiasedLockingTask(size_t interval_time) : PeriodicTask(interval_time) {} 76 77 virtual void task() { 78 // Use async VM operation to avoid blocking the Watcher thread. 79 // VM Thread will free C heap storage. 80 VM_EnableBiasedLocking *op = new VM_EnableBiasedLocking(true); |