src/hotspot/share/classfile/symbolTable.hpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 54927 1512d88b24c6
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 52951
diff changeset
     2
 * Copyright (c) 1997, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    25
#ifndef SHARE_CLASSFILE_SYMBOLTABLE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    26
#define SHARE_CLASSFILE_SYMBOLTABLE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
    28
#include "memory/allocation.hpp"
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    29
#include "memory/padded.hpp"
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    30
#include "oops/symbol.hpp"
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
    31
#include "utilities/tableStatistics.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 52951
diff changeset
    33
class JavaThread;
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 52951
diff changeset
    34
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    35
// TempNewSymbol acts as a handle class in a handle/body idiom and is
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    36
// responsible for proper resource management of the body (which is a Symbol*).
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    37
// The body is resource managed by a reference counting scheme.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    38
// TempNewSymbol can therefore be used to properly hold a newly created or referenced
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    39
// Symbol* temporarily in scope.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    40
//
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    41
// Routines in SymbolTable will initialize the reference count of a Symbol* before
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    42
// it becomes "managed" by TempNewSymbol instances. As a handle class, TempNewSymbol
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    43
// needs to maintain proper reference counting in context of copy semantics.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    44
//
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
    45
// In SymbolTable, new_symbol() will create a Symbol* if not already in the
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    46
// 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
    47
// 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
    48
