src/hotspot/share/classfile/stringTable.hpp
author coleenp
Wed, 18 Apr 2018 10:39:40 -0400
changeset 49816 a3e79f97e86b
parent 49621 5ef28d560b6f
child 50445 bd6b78feb6a3
permissions -rw-r--r--
8200555: OopHandle should use Access API Summary: Add RootAccess<> to OopHandle.resolve() in runtime and interpreter code. Add comments for compiler code for later. Reviewed-by: eosterlund, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     1
/*
49621
5ef28d560b6f 8200276: Cleanup allocation.hpp includes
coleenp
parents: 48618
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     4
 *
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     8
 *
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    13
 * accompanied this code).
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    14
 *
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    18
 *
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    21
 * questions.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    22
 *
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    23
 */
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    24
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_STRINGTABLE_HPP
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_STRINGTABLE_HPP
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    27
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    28
#include "utilities/hashtable.hpp"
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    29
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    30
template <class T, class N> class CompactHashtable;
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37172
diff changeset
    31
class CompactStringTableWriter;
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    32
class FileMapInfo;
37995
92aec042a43b 8150607: Clean up CompactHashtable
iklam
parents: 37172
diff changeset
    33
class SerializeClosure;
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    34
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
    35
class StringTable : public RehashableHashtable<oop, mtSymbol> {
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    36
  friend class VMStructs;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    37
  friend class Symbol;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    38
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    39
private:
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    40
  // The string table
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    41
  static StringTable* _the_table;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    42
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    43
  // Shared string table
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    44
  static CompactHashtable<oop, char> _shared_table;
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
    45
  static bool _shared_string_mapped;
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    46
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    47
  // Set if one bucket is out of balance due to hash algorithm deficiency
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    48
  static bool _needs_rehashing;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    49
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    50
  // Claimed high water mark for parallel chunked scanning
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    51
  static volatile int _parallel_claimed_idx;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    52
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    53
  static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    54
  oop basic_add(int index, Handle string_or_null, jchar* name, int len,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    55
                unsigned int hashValue, TRAPS);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    56
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
    57
  oop lookup_in_main_table(int index, jchar* chars, int length, unsigned int hashValue);
44323
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    58
  static oop lookup_shared(jchar* name, int len, unsigned int hash);
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    59
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    60
  // Apply the give oop closure to the entries to the buckets
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    61
  // in the range [start_idx, end_idx).
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    62
  static void buckets_oops_do(OopClosure* f, int start_idx, int end_idx);
45114
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    63
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    64
  typedef StringTable::BucketUnlinkContext BucketUnlinkContext;
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    65
  // Unlink or apply the give oop closure to the entries to the buckets
45114
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    66
  // in the range [start_idx, end_idx). Unlinked bucket entries are collected in the given
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    67
  // context to be freed later.
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    68
  // This allows multiple threads to work on the table at once.
45644c5f6b8e 8180048: Interned string and symbol table leak memory during parallel unlinking
tschatzl
parents: 44323
diff changeset
    69
  static void buckets_unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* f, int start_idx, int end_idx, BucketUnlinkContext* context);
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    70
44323
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    71
  // Hashing algorithm, used as the hash value used by the
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    72
  //     StringTable for bucket selection and comparison (stored in the
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    73
  //     HashtableEntry structures).  This is used in the String.intern() method.
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    74
  static unsigned int hash_string(const jchar* s, int len);
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    75
  static unsigned int hash_string(oop string);
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    76
  static unsigned int alt_hash_string(const jchar* s, int len);
1566bea4793a 8176593: Throwable::getStackTrace performance regression
redestad
parents: 37995
diff changeset
    77
48618
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    78
  // Accessors for the string roots in the hashtable entries.
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    79
  // Use string_object_no_keepalive() only when the value is not returned
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    80
  // outside of a scope where a thread transition is possible.
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    81
  static oop string_object(HashtableEntry<oop, mtSymbol>* entry);
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    82
  static oop string_object_no_keepalive(HashtableEntry<oop, mtSymbol>* entry);
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    83
  static void set_string_object(HashtableEntry<oop, mtSymbol>* entry, oop string);
688e5cbd0b91 8192003: Refactor weak references in StringTable to use the Access API
eosterlund
parents: 48157
diff changeset
    84
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
    85
  StringTable() : RehashableHashtable<oop, mtSymbol>((int)StringTableSize,
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    86
                              sizeof (HashtableEntry<oop, mtSymbol>)) {}
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    87
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    88
  StringTable(HashtableBucket<mtSymbol>* t, int number_of_entries)
