hotspot/src/share/vm/classfile/loaderConstraints.hpp
author redestad
Mon, 28 Aug 2017 00:20:35 +0200
changeset 46994 7663ce98384b
parent 46742 24ec8a039c90
permissions -rw-r--r--
8179040: Avoid Ticks::now calls when EventClassLoad is not enabled Reviewed-by: ehelin, mgronlun, dholmes, iklam Contributed-by: claes.redestad@oracle.com, markus.gronlund@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
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: 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/placeholders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/hashtable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46380
diff changeset
    31
class ClassLoaderData;
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
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    35
class LoaderConstraintTable : public Hashtable<InstanceKlass*, mtClass> {
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46380
diff changeset
    36
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
private:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    38
  LoaderConstraintEntry** find_loader_constraint(Symbol* name,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
                                                 Handle loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46380
diff changeset
    43
  LoaderConstraintTable(int table_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    45
  LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    46
                                   InstanceKlass* klass, int num_loaders,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
                                   int max_loaders);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    48
  void free_entry(LoaderConstraintEntry *entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
    50
  LoaderConstraintEntry* bucket(int i) const {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    51
    return (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  LoaderConstraintEntry** bucket_addr(int i) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    55
    return (LoaderConstraintEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Check class loader constraints
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    59
  bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1,
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    60
                                    InstanceKlass* klass2, Handle loader2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    62
  // 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
    63
  // SystemDictionary::check_signature_loaders(Symbol* signature,
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    64
  //                                           Handle loader1, Handle loader2,
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    65
  //                                           bool is_method, TRAPS)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    67
  InstanceKlass* find_constrained_klass(Symbol* name, Handle loader);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Class loader constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    73
                                InstanceKlass* klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void merge_loader_constraints(LoaderConstraintEntry** pp1,
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    75
                                LoaderConstraintEntry** pp2, InstanceKlass* klass);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    77
  bool check_or_update(InstanceKlass* k, Handle loader, Symbol* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    79
  void purge_loader_constraints();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46380
diff changeset
    81
  void verify(PlaceholderTable* placeholders);
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
    82
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    85
class LoaderConstraintEntry : public HashtableEntry<InstanceKlass*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
private:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    87
  Symbol*                _name;                   // class name
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int                    _num_loaders;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  int                    _max_loaders;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    90
  // Loader constraints enforce correct linking behavior.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    91
  // 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
    92
  // not class loaders.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    93
  ClassLoaderData**              _loaders;                // initiating loaders
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    97
  InstanceKlass* klass() { return literal(); }
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    98
  InstanceKlass** klass_addr() { return literal_addr(); }
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
    99
  void set_klass(InstanceKlass* k) { set_literal(k); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  LoaderConstraintEntry* next() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
   102
    return (LoaderConstraintEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  LoaderConstraintEntry** next_addr() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
   106
    return (LoaderConstraintEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void set_next(LoaderConstraintEntry* next) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 13728
diff changeset
   109
    HashtableEntry<InstanceKlass*, mtClass>::set_next(next);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   112
  Symbol* name() { return _name; }
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   113
  void set_name(Symbol* name) {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   114
    _name = name;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   115
    if (name != NULL) name->increment_refcount();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   116
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  int num_loaders() { return _num_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void set_num_loaders(int i) { _num_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  int max_loaders() { return _max_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void set_max_loaders(int i) { _max_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   124
  ClassLoaderData** loaders() { return _loaders; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   125
  void set_loaders(ClassLoaderData** loaders) { _loaders = loaders; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   127
  ClassLoaderData* loader_data(int i) { return _loaders[i]; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   128
  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
   129
  // convenience
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   130
  void set_loader(int i, oop p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   132
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   133
#endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP