src/hotspot/share/classfile/dictionary.hpp
author hseigel
Mon, 05 Mar 2018 10:29:23 -0500
changeset 49340 4e82736053ae
parent 48811 58787a1708d2
child 49818 e57e6addb978
permissions -rw-r--r--
8191102: Incorrect include file use in classLoader.hpp Summary: Move appropriate methods to <fiile>.inline.hpp files. Create <file>.inline.hpp files when needed. Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48781
6ebef5cd0c8d 8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents: 47774
diff changeset
     2
 * Copyright (c) 2003, 2018, 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: 5420
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5420
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: 5420
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_DICTIONARY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CLASSFILE_DICTIONARY_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
46382
5520c435279b 8178336: Unnecessary SystemDictionary walk for Protection domain liveness
coleenp
parents: 46380
diff changeset
    28
#include "classfile/protectionDomainCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "oops/instanceKlass.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 26181
diff changeset
    31
#include "oops/oop.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "utilities/hashtable.hpp"
36381
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
    33
#include "utilities/ostream.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class DictionaryEntry;
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
    36
class BoolObjectClosure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    39
// The data structure for the class loader data dictionaries (and the shared system
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// dictionary).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    42
class Dictionary : public Hashtable<InstanceKlass*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    45
  static bool _some_dictionary_needs_resizing;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    46
  bool _resizable;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    47
  bool _needs_resizing;
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    48
  void check_if_needs_resize();
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    49
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    50
  ClassLoaderData* _loader_data;  // backpointer to owning loader
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    51
  ClassLoaderData* loader_data() const { return _loader_data; }
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
    52
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    53
  DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
48811
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
    55
  void clean_cached_protection_domains(BoolObjectClosure* is_alive, DictionaryEntry* probe);
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
    56
34257
4be3504cc03b 8140802: Clean up and refactor of class loading code for CDS
iklam
parents: 33602
diff changeset
    57
