src/hotspot/share/classfile/dictionary.cpp
author pliden
Tue, 17 Sep 2019 09:51:02 +0200
changeset 58177 4932dce35882
parent 54927 1512d88b24c6
child 58447 319173c62caa
permissions -rw-r--r--
8230841: Remove oopDesc::equals() Reviewed-by: rkennke, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53601
112ad164d26c 8215505: Cleanup jvm.cpp obsolete code after JDK-8210094: Better loading of classloader classes
coleenp
parents: 53322
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 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"
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
    27
#include "classfile/dictionary.hpp"
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
    28
#include "classfile/protectionDomainCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "classfile/systemDictionary.hpp"
46701
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
    30
#include "logging/log.hpp"
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
    31
#include "logging/logStream.hpp"
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    32
#include "memory/iterator.hpp"
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
    33
#include "memory/metaspaceClosure.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 37242
diff changeset
    34
#include "memory/resourceArea.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "oops/oop.inline.hpp"
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    36
#include "runtime/atomic.hpp"
50429
83aec1d357d4 8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents: 50039
diff changeset
    37
#include "runtime/orderAccess.hpp"
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
    38
#include "runtime/mutexLocker.hpp"
49594
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents: 49348
diff changeset
    39
#include "runtime/safepointVerifiers.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "utilities/hashtable.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    42
// Optimization: if any dictionary needs resizing, we set this flag,
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    43
// so that we dont't have to walk all dictionaries to check if any actually
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    44
// needs resizing, which is costly to do at Safepoint.
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    45
bool Dictionary::_some_dictionary_needs_resizing = false;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    46
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    47
Dictionary::Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable)
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52340
diff changeset
    48
  : Hashtable<InstanceKlass*, mtClass>(table_size, (int)sizeof(DictionaryEntry)),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 50634
diff changeset
    49
    _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    53
Dictionary::Dictionary(ClassLoaderData* loader_data,
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    54
                       int table_size, HashtableBucket<mtClass>* t,
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    55
                       int number_of_entries, bool resizable)
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52340
diff changeset
    56
  : Hashtable<InstanceKlass*, mtClass>(table_size, (int)sizeof(DictionaryEntry), t, number_of_entries),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 50634
diff changeset
    57
    _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    60
Dictionary::~Dictionary() {
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    61
  DictionaryEntry* probe = NULL;
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    62
  for (int index = 0; index < table_size(); index++) {
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    63
    for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    64
      probe = *p;
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    65
      *p = probe->next();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    66
      free_entry(probe);
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    67
    }
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    68
  }
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    69
  assert(number_of_entries() == 0, "should have removed all entries");
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    70
  assert(new_entry_free_list() == NULL, "entry present on Dictionary's free list");
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
    71
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    73
DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) {
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    74
  DictionaryEntry* entry = (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::allocate_new_entry(hash, klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  entry->set_pd_set(NULL);
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33602
diff changeset
    76
  assert(klass->is_instance_klass(), "Must be");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
void Dictionary::free_entry(DictionaryEntry* entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // avoid recursion when deleting linked list
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
    83
  // pd_set is accessed during a safepoint.
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
    84
  // This doesn't require a lock because nothing is reading this
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
    85
  // entry anymore.  The ClassLoader is dead.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  while (entry->pd_set() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    ProtectionDomainEntry* to_delete = entry->pd_set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    entry->set_pd_set(to_delete->next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    delete to_delete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    91
  // Unlink from the Hashtable prior to freeing
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    92
  unlink_entry(entry);
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
    93
  FREE_C_HEAP_ARRAY(char, entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    96
const int _resize_load_trigger = 5;       // load factor that will trigger the resize
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    97
const double _resize_factor    = 2.0;     // by how much we will resize using current number of entries
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    98
const int _resize_max_size     = 40423;   // the max dictionary size allowed
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    99
const int _primelist[] = {107, 1009, 2017, 4049, 5051, 10103, 20201, _resize_max_size};
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   100
const int _prime_array_size = sizeof(_primelist)/sizeof(int);
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   101
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   102
// Calculate next "good" dictionary size based on requested count
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   103
static int calculate_dictionary_size(int requested) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   104
  int newsize = _primelist[0];
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   105
  int index = 0;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   106
  for (newsize = _primelist[index]; index < (_prime_array_size - 1);
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   107
       newsize = _primelist[++index]) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   108
    if (requested <= newsize) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   109
      break;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   110
    }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   111
  }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   112
  return newsize;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   113
}
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   114
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   115
bool Dictionary::does_any_dictionary_needs_resizing() {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   116
  return Dictionary::_some_dictionary_needs_resizing;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   117
}
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   118
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   119
void Dictionary::check_if_needs_resize() {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   120
  if (_resizable == true) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   121
    if (number_of_entries() > (_resize_load_trigger*table_size())) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   122
      _needs_resizing = true;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   123
      Dictionary::_some_dictionary_needs_resizing = true;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   124
    }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   125
  }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   126
}
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   127
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   128
bool Dictionary::resize_if_needed() {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   129
  int desired_size = 0;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   130
  if (_needs_resizing == true) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   131
    desired_size = calculate_dictionary_size((int)(_resize_factor*number_of_entries()));
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   132
    if (desired_size >= _resize_max_size) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   133
      desired_size = _resize_max_size;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   134
      // We have reached the limit, turn resizing off
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   135
      _resizable = false;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   136
    }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   137
    if ((desired_size != 0) && (desired_size != table_size())) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   138
      if (!resize(desired_size)) {
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   139
        // Something went wrong, turn resizing off
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   140
        _resizable = false;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   141
      }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   142
    }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   143
  }
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   144
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   145
  _needs_resizing = false;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   146
  Dictionary::_some_dictionary_needs_resizing = false;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   147
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   148
  return (desired_size != 0);
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   149
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
bool DictionaryEntry::contains_protection_domain(oop protection_domain) const {
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   152
  // Lock the pd_set list.  This lock cannot safepoint since the caller holds
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   153
  // a Dictionary entry, which can be moved if the Dictionary is resized.
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53962
diff changeset
   154
  MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
#ifdef ASSERT
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 54927
diff changeset
   156
  if (protection_domain == instance_klass()->protection_domain()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    // Ensure this doesn't show up in the pd_set (invariant)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    bool in_pd_set = false;
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   159
    for (ProtectionDomainEntry* current = pd_set();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
                                current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
                                current = current->next()) {
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 54927
diff changeset
   162
      if (current->object_no_keepalive() == protection_domain) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
        in_pd_set = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    if (in_pd_set) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      assert(false, "A klass's protection domain should not show up "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                    "in its sys. dict. PD set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#endif /* ASSERT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 54927
diff changeset
   174
  if (protection_domain == instance_klass()->protection_domain()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // Succeeds trivially
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   179
  for (ProtectionDomainEntry* current = pd_set();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
                              current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
                              current = current->next()) {
58177
4932dce35882 8230841: Remove oopDesc::equals()
pliden
parents: 54927
diff changeset
   182
    if (current->object_no_keepalive() == protection_domain) return true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   188
void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  assert_locked_or_safepoint(SystemDictionary_lock);
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   190
  if (!contains_protection_domain(protection_domain())) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   191
    ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain);
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   192
    // The pd_set in the dictionary entry is protected by a low level lock.
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   193
    // With concurrent PD table cleanup, these links could be broken.
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53962
diff changeset
   194
    MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    ProtectionDomainEntry* new_head =
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   196
                new ProtectionDomainEntry(entry, pd_set());
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   197
    set_pd_set(new_head);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  }
46701
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
   199
  LogTarget(Trace, protectiondomain) lt;
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
   200
  if (lt.is_enabled()) {
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
   201
    LogStream ls(lt);
f559541c0daa 8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents: 46475
diff changeset
   202
    print_count(&ls);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   206
//   Just the classes from defining class loaders
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   207
void Dictionary::classes_do(void f(InstanceKlass*)) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   208
  for (int index = 0; index < table_size(); index++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   209
    for (DictionaryEntry* probe = bucket(index);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   210
                          probe != NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   211
                          probe = probe->next()) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   212
      InstanceKlass* k = probe->instance_klass();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   213
      if (loader_data() == k->class_loader_data()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        f(k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
// Added for initialize_itable_for_klass to handle exceptions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
//   Just the classes from defining class loaders
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   222
void Dictionary::classes_do(void f(InstanceKlass*, TRAPS), TRAPS) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
                          probe = probe->next()) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   227
      InstanceKlass* k = probe->instance_klass();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   228
      if (loader_data() == k->class_loader_data()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        f(k, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   235
// All classes, and their class loaders, including initiating class loaders
51530
1f0b605bdc28 8209821: Make JVMTI GetClassLoaderClasses not walk CLDG
coleenp
parents: 51523
diff changeset
   236
void Dictionary::all_entries_do(KlassClosure* closure) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
                          probe = probe->next()) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   241
      InstanceKlass* k = probe->instance_klass();
51530
1f0b605bdc28 8209821: Make JVMTI GetClassLoaderClasses not walk CLDG
coleenp
parents: 51523
diff changeset
   242
      closure->do_klass(k);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   247
// Used to scan and relocate the classes during CDS archive dump.
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   248
void Dictionary::classes_do(MetaspaceClosure* it) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54623
diff changeset
   249
  assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump-time only");
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   250
  for (int index = 0; index < table_size(); index++) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   251
    for (DictionaryEntry* probe = bucket(index);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   252
                          probe != NULL;
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   253
                          probe = probe->next()) {
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   254
      it->push(probe->klass_addr());
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   255
    }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   256
  }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   257
}
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   258
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   259
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   261
// Add a loaded class to the dictionary.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
// Readers of the SystemDictionary aren't always locked, so _buckets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// is volatile. The store of the next field in the constructor is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
// also cast to volatile;  we do this to ensure store order is maintained
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
// by the compilers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   267
void Dictionary::add_klass(unsigned int hash, Symbol* class_name,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   268
                           InstanceKlass* obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  assert_locked_or_safepoint(SystemDictionary_lock);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   270
  assert(obj != NULL, "adding NULL obj");
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   271
  assert(obj->name() == class_name, "sanity check on name");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   273
  DictionaryEntry* entry = new_entry(hash, obj);
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   274
  int index = hash_to_index(hash);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  add_entry(index, entry);
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   276
  check_if_needs_resize();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   280
// This routine does not lock the dictionary.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
// Since readers don't hold a lock, we must make sure that system
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// dictionary entries are only removed at a safepoint (when only one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// thread is running), and are added to in a safe way (all links must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// be updated in an MT-safe manner).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// Callers should be aware that an entry could be added just after
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// _buckets[index] is read here, so the caller will not see the new entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   290
                                       Symbol* class_name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  for (DictionaryEntry* entry = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
                        entry != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
                        entry = entry->next()) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   294
    if (entry->hash() == hash && entry->equals(class_name)) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52340
diff changeset
   295
      return entry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   302
InstanceKlass* Dictionary::find(unsigned int hash, Symbol* name,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   303
                                Handle protection_domain) {
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   304
  NoSafepointVerifier nsv;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   305
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   306
  int index = hash_to_index(hash);
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   307
  DictionaryEntry* entry = get_entry(index, hash, name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   309
    return entry->instance_klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   315
InstanceKlass* Dictionary::find_class(int index, unsigned int hash,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   316
                                      Symbol* name) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  assert_locked_or_safepoint(SystemDictionary_lock);
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   318
  assert (index == index_for(name), "incorrect index?");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   320
  DictionaryEntry* entry = get_entry(index, hash, name);
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   321
  return (entry != NULL) ? entry->instance_klass() : NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
void Dictionary::add_protection_domain(int index, unsigned int hash,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   326
                                       InstanceKlass* klass,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   327
                                       Handle protection_domain,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
                                       TRAPS) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   329
  Symbol*  klass_name = klass->name();
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   330
  DictionaryEntry* entry = get_entry(index, hash, klass_name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  assert(entry != NULL,"entry must be present, we just created it");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  assert(protection_domain() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
         "real protection domain should be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 46271
diff changeset
   336
  entry->add_protection_domain(this, protection_domain);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
48811
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
   338
#ifdef ASSERT
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
   339
  assert(loader_data() != ClassLoaderData::the_null_class_loader_data(), "doesn't make sense");
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
   340
#endif
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
   341
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  assert(entry->contains_protection_domain(protection_domain()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
         "now protection domain should be present");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   347
bool Dictionary::is_valid_protection_domain(unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   348
                                            Symbol* name,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
                                            Handle protection_domain) {
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
   350
  int index = hash_to_index(hash);
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   351
  DictionaryEntry* entry = get_entry(index, hash, name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  return entry->is_valid_protection_domain(protection_domain);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   355
// During class loading we may have cached a protection domain that has
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   356
// since been unreferenced, so this entry should be cleared.
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   357
void Dictionary::clean_cached_protection_domains() {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   358
  assert_locked_or_safepoint(SystemDictionary_lock);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   359
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   360
  if (loader_data()->is_the_null_class_loader_data()) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   361
    // Classes in the boot loader are not loaded with protection domains
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   362
    return;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   363
  }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   364
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   365
  for (int index = 0; index < table_size(); index++) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   366
    for (DictionaryEntry* probe = bucket(index);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   367
                          probe != NULL;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   368
                          probe = probe->next()) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   369
      Klass* e = probe->instance_klass();
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   370
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53962
diff changeset
   371
      MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   372
      ProtectionDomainEntry* current = probe->pd_set();
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   373
      ProtectionDomainEntry* prev = NULL;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   374
      while (current != NULL) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   375
        if (current->object_no_keepalive() == NULL) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   376
          LogTarget(Debug, protectiondomain) lt;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   377
          if (lt.is_enabled()) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   378
            ResourceMark rm;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   379
            // Print out trace information
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   380
            LogStream ls(lt);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   381
            ls.print_cr("PD in set is not alive:");
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   382
            ls.print("class loader: "); loader_data()->class_loader()->print_value_on(&ls);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   383
            ls.print(" loading: "); probe->instance_klass()->print_value_on(&ls);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   384
            ls.cr();
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   385
          }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   386
          if (probe->pd_set() == current) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   387
            probe->set_pd_set(current->next());
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   388
          } else {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   389
            assert(prev != NULL, "should be set by alive entry");
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   390
            prev->set_next(current->next());
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   391
          }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   392
          ProtectionDomainEntry* to_delete = current;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   393
          current = current->next();
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   394
          delete to_delete;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   395
        } else {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   396
          prev = current;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   397
          current = current->next();
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   398
        }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   399
      }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   400
    }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   401
  }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   402
}
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   403
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   404
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   405
SymbolPropertyTable::SymbolPropertyTable(int table_size)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   406
  : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   407
{
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   408
}
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   409
SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t,
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   410
                                         int number_of_entries)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   411
  : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   412
{
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   413
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   414
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   415
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   416
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
   417
                                                     Symbol* sym,
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   418
                                                     intptr_t sym_mode) {
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   419
  assert(index == index_for(sym, sym_mode), "incorrect index?");
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   420
  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
   421
    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
   422
      return p;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   423
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   424
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   425
  return NULL;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   426
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   427
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   428
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   429
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
   430
                                                    Symbol* sym, intptr_t sym_mode) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   431
  assert_locked_or_safepoint(SystemDictionary_lock);
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   432
  assert(index == index_for(sym, sym_mode), "incorrect index?");
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   433
  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
   434
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   435
  SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11628
diff changeset
   436
  Hashtable<Symbol*, mtSymbol>::add_entry(index, p);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   437
  return p;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   438
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   439
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   440
void SymbolPropertyTable::oops_do(OopClosure* f) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   441
  for (int index = 0; index < table_size(); index++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   442
    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
   443
      if (p->method_type() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   444
        f->do_oop(p->method_type_addr());
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   445
      }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   446
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   447
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   448
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   449
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   450
void SymbolPropertyTable::methods_do(void f(Method*)) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   451
  for (int index = 0; index < table_size(); index++) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 670
diff changeset
   452
    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
   453
      Method* prop = p->method();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   454
      if (prop != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   455
        f((Method*)prop);
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
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   461
void DictionaryEntry::verify_protection_domain_set() {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53962
diff changeset
   462
  MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   463
  for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   464
                              current != NULL;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   465
                              current = current->_next) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   466
    guarantee(oopDesc::is_oop_or_null(current->_pd_cache->object_no_keepalive()), "Invalid oop");
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   467
  }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   468
}
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   469
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   470
void DictionaryEntry::print_count(outputStream *st) {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53962
diff changeset
   471
  MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
53962
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   472
  int count = 0;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   473
  for (ProtectionDomainEntry* current = pd_set();  // accessed inside SD lock
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   474
                              current != NULL;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   475
                              current = current->_next) {
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   476
    count++;
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   477
  }
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   478
  st->print_cr("pd set count = #%d", count);
2653e078b057 8218266: G1 crash in AccessInternal::PostRuntimeDispatch
coleenp
parents: 53601
diff changeset
   479
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
// ----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   483
void Dictionary::print_on(outputStream* st) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   486
  assert(loader_data() != NULL, "loader data should not be null");
51523
73523d329966 8208061: runtime/LoadClass/TestResize.java fails with "Load factor too high" when running in CDS mode.
jiangli
parents: 51334
diff changeset
   487
  st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
73523d329966 8208061: runtime/LoadClass/TestResize.java fails with "Load factor too high" when running in CDS mode.
jiangli
parents: 51334
diff changeset
   488
               table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   489
  st->print_cr("^ indicates that initiating loader is different from defining loader");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  for (int index = 0; index < table_size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    for (DictionaryEntry* probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
                          probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
                          probe = probe->next()) {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   495
      Klass* e = probe->instance_klass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
      bool is_defining_class =
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   497
         (loader_data() == e->class_loader_data());
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   498
      st->print("%4d: %s%s", index, is_defining_class ? " " : "^", e->external_name());
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   499
      ClassLoaderData* cld = e->class_loader_data();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52340
diff changeset
   500
      if (!loader_data()->is_the_null_class_loader_data()) {
49348
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   501
        // Class loader output for the dictionary for the null class loader data is
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   502
        // redundant and obvious.
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   503
        st->print(", ");
fde3feaaa4ed 8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents: 49340
diff changeset
   504
        cld->print_value_on(st);
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
   505
      }
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   506
      st->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  }
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 18439
diff changeset
   509
  tty->cr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
46475
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   512
void DictionaryEntry::verify() {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   513
  Klass* e = instance_klass();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   514
  guarantee(e->is_instance_klass(),
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   515
                          "Verify of dictionary failed");
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   516
  e->verify();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   517
  verify_protection_domain_set();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   518
}
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   519
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   520
void Dictionary::verify() {
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   521
  guarantee(number_of_entries() >= 0, "Verify of dictionary failed");
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   522
46475
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   523
  ClassLoaderData* cld = loader_data();
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   524
  // class loader must be present;  a null class loader is the
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   525
  // boostrap loader
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52340
diff changeset
   526
  guarantee(cld != NULL ||
46475
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   527
            cld->class_loader() == NULL ||
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   528
            cld->class_loader()->is_instance(),
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   529
            "checking type of class_loader");
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   530
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   531
  ResourceMark rm;
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   532
  stringStream tempst;
50634
c349d409262a 8202605: Standardize on ClassLoaderData::loader_name() throughout the VM to obtain a class loader's name
lfoltan
parents: 50429
diff changeset
   533
  tempst.print("System Dictionary for %s class loader", cld->loader_name_and_id());
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46701
diff changeset
   534
  verify_table<DictionaryEntry>(tempst.as_string());
42073
89e056fd82cc 8166145: runtime/threads/ThreadInterruptTest3 fails with ExitCode 0
gziemski
parents: 39982
diff changeset
   535
}