530
531 void CodeCache::commit(CodeBlob* cb) {
532 // this is called by nmethod::nmethod, which must already own CodeCache_lock
533 assert_locked_or_safepoint(CodeCache_lock);
534 CodeHeap* heap = get_code_heap(cb);
535 if (cb->is_nmethod()) {
536 heap->set_nmethod_count(heap->nmethod_count() + 1);
537 if (((nmethod *)cb)->has_dependencies()) {
538 _number_of_nmethods_with_dependencies++;
539 }
540 }
541 if (cb->is_adapter_blob()) {
542 heap->set_adapter_count(heap->adapter_count() + 1);
543 }
544
545 // flush the hardware I-cache
546 ICache::invalidate_range(cb->content_begin(), cb->content_size());
547 }
548
549 bool CodeCache::contains(void *p) {
550 // It should be ok to call contains without holding a lock
551 FOR_ALL_HEAPS(heap) {
552 if ((*heap)->contains(p)) {
553 return true;
554 }
555 }
556 return false;
557 }
558
559 // This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not
560 // looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain
561 // valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled.
562 CodeBlob* CodeCache::find_blob(void* start) {
563 CodeBlob* result = find_blob_unsafe(start);
564 // We could potentially look up non_entrant methods
565 guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || is_error_reported(), "unsafe access to zombie method");
566 return result;
567 }
568
569 // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
570 // what you are doing)
|
530
531 void CodeCache::commit(CodeBlob* cb) {
532 // this is called by nmethod::nmethod, which must already own CodeCache_lock
533 assert_locked_or_safepoint(CodeCache_lock);
534 CodeHeap* heap = get_code_heap(cb);
535 if (cb->is_nmethod()) {
536 heap->set_nmethod_count(heap->nmethod_count() + 1);
537 if (((nmethod *)cb)->has_dependencies()) {
538 _number_of_nmethods_with_dependencies++;
539 }
540 }
541 if (cb->is_adapter_blob()) {
542 heap->set_adapter_count(heap->adapter_count() + 1);
543 }
544
545 // flush the hardware I-cache
546 ICache::invalidate_range(cb->content_begin(), cb->content_size());
547 }
548
549 bool CodeCache::contains(void *p) {
550 // S390 uses contains() in current_frame(), which is used before
551 // code cache initialization if NativeMemoryTracking=detail is set.
552 if (_heaps == NULL) return false;
553 // It should be ok to call contains without holding a lock.
554 FOR_ALL_HEAPS(heap) {
555 if ((*heap)->contains(p)) {
556 return true;
557 }
558 }
559 return false;
560 }
561
562 // This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not
563 // looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain
564 // valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled.
565 CodeBlob* CodeCache::find_blob(void* start) {
566 CodeBlob* result = find_blob_unsafe(start);
567 // We could potentially look up non_entrant methods
568 guarantee(result == NULL || !result->is_zombie() || result->is_locked_by_vm() || is_error_reported(), "unsafe access to zombie method");
569 return result;
570 }
571
572 // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
573 // what you are doing)
|