src/hotspot/share/classfile/placeholders.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46742 hotspot/src/share/vm/classfile/placeholders.cpp@24ec8a039c90
child 49824 e242740a92b8
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46380
4a51438196cf 8026985: Rewrite SystemDictionary::classes_do and Dictionary::classes_do to use KlassClosure
coleenp
parents: 33611
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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "classfile/placeholders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/fieldType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "utilities/hashtable.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Placeholder methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    34
PlaceholderEntry* PlaceholderTable::new_entry(int hash, Symbol* name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    35
                                              ClassLoaderData* loader_data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    36
                                              bool havesupername,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    37
                                              Symbol* supername) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    38
  PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable<Symbol*, mtClass>::new_entry(hash, name);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    39
  // Hashtable with Symbol* literal must increment and decrement refcount.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    40
  name->increment_refcount();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    41
  entry->set_loader_data(loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  entry->set_havesupername(havesupername);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  entry->set_supername(supername);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  entry->set_superThreadQ(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  entry->set_loadInstanceThreadQ(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  entry->set_defineThreadQ(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  entry->set_definer(NULL);
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13728
diff changeset
    48
  entry->set_instance_klass(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    52
void PlaceholderTable::free_entry(PlaceholderEntry* entry) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    53
  // decrement Symbol refcount here because Hashtable doesn't.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    54
  entry->literal()->decrement_refcount();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    55
  if (entry->supername() != NULL) entry->supername()->decrement_refcount();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
    56
  Hashtable<Symbol*, mtClass>::free_entry(entry);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    57
}
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    58
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// Placeholder objects represent classes currently being loaded.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// All threads examining the placeholder table must hold the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// SystemDictionary_lock, so we don't need special precautions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// on store ordering here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
void PlaceholderTable::add_entry(int index, unsigned int hash,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    65
                                 Symbol* class_name, ClassLoaderData* loader_data,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    66
                                 bool havesupername, Symbol* supername){
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  assert_locked_or_safepoint(SystemDictionary_lock);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    68
  assert(class_name != NULL, "adding NULL obj");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Both readers and writers are locked so it's safe to just
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // create the placeholder and insert it in the list without a membar.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    72
  PlaceholderEntry* entry = new_entry(hash, class_name, loader_data, havesupername, supername);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  add_entry(index, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// Remove a placeholder object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
void PlaceholderTable::remove_entry(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    79
                                    Symbol* class_name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    80
                                    ClassLoaderData* loader_data) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  assert_locked_or_safepoint(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  PlaceholderEntry** p = bucket_addr(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  while (*p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    PlaceholderEntry *probe = *p;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    85
    if (probe->hash() == hash && probe->equals(class_name, loader_data)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      // Delete entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      *p = probe->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      free_entry(probe);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    p = probe->next_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    96
                                       Symbol* class_name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    97
                                       ClassLoaderData* loader_data) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  assert_locked_or_safepoint(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  for (PlaceholderEntry *place_probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                         place_probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                         place_probe = place_probe->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    if (place_probe->hash() == hash &&
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   104
        place_probe->equals(class_name, loader_data)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      return place_probe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   111
Symbol* PlaceholderTable::find_entry(int index, unsigned int hash,
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   112
                                       Symbol* class_name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   113
                                       ClassLoaderData* loader_data) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   114
  PlaceholderEntry* probe = get_entry(index, hash, class_name, loader_data);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   115
  return (probe? probe->klassname(): (Symbol*)NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // find_and_add returns probe pointer - old or new
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // If no entry exists, add a placeholder entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // If entry exists, reuse entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // For both, push SeenThread for classloadAction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // if havesupername: this is used for circularity for instanceklass loading
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   123
PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   124
                                                 Symbol* name,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   125
                                                 ClassLoaderData* loader_data,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   126
                                                 classloadAction action,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   127
                                                 Symbol* supername,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   128
                                                 Thread* thread) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   129
  PlaceholderEntry* probe = get_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  if (probe == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    // Nothing found, add place holder
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   132
    add_entry(index, hash, name, loader_data, (action == LOAD_SUPER), supername);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   133
    probe = get_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    if (action == LOAD_SUPER) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      probe->set_havesupername(true);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   137
      probe->set_supername(supername);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  if (probe) probe->add_seen_thread(thread, action);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  return probe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   145
// placeholder is used to track class loading internal states
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
// placeholder existence now for loading superclass/superinterface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
// superthreadQ tracks class circularity, while loading superclass/superinterface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
// loadInstanceThreadQ tracks load_instance_class calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
// definer() tracks the single thread that owns define token
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
// defineThreadQ tracks waiters on defining thread's results
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
// 1st claimant creates placeholder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
// find_and_add adds SeenThread entry for appropriate queue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// All claimants remove SeenThread after completing action
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// On removal: if definer and all queues empty, remove entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// Note: you can be in both placeholders and systemDictionary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// Therefore - must always check SD first
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// Ignores the case where entry is not found
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
void PlaceholderTable::find_and_remove(int index, unsigned int hash,
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   159
                                       Symbol* name, ClassLoaderData* loader_data,
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   160
                                       classloadAction action,
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   161
                                       Thread* thread) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    assert_locked_or_safepoint(SystemDictionary_lock);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   163
    PlaceholderEntry *probe = get_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    if (probe != NULL) {
15188
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   165
       probe->remove_seen_thread(thread, action);
3916ac601e04 7199207: NPG: Crash in PlaceholderTable::verify after StackOverflow
acorn
parents: 14488
diff changeset
   166
       // If no other threads using this entry, and this thread is not using this entry for other states
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
       if ((probe->superThreadQ() == NULL) && (probe->loadInstanceThreadQ() == NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
          && (probe->defineThreadQ() == NULL) && (probe->definer() == NULL)) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   169
         remove_entry(index, hash, name, loader_data);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
PlaceholderTable::PlaceholderTable(int table_size)
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46545
diff changeset
   175
    : Hashtable<Symbol*, mtClass>(table_size, sizeof(PlaceholderEntry)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
void PlaceholderEntry::verify() const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   179
  guarantee(loader_data() != NULL, "Must have been setup.");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   180
  guarantee(loader_data()->class_loader() == NULL || loader_data()->class_loader()->is_instance(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
            "checking type of _loader");
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13728
diff changeset
   182
  guarantee(instance_klass() == NULL
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 15188
diff changeset
   183
            || instance_klass()->is_instance_klass(),
14488
ab48109f7d1b 8001471: Klass::cast() does nothing
hseigel
parents: 13728
diff changeset
   184
            "checking type of instance_klass result");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
void PlaceholderTable::verify() {
46545
b970b6e40209 8181450: assert in BasicHashtable::verify_table
coleenp
parents: 46380
diff changeset
   188
  verify_table<PlaceholderEntry>("Placeholder Table");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   192
// Note, doesn't append a cr
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   193
// Can't call this print_on because HashtableEntry doesn't initialize its vptr
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   194
// and print_on is a virtual function so the vptr call crashes.
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   195
void PlaceholderEntry::print_entry(outputStream* st) const {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   196
  klassname()->print_value_on(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   197
  if (loader_data() != NULL) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   198
    st->print(", loader ");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   199
    loader_data()->print_value_on(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   200
  }
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   201
  if (supername() != NULL) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   202
    st->print(", supername ");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   203
    supername()->print_value_on(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   204
  }
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   205
  if (definer() != NULL) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   206
    st->print(", definer ");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   207
    definer()->print_value_on(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   208
  }
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   209
  if (instance_klass() != NULL) {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   210
    st->print(", InstanceKlass ");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   211
    instance_klass()->print_value_on(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   212
  }
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   213
  st->cr();
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   214
  st->print("loadInstanceThreadQ threads:");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   215
  loadInstanceThreadQ()->print_action_queue(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   216
  st->cr();
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   217
  st->print("superThreadQ threads:");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   218
  superThreadQ()->print_action_queue(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   219
  st->cr();
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   220
  st->print("defineThreadQ threads:");
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   221
  defineThreadQ()->print_action_queue(st);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   222
  st->cr();
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   223
}
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   224
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   225
void PlaceholderTable::print_on(outputStream* st) const {
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   226
  st->print_cr("Placeholder table (table_size=%d, placeholders=%d)",
46545
b970b6e40209 8181450: assert in BasicHashtable::verify_table
coleenp
parents: 46380
diff changeset
   227
                table_size(), number_of_entries());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  for (int pindex = 0; pindex < table_size(); pindex++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    for (PlaceholderEntry* probe = bucket(pindex);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                           probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                           probe = probe->next()) {
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   232
      st->print("%4d: placeholder ", pindex);
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   233
      probe->print_entry(st);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
}