< prev index next >

src/hotspot/share/oops/constantPool.cpp

Print this page
*** 30,10 ***
--- 30,11 ---
  #include "classfile/metadataOnStackMark.hpp"
  #include "classfile/stringTable.hpp"
  #include "classfile/systemDictionary.hpp"
  #include "classfile/vmClasses.hpp"
  #include "classfile/vmSymbols.hpp"
+ #include "code/codeCache.hpp"
  #include "interpreter/bootstrapInfo.hpp"
  #include "interpreter/linkResolver.hpp"
  #include "logging/log.hpp"
  #include "logging/logStream.hpp"
  #include "memory/allocation.inline.hpp"

*** 2213,10 ***
--- 2214,20 ---
    return (int)(bytes - start_bytes);
  } /* end copy_cpool_bytes */
  
  #undef DBG
  
+ // For redefinition, if any methods found in InstanceStackChunks, the marking_cycle is
+ // recorded in their constant pool cache. The on_stack-ness of the constant pool controls whether
+ // memory for the method is reclaimed.
+ bool ConstantPool::on_stack() const {
+   if (_cache == NULL || _pool_holder == NULL) return false; // removed in loading
+ 
+   // See nmethod::is_not_on_continuation_stack for explanation of what this means.
+   bool not_on_vthread_stack = CodeCache::marking_cycle() >= align_up(cache()->marking_cycle(), 2) + 2;
+   return (_flags &_on_stack) != 0 || !not_on_vthread_stack;
+ }
  
  void ConstantPool::set_on_stack(const bool value) {
    if (value) {
      // Only record if it's not already set.
      if (!on_stack()) {
< prev index next >