hotspot/src/share/vm/classfile/loaderConstraints.hpp
author alanb
Thu, 17 Mar 2016 19:04:01 +0000
changeset 36508 5f9eee6b383b
parent 13728 882756847a04
child 46329 53ccc37bda19
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, harold.seigel@oracle.com, lois.foltan@oracle.com, calvin.cheung@oracle.com, christian.tornqvist@oracle.com, erik.joelsson@oracle.com, george.triantafillou@oracle.com, igor.ignatyev@oracle.com, ioi.lam@oracle.com, james.laskey@oracle.com, jean-francois.denise@oracle.com, jiangli.zhou@oracle.com, markus.gronlund@oracle.com, serguei.spitsyn@oracle.com, staffan.larsen@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
     2
 * Copyright (c) 2003, 2012, 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: 5124
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5124
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: 5124
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
#ifndef SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/dictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "classfile/placeholders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "utilities/hashtable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class LoaderConstraintEntry;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    33
class Symbol;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    35
class LoaderConstraintTable : public Hashtable<Klass*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  enum Constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    _loader_constraint_size = 107,                     // number of entries in constraint table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    _nof_buckets            = 1009                     // number of buckets in hash table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    44
  LoaderConstraintEntry** find_loader_constraint(Symbol* name,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
                                                 Handle loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  LoaderConstraintTable(int nof_buckets);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    51
  LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    52
                                   Klass* klass, int num_loaders,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                                   int max_loaders);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    54
  void free_entry(LoaderConstraintEntry *entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  LoaderConstraintEntry* bucket(int i) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    57
    return (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::bucket(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  LoaderConstraintEntry** bucket_addr(int i) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    61
    return (LoaderConstraintEntry**)Hashtable<Klass*, mtClass>::bucket_addr(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    64
  // Enhanced Class Redefinition support
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    65
  void classes_do(KlassClosure* f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Check class loader constraints
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    68
  bool add_entry(Symbol* name, Klass* klass1, Handle loader1,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    69
                                    Klass* klass2, Handle loader2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    71
  // Note:  The main entry point for this module is via SystemDictionary.
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    72
  // SystemDictionary::check_signature_loaders(Symbol* signature,
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    73
  //                                           Handle loader1, Handle loader2,
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    74
  //                                           bool is_method, TRAPS)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    76
  Klass* find_constrained_klass(Symbol* name, Handle loader);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Class loader constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    82
                                Klass* klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void merge_loader_constraints(LoaderConstraintEntry** pp1,
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    84
                                LoaderConstraintEntry** pp2, Klass* klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  bool check_or_update(instanceKlassHandle k, Handle loader,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    87
                              Symbol* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    90
  void purge_loader_constraints();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
4899
ab225bac579c 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 2332
diff changeset
    92
  void verify(Dictionary* dictionary, PlaceholderTable* placeholders);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    98
class LoaderConstraintEntry : public HashtableEntry<Klass*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
private:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   101
  Symbol*                _name;                   // class name
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  int                    _num_loaders;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  int                    _max_loaders;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   104
  // Loader constraints enforce correct linking behavior.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   105
  // Thus, it really operates on ClassLoaderData which represents linking domain,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   106
  // not class loaders.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   107
  ClassLoaderData**              _loaders;                // initiating loaders
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   111
  Klass* klass() { return literal(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   112
  Klass** klass_addr() { return literal_addr(); }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   113
  void set_klass(Klass* k) { set_literal(k); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  LoaderConstraintEntry* next() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   116
    return (LoaderConstraintEntry*)HashtableEntry<Klass*, mtClass>::next();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  LoaderConstraintEntry** next_addr() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   120
    return (LoaderConstraintEntry**)HashtableEntry<Klass*, mtClass>::next_addr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void set_next(LoaderConstraintEntry* next) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   123
    HashtableEntry<Klass*, mtClass>::set_next(next);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   126
  Symbol* name() { return _name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   127
  void set_name(Symbol* name) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   128
    _name = name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   129
    if (name != NULL) name->increment_refcount();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   130
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  int num_loaders() { return _num_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void set_num_loaders(int i) { _num_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  int max_loaders() { return _max_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void set_max_loaders(int i) { _max_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   138
  ClassLoaderData** loaders() { return _loaders; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   139
  void set_loaders(ClassLoaderData** loaders) { _loaders = loaders; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   141
  ClassLoaderData* loader_data(int i) { return _loaders[i]; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   142
  void set_loader_data(int i, ClassLoaderData* p) { _loaders[i] = p; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   143
  // convenience
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   144
  void set_loader(int i, oop p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   146
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   147
#endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP