hotspot/src/share/vm/code/codeCache.hpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)codeCache.hpp        1.68 07/09/01 18:01:02 JVM"
   3 #endif
   4 /*
   5  * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  57 
  58   // Allocation/administration
  59   static CodeBlob* allocate(int size);              // allocates a new CodeBlob
  60   static void commit(CodeBlob* cb);                 // called when the allocated CodeBlob has been filled
  61   static int alignment_unit();                      // guaranteed alignment of all CodeBlobs
  62   static int alignment_offset();                    // guaranteed offset of first CodeBlob byte within alignment unit (i.e., allocation header)
  63   static void free(CodeBlob* cb);                   // frees a CodeBlob
  64   static void flush();                              // flushes all CodeBlobs
  65   static bool contains(void *p);                    // returns whether p is included  
  66   static void blobs_do(void f(CodeBlob* cb));       // iterates over all CodeBlobs 
  67   static void nmethods_do(void f(nmethod* nm));     // iterates over all nmethods 
  68 
  69   // Lookup
  70   static CodeBlob* find_blob(void* start);
  71   static nmethod*  find_nmethod(void* start);
  72 
  73   // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
  74   // what you are doing)
  75   static CodeBlob* find_blob_unsafe(void* start) {
  76     CodeBlob* result = (CodeBlob*)_heap->find_start(start); 
  77     assert(result == NULL || result->blob_contains((address)start), "found wrong CodeBlob");      















  78     return result;   
  79   } 
  80 
  81   // Iteration
  82   static CodeBlob* first();
  83   static CodeBlob* next (CodeBlob* cb);  
  84   static CodeBlob* alive(CodeBlob *cb);
  85   static nmethod* alive_nmethod(CodeBlob *cb);
  86   static int       nof_blobs()                 { return _number_of_blobs; }
  87 
  88   // GC support
  89   static void gc_epilogue();
  90   static void gc_prologue();
  91   // If "unloading_occurred" is true, then unloads (i.e., breaks root links
  92   // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
  93   // to "true" iff some code got unloaded.
  94   static void do_unloading(BoolObjectClosure* is_alive,
  95                            OopClosure* keep_alive,
  96                            bool unloading_occurred);
  97   static void oops_do(OopClosure* f);


   1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)codeCache.hpp        1.68 07/09/01 18:01:02 JVM"
   3 #endif
   4 /*
   5  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  57 
  58   // Allocation/administration
  59   static CodeBlob* allocate(int size);              // allocates a new CodeBlob
  60   static void commit(CodeBlob* cb);                 // called when the allocated CodeBlob has been filled
  61   static int alignment_unit();                      // guaranteed alignment of all CodeBlobs
  62   static int alignment_offset();                    // guaranteed offset of first CodeBlob byte within alignment unit (i.e., allocation header)
  63   static void free(CodeBlob* cb);                   // frees a CodeBlob
  64   static void flush();                              // flushes all CodeBlobs
  65   static bool contains(void *p);                    // returns whether p is included  
  66   static void blobs_do(void f(CodeBlob* cb));       // iterates over all CodeBlobs 
  67   static void nmethods_do(void f(nmethod* nm));     // iterates over all nmethods 
  68 
  69   // Lookup
  70   static CodeBlob* find_blob(void* start);
  71   static nmethod*  find_nmethod(void* start);
  72 
  73   // Lookup that does not fail if you lookup a zombie method (if you call this, be sure to know
  74   // what you are doing)
  75   static CodeBlob* find_blob_unsafe(void* start) {
  76     CodeBlob* result = (CodeBlob*)_heap->find_start(start);
  77     // this assert is too strong because the heap code will return the
  78     // heapblock containing start. That block can often be larger than
  79     // the codeBlob itself. If you look up an address that is within
  80     // the heapblock but not in the codeBlob you will assert.
  81     //
  82     // Most things will not lookup such bad addresses. However
  83     // AsyncGetCallTrace can see intermediate frames and get that kind
  84     // of invalid address and so can a developer using hsfind.
  85     //
  86     // The more correct answer is to return NULL if blob_contains() returns
  87     // false.
  88     // assert(result == NULL || result->blob_contains((address)start), "found wrong CodeBlob");
  89 
  90     if (result != NULL && !result->blob_contains((address)start)) {
  91       result = NULL;
  92     }
  93     return result;
  94   }
  95 
  96   // Iteration
  97   static CodeBlob* first();
  98   static CodeBlob* next (CodeBlob* cb);  
  99   static CodeBlob* alive(CodeBlob *cb);
 100   static nmethod* alive_nmethod(CodeBlob *cb);
 101   static int       nof_blobs()                 { return _number_of_blobs; }
 102 
 103   // GC support
 104   static void gc_epilogue();
 105   static void gc_prologue();
 106   // If "unloading_occurred" is true, then unloads (i.e., breaks root links
 107   // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
 108   // to "true" iff some code got unloaded.
 109   static void do_unloading(BoolObjectClosure* is_alive,
 110                            OopClosure* keep_alive,
 111                            bool unloading_occurred);
 112   static void oops_do(OopClosure* f);