hotspot/src/share/vm/classfile/symbolTable.hpp
author thartmann
Tue, 03 Nov 2015 09:41:03 +0100
changeset 33628 09241459a8b8
parent 28363 047115468f16
child 33638 ef49ed90010b
permissions -rw-r--r--
8141132: JEP 254: Compact Strings Summary: Adopt a more space-efficient internal representation for strings. Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti Contributed-by: Brent Christian <brent.christian@oracle.com>, Vivek Deshpande <vivek.r.deshpande@intel.com>, Tobias Hartmann <tobias.hartmann@oracle.com>, Charlie Hunt <charlie.hunt@oracle.com>, Vladimir Kozlov <vladimir.kozlov@oracle.com>, Roger Riggs <roger.riggs@oracle.com>, Xueming Shen <xueming.shen@oracle.com>, Aleksey Shipilev <aleksey.shipilev@oracle.com>, Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
18091
ddde9f0f414d 8015237: Parallelize string table scanning during strong root processing
johnc
parents: 17846
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2332
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2332
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2332
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.inline.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    29
#include "oops/symbol.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "utilities/hashtable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    32
// The symbol table holds all Symbol*s and corresponding interned strings.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    33
// Symbol*s and literal strings should be canonicalized.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// The interned strings are created lazily.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// It is implemented as an open hash table with a fixed number of buckets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// %note:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//  - symbolTableEntrys are allocated in blocks to reduce the space overhead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class BoolObjectClosure;
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
    43
