src/share/vm/classfile/loaderConstraints.hpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4037
da91efe96a93
child 6876
710a3c8b516e
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2003, 2012, 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 #ifndef SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP
stefank@2314 26 #define SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP
stefank@2314 27
stefank@2314 28 #include "classfile/dictionary.hpp"
stefank@2314 29 #include "classfile/placeholders.hpp"
stefank@2314 30 #include "utilities/hashtable.hpp"
stefank@2314 31
duke@435 32 class LoaderConstraintEntry;
coleenp@4037 33 class Symbol;
duke@435 34
coleenp@4037 35 class LoaderConstraintTable : public Hashtable<Klass*, mtClass> {
duke@435 36 friend class VMStructs;
duke@435 37 private:
duke@435 38
duke@435 39 enum Constants {
duke@435 40 _loader_constraint_size = 107, // number of entries in constraint table
duke@435 41 _nof_buckets = 1009 // number of buckets in hash table
duke@435 42 };
duke@435 43
coleenp@2497 44 LoaderConstraintEntry** find_loader_constraint(Symbol* name,
duke@435 45 Handle loader);
duke@435 46
duke@435 47 public:
duke@435 48
duke@435 49 LoaderConstraintTable(int nof_buckets);
duke@435 50
coleenp@2497 51 LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
coleenp@4037 52 Klass* klass, int num_loaders,
duke@435 53 int max_loaders);
coleenp@2497 54 void free_entry(LoaderConstraintEntry *entry);
duke@435 55
duke@435 56 LoaderConstraintEntry* bucket(int i) {
coleenp@4037 57 return (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::bucket(i);
duke@435 58 }
duke@435 59
duke@435 60 LoaderConstraintEntry** bucket_addr(int i) {
coleenp@4037 61 return (LoaderConstraintEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i);
duke@435 62 }
duke@435 63
coleenp@4037 64 // Enhanced Class Redefinition support
coleenp@4037 65 void classes_do(KlassClosure* f);
duke@435 66
duke@435 67 // Check class loader constraints
coleenp@4037 68 bool add_entry(Symbol* name, Klass* klass1, Handle loader1,
coleenp@4037 69 Klass* klass2, Handle loader2);
duke@435 70
jrose@1100 71 // Note: The main entry point for this module is via SystemDictionary.
coleenp@2497 72 // SystemDictionary::check_signature_loaders(Symbol* signature,
jrose@1100 73 // Handle loader1, Handle loader2,
jrose@1100 74 // bool is_method, TRAPS)
duke@435 75
coleenp@4037 76 Klass* find_constrained_klass(Symbol* name, Handle loader);
duke@435 77
duke@435 78 // Class loader constraints
duke@435 79
duke@435 80 void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
duke@435 81 void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
coleenp@4037 82 Klass* klass);
duke@435 83 void merge_loader_constraints(LoaderConstraintEntry** pp1,
coleenp@4037 84 LoaderConstraintEntry** pp2, Klass* klass);
duke@435 85
duke@435 86 bool check_or_update(instanceKlassHandle k, Handle loader,
coleenp@2497 87 Symbol* name);
duke@435 88
duke@435 89
coleenp@4037 90 void purge_loader_constraints();
duke@435 91
tonyp@1693 92 void verify(Dictionary* dictionary, PlaceholderTable* placeholders);
duke@435 93 #ifndef PRODUCT
duke@435 94 void print();
duke@435 95 #endif
duke@435 96 };
duke@435 97
coleenp@4037 98 class LoaderConstraintEntry : public HashtableEntry<Klass*, mtClass> {
duke@435 99 friend class VMStructs;
duke@435 100 private:
coleenp@2497 101 Symbol* _name; // class name
duke@435 102 int _num_loaders;
duke@435 103 int _max_loaders;
coleenp@4037 104 // Loader constraints enforce correct linking behavior.
coleenp@4037 105 // Thus, it really operates on ClassLoaderData which represents linking domain,
coleenp@4037 106 // not class loaders.
coleenp@4037 107 ClassLoaderData** _loaders; // initiating loaders
duke@435 108
duke@435 109 public:
duke@435 110
coleenp@4037 111 Klass* klass() { return literal(); }
coleenp@4037 112 Klass** klass_addr() { return literal_addr(); }
coleenp@4037 113 void set_klass(Klass* k) { set_literal(k); }
duke@435 114
duke@435 115 LoaderConstraintEntry* next() {
coleenp@4037 116 return (LoaderConstraintEntry*)HashtableEntry<Klass*, mtClass>::next();
duke@435 117 }
duke@435 118
duke@435 119 LoaderConstraintEntry** next_addr() {
coleenp@4037 120 return (LoaderConstraintEntry**)HashtableEntry<Klass*, mtClass>::next_addr();
duke@435 121 }
duke@435 122 void set_next(LoaderConstraintEntry* next) {
coleenp@4037 123 HashtableEntry<Klass*, mtClass>::set_next(next);
duke@435 124 }
duke@435 125
coleenp@2497 126 Symbol* name() { return _name; }
coleenp@2497 127 void set_name(Symbol* name) {
coleenp@2497 128 _name = name;
coleenp@2497 129 if (name != NULL) name->increment_refcount();
coleenp@2497 130 }
duke@435 131
duke@435 132 int num_loaders() { return _num_loaders; }
duke@435 133 void set_num_loaders(int i) { _num_loaders = i; }
duke@435 134
duke@435 135 int max_loaders() { return _max_loaders; }
duke@435 136 void set_max_loaders(int i) { _max_loaders = i; }
duke@435 137
coleenp@4037 138 ClassLoaderData** loaders() { return _loaders; }
coleenp@4037 139 void set_loaders(ClassLoaderData** loaders) { _loaders = loaders; }
duke@435 140
coleenp@4037 141 ClassLoaderData* loader_data(int i) { return _loaders[i]; }
coleenp@4037 142 void set_loader_data(int i, ClassLoaderData* p) { _loaders[i] = p; }
coleenp@4037 143 // convenience
coleenp@4037 144 void set_loader(int i, oop p);
duke@435 145 };
stefank@2314 146
stefank@2314 147 #endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP

mercurial