< prev index next >

src/share/vm/code/codeCache.cpp

Print this page
rev 13198 : Consolidated and devirtualize CodeHeap::contains and contains_blob

@@ -413,10 +413,20 @@
 
   // Register the CodeHeap
   MemoryService::add_code_heap_memory_pool(heap, name);
 }
 
+CodeHeap* CodeCache::get_code_heap(void* start) {
+  assert(start != NULL, "start is null");
+  FOR_ALL_HEAPS(heap) {
+    if ((*heap)->contains(start)) {
+      return *heap;
+    }
+  }
+  return NULL;
+}
+
 CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) {
   assert(cb != NULL, "CodeBlob is null");
   FOR_ALL_HEAPS(heap) {
     if ((*heap)->contains_blob(cb)) {
       return *heap;

@@ -600,16 +610,14 @@
 
 // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
 // what you are doing)
 CodeBlob* CodeCache::find_blob_unsafe(void* start) {
   // NMT can walk the stack before code cache is created
-  if (_heaps != NULL && !_heaps->is_empty()) {
-    FOR_ALL_HEAPS(heap) {
-      CodeBlob* result = (*heap)->find_blob_unsafe(start);
-      if (result != NULL) {
-        return result;
-      }
+  if (_heaps != NULL) {
+    CodeHeap* heap = get_code_heap(start);
+    if (heap != NULL) {
+      return heap->find_blob_unsafe(start);
     }
   }
   return NULL;
 }
 
< prev index next >