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,
704
705 void SingletonBlob::print_on(outputStream* st) const {
706 ttyLocker ttyl;
707 RuntimeBlob::print_on(st);
708 st->print_cr("%s", name());
709 Disassembler::decode((RuntimeBlob*)this, st);
710 }
711
712 void SingletonBlob::print_value_on(outputStream* st) const {
713 st->print_cr("%s", name());
714 }
715
716 void DeoptimizationBlob::print_value_on(outputStream* st) const {
717 st->print_cr("Deoptimization (frame not available)");
718 }
719
720 // Implementation of OptimizedEntryBlob
721
722 OptimizedEntryBlob::OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,
723 jobject receiver, ByteSize frame_data_offset) :
724 BufferBlob(name, size, cb),
725 _exception_handler_offset(exception_handler_offset),
726 _receiver(receiver),
727 _frame_data_offset(frame_data_offset) {
728 CodeCache::commit(this);
729 }
730
731 OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb, intptr_t exception_handler_offset,
732 jobject receiver, ByteSize frame_data_offset) {
733 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
734
735 OptimizedEntryBlob* blob = nullptr;
736 unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));
737 {
738 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
739 blob = new (size) OptimizedEntryBlob(name, size, cb, exception_handler_offset, receiver, frame_data_offset);
740 }
741 // Track memory usage statistic after releasing CodeCache_lock
742 MemoryService::track_code_cache_memory_usage();
743
744 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,
733
734 void SingletonBlob::print_on(outputStream* st) const {
735 ttyLocker ttyl;
736 RuntimeBlob::print_on(st);
737 st->print_cr("%s", name());
738 Disassembler::decode((RuntimeBlob*)this, st);
739 }
740
741 void SingletonBlob::print_value_on(outputStream* st) const {
742 st->print_cr("%s", name());
743 }
744
745 void DeoptimizationBlob::print_value_on(outputStream* st) const {
746 st->print_cr("Deoptimization (frame not available)");
747 }
748
749 // Implementation of OptimizedEntryBlob
750
751 OptimizedEntryBlob::OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,
752 jobject receiver, ByteSize frame_data_offset) :
753 BufferBlob(name, sizeof(OptimizedEntryBlob), size, cb),
754 _exception_handler_offset(exception_handler_offset),
755 _receiver(receiver),
756 _frame_data_offset(frame_data_offset) {
757 CodeCache::commit(this);
758 }
759
760 OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb, intptr_t exception_handler_offset,
761 jobject receiver, ByteSize frame_data_offset) {
762 ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
763
764 OptimizedEntryBlob* blob = nullptr;
765 unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));
766 {
767 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
768 blob = new (size) OptimizedEntryBlob(name, size, cb, exception_handler_offset, receiver, frame_data_offset);
769 }
770 // Track memory usage statistic after releasing CodeCache_lock
771 MemoryService::track_code_cache_memory_usage();
772
773 return blob;
|