< prev index next >

src/hotspot/share/code/codeBlob.cpp

Print this page

232 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
233   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
234 
235   BufferBlob* blob = NULL;
236   unsigned int size = sizeof(BufferBlob);
237   // align the size to CodeEntryAlignment
238   size = CodeBlob::align_code_offset(size);
239   size += align_up(buffer_size, oopSize);
240   assert(name != NULL, "must provide a name");
241   {
242     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
243     blob = new (size) BufferBlob(name, size);
244   }
245   // Track memory usage statistic after releasing CodeCache_lock
246   MemoryService::track_code_cache_memory_usage();
247 
248   return blob;
249 }
250 
251 
252 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb)
253   : RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL)
254 {}
255 
256 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
257   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
258 
259   BufferBlob* blob = NULL;
260   unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
261   assert(name != NULL, "must provide a name");
262   {
263     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
264     blob = new (size) BufferBlob(name, size, cb);
265   }
266   // Track memory usage statistic after releasing CodeCache_lock
267   MemoryService::track_code_cache_memory_usage();
268 
269   return blob;
270 }
271 
272 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
273   return CodeCache::allocate(size, CodeBlobType::NonNMethod);
274 }
275 
276 void BufferBlob::free(BufferBlob *blob) {
277   assert(blob != NULL, "caller must check for NULL");
278   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
279   blob->flush();
280   {
281     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
282     CodeCache::free((RuntimeBlob*)blob);
283   }
284   // Track memory usage statistic after releasing CodeCache_lock
285   MemoryService::track_code_cache_memory_usage();
286 }
287 




288 
289 //----------------------------------------------------------------------------------------------------
290 // Implementation of AdapterBlob
291 
292 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb) :
293   BufferBlob("I2C/C2I adapters", size, cb) {
294   CodeCache::commit(this);
295 }
296 
297 AdapterBlob* AdapterBlob::create(CodeBuffer* cb) {
298   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
299 
300   AdapterBlob* blob = NULL;
301   unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));
302   {
303     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
304     blob = new (size) AdapterBlob(size, cb);
305   }
306   // Track memory usage statistic after releasing CodeCache_lock
307   MemoryService::track_code_cache_memory_usage();
308 
309   return blob;
310 }
311 
312 void* VtableBlob::operator new(size_t s, unsigned size) throw() {
313   // Handling of allocation failure stops compilation and prints a bunch of
314   // stuff, which requires unlocking the CodeCache_lock, so that the Compile_lock
315   // can be locked, and then re-locking the CodeCache_lock. That is not safe in
316   // this context as we hold the CompiledICLocker. So we just don't handle code
317   // cache exhaustion here; we leave that for a later allocation that does not
318   // hold the CompiledICLocker.
319   return CodeCache::allocate(size, CodeBlobType::NonNMethod, false /* handle_alloc_failure */);
320 }
321 
322 VtableBlob::VtableBlob(const char* name, int size) :
323   BufferBlob(name, size) {
324 }

362   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
363 
364   MethodHandlesAdapterBlob* blob = NULL;
365   unsigned int size = sizeof(MethodHandlesAdapterBlob);
366   // align the size to CodeEntryAlignment
367   size = CodeBlob::align_code_offset(size);
368   size += align_up(buffer_size, oopSize);
369   {
370     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
371     blob = new (size) MethodHandlesAdapterBlob(size);
372     if (blob == NULL) {
373       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");
374     }
375   }
376   // Track memory usage statistic after releasing CodeCache_lock
377   MemoryService::track_code_cache_memory_usage();
378 
379   return blob;
380 }
381 

























382 //----------------------------------------------------------------------------------------------------
383 // Implementation of RuntimeStub
384 
385 RuntimeStub::RuntimeStub(
386   const char* name,
387   CodeBuffer* cb,
388   int         size,
389   int         frame_complete,
390   int         frame_size,
391   OopMapSet*  oop_maps,
392   bool        caller_must_gc_arguments
393 )
394 : RuntimeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
395 {
396 }
397 
398 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
399                                            CodeBuffer* cb,
400                                            int frame_complete,
401                                            int frame_size,

