552 void CodeCache::free(CodeBlob* cb) {
553 assert_locked_or_safepoint(CodeCache_lock);
554 CodeHeap* heap = get_code_heap(cb);
555 print_trace("free", cb);
556 if (cb->is_nmethod()) {
557 heap->set_nmethod_count(heap->nmethod_count() - 1);
558 if (((nmethod *)cb)->has_dependencies()) {
559 _number_of_nmethods_with_dependencies--;
560 }
561 }
562 if (cb->is_adapter_blob()) {
563 heap->set_adapter_count(heap->adapter_count() - 1);
564 }
565
566 // Get heap for given CodeBlob and deallocate
567 get_code_heap(cb)->deallocate(cb);
568
569 assert(heap->blob_count() >= 0, "sanity check");
570 }
571
572 void CodeCache::commit(CodeBlob* cb) {
573 // this is called by nmethod::nmethod, which must already own CodeCache_lock
574 assert_locked_or_safepoint(CodeCache_lock);
575 CodeHeap* heap = get_code_heap(cb);
576 if (cb->is_nmethod()) {
577 heap->set_nmethod_count(heap->nmethod_count() + 1);
578 if (((nmethod *)cb)->has_dependencies()) {
579 _number_of_nmethods_with_dependencies++;
580 }
581 }
582 if (cb->is_adapter_blob()) {
583 heap->set_adapter_count(heap->adapter_count() + 1);
584 }
585
586 // flush the hardware I-cache
587 ICache::invalidate_range(cb->content_begin(), cb->content_size());
588 }
589
590 bool CodeCache::contains(void *p) {
591 // S390 uses contains() in current_frame(), which is used before
|
552 void CodeCache::free(CodeBlob* cb) {
553 assert_locked_or_safepoint(CodeCache_lock);
554 CodeHeap* heap = get_code_heap(cb);
555 print_trace("free", cb);
556 if (cb->is_nmethod()) {
557 heap->set_nmethod_count(heap->nmethod_count() - 1);
558 if (((nmethod *)cb)->has_dependencies()) {
559 _number_of_nmethods_with_dependencies--;
560 }
561 }
562 if (cb->is_adapter_blob()) {
563 heap->set_adapter_count(heap->adapter_count() - 1);
564 }
565
566 // Get heap for given CodeBlob and deallocate
567 get_code_heap(cb)->deallocate(cb);
568
569 assert(heap->blob_count() >= 0, "sanity check");
570 }
571
572 void CodeCache::free_unused_tail(CodeBlob* cb, size_t used) {
573 assert_locked_or_safepoint(CodeCache_lock);
574 guarantee(cb->is_buffer_blob() && strncmp("Interpreter", cb->name(), 11) == 0, "Only possible for interpreter!");
575 print_trace("free_unused_tail", cb);
576
577 // We also have to account for the extra space (i.e. header) used by the CodeBlob
578 // which provides the memory (see BufferBlob::create() in codeBlob.cpp).
579 used += CodeBlob::align_code_offset(cb->header_size());
580
581 // Get heap for given CodeBlob and deallocate its unused tail
582 get_code_heap(cb)->deallocate_tail(cb, used);
583 // Adjust the sizes of the CodeBlob
584 cb->adjust_size(used);
585 }
586
587 void CodeCache::commit(CodeBlob* cb) {
588 // this is called by nmethod::nmethod, which must already own CodeCache_lock
589 assert_locked_or_safepoint(CodeCache_lock);
590 CodeHeap* heap = get_code_heap(cb);
591 if (cb->is_nmethod()) {
592 heap->set_nmethod_count(heap->nmethod_count() + 1);
593 if (((nmethod *)cb)->has_dependencies()) {
594 _number_of_nmethods_with_dependencies++;
595 }
596 }
597 if (cb->is_adapter_blob()) {
598 heap->set_adapter_count(heap->adapter_count() + 1);
599 }
600
601 // flush the hardware I-cache
602 ICache::invalidate_range(cb->content_begin(), cb->content_size());
603 }
604
605 bool CodeCache::contains(void *p) {
606 // S390 uses contains() in current_frame(), which is used before
|