< prev index next >
src/hotspot/share/code/vtableStubs.cpp
address VtableStub::_chunk_end = NULL;
VMReg VtableStub::_receiver_location = VMRegImpl::Bad();
void* VtableStub::operator new(size_t size, int code_size) throw() {
+ assert_lock_strong(VtableStubs_lock);
assert(size == sizeof(VtableStub), "mismatched size");
// compute real VtableStub size (rounded to nearest word)
const int real_size = align_up(code_size + (int)sizeof(VtableStub), wordSize);
// malloc them in chunks to minimize header overhead
const int chunk_factor = 32;
***************
address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
assert(vtable_index >= 0, "must be positive");
! VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
! if (s == NULL) {
! if (is_vtable_stub) {
! s = create_vtable_stub(vtable_index);
! } else {
! s = create_itable_stub(vtable_index);
! }
!
! // Creation of vtable or itable can fail if there is not enough free space in the code cache.
if (s == NULL) {
! return NULL;
! }
! enter(is_vtable_stub, vtable_index, s);
! if (PrintAdapterHandlers) {
! tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
! is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
! Disassembler::decode(s->code_begin(), s->code_end());
! }
! // Notify JVMTI about this stub. The event will be recorded by the enclosing
! // JvmtiDynamicCodeEventCollector and posted when this thread has released
! // all locks.
! if (JvmtiExport::should_post_dynamic_code_generated()) {
! JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
! s->code_begin(), s->code_end());
}
}
return s->entry_point();
}
address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
assert(vtable_index >= 0, "must be positive");
! VtableStub* s;
! {
! MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
! s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
if (s == NULL) {
! if (is_vtable_stub) {
! s = create_vtable_stub(vtable_index);
! } else {
! s = create_itable_stub(vtable_index);
! }
!
! // Creation of vtable or itable can fail if there is not enough free space in the code cache.
! if (s == NULL) {
! return NULL;
! }
! enter(is_vtable_stub, vtable_index, s);
! if (PrintAdapterHandlers) {
! tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
! is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
! Disassembler::decode(s->code_begin(), s->code_end());
! }
! // Notify JVMTI about this stub. The event will be recorded by the enclosing
! // JvmtiDynamicCodeEventCollector and posted when this thread has released
! // all locks.
! if (JvmtiExport::should_post_dynamic_code_generated()) {
! JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
! s->code_begin(), s->code_end());
! }
}
}
return s->entry_point();
}
***************
return (is_vtable_stub ? ~hash : hash) & mask;
}
VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
! MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
VtableStub* s = _table[hash];
while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
return s;
}
void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
! MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
// enter s at the beginning of the corresponding list
s->set_next(_table[h]);
_table[h] = s;
return (is_vtable_stub ? ~hash : hash) & mask;
}
VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
! assert_lock_strong(VtableStubs_lock);
unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
VtableStub* s = _table[hash];
while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
return s;
}
void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
! assert_lock_strong(VtableStubs_lock);
assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
// enter s at the beginning of the corresponding list
s->set_next(_table[h]);
_table[h] = s;
< prev index next >