699 
700 void SingletonBlob::print_on(outputStream* st) const {
701   ttyLocker ttyl;
702   RuntimeBlob::print_on(st);
703   st->print_cr("%s", name());
704   Disassembler::decode((RuntimeBlob*)this, st);
705 }
706 
707 void SingletonBlob::print_value_on(outputStream* st) const {
708   st->print_cr("%s", name());
709 }
710 
711 void DeoptimizationBlob::print_value_on(outputStream* st) const {
712   st->print_cr("Deoptimization (frame not available)");
713 }
714 
715 // Implementation of OptimizedEntryBlob
716 
717 OptimizedEntryBlob::OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,
718                                        jobject receiver, ByteSize frame_data_offset) :
719   BufferBlob(name, size, cb),
720   _exception_handler_offset(exception_handler_offset),
721   _receiver(receiver),
722   _frame_data_offset(frame_data_offset) {
723   CodeCache::commit(this);
724 }
725 
726 OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb, intptr_t exception_handler_offset,
727                                                jobject receiver, ByteSize frame_data_offset) {
728   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
729 
730   OptimizedEntryBlob* blob = nullptr;
731   unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));
732   {
733     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
734     blob = new (size) OptimizedEntryBlob(name, size, cb, exception_handler_offset, receiver, frame_data_offset);
735   }
736   // Track memory usage statistic after releasing CodeCache_lock
737   MemoryService::track_code_cache_memory_usage();
738 
739   return blob;

232 BufferBlob* BufferBlob::create(const char* name, int buffer_size) {
233   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
234 
235   BufferBlob* blob = NULL;
236   unsigned int size = sizeof(BufferBlob);
237   // align the size to CodeEntryAlignment
238   size = CodeBlob::align_code_offset(size);
239   size += align_up(buffer_size, oopSize);
240   assert(name != NULL, "must provide a name");
241   {
242     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
243     blob = new (size) BufferBlob(name, size);
244   }
245   // Track memory usage statistic after releasing CodeCache_lock
246   MemoryService::track_code_cache_memory_usage();
247 
248   return blob;
249 }
250 
251 
252 BufferBlob::BufferBlob(const char* name, int header_size, int size, CodeBuffer* cb)
253   : RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, 0, NULL)
254 {}
255 
256 BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) {
257   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
258 
259   BufferBlob* blob = NULL;
260   unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob));
261   assert(name != NULL, "must provide a name");
262   {
263     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
264     blob = new (size) BufferBlob(name, sizeof(BufferBlob), size, cb);
265   }
266   // Track memory usage statistic after releasing CodeCache_lock
267   MemoryService::track_code_cache_memory_usage();
268 
269   return blob;
270 }
271 
272 void* BufferBlob::operator new(size_t s, unsigned size) throw() {
273   return CodeCache::allocate(size, CodeBlobType::NonNMethod);
274 }
275 
276 void BufferBlob::free(BufferBlob *blob) {
277   assert(blob != NULL, "caller must check for NULL");
278   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
279   blob->flush();
280   {
281     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
282     CodeCache::free((RuntimeBlob*)blob);
283   }
284   // Track memory usage statistic after releasing CodeCache_lock
285   MemoryService::track_code_cache_memory_usage();
286 }
287 
288 BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments)
289   : RuntimeBlob(name, cb, sizeof(BufferBlob), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
290 {}
291 
292 
293 //----------------------------------------------------------------------------------------------------
294 // Implementation of AdapterBlob
295 
296 AdapterBlob::AdapterBlob(int size, CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) :
297   BufferBlob("I2C/C2I adapters", size, cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) {
298   CodeCache::commit(this);
299 }
300 
301 AdapterBlob* AdapterBlob::create(CodeBuffer* cb, int frame_complete, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) {
302   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
303 
304   AdapterBlob* blob = NULL;
305   unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob));
306   {
307     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
308     blob = new (size) AdapterBlob(size, cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments);
309   }
310   // Track memory usage statistic after releasing CodeCache_lock
311   MemoryService::track_code_cache_memory_usage();
312 
313   return blob;
314 }
315 
316 void* VtableBlob::operator new(size_t s, unsigned size) throw() {
317   // Handling of allocation failure stops compilation and prints a bunch of
318   // stuff, which requires unlocking the CodeCache_lock, so that the Compile_lock
319   // can be locked, and then re-locking the CodeCache_lock. That is not safe in
320   // this context as we hold the CompiledICLocker. So we just don't handle code
321   // cache exhaustion here; we leave that for a later allocation that does not
322   // hold the CompiledICLocker.
323   return CodeCache::allocate(size, CodeBlobType::NonNMethod, false /* handle_alloc_failure */);
324 }
325 
326 VtableBlob::VtableBlob(const char* name, int size) :
327   BufferBlob(name, size) {
328 }