class outputStream;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    45
// Class to hold a newly created or referenced Symbol* temporarily in scope.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    46
// new_symbol() and lookup() will create a Symbol* if not already in the
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    47
// symbol table and add to the symbol's reference count.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    48
// probe() and lookup_only() will increment the refcount if symbol is found.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    49
class TempNewSymbol : public StackObj {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    50
  Symbol* _temp;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    51
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    52
 public:
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    53
  TempNewSymbol() : _temp(NULL) {}
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    54
  // Creating or looking up a symbol increments the symbol's reference count
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    55
  TempNewSymbol(Symbol *s) : _temp(s) {}
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    56
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    57
  // Operator= increments reference count.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    58
  void operator=(const TempNewSymbol &s) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13199
diff changeset
    59
    //clear();  //FIXME
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    60
    _temp = s._temp;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    61
    if (_temp !=NULL) _temp->increment_refcount();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    62
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    63
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    64
  // Decrement reference counter so it can go away if it's unique
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13199
diff changeset
    65
  void clear() { if (_temp != NULL)  _temp->decrement_refcount();  _temp = NULL; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13199
diff changeset
    66
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13199
diff changeset
    67
  ~TempNewSymbol() { clear(); }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    68
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    69
  // Operators so they can be used like Symbols
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    70
  Symbol* operator -> () const                   { return _temp; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    71
  bool    operator == (Symbol* o) const          { return _temp == o; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    72
  // Sneaky conversion function
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    73
  operator Symbol*()                             { return _temp; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    74
};
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    75
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    76
template <class T, class N> class CompactHashtable;
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    77
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
    78
class SymbolTable : public RehashableHashtable<Symbol*, mtSymbol> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  friend class VMStructs;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    80
  friend class ClassFileParser;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // The symbol table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static SymbolTable* _the_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
    86
  // Set if one bucket is out of balance due to hash algorithm deficiency
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
    87
  static bool _needs_rehashing;
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    88
  static bool _lookup_shared_first;
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
    89
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    90
  // For statistics
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
    91
  static int _symbols_removed;
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
    92
  static int _symbols_counted;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    93
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    94
  // shared symbol table.
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    95
  static CompactHashtable<Symbol*, char> _shared_table;
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    96
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
    97
  Symbol* allocate_symbol(const u1* name, int len, bool c_heap, TRAPS); // Assumes no characters larger than 0x7F
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    98
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Adding elements
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   100
  Symbol* basic_add(int index, u1* name, int len, unsigned int hashValue,
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   101
                    bool c_heap, TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   102
  bool basic_add(ClassLoaderData* loader_data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   103
                 constantPoolHandle cp, int names_count,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                 const char** names, int* lengths, int* cp_indices,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                 unsigned int* hashValues, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   107
  static void new_symbols(ClassLoaderData* loader_data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   108
                          constantPoolHandle cp, int names_count,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   109
                          const char** name, int* lengths,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   110
                          int* cp_indices, unsigned int* hashValues,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   111
                          TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   112
    add(loader_data, cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   113
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   114
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   115
  static Symbol* lookup_shared(const char* name, int len, unsigned int hash);
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   116
  Symbol* lookup_dynamic(int index, const char* name, int len, unsigned int hash);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   117
  Symbol* lookup(int index, const char* name, int len, unsigned int hash);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  SymbolTable()
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
   120
    : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>)) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13097
diff changeset
   122
  SymbolTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
   123
    : RehashableHashtable<Symbol*, mtSymbol>(SymbolTableSize, sizeof (HashtableEntry<Symbol*, mtSymbol>), t,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
                number_of_entries) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   126
  // Arena for permanent symbols (null class loader) that are never unloaded
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   127
  static Arena*  _arena;
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   128
  static Arena* arena() { return _arena; }  // called for statistics
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   130
  static void initialize_symbols(int arena_alloc_size = 0);
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   131
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   132
  static volatile int _parallel_claimed_idx;
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   133
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   134
  // Release any dead symbols
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   135
  static void buckets_unlink(int start_idx, int end_idx, int* processed, int* removed, size_t* memory_total);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  enum {
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   138
    symbol_alloc_batch_size = 8,
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   139
    // Pick initial size based on java -version size measurements
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   140
    symbol_alloc_arena_size = 360*K
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // The symbol table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  static SymbolTable* the_table() { return _the_table; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
20393
0675c0224a5a 8019375: Internal symbol table size should be tunable.
kevinw
parents: 20053
diff changeset
   146
  // Size of one bucket in the string table.  Used when checking for rollover.
0675c0224a5a 8019375: Internal symbol table size should be tunable.
kevinw
parents: 20053
diff changeset
   147
  static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
0675c0224a5a 8019375: Internal symbol table size should be tunable.
kevinw
parents: 20053
diff changeset
   148
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  static void create_table() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    assert(_the_table == NULL, "One symbol table allowed.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    _the_table = new SymbolTable();
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   152
    initialize_symbols(symbol_alloc_arena_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
13097
c146b608d91f 7178670: runtime/7158800/BadUtf8.java fails in SymbolTable::rehash_table
coleenp
parents: 13087
diff changeset
   155
  static unsigned int hash_symbol(const char* s, int len);
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   156
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   157
  static Symbol* lookup(const char* name, int len, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // lookup only, won't add. Also calculate hash.
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   159
  static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // Only copy to C string to be added if lookup failed.
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   161
  static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   162
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   163
  static void release(Symbol* sym);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
11480
1bf714e8adb4 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 8885
diff changeset
   165
  // Look up the address of the literal in the SymbolTable for this Symbol*
1bf714e8adb4 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 8885
diff changeset
   166
  static Symbol** lookup_symbol_addr(Symbol* sym);
1bf714e8adb4 7115199: Add event tracing hooks and Java Flight Recorder infrastructure
phh
parents: 8885
diff changeset
   167
33628
09241459a8b8 8141132: JEP 254: Compact Strings
thartmann
parents: 28363
diff changeset
   168
  // jchar (UTF16) version of lookups
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   169
  static Symbol* lookup_unicode(const jchar* name, int len, TRAPS);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   170
  static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   171
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   172
  static void add(ClassLoaderData* loader_data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   173
                  constantPoolHandle cp, int names_count,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
                  const char** names, int* lengths, int* cp_indices,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
                  unsigned int* hashValues, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   177
  // Release any dead symbols
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   178
  static void unlink() {
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   179
    int processed = 0;
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   180
    int removed = 0;
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   181
    unlink(&processed, &removed);
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   182
  }
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   183
  static void unlink(int* processed, int* removed);
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   184
  // Release any dead symbols, possibly parallel version
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   185
  static void possibly_parallel_unlink(int* processed, int* removed);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   186
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   187
  // iterate over symbols
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   188
  static void symbols_do(SymbolClosure *cl);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   189
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   190
  // Symbol creation
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   191
  static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   192
    assert(utf8_buffer != NULL, "just checking");
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   193
    return lookup(utf8_buffer, length, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   195
  static Symbol*       new_symbol(const char* name, TRAPS) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   196
    return new_symbol(name, (int)strlen(name), THREAD);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   197
  }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   198
  static Symbol*       new_symbol(const Symbol* sym, int begin, int end, TRAPS) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   199
    assert(begin <= end && end <= sym->utf8_length(), "just checking");
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   200
    return lookup(sym, begin, end, THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   203
  // Create a symbol in the arena for symbols that are not deleted
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   204
  static Symbol* new_permanent_symbol(const char* name, TRAPS);
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   205
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // Symbol lookup
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   207
  static Symbol* lookup(int index, const char* name, int len, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // Needed for preloading classes in signatures when compiling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  // Returns the symbol is already present in symbol table, otherwise
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // NULL.  NO ALLOCATION IS GUARANTEED!
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   212
  static Symbol* probe(const char* name, int len) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   213
    unsigned int ignore_hash;
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   214
    return lookup_only(name, len, ignore_hash);
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   215
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   216
  static Symbol* probe_unicode(const jchar* name, int len) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   217
    unsigned int ignore_hash;
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   218
    return lookup_only_unicode(name, len, ignore_hash);
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   219
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  // Histogram
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  static void print_histogram()     PRODUCT_RETURN;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   223
  static void print()     PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  static void verify();
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   227
  static void dump(outputStream* st, bool verbose=false);
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   228
  static void read(const char* filename, TRAPS);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // Sharing
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   231
  static bool copy_compact_table(char** top, char* end);
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   232
  static const char* init_shared_table(const char* buffer);
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   233
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   234
  // Rehash the symbol table if it gets out of balance
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   235
  static void rehash_table();
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   236
  static bool needs_rehashing()         { return _needs_rehashing; }
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   237
  // Parallel chunked scanning
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   238
  static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; }
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   239
  static int parallel_claimed_index()        { return _parallel_claimed_idx; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   242
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP