hotspot/src/share/vm/classfile/dictionary.cpp
author coleenp
Thu, 13 Apr 2017 09:42:10 -0400
changeset 46382 5520c435279b
parent 46380 4a51438196cf
child 46475 75902cea18af
permissions -rw-r--r--
8178336: Unnecessary SystemDictionary walk for Protection domain liveness Summary: remove system dictionary walk and pass strong closure for !ClassUnloading Reviewed-by: jiangli, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42073
diff changeset
     2
 * Copyright (c) 2003, 2017, 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: 5426
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5426
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: 5426
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
#include "precompiled.hpp"
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 34257
diff changeset
    26
#include "classfile/classLoaderData.inline.hpp"
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    27
#include "classfile/sharedClassUtil.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/dictionary.hpp"
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
    29
#include "classfile/protectionDomainCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "classfile/systemDictionary.hpp"
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    31
#include "classfile/systemDictionaryShared.hpp"
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    32
#include "memory/iterator.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 37242
diff changeset
    33
#include "memory/resourceArea.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "oops/oop.inline.hpp"
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22794
diff changeset
    35
#include "runtime/orderAccess.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "utilities/hashtable.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
DictionaryEntry*  Dictionary::_current_class_entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
int               Dictionary::_current_class_index =    0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    41
size_t Dictionary::entry_size() {
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    42
  if (DumpSharedSpaces) {
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    43
    return SystemDictionaryShared::dictionary_entry_size();
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    44
  } else {
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    45
    return sizeof(DictionaryEntry);
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    46
  }
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    47
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
Dictionary::Dictionary(int table_size)
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    50
  : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  _current_class_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  _current_class_entry = NULL;
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    53
  _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
    57
Dictionary::Dictionary(int table_size, HashtableBucket<mtClass>* t,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                       int number_of_entries)
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    59
  : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  _current_class_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  _current_class_entry = NULL;
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    62
  _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
    65
ProtectionDomainCacheEntry* Dictionary::cache_get(Handle protection_domain) {
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    66
  return _pd_cache_table->get(protection_domain);
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    67
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    69
DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    70
                                       ClassLoaderData* loader_data) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    71
  DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    72
  entry->set_loader_data(loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  entry->set_pd_set(NULL);
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33602
diff changeset
    74
  assert(klass->is_instance_klass(), "Must be");
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    75
  if (DumpSharedSpaces) {
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    76
    SystemDictionaryShared::init_shared_dictionary_entry(klass, entry);
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33611
diff changeset
    77
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
void Dictionary::free_entry(DictionaryEntry* entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // avoid recursion when deleting linked list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  while (entry->pd_set() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    ProtectionDomainEntry* to_delete = entry->pd_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    entry->set_pd_set(to_delete->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    delete to_delete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    89
  Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
#ifdef ASSERT
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
    95
  if (protection_domain == klass()->protection_domain()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    // Ensure this doesn't show up in the pd_set (invariant)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    bool in_pd_set = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    for (ProtectionDomainEntry* current = _pd_set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                                current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                                current = current->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      if (current->protection_domain() == protection_domain) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        in_pd_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    if (in_pd_set) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      assert(false, "A klass's protection domain should not show up "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                    "in its sys. dict. PD set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
   113
  if (protection_domain == klass()->protection_domain()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    // Succeeds trivially
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  for (ProtectionDomainEntry* current = _pd_set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
                              current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
                              current = current->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    if (current->protection_domain() == protection_domain) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   127
void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  assert_locked_or_safepoint(SystemDictionary_lock);
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   129
  if (!contains_protection_domain(protection_domain())) {
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   130
    ProtectionDomainCacheEntry* entry = dict->cache_get(protection_domain);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    ProtectionDomainEntry* new_head =
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   132
                new ProtectionDomainEntry(entry, _pd_set);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    // Warning: Preserve store ordering.  The SystemDictionary is read
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    //          without locks.  The new ProtectionDomainEntry must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    //          complete before other threads can be allowed to see it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    //          via a store to _pd_set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    OrderAccess::release_store_ptr(&_pd_set, new_head);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  }
36381
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
   139
  if (log_is_enabled(Trace, protectiondomain)) {
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
   140
    ResourceMark rm;
37242
91e5f98fff6f 8152632: Rename LogHandle(...) to Log(...)
stefank
parents: 36381
diff changeset
   141
    outputStream* log = Log(protectiondomain)::trace_stream();
36381
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
   142
    print_count(log);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents: 25492
diff changeset
   147
void Dictionary::do_unloading() {
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 2534
diff changeset
   148
  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // Remove unloadable entries and classes from system dictionary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  DictionaryEntry* probe = NULL;
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents: 25492
diff changeset
   152
  for (int index = 0; index < table_size(); index++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      probe = *p;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   155
      Klass* e = probe->klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   156
      ClassLoaderData* loader_data = probe->loader_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   158
      InstanceKlass* ik = InstanceKlass::cast(e);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   160
      // Only unload classes that are not strongly reachable
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   161
      if (!is_strongly_reachable(loader_data, e)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        // Entry was not visited in phase1 (negated test from phase1)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   163
        assert(!loader_data->is_the_null_class_loader_data(), "unloading entry with null class loader");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   164
        ClassLoaderData* k_def_class_loader_data = ik->class_loader_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        // Do we need to delete this system dictionary entry?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
        bool purge_entry = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        // Do we need to delete this system dictionary entry?
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   170
        if (loader_data->is_unloading()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
          // If the loader is not live this entry should always be
26174
ca46a107cb78 8054402: "klass->is_loader_alive(_is_alive)) failed: must be alive" for anonymous classes
thartmann
parents: 25492
diff changeset
   172
          // removed (will never be looked up again).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
          purge_entry = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
          // The loader in this entry is alive. If the klass is dead,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   176
          // (determined by checking the defining class loader)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
          // the loader must be an initiating loader (rather than the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
          // defining loader). Remove this entry.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   179
          if (k_def_class_loader_data->is_unloading()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   180
            // If we get here, the class_loader_data must not be the defining
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
            // loader, it must be an initiating one.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   182
            assert(k_def_class_loader_data != loader_data,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
                   "cannot have live defining loader and unreachable klass");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
            // Loader is live, but class and its defining loader are dead.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
            // Remove the entry. The class is going away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
            purge_entry = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
        if (purge_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
          *p = probe->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
          if (probe == _current_class_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
            _current_class_entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
          free_entry(probe);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
          continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      p = probe->next_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   204
void Dictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   205
  // Do strong roots marking if the closures are the same.
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   206
  if (strong == weak || !ClassUnloading) {
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   207
    // Only the protection domain oops contain references into the heap. Iterate
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   208
    // over all of them.
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   209
    _pd_cache_table->oops_do(strong);
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   210
  } else {
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   211
   if (weak != NULL) {
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   212
     _pd_cache_table->oops_do(weak);
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   213
   }
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   214
  }
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
   215
}
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   216
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   218
void Dictionary::remove_classes_in_error_state() {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   219
  assert(DumpSharedSpaces, "supported only when dumping");
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   220
  DictionaryEntry* probe = NULL;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   221
  for (int index = 0; index < table_size(); index++) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   222
    for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   223
      probe = *p;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   224
      InstanceKlass* ik = InstanceKlass::cast(probe->klass());
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   225
      if (ik->is_in_error_state()) { // purge this entry
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   226
        *p = probe->next();
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   227
        if (probe == _current_class_entry) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   228
          _current_class_entry = NULL;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   229
        }
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   230
        free_entry(probe);
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   231
        ResourceMark rm;
27618
790a8bf5488b 8064375: Change certain errors to warnings in CDS output.
jiangli
parents: 26181
diff changeset
   232
        tty->print_cr("Preload Warning: Removed error class: %s", ik->external_name());
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   233
        continue;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   234
      }
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   235
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   236
      p = probe->next_addr();
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   237
    }
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   238
  }
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   239
}
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   240
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   241
//   Just the classes from defining class loaders
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   242
void Dictionary::classes_do(void f(Klass*)) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   243
  for (int index = 0; index < table_size(); index++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   244
    for (DictionaryEntry* probe = bucket(index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   245
                          probe != NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   246
                          probe = probe->next()) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   247
      Klass* k = probe->klass();
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
   248
      if (probe->loader_data() == k->class_loader_data()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
        f(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// Added for initialize_itable_for_klass to handle exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
//   Just the classes from defining class loaders
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   257
void Dictionary::classes_do(void f(Klass*, TRAPS), TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
                          probe = probe->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   262
      Klass* k = probe->klass();
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
   263
      if (probe->loader_data() == k->class_loader_data()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
        f(k, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
//   All classes, and their class loaders
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// Don't iterate over placeholders
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   272
void Dictionary::classes_do(void f(Klass*, ClassLoaderData*)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
                          probe = probe->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   277
      Klass* k = probe->klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   278
      f(k, probe->loader_data());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
void Dictionary::oops_do(OopClosure* f) {
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   284
  // Only the protection domain oops contain references into the heap. Iterate
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   285
  // over all of them.
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   286
  _pd_cache_table->oops_do(f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   289
void Dictionary::unlink(BoolObjectClosure* is_alive) {
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   290
  // Only the protection domain cache table may contain references to the heap
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   291
  // that need to be unlinked.
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   292
  _pd_cache_table->unlink(is_alive);
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   293
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   295
InstanceKlass* Dictionary::try_get_next_class() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  while (true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    if (_current_class_entry != NULL) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   298
      InstanceKlass* k = _current_class_entry->klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
      _current_class_entry = _current_class_entry->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
      return k;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    _current_class_index = (_current_class_index + 1) % table_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    _current_class_entry = bucket(_current_class_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // never reached
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
// Add a loaded class to the system dictionary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
// Readers of the SystemDictionary aren't always locked, so _buckets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
// is volatile. The store of the next field in the constructor is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
// also cast to volatile;  we do this to ensure store order is maintained
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// by the compilers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   314
void Dictionary::add_klass(Symbol* class_name, ClassLoaderData* loader_data,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   315
                           InstanceKlass* obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  assert_locked_or_safepoint(SystemDictionary_lock);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   317
  assert(obj != NULL, "adding NULL obj");
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   318
  assert(obj->name() == class_name, "sanity check on name");
15847
f9ce2cd20dee 8008549: NPG: SystemDictionary::find(...) unnecessarily keeps class loaders alive
stefank
parents: 14588
diff changeset
   319
  assert(loader_data != NULL, "Must be non-NULL");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   321
  unsigned int hash = compute_hash(class_name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  int index = hash_to_index(hash);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   323
  DictionaryEntry* entry = new_entry(hash, obj, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  add_entry(index, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
// This routine does not lock the system dictionary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
// Since readers don't hold a lock, we must make sure that system
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
// dictionary entries are only removed at a safepoint (when only one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
// thread is running), and are added to in a safe way (all links must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// be updated in an MT-safe manner).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
// Callers should be aware that an entry could be added just after
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
// _buckets[index] is read here, so the caller will not see the new entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   338
                                       Symbol* class_name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   339
                                       ClassLoaderData* loader_data) {
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   340
  DEBUG_ONLY(_lookup_count++);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  for (DictionaryEntry* entry = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
                        entry != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                        entry = entry->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   344
    if (entry->hash() == hash && entry->equals(class_name, loader_data)) {
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   345
      DEBUG_ONLY(bucket_count_hit(index));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
      return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    }
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   348
    DEBUG_ONLY(_lookup_length++);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   354
InstanceKlass* Dictionary::find(int index, unsigned int hash, Symbol* name,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   355
                                ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   356
  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    return entry->klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   365
InstanceKlass* Dictionary::find_class(int index, unsigned int hash,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   366
                                      Symbol* name, ClassLoaderData* loader_data) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  assert_locked_or_safepoint(SystemDictionary_lock);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   368
  assert (index == index_for(name, loader_data), "incorrect index?");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   370
  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   371
  return (entry != NULL) ? entry->klass() : NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
// Variant of find_class for shared classes.  No locking required, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
// that table is static.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   378
InstanceKlass* Dictionary::find_shared_class(int index, unsigned int hash,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   379
                                             Symbol* name) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   380
  assert (index == index_for(name, NULL), "incorrect index?");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   382
  DictionaryEntry* entry = get_entry(index, hash, name, NULL);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   383
  return (entry != NULL) ? entry->klass() : NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
void Dictionary::add_protection_domain(int index, unsigned int hash,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   388
                                       InstanceKlass* klass,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   389
                                       ClassLoaderData* loader_data, Handle protection_domain,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
                                       TRAPS) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   391
  Symbol*  klass_name = klass->name();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   392
  DictionaryEntry* entry = get_entry(index, hash, klass_name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  assert(entry != NULL,"entry must be present, we just created it");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  assert(protection_domain() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
         "real protection domain should be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   398
  entry->add_protection_domain(this, protection_domain);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  assert(entry->contains_protection_domain(protection_domain()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
         "now protection domain should be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   406
                                            Symbol* name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   407
                                            ClassLoaderData* loader_data,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
                                            Handle protection_domain) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   409
  DictionaryEntry* entry = get_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  return entry->is_valid_protection_domain(protection_domain);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
void Dictionary::reorder_dictionary() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  // Copy all the dictionary entries into a single master list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  DictionaryEntry* master_list = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  for (int i = 0; i < table_size(); ++i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    DictionaryEntry* p = bucket(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    while (p != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      DictionaryEntry* tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      tmp = p->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      p->set_next(master_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      master_list = p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      p = tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    set_entry(i, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // Add the dictionary entries back to the list in the correct buckets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  while (master_list != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    DictionaryEntry* p = master_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    master_list = master_list->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    p->set_next(NULL);
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
   436
    Symbol* class_name = p->klass()->name();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   437
    // Since the null class loader data isn't copied to the CDS archive,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   438
    // compute the hash with NULL for loader data.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   439
    unsigned int hash = compute_hash(class_name, NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    int index = hash_to_index(hash);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    p->set_hash(hash);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   442
    p->set_loader_data(NULL);   // loader_data isn't copied to CDS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    p->set_next(bucket(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    set_entry(index, p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 34257
diff changeset
   448
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   449
SymbolPropertyTable::SymbolPropertyTable(int table_size)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   450
  : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   451
{
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   452
}
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   453
SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   454
                                         int number_of_entries)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   455
  : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   456
{
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   457
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   458
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   459
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   460
SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   461
                                                     Symbol* sym,
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   462
                                                     intptr_t sym_mode) {
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   463
  assert(index == index_for(sym, sym_mode), "incorrect index?");
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   464
  for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   465
    if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   466
      return p;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   467
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   468
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   469
  return NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   470
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   471
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   472
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   473
SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   474
                                                    Symbol* sym, intptr_t sym_mode) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   475
  assert_locked_or_safepoint(SystemDictionary_lock);
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   476
  assert(index == index_for(sym, sym_mode), "incorrect index?");
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   477
  assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry");
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   478
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   479
  SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   480
  Hashtable<Symbol*, mtSymbol>::add_entry(index, p);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   481
  return p;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   482
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   483
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   484
void SymbolPropertyTable::oops_do(OopClosure* f) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   485
  for (int index = 0; index < table_size(); index++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   486
    for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   487
      if (p->method_type() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   488
        f->do_oop(p->method_type_addr());
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   489
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   490
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   491
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   492
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   493
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   494
void SymbolPropertyTable::methods_do(void f(Method*)) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   495
  for (int index = 0; index < table_size(); index++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   496
    for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   497
      Method* prop = p->method();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   498
      if (prop != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   499
        f((Method*)prop);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   500
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   501
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   502
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   503
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   504
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
// ----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   508
void Dictionary::print(bool details) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   511
  if (details) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   512
    tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   513
                   table_size(), number_of_entries());
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   514
    tty->print_cr("^ indicates that initiating loader is different from "
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   515
                  "defining loader");
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   516
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
                          probe = probe->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   522
      Klass* e = probe->klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   523
      ClassLoaderData* loader_data =  probe->loader_data();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      bool is_defining_class =
33602
16053580a684 8139163: InstanceKlass::cast passes through NULL
coleenp
parents: 33148
diff changeset
   525
         (loader_data == e->class_loader_data());
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   526
      if (details) {
42073
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   527
        tty->print("%4d: ", index);
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   528
      }
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   529
      tty->print("%s%s", ((!details) || is_defining_class) ? " " : "^",
39982
1a3808e3f4d9 8138760: [JVMCI] VM warning: Performance bug: SystemDictionary lookup_count=21831450 lookup_length=1275207287 average=58.411479 load=5.572844
gziemski
parents: 38259
diff changeset
   530
                 e->external_name());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   531
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   532
      if (details) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        tty->print(", loader ");
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   534
        if (loader_data != NULL) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   535
          loader_data->print_value();
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   536
        } else {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   537
          tty->print("NULL");
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   538
        }
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   539
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   543
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   544
  if (details) {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   545
    tty->cr();
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   546
    _pd_cache_table->print();
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
   547
  }
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   548
  tty->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
42073
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   551
#ifdef ASSERT
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   552
void Dictionary::printPerformanceInfoDetails() {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   553
  if (log_is_enabled(Info, hashtables)) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   554
    ResourceMark rm;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   555
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   556
    log_info(hashtables)(" ");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   557
    log_info(hashtables)("Java system dictionary (table_size=%d, classes=%d)",
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   558
                            table_size(), number_of_entries());
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   559
    log_info(hashtables)("1st number: the bucket index");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   560
    log_info(hashtables)("2nd number: the hit percentage for this bucket");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   561
    log_info(hashtables)("3rd number: the entry's index within this bucket");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   562
    log_info(hashtables)("4th number: the hash index of this entry");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   563
    log_info(hashtables)(" ");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   564
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   565
    // find top buckets with highest lookup count
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   566
#define TOP_COUNT 16
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   567
    int topItemsIndicies[TOP_COUNT];
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   568
    for (int i = 0; i < TOP_COUNT; i++) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   569
      topItemsIndicies[i] = i;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   570
    }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   571
    double total = 0.0;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   572
    for (int i = 0; i < table_size(); i++) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   573
      // find the total count number, so later on we can
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   574
      // express bucket lookup count as a percentage of all lookups
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   575
      unsigned value = bucket_hits(i);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   576
      total += value;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   577
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   578
      // find the top entry with min value
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   579
      int min_index = 0;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   580
      unsigned min_value = bucket_hits(topItemsIndicies[min_index]);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   581
      for (int j = 1; j < TOP_COUNT; j++) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   582
        unsigned top_value = bucket_hits(topItemsIndicies[j]);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   583
        if (top_value < min_value) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   584
          min_value = top_value;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   585
          min_index = j;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   586
        }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   587
      }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   588
      // if the bucket loookup value is bigger than the top buckets min
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   589
      // move that bucket index into the top list
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   590
      if (value > min_value) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   591
        topItemsIndicies[min_index] = i;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   592
      }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   593
    }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   594
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   595
    for (int index = 0; index < table_size(); index++) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   596
      double percentage = 100.0 * (double)bucket_hits(index)/total;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   597
      int chain = 0;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   598
      for (DictionaryEntry* probe = bucket(index);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   599
           probe != NULL;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   600
           probe = probe->next()) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   601
        Klass* e = probe->klass();
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   602
        ClassLoaderData* loader_data =  probe->loader_data();
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   603
        bool is_defining_class =
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   604
        (loader_data == e->class_loader_data());
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   605
        log_info(hashtables)("%4d: %5.2f%%: %3d: %10u: %s, loader %s",
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   606
                                index, percentage, chain, probe->hash(), e->external_name(),
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   607
                                (loader_data != NULL) ? loader_data->loader_name() : "NULL");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   608
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   609
        chain++;
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   610
      }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   611
      if (chain == 0) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   612
        log_info(hashtables)("%4d:", index+1);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   613
      }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   614
    }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   615
    log_info(hashtables)(" ");
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   616
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   617
    // print out the TOP_COUNT of buckets with highest lookup count (unsorted)
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   618
    log_info(hashtables)("Top %d buckets:", TOP_COUNT);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   619
    for (int i = 0; i < TOP_COUNT; i++) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   620
      log_info(hashtables)("%4d: hits %5.2f%%",
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   621
                              topItemsIndicies[i],
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   622
                                100.0*(double)bucket_hits(topItemsIndicies[i])/total);
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   623
    }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   624
  }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   625
}
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   626
#endif // ASSERT
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   627
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
void Dictionary::verify() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   630
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  int element_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
                          probe = probe->next()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   636
      Klass* e = probe->klass();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   637
      ClassLoaderData* loader_data = probe->loader_data();
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33602
diff changeset
   638
      guarantee(e->is_instance_klass(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
                              "Verify of system dictionary failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      // class loader must be present;  a null class loader is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      // boostrap loader
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   642
      guarantee(loader_data != NULL || DumpSharedSpaces ||
14588
8ec26d2d9339 8000662: NPG: nashorn ant clean test262 out-of-memory with Java heap
coleenp
parents: 14488
diff changeset
   643
                loader_data->class_loader() == NULL ||
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   644
                loader_data->class_loader()->is_instance(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
                "checking type of class_loader");
22794
f1c014ad3754 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents: 20408
diff changeset
   646
      e->verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
      probe->verify_protection_domain_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
      element_count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  guarantee(number_of_entries() == element_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
            "Verify of system dictionary failed");
42073
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   653
#ifdef ASSERT
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   654
  if (!verify_lookup_length((double)number_of_entries() / table_size(), "System Dictionary")) {
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   655
    this->printPerformanceInfoDetails();
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   656
  }
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   657
#endif // ASSERT
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   658
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   659
  _pd_cache_table->verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   661