protected:
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    58
  static size_t entry_size();
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    59
public:
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    60
  Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable = false);
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    61
  Dictionary(ClassLoaderData* loader_data, int table_size, HashtableBucket<mtClass>* t, int number_of_entries, bool resizable = false);
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    62
  ~Dictionary();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    64
  static bool does_any_dictionary_needs_resizing();
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    65
  bool resize_if_needed();
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    66
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    67
  DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass);
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    68
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    69
  void add_klass(unsigned int hash, Symbol* class_name, InstanceKlass* obj);
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    70
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    71
  InstanceKlass* find_class(int index, unsigned int hash, Symbol* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
    73
  InstanceKlass* find_shared_class(int index, unsigned int hash, Symbol* name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // GC support
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    76
  void oops_do(OopClosure* f);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    77
  void roots_oops_do(OopClosure* strong, OopClosure* weak);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    79
  void classes_do(void f(InstanceKlass*));
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    80
  void classes_do(void f(InstanceKlass*, TRAPS), TRAPS);
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    81
  void all_entries_do(void f(InstanceKlass*, ClassLoaderData*));
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
    82
  void classes_do(MetaspaceClosure* it);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
    83
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
    84
  void unlink(BoolObjectClosure* is_alive);
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 25492
diff changeset
    85
  void remove_classes_in_error_state();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    87
  // Unload classes whose defining loaders are unloaded
48811
58787a1708d2 8175249: VMThread::run fails in VerifyBeforeExit : Universe::verify
coleenp
parents: 48781
diff changeset
    88
  void do_unloading(BoolObjectClosure* is_alive);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // Protection domains
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    91
  InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain);
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47761
diff changeset
    92
  bool is_valid_protection_domain(unsigned int hash,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    93
                                  Symbol* name,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                  Handle protection_domain);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  void add_protection_domain(int index, unsigned int hash,
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
    96
                             InstanceKlass* klass,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                             Handle protection_domain, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  // Sharing support
47761
1b0566927c7a 8190191: Subclasses of jdk.jfr.Event loaded from CDS breaks -XX:FlightRecorderOptions=retransform=false
iklam
parents: 47634
diff changeset
   100
  void reorder_dictionary_for_sharing() NOT_CDS_RETURN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   102
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void verify();
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   104
  DictionaryEntry* bucket(int i) const {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   105
    return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   106
  }
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   107
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   108
  // The following method is not MT-safe and must be done under lock.
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   109
  DictionaryEntry** bucket_addr(int i) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   110
    return (DictionaryEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   111
  }
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   112
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   113
  void add_entry(int index, DictionaryEntry* new_entry) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   114
    Hashtable<InstanceKlass*, mtClass>::add_entry(index, (HashtableEntry<InstanceKlass*, mtClass>*)new_entry);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   115
  }
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   116
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   117
  void unlink_entry(DictionaryEntry* entry) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   118
    Hashtable<InstanceKlass*, mtClass>::unlink_entry((HashtableEntry<InstanceKlass*, mtClass>*)entry);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   119
  }
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   120
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   121
  void free_entry(DictionaryEntry* entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   124
// An entry in the class loader data dictionaries, this describes a class as
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   125
// { InstanceKlass*, protection_domain }.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   127
class DictionaryEntry : public HashtableEntry<InstanceKlass*, mtClass> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Contains the set of approved protection domains that can access
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   131
  // this dictionary entry.
20405
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   132
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   133
  // This protection domain set is a set of tuples:
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   134
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   135
  // (InstanceKlass C, initiating class loader ICL, Protection Domain PD)
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   136
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   137
  // [Note that C.protection_domain(), which is stored in the java.lang.Class
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   138
  // mirror of C, is NOT the same as PD]
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   139
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   140
  // If such an entry (C, ICL, PD) exists in the table, it means that
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   141
  // it is okay for a class Foo to reference C, where
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   142
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   143
  //    Foo.protection_domain() == PD, and
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   144
  //    Foo's defining class loader == ICL
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   145
  //
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   146
  // The usage of the PD set can be seen in SystemDictionary::validate_protection_domain()
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   147
  // It is essentially a cache to avoid repeated Java up-calls to
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   148
  // ClassLoader.checkPackageAccess().
3321f6b16639 8003420: NPG: make new GC root for pd_set
tschatzl
parents: 17373
diff changeset
   149
  //
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   150
  ProtectionDomainEntry* volatile _pd_set;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Tells whether a protection is in the approved set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  bool contains_protection_domain(oop protection_domain) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Adds a protection domain to the approved set.
46274
534d019edb92 8175104: Unhandled oop in ProtectionDomainCacheTable::compute_hash
coleenp
parents: 42073
diff changeset
   156
  void add_protection_domain(Dictionary* dict, Handle protection_domain);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   158
  InstanceKlass* instance_klass() const { return literal(); }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46742
diff changeset
   159
  InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  DictionaryEntry* next() const {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   162
    return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  DictionaryEntry** next_addr() {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   166
    return (DictionaryEntry**)HashtableEntry<InstanceKlass*, mtClass>::next_addr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   169
  ProtectionDomainEntry* pd_set() const            { return _pd_set; }
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   170
  void set_pd_set(ProtectionDomainEntry* new_head) {  _pd_set = new_head; }
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   171
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48811
diff changeset
   172
  ProtectionDomainEntry* pd_set_acquire() const;
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48811
diff changeset
   173
  void release_set_pd_set(ProtectionDomainEntry* new_head);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   175
  // Tells whether the initiating class' protection domain can access the klass in this entry
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  bool is_valid_protection_domain(Handle protection_domain) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    if (!ProtectionDomainVerification) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    if (!SystemDictionary::has_checkPackageAccess()) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    return protection_domain() == NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
         ? true
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
         : contains_protection_domain(protection_domain());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void verify_protection_domain_set() {
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   186
    for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
                                current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
                                current = current->_next) {
48781
6ebef5cd0c8d 8194736: Refactor weak oops in ProtectionDomain table to use the Access API
eosterlund
parents: 47774
diff changeset
   189
      current->_pd_cache->object_no_keepalive()->verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   193
  bool equals(const Symbol* class_name) const {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46274
diff changeset
   194
    InstanceKlass* klass = (InstanceKlass*)literal();
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   195
    return (klass->name() == class_name);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
36381
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
   198
  void print_count(outputStream *st) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    int count = 0;
47098
e704f55561c3 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp
coleenp
parents: 46746
diff changeset
   200
    for (ProtectionDomainEntry* current = pd_set();  // accessed inside SD lock
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
                                current != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
                                current = current->_next) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    }
36381
b9ed6bef9364 8149064: TraceProtectionDomainVerification has been converted to Unified Logging.
mockner
parents: 35498
diff changeset
   205
    st->print_cr("pd set count = #%d", count);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  }
46475
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   207
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46382
diff changeset
   208
  void verify();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
};
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   210
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   211
// Entry in a SymbolPropertyTable, mapping a single Symbol*
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   212
// to a managed and an unmanaged pointer.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   213
class SymbolPropertyEntry : public HashtableEntry<Symbol*, mtSymbol> {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   214
  friend class VMStructs;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   215
 private:
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   216
  intptr_t _symbol_mode;  // secondary key
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   217
  Method*   _method;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   218
  oop       _method_type;
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   219
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   220
 public:
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   221
  Symbol* symbol() const            { return literal(); }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   222
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   223
  intptr_t symbol_mode() const      { return _symbol_mode; }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   224
  void set_symbol_mode(intptr_t m)  { _symbol_mode = m; }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   225
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   226
  Method*        method() const     { return _method; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   227
  void set_method(Method* p)        { _method = p; }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   228
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   229
  oop      method_type() const      { return _method_type; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   230
  oop*     method_type_addr()       { return &_method_type; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   231
  void set_method_type(oop p)       { _method_type = p; }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   232
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   233
  SymbolPropertyEntry* next() const {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   234
    return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next();
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   235
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   236
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   237
  SymbolPropertyEntry** next_addr() {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   238
    return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr();
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   239
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   240
46742
24ec8a039c90 8184994: Add Dictionary size logging and jcmd
coleenp
parents: 46729
diff changeset
   241
  void print_entry(outputStream* st) const {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   242
    symbol()->print_value_on(st);
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 29081
diff changeset
   243
    st->print("/mode=" INTX_FORMAT, symbol_mode());
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   244
    st->print(" -> ");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   245
    bool printed = false;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   246
    if (method() != NULL) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   247
      method()->print_value_on(st);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   248
      printed = true;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   249
    }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   250
    if (method_type() != NULL) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   251
      if (printed)  st->print(" and ");
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 20408
diff changeset
   252
      st->print(INTPTR_FORMAT, p2i((void *)method_type()));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   253
      printed = true;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   254
    }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   255
    st->print_cr(printed ? "" : "(empty)");
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   256
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   257
};
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   258
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   259
// A system-internal mapping of symbols to pointers, both managed
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   260
// and unmanaged.  Used to record the auto-generation of each method
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   261
// MethodHandle.invoke(S)T, for all signatures (S)T.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   262
class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   263
  friend class VMStructs;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   264
private:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   265
  // The following method is not MT-safe and must be done under lock.
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   266
  SymbolPropertyEntry** bucket_addr(int i) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   267
    return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   268
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   269
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   270
  void add_entry(int index, SymbolPropertyEntry* new_entry) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   271
    ShouldNotReachHere();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   272
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   273
  void set_entry(int index, SymbolPropertyEntry* new_entry) {
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   274
    ShouldNotReachHere();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   275
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   276
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   277
  SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   278
    SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::new_entry(hash, symbol);
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   279
    // Hashtable with Symbol* literal must increment and decrement refcount.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   280
    symbol->increment_refcount();
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   281
    entry->set_symbol_mode(symbol_mode);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   282
    entry->set_method(NULL);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   283
    entry->set_method_type(NULL);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   284
    return entry;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   285
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   286
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   287
public:
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   288
  SymbolPropertyTable(int table_size);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   289
  SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   290
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   291
  void free_entry(SymbolPropertyEntry* entry) {
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   292
    // decrement Symbol refcount here because hashtable doesn't.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   293
    entry->literal()->decrement_refcount();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   294
    Hashtable<Symbol*, mtSymbol>::free_entry(entry);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   295
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   296
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   297
  unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   298
    // Use the regular identity_hash.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8921
diff changeset
   299
    return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode;
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   300
  }
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   301
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   302
  int index_for(Symbol* name, intptr_t symbol_mode) {
5420
586d3988e72b 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 2534
diff changeset
   303
    return hash_to_index(compute_hash(name, symbol_mode));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   304
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   305
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   306
  // need not be locked; no state change
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   307
  SymbolPropertyEntry* find_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   308
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   309
  // must be done under SystemDictionary_lock
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   310
  SymbolPropertyEntry* add_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   311
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   312
  // GC support
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   313
  void oops_do(OopClosure* f);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   314
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   315
  void methods_do(void f(Method*));
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   316
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   317
  void verify();
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   318
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   319
  SymbolPropertyEntry* bucket(int i) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   320
    return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i);
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 47098
diff changeset
   321
  }
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   322
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   323
#endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP