hashtable.cpp revision 3460
3448N/A * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2062N/A void*,
unsigned int,
void*,
void*);
0N/A// This is a generic hashtable, designed to be used for the symbol 0N/A// and string tables. 0N/A// It is implemented as an open hash table with a fixed number of buckets. 0N/A// - HashtableEntrys are allocated in blocks to reduce the space overhead. 3448N/A// Check to see if the hashtable is unbalanced. The caller set a flag to 3448N/A// rehash at the next safepoint. If this bucket is 60 times greater than the 3448N/A// expected average bucket length, it's an unbalanced hashtable. 3448N/A// This is somewhat an arbitrary heuristic but if one bucket gets to 3448N/A// rehash_count which is currently 100, there's probably something wrong. 3448N/A // Set a flag for the next safepoint, which should be at some guaranteed 3448N/A// Create a new table and using alternate hash code, populate the new table 3448N/A// with the existing elements. This can be used to change the hash code 3448N/A// and could in the future change the size of the table. 3448N/A // Iterate through the table and create a new entry for the new table 3448N/A // Use alternate hashing algorithm on the symbol in the first table 3448N/A // Get a new index relative to the new table (can also change size) 3460N/A // Keep the shared bit in the Hashtable entry to indicate that this entry 3460N/A // can't be deleted. The shared bit is the LSB in the _next field so 3460N/A // walking the hashtable past these entries requires 3460N/A // BasicHashtableEntry::make_ptr() call. 3448N/A // give the new table the free list as well 3448N/A // Destroy memory used by the buckets in the hashtable. The memory 3448N/A // for the elements has been used in a new table and is not 3448N/A // destroyed. The memory reuse will benefit resizing the SystemDictionary 3448N/A // to avoid a memory allocation spike at safepoint. 3460N/A // Don't delete the buckets in the shared space. They aren't 0N/A// Reverse the order of elements in the hash buckets. 0N/A// Copy the table to the shared space. 0N/A // Dump the hash table entries. 0N/A // Set the shared bit. 0N/A// Reverse the order of elements in the hash buckets. 0N/A// Dump the hash table buckets. 0N/A warning(
"Performance bug: SystemDictionary lookup_count=%d " 0N/A "lookup_length=%d average=%lf load=%f",
2062N/A// Explicitly instantiate these types