/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_UTILITIES_HASHTABLE_HPP
#define SHARE_VM_UTILITIES_HASHTABLE_HPP
#include "memory/allocation.hpp"
#include "oops/symbol.hpp"
#include "runtime/handles.hpp"
// This is a generic hashtable, designed to be used for the symbol
// and string tables.
//
// It is implemented as an open hash table with a fixed number of buckets.
//
// %note:
// - TableEntrys are allocated in blocks to reduce the space overhead.
friend class VMStructs;
private:
// 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
// shared entries will not change. New entries will always be
// unshared and since pointers are align, bit 0 will always remain 0
// with no extra effort.
// Windows IA64 compiler requires subclasses to be able to access these
protected:
// Entry objects should not be created, they should be taken from the
// free list with BasicHashtable.new_entry().
// Entry objects should not be destroyed. They should be placed on
// the free list instead with BasicHashtable.free_entry().
~BasicHashtableEntry() { ShouldNotReachHere(); }
public:
}
}
}
return &_next;
}
bool is_shared() const {
}
void set_shared() {
}
};
friend class VMStructs;
private:
public:
// Literal
}
}
};
friend class VMStructs;
private:
// Instance variable
public:
// Accessing
// The following methods use order access methods to avoid race
// conditions in multiprocessor systems.
BasicHashtableEntry<F>* get_entry() const;
void set_entry(BasicHashtableEntry<F>* l);
// The following method is not MT-safe and must be done under lock.
};
friend class VMStructs;
public:
// Sharing support.
// Bucket handling
int h = full_hash % _table_size;
return h;
}
// Reverse the order of elements in each of the buckets.
void reverse();
private:
// Instance variables
int _table_size;
char* _first_free_entry;
char* _end_block;
int _entry_size;
int _number_of_entries;
protected:
#ifdef ASSERT
int _lookup_count;
int _lookup_length;
void verify_lookup_length(double load);
#endif
enum {
};
// Accessor
// The following method is MT-safe and may be used with caution.
BasicHashtableEntry<F>* bucket(int i);
// The following method is not MT-safe and must be done under lock.
// Table entry management
// Check that the table is unbalanced
bool check_rehash_table(int count);
// Used when moving the entry to another table
// Clean up links, but do not add to free_list
}
// Move over freelist and free block for allocation
}
// Free the buckets in this hashtable
void free_buckets();
public:
};
friend class VMStructs;
public:
// Debugging
// Reverse the order of elements in each of the buckets. Hashtable
// entries which refer to objects at a lower address than 'boundary'
// are separated from those which refer to objects at higher
// addresses, and appear first in the list.
protected:
return (unsigned int) name->identity_hash();
}
}
// Table entry management
// The following method is MT-safe and may be used with caution.
}
// The following method is not MT-safe and must be done under lock.
}
// Function to move these elements into the new table.
private:
};
// Verions of hashtable where two handles are used to compute the index.
friend class VMStructs;
protected:
int number_of_entries)
public:
// Be careful with identity_hash(), it can safepoint and if this
// were one expression, the compiler could choose to unhandle each
// oop before calling identity_hash() for either of them. If the first
// causes a GC, the next would fail.
return name_hash ^ loader_hash;
}
}
};
#endif // SHARE_VM_UTILITIES_HASHTABLE_HPP