src/share/vm/utilities/hashtable.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File

## src/share/vm/utilities/hashtable.hpp

Print this page

    *** 38,52 ****
      //
      // %note:
      //  - TableEntrys are allocated in blocks to reduce the space overhead.

    -
      template <MEMFLAGS F> class BasicHashtableEntry : public CHeapObj<F> {
        friend class VMStructs;
      private:
        unsigned int         _hash;           // 32-bit hash for item

        // Link to next element in the linked list for this bucket.  EXCEPT
        // bit 0 set indicates that this entry is shared and must not be
        // unlinked from the table. Bit 0 is set during the dumping of the
        // archive. Since shared entries are immutable, _next fields in the
    --- 38,53 ----
      //
      // %note:
      //  - TableEntrys are allocated in blocks to reduce the space overhead.

      template <MEMFLAGS F> class BasicHashtableEntry : public CHeapObj<F> {
        friend class VMStructs;
      private:
        unsigned int        _hash;           // 32-bit hash for item
    +   public:
    +   int                 _debug_lookups;

        // Link to next element in the linked list for this bucket.  EXCEPT
        // bit 0 set indicates that this entry is shared and must not be
        // unlinked from the table. Bit 0 is set during the dumping of the
        // archive. Since shared entries are immutable, _next fields in the
    *** 114,125 ****
        HashtableEntry** next_addr() {
          return (HashtableEntry**)BasicHashtableEntry<F>::next_addr();
        }
      };

    -
    -
      template <MEMFLAGS F> class HashtableBucket : public CHeapObj<F> {
        friend class VMStructs;
      private:
        // Instance variable
        BasicHashtableEntry<F>*       _entry;
    --- 115,124 ----
    *** 135,144 ****
    --- 134,149 ----

        // The following method is not MT-safe and must be done under lock.
        BasicHashtableEntry<F>** entry_addr()  { return &_entry; }
      };

    + typedef struct
    + {
    +   bool resized;
    +   unsigned int old_size;
    +   unsigned int new_size;
    + } ResizeHashtableStats;

      template <MEMFLAGS F> class BasicHashtable : public CHeapObj<F> {
        friend class VMStructs;

      public:
    *** 148,157 ****
    --- 153,165 ----

        // Sharing support.
        void copy_buckets(char** top, char* end);
        void copy_table(char** top, char* end);

    +   // Resizing support.
    +   ResizeHashtableStats resize_table(Monitor* lock, float trigger, float desired);
    +
        // Bucket handling
        int hash_to_index(unsigned int full_hash) {
          int h = full_hash % _table_size;
          assert(h >= 0 && h < _table_size, "Illegal hash value");
          return h;
    *** 170,179 ****
    --- 178,216 ----
        int               _entry_size;
        int               _number_of_entries;

      protected:

    +   julong            _debug_resize_fire; // FORCE_RESIZE
    +
    + #ifndef PRODUCT
    + //#ifdef PRODUCT_TEST
    +
    +   long              _debug_table_threads[1024];
    +
    +   // statistics kept through life of VM per table type
    +   julong            _debug_all_lookup_count;
    +   julong            _debug_all_insertion_count;
    +
    +   // statistics per table's duration of life
    +   julong            _debug_lookup_count;
    +   julong            _debug_insertion_count;
    +   julong            _debug_lookup_found_count;
    +   julong            _debug_lookup_found_max_duration;
    +   julong            _debug_lookup_found_total_duration;
    +   julong            _debug_chain_found_maximum_length;
    +   julong            _debug_chain_found_total_length;
    +   julong            _debug_lookup_failed_count;
    +   julong            _debug_lookup_failed_max_duration;
    +   julong            _debug_lookup_failed_total_duration;
    +   julong            _debug_chain_failed_maximum_length;
    +   julong            _debug_chain_failed_total_length;
    +   julong            _debug_resize_max_duration;
    +   julong            _debug_resize_total_duration;
    +   julong            _debug_resize_total_count;
    + #endif
    +
      #ifdef ASSERT
        int               _lookup_count;
        int               _lookup_length;
        void verify_lookup_length(double load);
      #endif
    *** 224,233 ****
    --- 261,272 ----
        void free_entry(BasicHashtableEntry<F>* entry);

        int number_of_entries() { return _number_of_entries; }

        void verify() PRODUCT_RETURN;
    +
    +   void dump(outputStream* st, const char* table_name) { tty->print("BasicHashtable\n"); };
      };

      template <class T, MEMFLAGS F> class Hashtable : public BasicHashtable<F> {
        friend class VMStructs;
    *** 270,279 ****
    --- 309,332 ----
        // The following method is not MT-safe and must be done under lock.
        HashtableEntry<T, F>** bucket_addr(int i) {
          return (HashtableEntry<T, F>**)BasicHashtable<F>::bucket_addr(i);
        }

    +   static int literal_size(Symbol *symbol);
    +   static int literal_size(oop oop);
    +   static int literal_size(Klass *k);
    +
    +   // The following ones are currently not used, but are needed anyway because some
    +   // C++ compilers (MacOS and Solaris) force the instantiation of
    +   // Hashtable<ConstantPool*, mtClass>::dump_table() even though we never call this function
    +   // in the VM code.
    +   static int literal_size(ConstantPool *cp) {Unimplemented(); return 0;}
    +   static int literal_size(nmethod *nm) {Unimplemented(); return 0;}
    +
    + public:
    +   void dump_table(outputStream* st, const char *table_name);
    +   void dump(outputStream* st, const char* table_name);
      };

      template <class T, MEMFLAGS F> class RehashableHashtable : public Hashtable<T, F> {
       protected:

    *** 297,318 ****
        // Function to move these elements into the new table.
        void move_to(RehashableHashtable<T, F>* new_table);
        static bool use_alternate_hashcode()  { return _seed != 0; }
        static juint seed()                    { return _seed; }

    -   static int literal_size(Symbol *symbol);
    -   static int literal_size(oop oop);
    -
    -   // The following two are currently not used, but are needed anyway because some
    -   // C++ compilers (MacOS and Solaris) force the instantiation of
    -   // Hashtable<ConstantPool*, mtClass>::dump_table() even though we never call this function
    -   // in the VM code.
    -   static int literal_size(ConstantPool *cp) {Unimplemented(); return 0;}
    -   static int literal_size(Klass *k)         {Unimplemented(); return 0;}
    -
    -   void dump_table(outputStream* st, const char *table_name);
    -
       private:
        static juint _seed;
      };

    --- 350,359 ----

src/share/vm/utilities/hashtable.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File