src/share/vm/classfile/metadataOnStackMark.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8140685.01 Sdiff src/share/vm/classfile

src/share/vm/classfile/metadataOnStackMark.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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);




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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/backtrace.hpp"
  27 #include "classfile/metadataOnStackMark.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "oops/metadata.hpp"
  31 #include "prims/jvmtiImpl.hpp"
  32 #include "runtime/synchronizer.hpp"
  33 #include "runtime/thread.hpp"
  34 #include "services/threadService.hpp"
  35 #include "utilities/chunkedList.hpp"
  36 #if INCLUDE_JVMCI
  37 #include "jvmci/jvmciRuntime.hpp"
  38 #endif
  39 
  40 MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = NULL;
  41 MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = NULL;
  42 
  43 MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = NULL;
  44 NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;)
  45 
  46 // Walk metadata on the stack and mark it so that redefinition doesn't delete
  47 // it.  Class unloading only deletes in-error class files, methods created by
  48 // the relocator and dummy constant pools.  None of these appear anywhere except
  49 // in metadata Handles.
  50 MetadataOnStackMark::MetadataOnStackMark(bool redefinition_walk) {
  51   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  52   assert(_used_buffers == NULL, "sanity check");
  53   assert(!_is_active, "MetadataOnStackMarks do not nest");
  54   NOT_PRODUCT(_is_active = true;)
  55 
  56   Threads::metadata_handles_do(Metadata::mark_on_stack);
  57 
  58   if (redefinition_walk) {
  59     Threads::metadata_do(Metadata::mark_on_stack);
  60     CodeCache::alive_nmethods_do(nmethod::mark_on_stack);
  61     CompileBroker::mark_on_stack();
  62     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
  63     ThreadService::metadata_do(Metadata::mark_on_stack);
  64     BacktraceList::mark_on_stack();
  65 #if INCLUDE_JVMCI
  66     JVMCIRuntime::metadata_do(Metadata::mark_on_stack);
  67 #endif
  68   }
  69 }
  70 
  71 MetadataOnStackMark::~MetadataOnStackMark() {
  72   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
  73   // Unmark everything that was marked.   Can't do the same walk because
  74   // redefine classes messes up the code cache so the set of methods
  75   // might not be the same.
  76   retire_current_buffer();
  77 
  78   MetadataOnStackBuffer* buffer = _used_buffers;
  79   while (buffer != NULL) {
  80     // Clear on stack state for all metadata.
  81     size_t size = buffer->size();
  82     for (size_t i  = 0; i < size; i++) {
  83       Metadata* md = buffer->at(i);
  84       md->set_on_stack(false);


src/share/vm/classfile/metadataOnStackMark.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File