26421
37d88e604ad0 8056084: Refactor Hashtable to allow implementations without rehashing support
mgerdin
parents: 24426
diff changeset
    89
    : RehashableHashtable<oop, mtSymbol>((int)StringTableSize, sizeof (HashtableEntry<oop, mtSymbol>), t,
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    90
                     number_of_entries) {}
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    91
public:
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    92
  // The string table
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    93
  static StringTable* the_table() { return _the_table; }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    94
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    95
  // Size of one bucket in the string table.  Used when checking for rollover.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    96
  static uint bucket_size() { return sizeof(HashtableBucket<mtSymbol>); }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    97
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    98
  static void create_table() {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
    99
    assert(_the_table == NULL, "One string table allowed.");
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   100
    _the_table = new StringTable();
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   101
  }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   102
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   103
  // GC support
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   104
  //   Delete pointers to otherwise-unreachable objects.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   105
  static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f) {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   106
    int processed = 0;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   107
    int removed = 0;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   108
    unlink_or_oops_do(cl, f, &processed, &removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   109
  }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   110
  static void unlink(BoolObjectClosure* cl) {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   111
    int processed = 0;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   112
    int removed = 0;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   113
    unlink_or_oops_do(cl, NULL, &processed, &removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   114
  }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   115
  static void unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f, int* processed, int* removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   116
  static void unlink(BoolObjectClosure* cl, int* processed, int* removed) {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   117
    unlink_or_oops_do(cl, NULL, processed, removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   118
  }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   119
  // Serially invoke "f->do_oop" on the locations of all oops in the table.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   120
  static void oops_do(OopClosure* f);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   121
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   122
  // Possibly parallel versions of the above
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   123
  static void possibly_parallel_unlink_or_oops_do(BoolObjectClosure* cl, OopClosure* f, int* processed, int* removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   124
  static void possibly_parallel_unlink(BoolObjectClosure* cl, int* processed, int* removed) {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   125
    possibly_parallel_unlink_or_oops_do(cl, NULL, processed, removed);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   126
  }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   127
  static void possibly_parallel_oops_do(OopClosure* f);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   128
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   129
  // Internal test.
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   130
  static void test_alt_hash() PRODUCT_RETURN;
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   131
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   132
  // Probing
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   133
  static oop lookup(Symbol* symbol);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   134
  static oop lookup(jchar* chars, int length);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   135
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   136
  // Interning
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   137
  static oop intern(Symbol* symbol, TRAPS);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   138
  static oop intern(oop string, TRAPS);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   139
  static oop intern(const char *utf8_string, TRAPS);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   140
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   141
  // Debugging
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   142
  static void verify();
28363
047115468f16 8059510: Compact symbol table layout inside shared archive.
jiangli
parents: 26421
diff changeset
   143
  static void dump(outputStream* st, bool verbose=false);
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   144
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   145
  enum VerifyMesgModes {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   146
    _verify_quietly    = 0,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   147
    _verify_with_mesgs = 1
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   148
  };
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   149
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   150
  enum VerifyRetTypes {
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   151
    _verify_pass          = 0,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   152
    _verify_fail_continue = 1,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   153
    _verify_fail_done     = 2
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   154
  };
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   155
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   156
  static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   157
                                        HashtableEntry<oop, mtSymbol>* e_ptr1,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   158
                                        int bkt2, int e_cnt2,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   159
                                        HashtableEntry<oop, mtSymbol>* e_ptr2);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   160
  static VerifyRetTypes verify_entry(int bkt, int e_cnt,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   161
                                     HashtableEntry<oop, mtSymbol>* e_ptr,
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   162
                                     VerifyMesgModes mesg_mode);
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   163
  static int verify_and_compare_entries();
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   164
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   165
  // Sharing
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   166
  static void set_shared_string_mapped() { _shared_string_mapped = true; }
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   167
  static bool shared_string_mapped()       { return _shared_string_mapped; }
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   168
  static void shared_oops_do(OopClosure* f) NOT_CDS_JAVA_HEAP_RETURN;
31345
1bba15125d8d 8015086: add interned strings to the shared archive.
jiangli
parents: 28363
diff changeset
   169
  static bool copy_shared_string(GrowableArray<MemRegion> *string_space,
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   170
                                 CompactStringTableWriter* ch_table) NOT_CDS_JAVA_HEAP_RETURN_(false);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   171
  static oop  create_archived_string(oop s, Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   172
  static void write_to_archive(GrowableArray<MemRegion> *string_space) NOT_CDS_JAVA_HEAP_RETURN;
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46746
diff changeset
   173
  static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
24426
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   174
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   175
  // Rehash the symbol table if it gets out of balance
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   176
  static void rehash_table();
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   177
  static bool needs_rehashing() { return _needs_rehashing; }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   178
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   179
  // Parallel chunked scanning
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   180
  static void clear_parallel_claimed_index() { _parallel_claimed_idx = 0; }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   181
  static int parallel_claimed_index() { return _parallel_claimed_idx; }
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   182
};
0a69c8cdfca9 8038654: Separate SymbolTable and StringTable code
gziemski
parents:
diff changeset
   183
#endif // SHARE_VM_CLASSFILE_STRINGTABLE_HPP