class TempNewSymbol : public StackObj {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    49
  Symbol* _temp;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    50
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    51
public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    52
  TempNewSymbol() : _temp(NULL) {}
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    53
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    54
  // Conversion from a Symbol* to a TempNewSymbol.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    55
  // Does not increment the current reference count.
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    56
  TempNewSymbol(Symbol *s) : _temp(s) {}
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    57
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    58
  // Copy constructor increments reference count.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    59
  TempNewSymbol(const TempNewSymbol& rhs) : _temp(rhs._temp) {
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    60
    if (_temp != NULL) {
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    61
      _temp->increment_refcount();
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    62
    }
8076
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
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    65
  // Assignment operator uses a c++ trick called copy and swap idiom.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    66
  // rhs is passed by value so within the scope of this method it is a copy.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    67
  // At method exit it contains the former value of _temp, triggering the correct refcount
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    68
  // decrement upon destruction.
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    69
  void operator=(TempNewSymbol rhs) {
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    70
    Symbol* tmp = rhs._temp;
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    71
    rhs._temp = _temp;
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    72
    _temp = tmp;
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    73
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 13199
diff changeset
    74
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    75
  // Decrement reference counter so it can go away if it's unused
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    76
  ~TempNewSymbol() {
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    77
    if (_temp != NULL) {
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    78
      _temp->decrement_refcount();
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    79
    }
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    80
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    81
35497
94c7c07d0161 8145940: TempNewSymbol should have correct copy and assignment functions
coleenp
parents: 34237
diff changeset
    82
  // Symbol* conversion operators
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    83
  Symbol* operator -> () const                   { return _temp; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    84
  bool    operator == (Symbol* o) const          { return _temp == o; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    85
  operator Symbol*()                             { return _temp; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    86
};
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    87
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51823
diff changeset
    88
class CompactHashtableWriter;
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    89
class SerializeClosure;
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
    90
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    91
class SymbolTableConfig;
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    92
class SymbolTableCreateEntry;
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    93
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
    94
class constantPoolHandle;
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
    95
class SymbolClosure;
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
    96
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
    97
class SymbolTable : public AllStatic {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  friend class VMStructs;
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
    99
  friend class Symbol;
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   100
  friend class ClassFileParser;
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   101
  friend class SymbolTableConfig;
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   102
  friend class SymbolTableCreateEntry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   104
 private:
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   105
  static volatile bool _has_work;
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   106
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   107
  // Set if one bucket is out of balance due to hash algorithm deficiency
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   108
  static volatile bool _needs_rehashing;
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   109
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   110
  static void delete_symbol(Symbol* sym);
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   111
  static void grow(JavaThread* jt);
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   112
  static void clean_dead_entries(JavaThread* jt);
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   113
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   114
  static double get_load_factor();
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   115
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   116
  static void check_concurrent_work();
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   117
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   118
  static void item_added();
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   119
  static void item_removed();
53587
739eaf4ac4ad 8213753: SymbolTable is double walked during class unloading and clean up table timing in do_unloading
coleenp
parents: 53244
diff changeset
   120
739eaf4ac4ad 8213753: SymbolTable is double walked during class unloading and clean up table timing in do_unloading
coleenp
parents: 53244
diff changeset
   121
  // For cleaning
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   122
  static void reset_has_items_to_clean();
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   123
  static void mark_has_items_to_clean();
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   124
  static bool has_items_to_clean();
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   125
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   126
  static Symbol* allocate_symbol(const char* name, int len, bool c_heap); // Assumes no characters larger than 0x7F
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   127
  static Symbol* do_lookup(const char* name, int len, uintx hash);
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   128
  static Symbol* do_add_if_needed(const char* name, int len, uintx hash, bool heap);
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   129
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   130
  // lookup only, won't add. Also calculate hash. Used by the ClassfileParser.
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   131
  static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   132
  static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   133
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Adding elements
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   135
  static void new_symbols(ClassLoaderData* loader_data,
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 28363
diff changeset
   136
                          const constantPoolHandle& cp, int names_count,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   137
                          const char** name, int* lengths,
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   138
                          int* cp_indices, unsigned int* hashValues);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   139
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54896
diff changeset
   140
  static Symbol* lookup_shared(const char* name, int len, unsigned int hash) NOT_CDS_RETURN_(NULL);
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   141
  static Symbol* lookup_dynamic(const char* name, int len, unsigned int hash);
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   142
  static Symbol* lookup_common(const char* name, int len, unsigned int hash);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   144
  // 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
   145
  static Arena*  _arena;
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   146
  static Arena* arena() { return _arena; }  // called for statistics
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   148
  static void print_table_statistics(outputStream* st, const char* table_name);
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   149
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   150
  static void try_rehash_table();
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   151
  static bool do_rehash();
22545
b93a7f0e9b9d 8027476: Improve performance of Stringtable unlink
tschatzl
parents: 20393
diff changeset
   152
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
public:
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   154
  // The symbol table
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   155
  static size_t table_size();
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   156
  static TableStatistics get_table_statistics();
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   157
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  enum {
12263
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   159
    symbol_alloc_batch_size = 8,
d20640f4f8fe 7150058: Allocate symbols from null boot loader to an arena for NMT
coleenp
parents: 11480
diff changeset
   160
    // Pick initial size based on java -version size measurements
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   161
    symbol_alloc_arena_size = 360*K // TODO (revisit)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   164
  static void create_table();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   166
  static void do_concurrent_work(JavaThread* jt);
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   167
  static bool has_work() { return _has_work; }
53587
739eaf4ac4ad 8213753: SymbolTable is double walked during class unloading and clean up table timing in do_unloading
coleenp
parents: 53244
diff changeset
   168
  static void trigger_cleanup();
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   169
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   170
  // Probing
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Needed for preloading classes in signatures when compiling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // Returns the symbol is already present in symbol table, otherwise
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // NULL.  NO ALLOCATION IS GUARANTEED!
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   174
  static Symbol* probe(const char* name, int len) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   175
    unsigned int ignore_hash;
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   176
    return lookup_only(name, len, ignore_hash);
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   177
  }
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   178
  static Symbol* probe_unicode(const jchar* name, int len) {
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   179
    unsigned int ignore_hash;
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   180
    return lookup_only_unicode(name, len, ignore_hash);
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
   181
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   183
  // Symbol lookup and create if not found.
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   184
  // jchar (UTF16) version of lookup
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   185
  static Symbol* new_symbol(const jchar* name, int len);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   186
  // char (UTF8) versions
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   187
  static Symbol* new_symbol(const Symbol* sym, int begin, int end);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   188
  static Symbol* new_symbol(const char* utf8_buffer, int length);
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   189
  static Symbol* new_symbol(const char* name) {
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   190
    return new_symbol(name, (int)strlen(name));
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   191
  }
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   192
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   193
  // Create a symbol in the arena for symbols that are not deleted
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54764
diff changeset
   194
  static Symbol* new_permanent_symbol(const char* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   196
  // Rehash the string table if it gets out of balance
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   197
  static void rehash_table();
54896
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   198
  static bool needs_rehashing() { return _needs_rehashing; }
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   199
  static inline void update_needs_rehash(bool rehash) {
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   200
    if (rehash) {
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   201
      _needs_rehashing = true;
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   202
    }
ea619918de95 8223956: Make SymbolTable and StringTable AllStatic
coleenp
parents: 54847
diff changeset
   203
  }
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   204
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   205
  // Heap dumper and CDS
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   206
  static void symbols_do(SymbolClosure *cl);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // Sharing
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   209
private:
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51823
diff changeset
   210
  static void copy_shared_symbol_table(CompactHashtableWriter* ch_table);
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   211
public:
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54896
diff changeset
   212
  static size_t estimate_size_for_archive() NOT_CDS_RETURN_(0);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54896
diff changeset
   213
  static void write_to_archive(bool is_static_archive = true) NOT_CDS_RETURN;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54896
diff changeset
   214
  static void serialize_shared_table_header(SerializeClosure* soc,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54896
diff changeset
   215
                                            bool is_static_archive = true) NOT_CDS_RETURN;
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   216
  static void metaspace_pointers_do(MetaspaceClosure* it);
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 12263
diff changeset
   217
51405
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   218
  // Jcmd
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   219
  static void dump(outputStream* st, bool verbose=false);
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   220
  // Debugging
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   221
  static void verify();
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   222
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   223
  // Histogram
8b23aa7cef47 8195100: Use a low latency hashtable for SymbolTable
gziemski
parents: 48157
diff changeset
   224
  static void print_histogram() PRODUCT_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
   227
#endif // SHARE_CLASSFILE_SYMBOLTABLE_HPP