< prev index next >

src/share/vm/classfile/metadataOnStackMark.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/metadataOnStackMark.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "oops/metadata.hpp"
  30 #include "prims/jvmtiImpl.hpp"
  31 #include "runtime/synchronizer.hpp"
  32 #include "runtime/thread.hpp"
  33 #include "services/threadService.hpp"
  34 #include "utilities/chunkedList.hpp"



  35 
  36 MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = NULL;
  37 MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = NULL;
  38 
  39 MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = NULL;
  40 NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;)
  41 
  42 // Walk metadata on the stack and mark it so that redefinition doesn't delete
  43 // it.  Class unloading only deletes in-error class files, methods created by
  44 // the relocator and dummy constant pools.  None of these appear anywhere except
  45 // in metadata Handles.
  46 MetadataOnStackMark::MetadataOnStackMark(bool redefinition_walk) {
  47   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  48   assert(_used_buffers == NULL, "sanity check");
  49   assert(!_is_active, "MetadataOnStackMarks do not nest");
  50   NOT_PRODUCT(_is_active = true;)
  51 
  52   Threads::metadata_handles_do(Metadata::mark_on_stack);
  53 
  54   if (redefinition_walk) {
  55     Threads::metadata_do(Metadata::mark_on_stack);
  56     CodeCache::alive_nmethods_do(nmethod::mark_on_stack);
  57     CompileBroker::mark_on_stack();
  58     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
  59     ThreadService::metadata_do(Metadata::mark_on_stack);



  60   }
  61 }
  62 
  63 MetadataOnStackMark::~MetadataOnStackMark() {
  64   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  65   // Unmark everything that was marked.   Can't do the same walk because
  66   // redefine classes messes up the code cache so the set of methods
  67   // might not be the same.
  68   retire_current_buffer();
  69 
  70   MetadataOnStackBuffer* buffer = _used_buffers;
  71   while (buffer != NULL) {
  72     // Clear on stack state for all metadata.
  73     size_t size = buffer->size();
  74     for (size_t i  = 0; i < size; i++) {
  75       Metadata* md = buffer->at(i);
  76       md->set_on_stack(false);
  77     }
  78 
  79     MetadataOnStackBuffer* next = buffer->next_used();




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/metadataOnStackMark.hpp"
  27 #include "code/codeCache.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "oops/metadata.hpp"
  30 #include "prims/jvmtiImpl.hpp"
  31 #include "runtime/synchronizer.hpp"
  32 #include "runtime/thread.hpp"
  33 #include "services/threadService.hpp"
  34 #include "utilities/chunkedList.hpp"
  35 #if INCLUDE_JVMCI
  36 #include "jvmci/jvmciRuntime.hpp"
  37 #endif
  38 
  39 MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = NULL;
  40 MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = NULL;
  41 
  42 MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = NULL;
  43 NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;)
  44 
  45 // Walk metadata on the stack and mark it so that redefinition doesn't delete
  46 // it.  Class unloading only deletes in-error class files, methods created by
  47 // the relocator and dummy constant pools.  None of these appear anywhere except
  48 // in metadata Handles.
  49 MetadataOnStackMark::MetadataOnStackMark(bool redefinition_walk) {
  50   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  51   assert(_used_buffers == NULL, "sanity check");
  52   assert(!_is_active, "MetadataOnStackMarks do not nest");
  53   NOT_PRODUCT(_is_active = true;)
  54 
  55   Threads::metadata_handles_do(Metadata::mark_on_stack);
  56 
  57   if (redefinition_walk) {
  58     Threads::metadata_do(Metadata::mark_on_stack);
  59     CodeCache::alive_nmethods_do(nmethod::mark_on_stack);
  60     CompileBroker::mark_on_stack();
  61     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
  62     ThreadService::metadata_do(Metadata::mark_on_stack);
  63 #if INCLUDE_JVMCI
  64     JVMCIRuntime::metadata_do(Metadata::mark_on_stack);
  65 #endif
  66   }
  67 }
  68 
  69 MetadataOnStackMark::~MetadataOnStackMark() {
  70   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  71   // Unmark everything that was marked.   Can't do the same walk because
  72   // redefine classes messes up the code cache so the set of methods
  73   // might not be the same.
  74   retire_current_buffer();
  75 
  76   MetadataOnStackBuffer* buffer = _used_buffers;
  77   while (buffer != NULL) {
  78     // Clear on stack state for all metadata.
  79     size_t size = buffer->size();
  80     for (size_t i  = 0; i < size; i++) {
  81       Metadata* md = buffer->at(i);
  82       md->set_on_stack(false);
  83     }
  84 
  85     MetadataOnStackBuffer* next = buffer->next_used();


< prev index next >