Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/placeholders.hpp" |
stefank@2314 | 27 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 28 | #include "oops/oop.inline.hpp" |
stefank@2314 | 29 | #include "runtime/fieldType.hpp" |
stefank@2314 | 30 | #include "utilities/hashtable.inline.hpp" |
duke@435 | 31 | |
duke@435 | 32 | // Placeholder methods |
duke@435 | 33 | |
duke@435 | 34 | PlaceholderEntry* PlaceholderTable::new_entry(int hash, symbolOop name, |
duke@435 | 35 | oop loader, bool havesupername, |
duke@435 | 36 | symbolOop supername) { |
duke@435 | 37 | PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable::new_entry(hash, name); |
duke@435 | 38 | entry->set_loader(loader); |
duke@435 | 39 | entry->set_havesupername(havesupername); |
duke@435 | 40 | entry->set_supername(supername); |
duke@435 | 41 | entry->set_superThreadQ(NULL); |
duke@435 | 42 | entry->set_loadInstanceThreadQ(NULL); |
duke@435 | 43 | entry->set_defineThreadQ(NULL); |
duke@435 | 44 | entry->set_definer(NULL); |
duke@435 | 45 | entry->set_instanceKlass(NULL); |
duke@435 | 46 | return entry; |
duke@435 | 47 | } |
duke@435 | 48 | |
duke@435 | 49 | |
duke@435 | 50 | // Placeholder objects represent classes currently being loaded. |
duke@435 | 51 | // All threads examining the placeholder table must hold the |
duke@435 | 52 | // SystemDictionary_lock, so we don't need special precautions |
duke@435 | 53 | // on store ordering here. |
duke@435 | 54 | void PlaceholderTable::add_entry(int index, unsigned int hash, |
duke@435 | 55 | symbolHandle class_name, Handle class_loader, |
duke@435 | 56 | bool havesupername, symbolHandle supername){ |
duke@435 | 57 | assert_locked_or_safepoint(SystemDictionary_lock); |
duke@435 | 58 | assert(!class_name.is_null(), "adding NULL obj"); |
duke@435 | 59 | |
duke@435 | 60 | // Both readers and writers are locked so it's safe to just |
duke@435 | 61 | // create the placeholder and insert it in the list without a membar. |
duke@435 | 62 | PlaceholderEntry* entry = new_entry(hash, class_name(), class_loader(), havesupername, supername()); |
duke@435 | 63 | add_entry(index, entry); |
duke@435 | 64 | } |
duke@435 | 65 | |
duke@435 | 66 | |
duke@435 | 67 | // Remove a placeholder object. |
duke@435 | 68 | void PlaceholderTable::remove_entry(int index, unsigned int hash, |
duke@435 | 69 | symbolHandle class_name, |
duke@435 | 70 | Handle class_loader) { |
duke@435 | 71 | assert_locked_or_safepoint(SystemDictionary_lock); |
duke@435 | 72 | PlaceholderEntry** p = bucket_addr(index); |
duke@435 | 73 | while (*p) { |
duke@435 | 74 | PlaceholderEntry *probe = *p; |
duke@435 | 75 | if (probe->hash() == hash && probe->equals(class_name(), class_loader())) { |
duke@435 | 76 | // Delete entry |
duke@435 | 77 | *p = probe->next(); |
duke@435 | 78 | free_entry(probe); |
duke@435 | 79 | return; |
duke@435 | 80 | } |
duke@435 | 81 | p = probe->next_addr(); |
duke@435 | 82 | } |
duke@435 | 83 | } |
duke@435 | 84 | |
duke@435 | 85 | PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash, |
duke@435 | 86 | symbolHandle class_name, |
duke@435 | 87 | Handle class_loader) { |
duke@435 | 88 | assert_locked_or_safepoint(SystemDictionary_lock); |
duke@435 | 89 | |
duke@435 | 90 | symbolOop class_name_ = class_name(); |
duke@435 | 91 | oop class_loader_ = class_loader(); |
duke@435 | 92 | |
duke@435 | 93 | for (PlaceholderEntry *place_probe = bucket(index); |
duke@435 | 94 | place_probe != NULL; |
duke@435 | 95 | place_probe = place_probe->next()) { |
duke@435 | 96 | if (place_probe->hash() == hash && |
duke@435 | 97 | place_probe->equals(class_name_, class_loader_)) { |
duke@435 | 98 | return place_probe; |
duke@435 | 99 | } |
duke@435 | 100 | } |
duke@435 | 101 | return NULL; |
duke@435 | 102 | } |
duke@435 | 103 | |
duke@435 | 104 | symbolOop PlaceholderTable::find_entry(int index, unsigned int hash, |
duke@435 | 105 | symbolHandle class_name, |
duke@435 | 106 | Handle class_loader) { |
duke@435 | 107 | PlaceholderEntry* probe = get_entry(index, hash, class_name, class_loader); |
duke@435 | 108 | return (probe? probe->klass(): symbolOop(NULL)); |
duke@435 | 109 | } |
duke@435 | 110 | |
duke@435 | 111 | // find_and_add returns probe pointer - old or new |
duke@435 | 112 | // If no entry exists, add a placeholder entry |
duke@435 | 113 | // If entry exists, reuse entry |
duke@435 | 114 | // For both, push SeenThread for classloadAction |
duke@435 | 115 | // if havesupername: this is used for circularity for instanceklass loading |
duke@435 | 116 | PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, symbolHandle name, Handle loader, classloadAction action, symbolHandle supername, Thread* thread) { |
duke@435 | 117 | PlaceholderEntry* probe = get_entry(index, hash, name, loader); |
duke@435 | 118 | if (probe == NULL) { |
duke@435 | 119 | // Nothing found, add place holder |
duke@435 | 120 | add_entry(index, hash, name, loader, (action == LOAD_SUPER), supername); |
duke@435 | 121 | probe = get_entry(index, hash, name, loader); |
duke@435 | 122 | } else { |
duke@435 | 123 | if (action == LOAD_SUPER) { |
duke@435 | 124 | probe->set_havesupername(true); |
duke@435 | 125 | probe->set_supername(supername()); |
duke@435 | 126 | } |
duke@435 | 127 | } |
duke@435 | 128 | if (probe) probe->add_seen_thread(thread, action); |
duke@435 | 129 | return probe; |
duke@435 | 130 | } |
duke@435 | 131 | |
duke@435 | 132 | |
duke@435 | 133 | // placeholder used to track class loading internal states |
duke@435 | 134 | // placeholder existence now for loading superclass/superinterface |
duke@435 | 135 | // superthreadQ tracks class circularity, while loading superclass/superinterface |
duke@435 | 136 | // loadInstanceThreadQ tracks load_instance_class calls |
duke@435 | 137 | // definer() tracks the single thread that owns define token |
duke@435 | 138 | // defineThreadQ tracks waiters on defining thread's results |
duke@435 | 139 | // 1st claimant creates placeholder |
duke@435 | 140 | // find_and_add adds SeenThread entry for appropriate queue |
duke@435 | 141 | // All claimants remove SeenThread after completing action |
duke@435 | 142 | // On removal: if definer and all queues empty, remove entry |
duke@435 | 143 | // Note: you can be in both placeholders and systemDictionary |
duke@435 | 144 | // see parse_stream for redefine classes |
duke@435 | 145 | // Therefore - must always check SD first |
duke@435 | 146 | // Ignores the case where entry is not found |
duke@435 | 147 | void PlaceholderTable::find_and_remove(int index, unsigned int hash, |
duke@435 | 148 | symbolHandle name, Handle loader, Thread* thread) { |
duke@435 | 149 | assert_locked_or_safepoint(SystemDictionary_lock); |
duke@435 | 150 | PlaceholderEntry *probe = get_entry(index, hash, name, loader); |
duke@435 | 151 | if (probe != NULL) { |
duke@435 | 152 | // No other threads using this entry |
duke@435 | 153 | if ((probe->superThreadQ() == NULL) && (probe->loadInstanceThreadQ() == NULL) |
duke@435 | 154 | && (probe->defineThreadQ() == NULL) && (probe->definer() == NULL)) { |
duke@435 | 155 | remove_entry(index, hash, name, loader); |
duke@435 | 156 | } |
duke@435 | 157 | } |
duke@435 | 158 | } |
duke@435 | 159 | |
duke@435 | 160 | PlaceholderTable::PlaceholderTable(int table_size) |
duke@435 | 161 | : TwoOopHashtable(table_size, sizeof(PlaceholderEntry)) { |
duke@435 | 162 | } |
duke@435 | 163 | |
duke@435 | 164 | |
duke@435 | 165 | void PlaceholderTable::oops_do(OopClosure* f) { |
duke@435 | 166 | for (int index = 0; index < table_size(); index++) { |
duke@435 | 167 | for (PlaceholderEntry* probe = bucket(index); |
duke@435 | 168 | probe != NULL; |
duke@435 | 169 | probe = probe->next()) { |
duke@435 | 170 | probe->oops_do(f); |
duke@435 | 171 | } |
duke@435 | 172 | } |
duke@435 | 173 | } |
duke@435 | 174 | |
duke@435 | 175 | |
duke@435 | 176 | void PlaceholderEntry::oops_do(OopClosure* blk) { |
duke@435 | 177 | assert(klass() != NULL, "should have a non-null klass"); |
duke@435 | 178 | blk->do_oop((oop*)klass_addr()); |
duke@435 | 179 | if (_loader != NULL) { |
duke@435 | 180 | blk->do_oop(loader_addr()); |
duke@435 | 181 | } |
duke@435 | 182 | if (_supername != NULL) { |
duke@435 | 183 | blk->do_oop((oop*)supername_addr()); |
duke@435 | 184 | } |
duke@435 | 185 | if (_instanceKlass != NULL) { |
duke@435 | 186 | blk->do_oop((oop*)instanceKlass_addr()); |
duke@435 | 187 | } |
duke@435 | 188 | } |
duke@435 | 189 | |
duke@435 | 190 | // do all entries in the placeholder table |
duke@435 | 191 | void PlaceholderTable::entries_do(void f(symbolOop, oop)) { |
duke@435 | 192 | for (int index = 0; index < table_size(); index++) { |
duke@435 | 193 | for (PlaceholderEntry* probe = bucket(index); |
duke@435 | 194 | probe != NULL; |
duke@435 | 195 | probe = probe->next()) { |
duke@435 | 196 | f(probe->klass(), probe->loader()); |
duke@435 | 197 | } |
duke@435 | 198 | } |
duke@435 | 199 | } |
duke@435 | 200 | |
duke@435 | 201 | |
duke@435 | 202 | #ifndef PRODUCT |
duke@435 | 203 | // Note, doesn't append a cr |
duke@435 | 204 | void PlaceholderEntry::print() const { |
duke@435 | 205 | klass()->print_value(); |
duke@435 | 206 | if (loader() != NULL) { |
duke@435 | 207 | tty->print(", loader "); |
duke@435 | 208 | loader()->print_value(); |
duke@435 | 209 | } |
duke@435 | 210 | if (supername() != NULL) { |
duke@435 | 211 | tty->print(", supername "); |
duke@435 | 212 | supername()->print_value(); |
duke@435 | 213 | } |
duke@435 | 214 | if (definer() != NULL) { |
duke@435 | 215 | tty->print(", definer "); |
duke@435 | 216 | definer()->print_value(); |
duke@435 | 217 | } |
duke@435 | 218 | if (instanceKlass() != NULL) { |
duke@435 | 219 | tty->print(", instanceKlass "); |
duke@435 | 220 | instanceKlass()->print_value(); |
duke@435 | 221 | } |
duke@435 | 222 | tty->print("\n"); |
duke@435 | 223 | tty->print("loadInstanceThreadQ threads:"); |
duke@435 | 224 | loadInstanceThreadQ()->printActionQ(); |
duke@435 | 225 | tty->print("\n"); |
duke@435 | 226 | tty->print("superThreadQ threads:"); |
duke@435 | 227 | superThreadQ()->printActionQ(); |
duke@435 | 228 | tty->print("\n"); |
duke@435 | 229 | tty->print("defineThreadQ threads:"); |
duke@435 | 230 | defineThreadQ()->printActionQ(); |
duke@435 | 231 | tty->print("\n"); |
duke@435 | 232 | } |
duke@435 | 233 | #endif |
duke@435 | 234 | |
duke@435 | 235 | void PlaceholderEntry::verify() const { |
duke@435 | 236 | guarantee(loader() == NULL || loader()->is_instance(), |
duke@435 | 237 | "checking type of _loader"); |
duke@435 | 238 | guarantee(instanceKlass() == NULL |
duke@435 | 239 | || Klass::cast(instanceKlass())->oop_is_instance(), |
duke@435 | 240 | "checking type of instanceKlass result"); |
duke@435 | 241 | klass()->verify(); |
duke@435 | 242 | } |
duke@435 | 243 | |
duke@435 | 244 | void PlaceholderTable::verify() { |
duke@435 | 245 | int element_count = 0; |
duke@435 | 246 | for (int pindex = 0; pindex < table_size(); pindex++) { |
duke@435 | 247 | for (PlaceholderEntry* probe = bucket(pindex); |
duke@435 | 248 | probe != NULL; |
duke@435 | 249 | probe = probe->next()) { |
duke@435 | 250 | probe->verify(); |
duke@435 | 251 | element_count++; // both klasses and place holders count |
duke@435 | 252 | } |
duke@435 | 253 | } |
duke@435 | 254 | guarantee(number_of_entries() == element_count, |
duke@435 | 255 | "Verify of system dictionary failed"); |
duke@435 | 256 | } |
duke@435 | 257 | |
duke@435 | 258 | |
duke@435 | 259 | #ifndef PRODUCT |
duke@435 | 260 | void PlaceholderTable::print() { |
duke@435 | 261 | for (int pindex = 0; pindex < table_size(); pindex++) { |
duke@435 | 262 | for (PlaceholderEntry* probe = bucket(pindex); |
duke@435 | 263 | probe != NULL; |
duke@435 | 264 | probe = probe->next()) { |
duke@435 | 265 | if (Verbose) tty->print("%4d: ", pindex); |
duke@435 | 266 | tty->print(" place holder "); |
duke@435 | 267 | |
duke@435 | 268 | probe->print(); |
duke@435 | 269 | tty->cr(); |
duke@435 | 270 | } |
duke@435 | 271 | } |
duke@435 | 272 | } |
duke@435 | 273 | #endif |