src/hotspot/share/code/codeCache.hpp
changeset 52385 5c679ec60888
parent 50416 ef980b9ac191
child 52405 c0c6cdea32f1
equal deleted inserted replaced
52384:d6dc479bcdd3 52385:5c679ec60888
    25 #ifndef SHARE_VM_CODE_CODECACHE_HPP
    25 #ifndef SHARE_VM_CODE_CODECACHE_HPP
    26 #define SHARE_VM_CODE_CODECACHE_HPP
    26 #define SHARE_VM_CODE_CODECACHE_HPP
    27 
    27 
    28 #include "code/codeBlob.hpp"
    28 #include "code/codeBlob.hpp"
    29 #include "code/nmethod.hpp"
    29 #include "code/nmethod.hpp"
       
    30 #include "gc/shared/gcBehaviours.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "memory/allocation.hpp"
    31 #include "memory/heap.hpp"
    32 #include "memory/heap.hpp"
    32 #include "oops/instanceKlass.hpp"
    33 #include "oops/instanceKlass.hpp"
    33 #include "oops/oopsHierarchy.hpp"
    34 #include "oops/oopsHierarchy.hpp"
    34 #include "runtime/mutexLocker.hpp"
    35 #include "runtime/mutexLocker.hpp"
    88   static GrowableArray<CodeHeap*>* _allocable_heaps;
    89   static GrowableArray<CodeHeap*>* _allocable_heaps;
    89 
    90 
    90   static address _low_bound;                            // Lower bound of CodeHeap addresses
    91   static address _low_bound;                            // Lower bound of CodeHeap addresses
    91   static address _high_bound;                           // Upper bound of CodeHeap addresses
    92   static address _high_bound;                           // Upper bound of CodeHeap addresses
    92   static int _number_of_nmethods_with_dependencies;     // Total number of nmethods with dependencies
    93   static int _number_of_nmethods_with_dependencies;     // Total number of nmethods with dependencies
    93   static bool _needs_cache_clean;                       // True if inline caches of the nmethods needs to be flushed
       
    94   static nmethod* _scavenge_root_nmethods;              // linked via nm->scavenge_root_link()
    94   static nmethod* _scavenge_root_nmethods;              // linked via nm->scavenge_root_link()
       
    95   static uint8_t _unloading_cycle;                      // Global state for recognizing old nmethods that need to be unloaded
    95 
    96 
    96   static void mark_scavenge_root_nmethods() PRODUCT_RETURN;
    97   static void mark_scavenge_root_nmethods() PRODUCT_RETURN;
    97   static void verify_perm_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN;
    98   static void verify_perm_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN;
    98 
    99 
    99   // CodeHeap management
   100   // CodeHeap management
   170   static void verify_oops();
   171   static void verify_oops();
   171   // If any oops are not marked this method unloads (i.e., breaks root links
   172   // If any oops are not marked this method unloads (i.e., breaks root links
   172   // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
   173   // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
   173   // to "true" iff some code got unloaded.
   174   // to "true" iff some code got unloaded.
   174   // "unloading_occurred" controls whether metadata should be cleaned because of class unloading.
   175   // "unloading_occurred" controls whether metadata should be cleaned because of class unloading.
       
   176   class UnloadingScope: StackObj {
       
   177     ClosureIsUnloadingBehaviour _is_unloading_behaviour;
       
   178 
       
   179   public:
       
   180     UnloadingScope(BoolObjectClosure* is_alive)
       
   181       : _is_unloading_behaviour(is_alive)
       
   182     {
       
   183       IsUnloadingBehaviour::set_current(&_is_unloading_behaviour);
       
   184       increment_unloading_cycle();
       
   185     }
       
   186 
       
   187     ~UnloadingScope() {
       
   188       IsUnloadingBehaviour::set_current(NULL);
       
   189     }
       
   190   };
   175   static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
   191   static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
       
   192   static uint16_t unloading_cycle() { return _unloading_cycle; }
       
   193   static void increment_unloading_cycle();
   176   static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
   194   static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
   177 
   195 
   178   // Apply f to every live code blob in scavengable nmethods. Prune nmethods
   196   // Apply f to every live code blob in scavengable nmethods. Prune nmethods
   179   // from the list of scavengable nmethods if f->fix_relocations() and a nmethod
   197   // from the list of scavengable nmethods if f->fix_relocations() and a nmethod
   180   // no longer has scavengable oops.  If f->fix_relocations(), then f must copy
   198   // no longer has scavengable oops.  If f->fix_relocations(), then f must copy
   220   static size_t unallocated_capacity();
   238   static size_t unallocated_capacity();
   221   static size_t max_capacity();
   239   static size_t max_capacity();
   222 
   240 
   223   static double reverse_free_ratio(int code_blob_type);
   241   static double reverse_free_ratio(int code_blob_type);
   224 
   242 
   225   static bool needs_cache_clean()                     { return _needs_cache_clean; }
       
   226   static void set_needs_cache_clean(bool v)           { _needs_cache_clean = v;    }
       
   227 
       
   228   static void clear_inline_caches();                  // clear all inline caches
   243   static void clear_inline_caches();                  // clear all inline caches
   229   static void cleanup_inline_caches();                // clean unloaded/zombie nmethods from inline caches
   244   static void cleanup_inline_caches();                // clean unloaded/zombie nmethods from inline caches
   230   static void do_unloading_nmethod_caches(bool class_unloading_occurred);  // clean all nmethod caches for unloading, including inline caches
       
   231 
   245 
   232   // Returns true if an own CodeHeap for the given CodeBlobType is available
   246   // Returns true if an own CodeHeap for the given CodeBlobType is available
   233   static bool heap_available(int code_blob_type);
   247   static bool heap_available(int code_blob_type);
   234 
   248 
   235   // Returns the CodeBlobType for the given CompiledMethod
   249   // Returns the CodeBlobType for the given CompiledMethod