src/hotspot/share/code/vtableStubs.cpp
changeset 52857 7e268f863ff0
parent 51627 d5ba88422499
child 52980 24525070d934
equal deleted inserted replaced
52856:5f3b9b633731 52857:7e268f863ff0
   122 
   122 
   123 
   123 
   124 void VtableStubs::initialize() {
   124 void VtableStubs::initialize() {
   125   VtableStub::_receiver_location = SharedRuntime::name_for_receiver();
   125   VtableStub::_receiver_location = SharedRuntime::name_for_receiver();
   126   {
   126   {
   127     MutexLocker ml(VtableStubs_lock);
   127     MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
   128     assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once");
   128     assert(_number_of_vtable_stubs == 0, "potential performance bug: VtableStubs initialized more than once");
   129     assert(is_power_of_2(N), "N must be a power of 2");
   129     assert(is_power_of_2(N), "N must be a power of 2");
   130     for (int i = 0; i < N; i++) {
   130     for (int i = 0; i < N; i++) {
   131       _table[i] = NULL;
   131       _table[i] = NULL;
   132     }
   132     }
   245   return (is_vtable_stub ? ~hash : hash)  & mask;
   245   return (is_vtable_stub ? ~hash : hash)  & mask;
   246 }
   246 }
   247 
   247 
   248 
   248 
   249 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
   249 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
   250   MutexLocker ml(VtableStubs_lock);
   250   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
   251   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
   251   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);
   252   VtableStub* s = _table[hash];
   252   VtableStub* s = _table[hash];
   253   while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
   253   while( s && !s->matches(is_vtable_stub, vtable_index)) s = s->next();
   254   return s;
   254   return s;
   255 }
   255 }
   256 
   256 
   257 
   257 
   258 void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
   258 void VtableStubs::enter(bool is_vtable_stub, int vtable_index, VtableStub* s) {
   259   MutexLocker ml(VtableStubs_lock);
   259   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
   260   assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
   260   assert(s->matches(is_vtable_stub, vtable_index), "bad vtable stub");
   261   unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
   261   unsigned int h = VtableStubs::hash(is_vtable_stub, vtable_index);
   262   // enter s at the beginning of the corresponding list
   262   // enter s at the beginning of the corresponding list
   263   s->set_next(_table[h]);
   263   s->set_next(_table[h]);
   264   _table[h] = s;
   264   _table[h] = s;
   265   _number_of_vtable_stubs++;
   265   _number_of_vtable_stubs++;
   266 }
   266 }
   267 
   267 
   268 VtableStub* VtableStubs::entry_point(address pc) {
   268 VtableStub* VtableStubs::entry_point(address pc) {
   269   MutexLocker ml(VtableStubs_lock);
   269   MutexLockerEx ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
   270   VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset());
   270   VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset());
   271   uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index());
   271   uint hash = VtableStubs::hash(stub->is_vtable_stub(), stub->index());
   272   VtableStub* s;
   272   VtableStub* s;
   273   for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {}
   273   for (s = _table[hash]; s != NULL && s != stub; s = s->next()) {}
   274   return (s == stub) ? s : NULL;
   274   return (s == stub) ? s : NULL;