8219464: ZGC: Move nmethod oop properties from ZNMethodTableEntry to ZNMethodData

Reviewed-by: pliden
This commit is contained in:
Stefan Karlsson 2019-02-20 10:47:03 +01:00
parent 7c5141a048
commit 2895d5534d
4 changed files with 150 additions and 162 deletions

View File

@ -37,71 +37,80 @@
#include "gc/z/zWorkers.hpp" #include "gc/z/zWorkers.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/allocation.inline.hpp" #include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "runtime/orderAccess.hpp" #include "runtime/orderAccess.hpp"
#include "utilities/debug.hpp" #include "utilities/debug.hpp"
class ZNMethodDataImmediateOops { class ZNMethodDataOops {
private: private:
const size_t _nimmediate_oops; const size_t _nimmediates;
bool _has_non_immediates;
static size_t header_size(); static size_t header_size();
ZNMethodDataImmediateOops(const GrowableArray<oop*>& immediate_oops); ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool has_non_immediates);
public: public:
static ZNMethodDataImmediateOops* create(const GrowableArray<oop*>& immediate_oops); static ZNMethodDataOops* create(const GrowableArray<oop*>& immediates, bool has_non_immediates);
static void destroy(ZNMethodDataImmediateOops* data_immediate_oops); static void destroy(ZNMethodDataOops* oops);
size_t immediate_oops_count() const; size_t immediates_count() const;
oop** immediate_oops_begin() const; oop** immediates_begin() const;
oop** immediate_oops_end() const; oop** immediates_end() const;
bool has_non_immediates() const;
}; };
size_t ZNMethodDataImmediateOops::header_size() { size_t ZNMethodDataOops::header_size() {
const size_t size = sizeof(ZNMethodDataImmediateOops); const size_t size = sizeof(ZNMethodDataOops);
assert(is_aligned(size, sizeof(oop*)), "Header misaligned"); assert(is_aligned(size, sizeof(oop*)), "Header misaligned");
return size; return size;
} }
ZNMethodDataImmediateOops* ZNMethodDataImmediateOops::create(const GrowableArray<oop*>& immediate_oops) { ZNMethodDataOops* ZNMethodDataOops::create(const GrowableArray<oop*>& immediates, bool has_non_immediates) {
// Allocate memory for the ZNMethodDataImmediateOops object // Allocate memory for the ZNMethodDataOops object
// plus the immediate oop* array that follows right after. // plus the immediate oop* array that follows right after.
const size_t size = ZNMethodDataImmediateOops::header_size() + (sizeof(oop*) * immediate_oops.length()); const size_t size = ZNMethodDataOops::header_size() + (sizeof(oop*) * immediates.length());
void* const data_immediate_oops = NEW_C_HEAP_ARRAY(uint8_t, size, mtGC); void* const data = NEW_C_HEAP_ARRAY(uint8_t, size, mtGC);
return ::new (data_immediate_oops) ZNMethodDataImmediateOops(immediate_oops); return ::new (data) ZNMethodDataOops(immediates, has_non_immediates);
} }
void ZNMethodDataImmediateOops::destroy(ZNMethodDataImmediateOops* data_immediate_oops) { void ZNMethodDataOops::destroy(ZNMethodDataOops* oops) {
ZNMethodTable::safe_delete(data_immediate_oops); ZNMethodTable::safe_delete(oops);
} }
ZNMethodDataImmediateOops::ZNMethodDataImmediateOops(const GrowableArray<oop*>& immediate_oops) : ZNMethodDataOops::ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool has_non_immediates) :
_nimmediate_oops(immediate_oops.length()) { _nimmediates(immediates.length()),
_has_non_immediates(has_non_immediates) {
// Save all immediate oops // Save all immediate oops
for (size_t i = 0; i < _nimmediate_oops; i++) { for (size_t i = 0; i < _nimmediates; i++) {
immediate_oops_begin()[i] = immediate_oops.at(i); immediates_begin()[i] = immediates.at(i);
} }
} }
size_t ZNMethodDataImmediateOops::immediate_oops_count() const { size_t ZNMethodDataOops::immediates_count() const {
return _nimmediate_oops; return _nimmediates;
} }
oop** ZNMethodDataImmediateOops::immediate_oops_begin() const { oop** ZNMethodDataOops::immediates_begin() const {
// The immediate oop* array starts immediately after this object // The immediate oop* array starts immediately after this object
return (oop**)((uintptr_t)this + header_size()); return (oop**)((uintptr_t)this + header_size());
} }
oop** ZNMethodDataImmediateOops::immediate_oops_end() const { oop** ZNMethodDataOops::immediates_end() const {
return immediate_oops_begin() + immediate_oops_count(); return immediates_begin() + immediates_count();
}
bool ZNMethodDataOops::has_non_immediates() const {
return _has_non_immediates;
} }
class ZNMethodData { class ZNMethodData {
private: private:
ZReentrantLock _lock; ZReentrantLock _lock;
ZNMethodDataImmediateOops* volatile _immediate_oops; ZNMethodDataOops* volatile _oops;
ZNMethodData(nmethod* nm); ZNMethodData(nmethod* nm);
@ -111,8 +120,8 @@ public:
ZReentrantLock* lock(); ZReentrantLock* lock();
ZNMethodDataImmediateOops* immediate_oops() const; ZNMethodDataOops* oops() const;
ZNMethodDataImmediateOops* swap_immediate_oops(const GrowableArray<oop*>& immediate_oops); ZNMethodDataOops* swap_oops(ZNMethodDataOops* oops);
}; };
ZNMethodData* ZNMethodData::create(nmethod* nm) { ZNMethodData* ZNMethodData::create(nmethod* nm) {
@ -121,26 +130,24 @@ ZNMethodData* ZNMethodData::create(nmethod* nm) {
} }
void ZNMethodData::destroy(ZNMethodData* data) { void ZNMethodData::destroy(ZNMethodData* data) {
ZNMethodDataImmediateOops::destroy(data->immediate_oops()); ZNMethodDataOops::destroy(data->oops());
ZNMethodTable::safe_delete(data); ZNMethodTable::safe_delete(data);
} }
ZNMethodData::ZNMethodData(nmethod* nm) : ZNMethodData::ZNMethodData(nmethod* nm) :
_lock(), _lock(),
_immediate_oops(NULL) {} _oops(NULL) {}
ZReentrantLock* ZNMethodData::lock() { ZReentrantLock* ZNMethodData::lock() {
return &_lock; return &_lock;
} }
ZNMethodDataImmediateOops* ZNMethodData::immediate_oops() const { ZNMethodDataOops* ZNMethodData::oops() const {
return OrderAccess::load_acquire(&_immediate_oops); return OrderAccess::load_acquire(&_oops);
} }
ZNMethodDataImmediateOops* ZNMethodData::swap_immediate_oops(const GrowableArray<oop*>& immediate_oops) { ZNMethodDataOops* ZNMethodData::swap_oops(ZNMethodDataOops* new_oops) {
ZNMethodDataImmediateOops* const data_immediate_oops = return Atomic::xchg(new_oops, &_oops);
immediate_oops.is_empty() ? NULL : ZNMethodDataImmediateOops::create(immediate_oops);
return Atomic::xchg(data_immediate_oops, &_immediate_oops);
} }
static ZNMethodData* gc_data(const nmethod* nm) { static ZNMethodData* gc_data(const nmethod* nm) {
@ -176,7 +183,7 @@ void ZNMethodTable::safe_delete(void* data) {
} }
} }
ZNMethodTableEntry ZNMethodTable::create_entry(nmethod* nm) { void ZNMethodTable::attach_gc_data(nmethod* nm) {
GrowableArray<oop*> immediate_oops; GrowableArray<oop*> immediate_oops;
bool non_immediate_oops = false; bool non_immediate_oops = false;
@ -211,12 +218,16 @@ ZNMethodTableEntry ZNMethodTable::create_entry(nmethod* nm) {
set_gc_data(nm, data); set_gc_data(nm, data);
} }
// Attach immediate oops in GC data // Attach oops in GC data
ZNMethodDataImmediateOops* const old_data_immediate_oops = data->swap_immediate_oops(immediate_oops); ZNMethodDataOops* const new_oops = ZNMethodDataOops::create(immediate_oops, non_immediate_oops);
ZNMethodDataImmediateOops::destroy(old_data_immediate_oops); ZNMethodDataOops* const old_oops = data->swap_oops(new_oops);
ZNMethodDataOops::destroy(old_oops);
}
// Create entry void ZNMethodTable::detach_gc_data(nmethod* nm) {
return ZNMethodTableEntry(nm, non_immediate_oops, !immediate_oops.is_empty()); // Destroy GC data
ZNMethodData::destroy(gc_data(nm));
set_gc_data(nm, NULL);
} }
ZReentrantLock* ZNMethodTable::lock_for_nmethod(nmethod* nm) { ZReentrantLock* ZNMethodTable::lock_for_nmethod(nmethod* nm) {
@ -240,8 +251,8 @@ size_t ZNMethodTable::next_index(size_t prev_index, size_t size) {
return (prev_index + 1) & mask; return (prev_index + 1) & mask;
} }
bool ZNMethodTable::register_entry(ZNMethodTableEntry* table, size_t size, ZNMethodTableEntry entry) { bool ZNMethodTable::register_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm) {
const nmethod* const nm = entry.method(); const ZNMethodTableEntry entry(nm);
size_t index = first_index(nm, size); size_t index = first_index(nm, size);
for (;;) { for (;;) {
@ -264,11 +275,6 @@ bool ZNMethodTable::register_entry(ZNMethodTableEntry* table, size_t size, ZNMet
} }
void ZNMethodTable::unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm) { void ZNMethodTable::unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm) {
if (size == 0) {
// Table is empty
return;
}
size_t index = first_index(nm, size); size_t index = first_index(nm, size);
for (;;) { for (;;) {
@ -278,10 +284,6 @@ void ZNMethodTable::unregister_entry(ZNMethodTableEntry* table, size_t size, nme
if (table_entry.registered() && table_entry.method() == nm) { if (table_entry.registered() && table_entry.method() == nm) {
// Remove entry // Remove entry
table[index] = ZNMethodTableEntry(true /* unregistered */); table[index] = ZNMethodTableEntry(true /* unregistered */);
// Destroy GC data
ZNMethodData::destroy(gc_data(nm));
set_gc_data(nm, NULL);
return; return;
} }
@ -309,7 +311,7 @@ void ZNMethodTable::rebuild(size_t new_size) {
for (size_t i = 0; i < _size; i++) { for (size_t i = 0; i < _size; i++) {
const ZNMethodTableEntry entry = _table[i]; const ZNMethodTableEntry entry = _table[i];
if (entry.registered()) { if (entry.registered()) {
register_entry(new_table, new_size, entry); register_entry(new_table, new_size, entry.method());
} }
} }
@ -353,12 +355,14 @@ void ZNMethodTable::rebuild_if_needed() {
} }
} }
void ZNMethodTable::log_register(const nmethod* nm, ZNMethodTableEntry entry) { void ZNMethodTable::log_register(const nmethod* nm) {
LogTarget(Trace, gc, nmethod) log; LogTarget(Trace, gc, nmethod) log;
if (!log.is_enabled()) { if (!log.is_enabled()) {
return; return;
} }
const ZNMethodDataOops* const oops = gc_data(nm)->oops();
log.print("Register NMethod: %s.%s (" PTR_FORMAT "), " log.print("Register NMethod: %s.%s (" PTR_FORMAT "), "
"Compiler: %s, Oops: %d, ImmediateOops: " SIZE_FORMAT ", NonImmediateOops: %s", "Compiler: %s, Oops: %d, ImmediateOops: " SIZE_FORMAT ", NonImmediateOops: %s",
nm->method()->method_holder()->external_name(), nm->method()->method_holder()->external_name(),
@ -366,8 +370,8 @@ void ZNMethodTable::log_register(const nmethod* nm, ZNMethodTableEntry entry) {
p2i(nm), p2i(nm),
nm->compiler_name(), nm->compiler_name(),
nm->oops_count() - 1, nm->oops_count() - 1,
entry.immediate_oops() ? gc_data(nm)->immediate_oops()->immediate_oops_count() : 0, oops->immediates_count(),
entry.non_immediate_oops() ? "Yes" : "No"); oops->has_non_immediates() ? "Yes" : "No");
LogTarget(Trace, gc, nmethod, oops) log_oops; LogTarget(Trace, gc, nmethod, oops) log_oops;
if (!log_oops.is_enabled()) { if (!log_oops.is_enabled()) {
@ -375,23 +379,22 @@ void ZNMethodTable::log_register(const nmethod* nm, ZNMethodTableEntry entry) {
} }
// Print nmethod oops table // Print nmethod oops table
oop* const begin = nm->oops_begin(); {
oop* const end = nm->oops_end(); oop* const begin = nm->oops_begin();
for (oop* p = begin; p < end; p++) { oop* const end = nm->oops_end();
log_oops.print(" Oop[" SIZE_FORMAT "] " PTR_FORMAT " (%s)", for (oop* p = begin; p < end; p++) {
(p - begin), p2i(*p), (*p)->klass()->external_name()); log_oops.print(" Oop[" SIZE_FORMAT "] " PTR_FORMAT " (%s)",
(p - begin), p2i(*p), (*p)->klass()->external_name());
}
} }
if (entry.immediate_oops()) { // Print nmethod immediate oops
// Print nmethod immediate oops {
const ZNMethodDataImmediateOops* const nmi = gc_data(nm)->immediate_oops(); oop** const begin = oops->immediates_begin();
if (nmi != NULL) { oop** const end = oops->immediates_end();
oop** const begin = nmi->immediate_oops_begin(); for (oop** p = begin; p < end; p++) {
oop** const end = nmi->immediate_oops_end(); log_oops.print(" ImmediateOop[" SIZE_FORMAT "] " PTR_FORMAT " @ " PTR_FORMAT " (%s)",
for (oop** p = begin; p < end; p++) { (p - begin), p2i(**p), p2i(*p), (**p)->klass()->external_name());
log_oops.print(" ImmediateOop[" SIZE_FORMAT "] " PTR_FORMAT " @ " PTR_FORMAT " (%s)",
(p - begin), p2i(**p), p2i(*p), (**p)->klass()->external_name());
}
} }
} }
} }
@ -423,13 +426,13 @@ void ZNMethodTable::register_nmethod(nmethod* nm) {
// Grow/Shrink/Prune table if needed // Grow/Shrink/Prune table if needed
rebuild_if_needed(); rebuild_if_needed();
// Create entry // Create and attach gc data
const ZNMethodTableEntry entry = create_entry(nm); attach_gc_data(nm);
log_register(nm, entry); log_register(nm);
// Insert new entry // Insert new entry
if (register_entry(_table, _size, entry)) { if (register_entry(_table, _size, nm)) {
// New entry registered. When register_entry() instead returns // New entry registered. When register_entry() instead returns
// false the nmethod was already in the table so we do not want // false the nmethod was already in the table so we do not want
// to increase number of registered entries in that case. // to increase number of registered entries in that case.
@ -465,6 +468,8 @@ void ZNMethodTable::unregister_nmethod(nmethod* nm) {
unregister_entry(_table, _size, nm); unregister_entry(_table, _size, nm);
_nunregistered++; _nunregistered++;
_nregistered--; _nregistered--;
detach_gc_data(nm);
} }
void ZNMethodTable::disarm_nmethod(nmethod* nm) { void ZNMethodTable::disarm_nmethod(nmethod* nm) {
@ -474,7 +479,7 @@ void ZNMethodTable::disarm_nmethod(nmethod* nm) {
} }
} }
void ZNMethodTable::nmethod_entries_do_begin() { void ZNMethodTable::nmethods_do_begin() {
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
// Prepare iteration // Prepare iteration
@ -484,7 +489,7 @@ void ZNMethodTable::nmethod_entries_do_begin() {
assert(_iter_deferred_deletes.is_empty(), "Should be emtpy"); assert(_iter_deferred_deletes.is_empty(), "Should be emtpy");
} }
void ZNMethodTable::nmethod_entries_do_end() { void ZNMethodTable::nmethods_do_end() {
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
// Finish iteration // Finish iteration
@ -506,58 +511,56 @@ void ZNMethodTable::nmethod_entries_do_end() {
CodeCache_lock->notify_all(); CodeCache_lock->notify_all();
} }
void ZNMethodTable::entry_oops_do(ZNMethodTableEntry entry, OopClosure* cl) { void ZNMethodTable::oops_do(nmethod* nm, OopClosure* cl) {
nmethod* const nm = entry.method();
// Process oops table // Process oops table
oop* const begin = nm->oops_begin(); {
oop* const end = nm->oops_end(); oop* const begin = nm->oops_begin();
for (oop* p = begin; p < end; p++) { oop* const end = nm->oops_end();
if (*p != Universe::non_oop_word()) { for (oop* p = begin; p < end; p++) {
cl->do_oop(p); if (*p != Universe::non_oop_word()) {
cl->do_oop(p);
}
} }
} }
ZNMethodDataOops* const oops = gc_data(nm)->oops();
// Process immediate oops // Process immediate oops
if (entry.immediate_oops()) { {
const ZNMethodDataImmediateOops* const nmi = gc_data(nm)->immediate_oops(); oop** const begin = oops->immediates_begin();
if (nmi != NULL) { oop** const end = oops->immediates_end();
oop** const begin = nmi->immediate_oops_begin(); for (oop** p = begin; p < end; p++) {
oop** const end = nmi->immediate_oops_end(); if (**p != Universe::non_oop_word()) {
for (oop** p = begin; p < end; p++) { cl->do_oop(*p);
if (**p != Universe::non_oop_word()) {
cl->do_oop(*p);
}
} }
} }
} }
// Process non-immediate oops // Process non-immediate oops
if (entry.non_immediate_oops()) { if (oops->has_non_immediates()) {
nmethod* const nm = entry.method();
nm->fix_oop_relocations(); nm->fix_oop_relocations();
} }
} }
class ZNMethodTableEntryToOopsDo : public ZNMethodTableEntryClosure { class ZNMethodToOopsDoClosure : public NMethodClosure {
private: private:
OopClosure* _cl; OopClosure* _cl;
public: public:
ZNMethodTableEntryToOopsDo(OopClosure* cl) : ZNMethodToOopsDoClosure(OopClosure* cl) :
_cl(cl) {} _cl(cl) {}
void do_nmethod_entry(ZNMethodTableEntry entry) { virtual void do_nmethod(nmethod* nm) {
ZNMethodTable::entry_oops_do(entry, _cl); ZNMethodTable::oops_do(nm, _cl);
} }
}; };
void ZNMethodTable::oops_do(OopClosure* cl) { void ZNMethodTable::oops_do(OopClosure* cl) {
ZNMethodTableEntryToOopsDo entry_cl(cl); ZNMethodToOopsDoClosure nm_cl(cl);
nmethod_entries_do(&entry_cl); nmethods_do(&nm_cl);
} }
void ZNMethodTable::nmethod_entries_do(ZNMethodTableEntryClosure* cl) { void ZNMethodTable::nmethods_do(NMethodClosure* cl) {
for (;;) { for (;;) {
// Claim table partition. Each partition is currently sized to span // Claim table partition. Each partition is currently sized to span
// two cache lines. This number is just a guess, but seems to work well. // two cache lines. This number is just a guess, but seems to work well.
@ -573,13 +576,13 @@ void ZNMethodTable::nmethod_entries_do(ZNMethodTableEntryClosure* cl) {
for (size_t i = partition_start; i < partition_end; i++) { for (size_t i = partition_start; i < partition_end; i++) {
const ZNMethodTableEntry entry = _iter_table[i]; const ZNMethodTableEntry entry = _iter_table[i];
if (entry.registered()) { if (entry.registered()) {
cl->do_nmethod_entry(entry); cl->do_nmethod(entry.method());
} }
} }
} }
} }
class ZNMethodTableUnlinkClosure : public ZNMethodTableEntryClosure { class ZNMethodTableUnlinkClosure : public NMethodClosure {
private: private:
bool _unloading_occurred; bool _unloading_occurred;
volatile bool _failed; volatile bool _failed;
@ -593,12 +596,11 @@ public:
_unloading_occurred(unloading_occurred), _unloading_occurred(unloading_occurred),
_failed(false) {} _failed(false) {}
virtual void do_nmethod_entry(ZNMethodTableEntry entry) { virtual void do_nmethod(nmethod* nm) {
if (failed()) { if (failed()) {
return; return;
} }
nmethod* const nm = entry.method();
if (!nm->is_alive()) { if (!nm->is_alive()) {
return; return;
} }
@ -619,7 +621,7 @@ public:
// Heal oops and disarm // Heal oops and disarm
ZNMethodOopClosure cl; ZNMethodOopClosure cl;
ZNMethodTable::entry_oops_do(entry, &cl); ZNMethodTable::oops_do(nm, &cl);
ZNMethodTable::disarm_nmethod(nm); ZNMethodTable::disarm_nmethod(nm);
// Clear compiled ICs and exception caches // Clear compiled ICs and exception caches
@ -643,16 +645,16 @@ public:
ZTask("ZNMethodTableUnlinkTask"), ZTask("ZNMethodTableUnlinkTask"),
_cl(unloading_occurred), _cl(unloading_occurred),
_verifier(verifier) { _verifier(verifier) {
ZNMethodTable::nmethod_entries_do_begin(); ZNMethodTable::nmethods_do_begin();
} }
~ZNMethodTableUnlinkTask() { ~ZNMethodTableUnlinkTask() {
ZNMethodTable::nmethod_entries_do_end(); ZNMethodTable::nmethods_do_end();
} }
virtual void work() { virtual void work() {
ICRefillVerifierMark mark(_verifier); ICRefillVerifierMark mark(_verifier);
ZNMethodTable::nmethod_entries_do(&_cl); ZNMethodTable::nmethods_do(&_cl);
} }
bool success() const { bool success() const {
@ -680,10 +682,9 @@ void ZNMethodTable::unlink(ZWorkers* workers, bool unloading_occurred) {
} }
} }
class ZNMethodTablePurgeClosure : public ZNMethodTableEntryClosure { class ZNMethodTablePurgeClosure : public NMethodClosure {
public: public:
virtual void do_nmethod_entry(ZNMethodTableEntry entry) { virtual void do_nmethod(nmethod* nm) {
nmethod* const nm = entry.method();
if (nm->is_alive() && nm->is_unloading()) { if (nm->is_alive() && nm->is_unloading()) {
nm->make_unloaded(); nm->make_unloaded();
} }
@ -698,15 +699,15 @@ public:
ZNMethodTablePurgeTask() : ZNMethodTablePurgeTask() :
ZTask("ZNMethodTablePurgeTask"), ZTask("ZNMethodTablePurgeTask"),
_cl() { _cl() {
ZNMethodTable::nmethod_entries_do_begin(); ZNMethodTable::nmethods_do_begin();
} }
~ZNMethodTablePurgeTask() { ~ZNMethodTablePurgeTask() {
ZNMethodTable::nmethod_entries_do_end(); ZNMethodTable::nmethods_do_end();
} }
virtual void work() { virtual void work() {
ZNMethodTable::nmethod_entries_do(&_cl); ZNMethodTable::nmethods_do(&_cl);
} }
}; };

View File

@ -30,13 +30,9 @@
#include "gc/z/zNMethodTableEntry.hpp" #include "gc/z/zNMethodTableEntry.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
class NMethodClosure;
class ZWorkers; class ZWorkers;
class ZNMethodTableEntryClosure {
public:
virtual void do_nmethod_entry(ZNMethodTableEntry entry) = 0;
};
class ZNMethodTable : public AllStatic { class ZNMethodTable : public AllStatic {
private: private:
static ZNMethodTableEntry* _table; static ZNMethodTableEntry* _table;
@ -48,20 +44,21 @@ private:
static size_t _nunregistered; static size_t _nunregistered;
static volatile size_t _claimed ATTRIBUTE_ALIGNED(ZCacheLineSize); static volatile size_t _claimed ATTRIBUTE_ALIGNED(ZCacheLineSize);
static ZNMethodTableEntry create_entry(nmethod* nm); static void attach_gc_data(nmethod* nm);
static void detach_gc_data(nmethod* nm);
static size_t first_index(const nmethod* nm, size_t size); static size_t first_index(const nmethod* nm, size_t size);
static size_t next_index(size_t prev_index, size_t size); static size_t next_index(size_t prev_index, size_t size);
static void wait_until_iteration_done(); static void wait_until_iteration_done();
static bool register_entry(ZNMethodTableEntry* table, size_t size, ZNMethodTableEntry entry); static bool register_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
static void unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm); static void unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
static void rebuild(size_t new_size); static void rebuild(size_t new_size);
static void rebuild_if_needed(); static void rebuild_if_needed();
static void log_register(const nmethod* nm, ZNMethodTableEntry entry); static void log_register(const nmethod* nm);
static void log_unregister(const nmethod* nm); static void log_unregister(const nmethod* nm);
public: public:
@ -78,11 +75,11 @@ public:
static void oops_do(OopClosure* cl); static void oops_do(OopClosure* cl);
static void entry_oops_do(ZNMethodTableEntry entry, OopClosure* cl); static void oops_do(nmethod* nm, OopClosure* cl);
static void nmethod_entries_do_begin(); static void nmethods_do_begin();
static void nmethod_entries_do_end(); static void nmethods_do_end();
static void nmethod_entries_do(ZNMethodTableEntryClosure* cl); static void nmethods_do(NMethodClosure* cl);
static void unlink(ZWorkers* workers, bool unloading_occurred); static void unlink(ZWorkers* workers, bool unloading_occurred);
static void purge(ZWorkers* workers); static void purge(ZWorkers* workers);

View File

@ -32,16 +32,16 @@
// -------------------------- // --------------------------
// //
// 6 // 6
// 3 3 2 1 0 // 3 2 1 0
// +--------------------------------------------------------------------+-+-+-+ // +---------------------------------------------------------------------+-+-+
// |11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111|1|1|1| // |11111111 11111111 11111111 11111111 11111111 11111111 11111111 111111|1|1|
// +--------------------------------------------------------------------+-+-+-+ // +---------------------------------------------------------------------+-+-+
// | | | | // | | |
// | 2-2 Non-immediate Oops Flag (1-bits) * | | // | | |
// | | | // | | |
// | 1-1 Immediate Oops/Unregistered Flag (1-bits) * | // | 1-1 Unregistered Flag (1-bits) * |
// | | // | |
// | 0-0 Registered Flag (1-bits) * // | 0-0 Registered Flag (1-bits) *
// | // |
// * 63-3 NMethod Address (61-bits) // * 63-3 NMethod Address (61-bits)
// //
@ -52,22 +52,20 @@ class ZNMethodTableEntry : public CHeapObj<mtGC> {
private: private:
typedef ZBitField<uint64_t, bool, 0, 1> field_registered; typedef ZBitField<uint64_t, bool, 0, 1> field_registered;
typedef ZBitField<uint64_t, bool, 1, 1> field_unregistered; typedef ZBitField<uint64_t, bool, 1, 1> field_unregistered;
typedef ZBitField<uint64_t, bool, 1, 1> field_immediate_oops; typedef ZBitField<uint64_t, nmethod*, 2, 62, 2> field_method;
typedef ZBitField<uint64_t, bool, 2, 1> field_non_immediate_oops;
typedef ZBitField<uint64_t, nmethod*, 3, 61, 3> field_method;
uint64_t _entry; uint64_t _entry;
public: public:
explicit ZNMethodTableEntry(bool unregistered = false) : explicit ZNMethodTableEntry(bool unregistered = false) :
_entry(field_unregistered::encode(unregistered) | _entry(field_registered::encode(false) |
field_registered::encode(false)) {} field_unregistered::encode(unregistered) |
field_method::encode(NULL)) {}
ZNMethodTableEntry(nmethod* method, bool non_immediate_oops, bool immediate_oops) : explicit ZNMethodTableEntry(nmethod* method) :
_entry(field_method::encode(method) | _entry(field_registered::encode(true) |
field_non_immediate_oops::encode(non_immediate_oops) | field_unregistered::encode(false) |
field_immediate_oops::encode(immediate_oops) | field_method::encode(method)) {}
field_registered::encode(true)) {}
bool registered() const { bool registered() const {
return field_registered::decode(_entry); return field_registered::decode(_entry);
@ -77,14 +75,6 @@ public:
return field_unregistered::decode(_entry); return field_unregistered::decode(_entry);
} }
bool immediate_oops() const {
return field_immediate_oops::decode(_entry);
}
bool non_immediate_oops() const {
return field_non_immediate_oops::decode(_entry);
}
nmethod* method() const { nmethod* method() const {
return field_method::decode(_entry); return field_method::decode(_entry);
} }

View File

@ -184,7 +184,7 @@ ZRootsIterator::ZRootsIterator() :
if (ClassUnloading) { if (ClassUnloading) {
nmethod::oops_do_marking_prologue(); nmethod::oops_do_marking_prologue();
} else { } else {
ZNMethodTable::nmethod_entries_do_begin(); ZNMethodTable::nmethods_do_begin();
} }
} }
@ -194,7 +194,7 @@ ZRootsIterator::~ZRootsIterator() {
if (ClassUnloading) { if (ClassUnloading) {
nmethod::oops_do_marking_epilogue(); nmethod::oops_do_marking_epilogue();
} else { } else {
ZNMethodTable::nmethod_entries_do_end(); ZNMethodTable::nmethods_do_end();
} }
JvmtiExport::gc_epilogue(); JvmtiExport::gc_epilogue();