mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8215206: VtableStubs::find_stub is not appropriately protected by VtableStubs_lock
Reviewed-by: thartmann, pliden
This commit is contained in:
parent
31fbc28af5
commit
b7bd4bccbf
1 changed files with 30 additions and 25 deletions
|
@ -51,6 +51,7 @@ VMReg VtableStub::_receiver_location = VMRegImpl::Bad();
|
||||||
|
|
||||||
|
|
||||||
void* VtableStub::operator new(size_t size, int code_size) throw() {
|
void* VtableStub::operator new(size_t size, int code_size) throw() {
|
||||||
|
assert_lock_strong(VtableStubs_lock);
|
||||||
assert(size == sizeof(VtableStub), "mismatched size");
|
assert(size == sizeof(VtableStub), "mismatched size");
|
||||||
// compute real VtableStub size (rounded to nearest word)
|
// compute real VtableStub size (rounded to nearest word)
|
||||||
const int real_size = align_up(code_size + (int)sizeof(VtableStub), wordSize);
|
const int real_size = align_up(code_size + (int)sizeof(VtableStub), wordSize);
|
||||||
|
@ -208,31 +209,35 @@ void VtableStubs::bookkeeping(MacroAssembler* masm, outputStream* out, VtableStu
|
||||||
address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
|
address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
|
||||||
assert(vtable_index >= 0, "must be positive");
|
assert(vtable_index >= 0, "must be positive");
|
||||||
|
|
||||||
VtableStub* s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
|
VtableStub* s;
|
||||||
if (s == NULL) {
|
{
|
||||||
if (is_vtable_stub) {
|
MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
|
||||||
s = create_vtable_stub(vtable_index);
|
s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
|
||||||
} 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) {
|
if (s == NULL) {
|
||||||
return NULL;
|
if (is_vtable_stub) {
|
||||||
}
|
s = create_vtable_stub(vtable_index);
|
||||||
|
} else {
|
||||||
|
s = create_itable_stub(vtable_index);
|
||||||
|
}
|
||||||
|
|
||||||
enter(is_vtable_stub, vtable_index, s);
|
// Creation of vtable or itable can fail if there is not enough free space in the code cache.
|
||||||
if (PrintAdapterHandlers) {
|
if (s == NULL) {
|
||||||
tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
|
return NULL;
|
||||||
is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
|
}
|
||||||
Disassembler::decode(s->code_begin(), s->code_end());
|
|
||||||
}
|
enter(is_vtable_stub, vtable_index, s);
|
||||||
// Notify JVMTI about this stub. The event will be recorded by the enclosing
|
if (PrintAdapterHandlers) {
|
||||||
// JvmtiDynamicCodeEventCollector and posted when this thread has released
|
tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
|
||||||
// all locks.
|
is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
|
||||||
if (JvmtiExport::should_post_dynamic_code_generated()) {
|
Disassembler::decode(s->code_begin(), s->code_end());
|
||||||
JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
|
}
|
||||||
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 s->entry_point();
|
||||||
|
@ -247,7 +252,7 @@ inline uint VtableStubs::hash(bool is_vtable_stub, int vtable_index){
|
||||||
|
|
||||||
|
|
||||||
VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
|
VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
|
||||||
MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
|
assert_lock_strong(VtableStubs_lock);
|
||||||
unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
|
unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
|
||||||
VtableStub* s = _table[hash];
|
VtableStub* s = _table[hash];
|
||||||
while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
|
while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
|
||||||
|
@ -256,7 +261,7 @@ VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
|
||||||
|
|
||||||
|
|
||||||
void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
|
void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
|
||||||
MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
|
assert_lock_strong(VtableStubs_lock);
|
||||||
assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
|
assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
|
||||||
unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
|
unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
|
||||||
// enter s at the beginning of the corresponding list
|
// enter s at the beginning of the corresponding list
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue