/*
* 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.
*
*/
#include "memory/allocation.inline.hpp"
#include "oops/symbol.hpp"
#include "utilities/hashtable.hpp"
// The symbol table holds all Symbol*s and corresponding interned strings.
// Symbol*s and literal strings should be canonicalized.
//
// The interned strings are created lazily.
//
// It is implemented as an open hash table with a fixed number of buckets.
//
// %note:
// - symbolTableEntrys are allocated in blocks to reduce the space overhead.
class BoolObjectClosure;
class outputStream;
// Class to hold a newly created or referenced Symbol* temporarily in scope.
// new_symbol() and lookup() will create a Symbol* if not already in the
// symbol table and add to the symbol's reference count.
// probe() and lookup_only() will increment the refcount if symbol is found.
public:
// Creating or looking up a symbol increments the symbol's reference count
// Operator= increments reference count.
void operator=(const TempNewSymbol &s) {
//clear(); //FIXME
}
// Decrement reference counter so it can go away if it's unique
~TempNewSymbol() { clear(); }
// Operators so they can be used like Symbols
// Sneaky conversion function
};
friend class VMStructs;
friend class ClassFileParser;
private:
// The symbol table
// Set if one bucket is out of balance due to hash algorithm deficiency
static bool _needs_rehashing;
// For statistics
static int symbols_removed;
static int symbols_counted;
Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F
// Adding elements
unsigned int* hashValues, TRAPS);
int names_count,
int* cp_indices, unsigned int* hashValues,
TRAPS) {
}
// Table size
enum {
};
// Arena for permanent symbols (null class loader) that are never unloaded
static void initialize_symbols(int arena_alloc_size = 0);
public:
enum {
// Pick initial size based on java -version size measurements
};
// The symbol table
static void create_table() {
_the_table = new SymbolTable();
}
int number_of_entries) {
"bad shared symbol size.");
// if CDS give symbol table a default arena size since most symbols
// are already allocated in the shared misc section.
}
static unsigned int hash_symbol(const char* s, int len);
// lookup only, won't add. Also calculate hash.
// Only copy to C string to be added if lookup failed.
// Look up the address of the literal in the SymbolTable for this Symbol*
// jchar (utf16) version of lookups
unsigned int* hashValues, TRAPS);
// Release any dead symbols
static void unlink();
// iterate over symbols
// Symbol creation
}
}
}
// Create a symbol in the arena for symbols that are not deleted
// Symbol lookup
// Needed for preloading classes in signatures when compiling.
// Returns the symbol is already present in symbol table, otherwise
// NULL. NO ALLOCATION IS GUARANTEED!
unsigned int ignore_hash;
}
unsigned int ignore_hash;
}
// Histogram
// Debugging
static void verify();
// Sharing
}
}
}
// Rehash the symbol table if it gets out of balance
static void rehash_table();
};
friend class VMStructs;
private:
// The string table
// Set if one bucket is out of balance due to hash algorithm deficiency
static bool _needs_rehashing;
// Claimed high water mark for parallel chunked scanning
static volatile int _parallel_claimed_idx;
// Apply the give oop closure to the entries to the buckets
// in the range [start_idx, end_idx).
public:
// The string table
static void create_table() {
_the_table = new StringTable();
}
int number_of_entries) {
"bad shared string size.");
}
// GC support
// Delete pointers to otherwise-unreachable objects.
// Serially invoke "f->do_oop" on the locations of all oops in the table.
static void oops_do(OopClosure* f);
// Possibly parallel version of the above
static void possibly_parallel_oops_do(OopClosure* f);
// Hashing algorithm, used as the hash value used by the
// StringTable for bucket selection and comparison (stored in the
// HashtableEntry structures). This is used in the String.intern() method.
// Internal test.
// Probing
// Interning
// Debugging
static void verify();
// Sharing
}
}
static void reverse() {
}
// Rehash the symbol table if it gets out of balance
static void rehash_table();
// Parallel chunked scanning
};
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP