hotspot/src/share/vm/classfile/loaderConstraints.hpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 f4b087cbb361
child 8076 96d498ec7ae1
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2003, 2010, 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;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class LoaderConstraintTable : public Hashtable {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  enum Constants {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    _loader_constraint_size = 107,                     // number of entries in constraint table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    _nof_buckets            = 1009                     // number of buckets in hash table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  LoaderConstraintEntry** find_loader_constraint(symbolHandle name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
                                                 Handle loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  LoaderConstraintTable(int nof_buckets);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  LoaderConstraintEntry* new_entry(unsigned int hash, symbolOop name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
                                   klassOop klass, int num_loaders,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
                                   int max_loaders);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  LoaderConstraintEntry* bucket(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    return (LoaderConstraintEntry*)Hashtable::bucket(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  LoaderConstraintEntry** bucket_addr(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    return (LoaderConstraintEntry**)Hashtable::bucket_addr(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // GC support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  void always_strong_classes_do(OopClosure* blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Check class loader constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  bool add_entry(symbolHandle name, klassOop klass1, Handle loader1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
                                    klassOop klass2, Handle loader2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
2332
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    70
  // Note:  The main entry point for this module is via SystemDictionary.
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    71
  // SystemDictionary::check_signature_loaders(symbolHandle signature,
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    72
  //                                           Handle loader1, Handle loader2,
5c7b6f4ce0a1 6814659: separable cleanups and subroutines for 6655638
jrose
parents: 1
diff changeset
    73
  //                                           bool is_method, TRAPS)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  klassOop find_constrained_klass(symbolHandle name, Handle loader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Class loader constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  void ensure_loader_constraint_capacity(LoaderConstraintEntry *p, int nfree);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void extend_loader_constraint(LoaderConstraintEntry* p, Handle loader,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
                                klassOop klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void merge_loader_constraints(LoaderConstraintEntry** pp1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
                                LoaderConstraintEntry** pp2, klassOop klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  bool check_or_update(instanceKlassHandle k, Handle loader,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                              symbolHandle name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  void purge_loader_constraints(BoolObjectClosure* is_alive);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
4899
ab225bac579c 6920977: G1: guarantee(k == probe->klass(),"klass should be in dictionary") fails
tonyp
parents: 2332
diff changeset
    91
  void verify(Dictionary* dictionary, PlaceholderTable* placeholders);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
class LoaderConstraintEntry : public HashtableEntry {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  symbolOop              _name;                   // class name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  int                    _num_loaders;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  int                    _max_loaders;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  oop*                   _loaders;                // initiating loaders
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  klassOop klass() { return (klassOop)literal(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  klassOop* klass_addr() { return (klassOop*)literal_addr(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  void set_klass(klassOop k) { set_literal(k); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  LoaderConstraintEntry* next() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    return (LoaderConstraintEntry*)HashtableEntry::next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  LoaderConstraintEntry** next_addr() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    return (LoaderConstraintEntry**)HashtableEntry::next_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  void set_next(LoaderConstraintEntry* next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    HashtableEntry::set_next(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  symbolOop name() { return _name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  symbolOop* name_addr() { return &_name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  void set_name(symbolOop name) { _name = name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  int num_loaders() { return _num_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void set_num_loaders(int i) { _num_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  int max_loaders() { return _max_loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void set_max_loaders(int i) { _max_loaders = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  oop* loaders() { return _loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  void set_loaders(oop* loaders) { _loaders = loaders; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  oop loader(int i) { return _loaders[i]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  oop* loader_addr(int i) { return &_loaders[i]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void set_loader(int i, oop p) { _loaders[i] = p; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   140
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   141
#endif // SHARE_VM_CLASSFILE_LOADERCONSTRAINTS_HPP