< prev index next >

src/hotspot/share/code/vtableStubs.cpp

Print this page




 196                                          (int)(masm->pc() - s->code_begin()),
 197                                          (int)(masm->pc() - s->code_end()));
 198   assert((masm->pc() + index_dependent_slop) <= s->code_end(), "%s #%d: spare space for 32-bit offset: required = %d, available = %d",
 199                                          name, index, index_dependent_slop,
 200                                          (int)(s->code_end() - masm->pc()));
 201 
 202   // After the first vtable/itable stub is generated, we have a much
 203   // better estimate for the stub size. Remember/update this
 204   // estimate after some sanity checks.
 205   check_and_set_size_limit(is_vtable_stub, masm->offset(), slop_bytes);
 206   s->set_exception_points(npe_addr, ame_addr);
 207 }
 208 
 209 
 210 address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
 211   assert(vtable_index >= 0, "must be positive");
 212 
 213   VtableStub* s;
 214   {
 215     MutexLocker ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
 216     s = lookup(is_vtable_stub, vtable_index);
 217     if (s == NULL) {
 218       if (is_vtable_stub) {
 219         s = create_vtable_stub(vtable_index);
 220       } else {
 221         s = create_itable_stub(vtable_index);
 222       }
 223 
 224       // Creation of vtable or itable can fail if there is not enough free space in the code cache.
 225       if (s == NULL) {
 226         return NULL;
 227       }
 228 
 229       enter(is_vtable_stub, vtable_index, s);
 230       if (PrintAdapterHandlers) {
 231         tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
 232                       is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
 233         Disassembler::decode(s->code_begin(), s->code_end());
 234       }
 235       // Notify JVMTI about this stub. The event will be recorded by the enclosing
 236       // JvmtiDynamicCodeEventCollector and posted when this thread has released
 237       // all locks. Only post this event if a new state is not required. Creating a new state would
 238       // cause a safepoint and the caller of this code has a NoSafepointVerifier.
 239       if (JvmtiExport::should_post_dynamic_code_generated()) {
 240         JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
 241                                                                      s->code_begin(), s->code_end());
 242       }
 243     }
 244   }
 245   return s->entry_point();
 246 }
 247 
 248 
 249 inline uint VtableStubs::hash(bool is_vtable_stub, int vtable_index){
 250   // Assumption: receiver_location < 4 in most cases.
 251   int hash = ((vtable_index << 2) ^ VtableStub::receiver_location()->value()) + vtable_index;
 252   return (is_vtable_stub ? ~hash : hash)  & mask;
 253 }
 254 
 255 
 256 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
 257   assert_lock_strong(VtableStubs_lock);
 258   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);




 196                                          (int)(masm->pc() - s->code_begin()),
 197                                          (int)(masm->pc() - s->code_end()));
 198   assert((masm->pc() + index_dependent_slop) <= s->code_end(), "%s #%d: spare space for 32-bit offset: required = %d, available = %d",
 199                                          name, index, index_dependent_slop,
 200                                          (int)(s->code_end() - masm->pc()));
 201 
 202   // After the first vtable/itable stub is generated, we have a much
 203   // better estimate for the stub size. Remember/update this
 204   // estimate after some sanity checks.
 205   check_and_set_size_limit(is_vtable_stub, masm->offset(), slop_bytes);
 206   s->set_exception_points(npe_addr, ame_addr);
 207 }
 208 
 209 
 210 address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) {
 211   assert(vtable_index >= 0, "must be positive");
 212 
 213   VtableStub* s;
 214   {
 215     MutexLocker ml(VtableStubs_lock, Mutex::_no_safepoint_check_flag);
 216     s = ShareVtableStubs ? lookup(is_vtable_stub, vtable_index) : NULL;
 217     if (s == NULL) {
 218       if (is_vtable_stub) {
 219         s = create_vtable_stub(vtable_index);
 220       } else {
 221         s = create_itable_stub(vtable_index);
 222       }
 223 
 224       // Creation of vtable or itable can fail if there is not enough free space in the code cache.
 225       if (s == NULL) {
 226         return NULL;
 227       }
 228 
 229       enter(is_vtable_stub, vtable_index, s);
 230       if (PrintAdapterHandlers) {
 231         tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT,
 232                       is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()));
 233         Disassembler::decode(s->code_begin(), s->code_end());
 234       }
 235       // Notify JVMTI about this stub. The event will be recorded by the enclosing
 236       // JvmtiDynamicCodeEventCollector and posted when this thread has released
 237       // all locks.

 238       if (JvmtiExport::should_post_dynamic_code_generated()) {
 239         JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub",
 240                                                                      s->code_begin(), s->code_end());
 241       }
 242     }
 243   }
 244   return s->entry_point();
 245 }
 246 
 247 
 248 inline uint VtableStubs::hash(bool is_vtable_stub, int vtable_index){
 249   // Assumption: receiver_location < 4 in most cases.
 250   int hash = ((vtable_index << 2) ^ VtableStub::receiver_location()->value()) + vtable_index;
 251   return (is_vtable_stub ? ~hash : hash)  & mask;
 252 }
 253 
 254 
 255 VtableStub* VtableStubs::lookup(bool is_vtable_stub, int vtable_index) {
 256   assert_lock_strong(VtableStubs_lock);
 257   unsigned hash = VtableStubs::hash(is_vtable_stub, vtable_index);


< prev index next >