366   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
367 
368   MethodHandlesAdapterBlob* blob = NULL;
369   unsigned int size = sizeof(MethodHandlesAdapterBlob);
370   // align the size to CodeEntryAlignment
371   size = CodeBlob::align_code_offset(size);
372   size += align_up(buffer_size, oopSize);
373   {
374     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
375     blob = new (size) MethodHandlesAdapterBlob(size);
376     if (blob == NULL) {
377       vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "CodeCache: no room for method handle adapter blob");
378     }
379   }
380   // Track memory usage statistic after releasing CodeCache_lock
381   MemoryService::track_code_cache_memory_usage();
382 
383   return blob;
384 }
385 
386 //----------------------------------------------------------------------------------------------------
387 // Implementation of BufferedInlineTypeBlob
388 BufferedInlineTypeBlob::BufferedInlineTypeBlob(int size, CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off) :
389   BufferBlob("buffered inline type", sizeof(BufferedInlineTypeBlob), size, cb),
390   _pack_fields_off(pack_fields_off),
391   _pack_fields_jobject_off(pack_fields_jobject_off),
392   _unpack_fields_off(unpack_fields_off) {
393   CodeCache::commit(this);
394 }
395 
396 BufferedInlineTypeBlob* BufferedInlineTypeBlob::create(CodeBuffer* cb, int pack_fields_off, int pack_fields_jobject_off, int unpack_fields_off) {
397   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
398 
399   BufferedInlineTypeBlob* blob = NULL;
400   unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferedInlineTypeBlob));
401   {
402     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
403     blob = new (size) BufferedInlineTypeBlob(size, cb, pack_fields_off, pack_fields_jobject_off, unpack_fields_off);
404   }
405   // Track memory usage statistic after releasing CodeCache_lock
406   MemoryService::track_code_cache_memory_usage();
407 
408   return blob;
409 }
410 
411 //----------------------------------------------------------------------------------------------------
412 // Implementation of RuntimeStub
413 
414 RuntimeStub::RuntimeStub(
415   const char* name,
416   CodeBuffer* cb,
417   int         size,
418   int         frame_complete,
419   int         frame_size,
420   OopMapSet*  oop_maps,
421   bool        caller_must_gc_arguments
422 )
423 : RuntimeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments)
424 {
425 }
426 
427 RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name,
428                                            CodeBuffer* cb,
429                                            int frame_complete,
430                                            int frame_size,

728 
729 void SingletonBlob::print_on(outputStream* st) const {
730   ttyLocker ttyl;
731   RuntimeBlob::print_on(st);
732   st->print_cr("%s", name());
733   Disassembler::decode((RuntimeBlob*)this, st);
734 }
735 
736 void SingletonBlob::print_value_on(outputStream* st) const {
737   st->print_cr("%s", name());
738 }
739 
740 void DeoptimizationBlob::print_value_on(outputStream* st) const {
741   st->print_cr("Deoptimization (frame not available)");
742 }
743 
744 // Implementation of OptimizedEntryBlob
745 
746 OptimizedEntryBlob::OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,
747                                        jobject receiver, ByteSize frame_data_offset) :
748   BufferBlob(name, sizeof(OptimizedEntryBlob), size, cb),
749   _exception_handler_offset(exception_handler_offset),
750   _receiver(receiver),
751   _frame_data_offset(frame_data_offset) {
752   CodeCache::commit(this);
753 }
754 
755 OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb, intptr_t exception_handler_offset,
756                                                jobject receiver, ByteSize frame_data_offset) {
757   ThreadInVMfromUnknown __tiv;  // get to VM state in case we block on CodeCache_lock
758 
759   OptimizedEntryBlob* blob = nullptr;
760   unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));
761   {
762     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
763     blob = new (size) OptimizedEntryBlob(name, size, cb, exception_handler_offset, receiver, frame_data_offset);
764   }
765   // Track memory usage statistic after releasing CodeCache_lock
766   MemoryService::track_code_cache_memory_usage();
767 
768   return blob;
< prev index next >