< prev index next >

src/hotspot/share/prims/resolvedMethodTable.hpp

Print this page




   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 #ifndef SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP
  26 #define SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP
  27 
  28 #include "gc/shared/oopStorage.hpp"
  29 #include "gc/shared/oopStorageParState.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "oops/weakHandle.hpp"
  33 #include "utilities/concurrentHashTable.hpp"
  34 #include "utilities/hashtable.hpp"
  35 
  36 class ResolvedMethodTable;
  37 class ResolvedMethodTableConfig;
  38 typedef ConcurrentHashTable<WeakHandle<vm_resolved_method_table_data>, ResolvedMethodTableConfig, mtClass> ResolvedMethodTableHash;
  39 
  40 class ResolvedMethodTable : public AllStatic {
  41   static ResolvedMethodTableHash* _local_table;
  42   static size_t                   _current_size;
  43 
  44   static OopStorage*              _weak_handles;




  45 
  46   static volatile bool            _has_work;


  47 
  48   static volatile size_t          _items_count;
  49   static volatile size_t          _uncleaned_items_count;
  50 
  51 public:
  52   // Initialization
  53   static void create_table();
  54 
  55   static size_t table_size();
  56 
  57   // Lookup and inserts
  58   static oop find_method(const Method* method);
  59   static oop add_method(const Method* method, Handle rmethod_name);
  60 
  61   // Callbacks
  62   static void item_added();
  63   static void item_removed();

  64 
  65   // Cleaning
  66   static bool has_work();
  67 
  68   // GC Support - Backing storage for the oop*s
  69   static OopStorage* weak_storage();
  70 
  71   // Cleaning and table management




  72 
  73   static double get_load_factor();
  74   static double get_dead_factor();

  75 
  76   static void check_concurrent_work();
  77   static void trigger_concurrent_work();
  78   static void do_concurrent_work(JavaThread* jt);
  79 
  80   static void grow(JavaThread* jt);
  81   static void clean_dead_entries(JavaThread* jt);

  82 
  83   // GC Notification

  84 
  85   // Must be called before a parallel walk where objects might die.
  86   static void reset_dead_counter();
  87   // After the parallel walk this method must be called to trigger
  88   // cleaning. Note it might trigger a resize instead.
  89   static void finish_dead_counter();
  90   // If GC uses ParState directly it should add the number of cleared
  91   // entries to this method.
  92   static void inc_dead_counter(size_t ndead);
  93 
  94   // JVMTI Support - It is called at safepoint only for RedefineClasses
  95   JVMTI_ONLY(static void adjust_method_entries(bool * trace_name_printed);)
  96 
  97   // Debugging
  98   static size_t items_count();
  99   static size_t verify_and_compare_entries();























 100 };
 101 
 102 #endif // SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP


   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 #ifndef SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP
  26 #define SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP
  27 



  28 #include "oops/symbol.hpp"
  29 #include "oops/weakHandle.hpp"

  30 #include "utilities/hashtable.hpp"
  31 
  32 // Hashtable to record Method* used in ResolvedMethods, via. ResolvedMethod oops.
  33 // This is needed for redefinition to replace Method* with redefined versions.

  34 
  35 // Entry in a ResolvedMethodTable, mapping a ClassLoaderWeakHandle for a single oop of
  36 // java_lang_invoke_ResolvedMethodName which holds JVM Method* in vmtarget.

  37 
  38 class ResolvedMethodEntry : public HashtableEntry<ClassLoaderWeakHandle, mtClass> {
  39  public:
  40   ResolvedMethodEntry* next() const {
  41     return (ResolvedMethodEntry*)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next();
  42   }
  43 
  44   ResolvedMethodEntry** next_addr() {
  45     return (ResolvedMethodEntry**)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next_addr();
  46   }
  47 
  48   oop object();
  49   oop object_no_keepalive();
  50 
  51   void print_on(outputStream* st) const;
  52 };







  53 
  54 class ResolvedMethodTable : public Hashtable<ClassLoaderWeakHandle, mtClass> {
  55   enum Constants {
  56     _table_size  = 1007
  57   };
  58 
  59   static int _total_oops_removed;

  60 
  61   static bool _dead_entries;

  62 
  63   static ResolvedMethodTable* _the_table;
  64 private:
  65   ResolvedMethodEntry* bucket(int i) {
  66     return (ResolvedMethodEntry*) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket(i);
  67   }
  68 
  69   ResolvedMethodEntry** bucket_addr(int i) {
  70     return (ResolvedMethodEntry**) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket_addr(i);
  71   }
  72 
  73   unsigned int compute_hash(Method* method);


  74 
  75   // need not be locked; no state change
  76   oop lookup(int index, unsigned int hash, Method* method);
  77   oop lookup(Method* method);
  78 
  79   // must be done under ResolvedMethodTable_lock
  80   oop basic_add(Method* method, Handle rmethod_name);
  81 
  82 public:
  83   ResolvedMethodTable();









  84 
  85   static void create_table() {
  86     assert(_the_table == NULL, "One symbol table allowed.");
  87     _the_table = new ResolvedMethodTable();
  88   }
  89 
  90   // Called from java_lang_invoke_ResolvedMethodName
  91   static oop find_method(Method* method);
  92   static oop add_method(const methodHandle& method, Handle rmethod_name);
  93 
  94   static bool has_work() { return _dead_entries; }
  95   static void trigger_cleanup();
  96 
  97   static int removed_entries_count() { return _total_oops_removed; };
  98 
  99 #if INCLUDE_JVMTI
 100   // It is called at safepoint only for RedefineClasses
 101   static void adjust_method_entries(bool * trace_name_printed);
 102 #endif // INCLUDE_JVMTI
 103 
 104   // Cleanup cleared entries
 105   static void unlink();
 106 
 107 #ifndef PRODUCT
 108   void print();
 109 #endif
 110   void verify();
 111 };
 112 
 113 #endif // SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP
< prev index next >