< prev index next >

src/hotspot/share/code/codeBlob.cpp

Print this page
rev 54763 : 8213084: Rework and enhance Print[Opto]Assembly output
Reviewed-by:


 165   // Danger Will Robinson! This method allocates a big
 166   // chunk of memory, its your job to free it.
 167   if (p != NULL) {
 168     _oop_maps = ImmutableOopMapSet::build_from(p);
 169   } else {
 170     _oop_maps = NULL;
 171   }
 172 }
 173 
 174 
 175 void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {
 176   // Do not hold the CodeCache lock during name formatting.
 177   assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
 178 
 179   if (stub != NULL) {
 180     char stub_id[256];
 181     assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
 182     jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
 183     if (PrintStubCode) {
 184       ttyLocker ttyl;

 185       tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);
 186       Disassembler::decode(stub->code_begin(), stub->code_end());





 187       tty->cr();
 188     }
 189     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 190 
 191     if (JvmtiExport::should_post_dynamic_code_generated()) {
 192       const char* stub_name = name2;
 193       if (name2[0] == '\0')  stub_name = name1;
 194       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 195     }
 196   }
 197 
 198   // Track memory usage statistic after releasing CodeCache_lock
 199   MemoryService::track_code_cache_memory_usage();
 200 }
 201 
 202 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
 203   assert(_oop_maps != NULL, "nope");
 204   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 205 }
 206 


 245   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 246 
 247   BufferBlob* blob = NULL;
 248   unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
 249   assert(name != NULL, "must provide a name");
 250   {
 251     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 252     blob = new (size) BufferBlob(name, size, cb);
 253   }
 254   // Track memory usage statistic after releasing CodeCache_lock
 255   MemoryService::track_code_cache_memory_usage();
 256 
 257   return blob;
 258 }
 259 
 260 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
 261   return CodeCache::allocate(size, CodeBlobType::NonNMethod);
 262 }
 263 
 264 void BufferBlob::free(BufferBlob *blob) {

 265   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 266   blob->flush();
 267   {
 268     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 269     CodeCache::free((RuntimeBlob*)blob);
 270   }
 271   // Track memory usage statistic after releasing CodeCache_lock
 272   MemoryService::track_code_cache_memory_usage();
 273 }
 274 
 275 
 276 //----------------------------------------------------------------------------------------------------
 277 // Implementation of AdapterBlob
 278 
 279 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
 280   BufferBlob("I2C/C2I adapters", size, cb) {
 281   CodeCache::commit(this);
 282 }
 283 
 284 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {




 165   // Danger Will Robinson! This method allocates a big
 166   // chunk of memory, its your job to free it.
 167   if (p != NULL) {
 168     _oop_maps = ImmutableOopMapSet::build_from(p);
 169   } else {
 170     _oop_maps = NULL;
 171   }
 172 }
 173 
 174 
 175 void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) {
 176   // Do not hold the CodeCache lock during name formatting.
 177   assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub");
 178 
 179   if (stub != NULL) {
 180     char stub_id[256];
 181     assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
 182     jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
 183     if (PrintStubCode) {
 184       ttyLocker ttyl;
 185       tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 186       tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);
 187       Disassembler::decode(stub->code_begin(), stub->code_end(), tty);
 188       if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) {
 189         tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 190         stub->oop_maps()->print();
 191       }
 192       tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
 193       tty->cr();
 194     }
 195     Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
 196 
 197     if (JvmtiExport::should_post_dynamic_code_generated()) {
 198       const char* stub_name = name2;
 199       if (name2[0] == '\0')  stub_name = name1;
 200       JvmtiExport::post_dynamic_code_generated(stub_name, stub->code_begin(), stub->code_end());
 201     }
 202   }
 203 
 204   // Track memory usage statistic after releasing CodeCache_lock
 205   MemoryService::track_code_cache_memory_usage();
 206 }
 207 
 208 const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) {
 209   assert(_oop_maps != NULL, "nope");
 210   return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin());
 211 }
 212 


 251   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 252 
 253   BufferBlob* blob = NULL;
 254   unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
 255   assert(name != NULL, "must provide a name");
 256   {
 257     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 258     blob = new (size) BufferBlob(name, size, cb);
 259   }
 260   // Track memory usage statistic after releasing CodeCache_lock
 261   MemoryService::track_code_cache_memory_usage();
 262 
 263   return blob;
 264 }
 265 
 266 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
 267   return CodeCache::allocate(size, CodeBlobType::NonNMethod);
 268 }
 269 
 270 void BufferBlob::free(BufferBlob *blob) {
 271   assert(blob != NULL, "caller must check for NULL");
 272   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
 273   blob->flush();
 274   {
 275     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 276     CodeCache::free((RuntimeBlob*)blob);
 277   }
 278   // Track memory usage statistic after releasing CodeCache_lock
 279   MemoryService::track_code_cache_memory_usage();
 280 }
 281 
 282 
 283 //----------------------------------------------------------------------------------------------------
 284 // Implementation of AdapterBlob
 285 
 286 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
 287   BufferBlob("I2C/C2I adapters", size, cb) {
 288   CodeCache::commit(this);
 289 }
 290 
 291 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {


< prev index next >