hotspot/src/share/vm/classfile/packageEntry.hpp
author lfoltan
Tue, 28 Jun 2016 10:11:01 -0400
changeset 39616 f82b1f888578
parent 39290 0cc9f5028562
child 43471 bfb383279a16
permissions -rw-r--r--
8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined Summary: Fixed an issue in class unloading to delay walk until class loader's aliveness is determined of modularity lists to remove dead modules Reviewed-by: coleenp, dholmes, sspitsyn, zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    24
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    28
#include "classfile/moduleEntry.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    29
#include "oops/symbol.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
#include "utilities/growableArray.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
#include "utilities/hashtable.hpp"
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
    32
#include "utilities/ostream.hpp"
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
// A PackageEntry basically represents a Java package.  It contains:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    35
//   - Symbol* containing the package's name.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    36
//   - ModuleEntry* for this package's containing module.
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    37
//   - a flag indicating if package is exported unqualifiedly
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
//   - a flag indicating if this package is exported to all unnamed modules.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    39
//   - a growable array containing other module entries that this
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
//     package is exported to.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    41
//
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    42
// Packages can be exported in the following 3 ways:
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
    43
//   - not exported:        the package does not have qualified or unqualified exports.
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    44
//   - qualified exports:   the package has been explicitly qualified to at least
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    45
//                            one particular module or has been qualifiedly exported
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    46
//                            to all unnamed modules.
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    47
//                            Note: _is_exported_allUnnamed is a form of a qualified
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    48
//                            export. It is equivalent to the package being
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    49
//                            explicitly exported to all current and future unnamed modules.
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    50
//   - unqualified exports: the package is exported to all modules.
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    51
//
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    52
// A package can transition from:
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    53
//   - being not exported, to being exported either in a qualified or unqualified manner
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    54
//   - being qualifiedly exported, to unqualifiedly exported. Its exported scope is widened.
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    55
//
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    56
// A package cannot transition from:
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    57
//   - being unqualifiedly exported, to exported qualifiedly to a specific module.
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    58
//       This transition attempt is silently ignored in set_exported.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    59
//
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    60
// The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    61
// data structure.
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
    62
class PackageEntry : public HashtableEntry<Symbol*, mtModule> {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    63
private:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    64
  ModuleEntry* _module;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    65
  // Used to indicate for packages with classes loaded by the boot loader that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    66
  // a class in that package has been loaded.  And, for packages with classes
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    67
  // loaded by the boot loader from -Xbootclasspath/a in an unnamed module, it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    68
  // indicates from which class path entry.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    69
  s2 _classpath_index;
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    70
  bool _is_exported_unqualified;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    71
  bool _is_exported_allUnnamed;
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents: 39290
diff changeset
    72
  bool _must_walk_exports;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    73
  GrowableArray<ModuleEntry*>* _exported_pending_delete; // transitioned from qualified to unqualified, delete at safepoint
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    74
  GrowableArray<ModuleEntry*>* _qualified_exports;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    75
  TRACE_DEFINE_TRACE_ID_FIELD;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    76
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    77
  // Initial size of a package entry's list of qualified exports.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    78
  enum {QUAL_EXP_SIZE = 43};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    79
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    80
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    81
  void init() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    82
    _module = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    83
    _classpath_index = -1;
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    84
    _is_exported_unqualified = false;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    85
    _is_exported_allUnnamed = false;
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents: 39290
diff changeset
    86
    _must_walk_exports = false;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    87
    _exported_pending_delete = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    88
    _qualified_exports = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    89
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    90
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    91
  // package name
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    92
  Symbol*            name() const               { return literal(); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    93
  void               set_name(Symbol* n)        { set_literal(n); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    94
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    95
  // the module containing the package definition
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    96
  ModuleEntry*       module() const             { return _module; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    97
  void               set_module(ModuleEntry* m) { _module = m; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    98
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    99
  // package's export state
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   100
  bool is_exported() const { // qualifiedly or unqualifiedly exported
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   101
      return (is_unqual_exported() || has_qual_exports_list() || is_exported_allUnnamed());
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   102
  }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   103
  // Returns true if the package has any explicit qualified exports or is exported to all unnamed
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   104
  bool is_qual_exported() const {
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   105
    return (has_qual_exports_list() || is_exported_allUnnamed());
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   106
  }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   107
  // Returns true if there are any explicit qualified exports
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   108
  bool has_qual_exports_list() const {
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   109
    assert(!(_qualified_exports != NULL && _is_exported_unqualified),
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   110
           "_qualified_exports set at same time as _is_exported_unqualified");
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   111
    return (_qualified_exports != NULL);
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   112
  }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   113
  bool is_exported_allUnnamed() const {
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   114
    assert(!(_is_exported_allUnnamed && _is_exported_unqualified),
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   115
           "_is_exported_allUnnamed set at same time as _is_exported_unqualified");
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   116
    return _is_exported_allUnnamed;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   117
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   118
  bool is_unqual_exported() const {
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   119
    assert(!(_qualified_exports != NULL && _is_exported_unqualified),
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   120
           "_qualified_exports set at same time as _is_exported_unqualified");
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   121
    assert(!(_is_exported_allUnnamed && _is_exported_unqualified),
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   122
           "_is_exported_allUnnamed set at same time as _is_exported_unqualified");
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   123
    return _is_exported_unqualified;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   124
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   125
  void set_unqual_exported() {
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
   126
    assert(Module_lock->owned_by_self(), "should have the Module_lock");
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   127
    _is_exported_unqualified = true;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   128
    _is_exported_allUnnamed = false;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   129
    _qualified_exports = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   130
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   131
  bool exported_pending_delete() const     { return (_exported_pending_delete != NULL); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   132
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   133
  void set_exported(ModuleEntry* m);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   134
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   135
  void set_is_exported_allUnnamed();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   136
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   137
  void set_classpath_index(s2 classpath_index) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   138
    _classpath_index = classpath_index;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   139
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   140
  s2 classpath_index() const { return _classpath_index; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   141
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   142
  bool has_loaded_class() const { return _classpath_index != -1; }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   143
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   144
  // returns true if the package is defined in the unnamed module
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   145
  bool in_unnamed_module() const  { return !_module->is_named(); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   146
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   147
  // returns true if the package specifies m as a qualified export, including through an unnamed export
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   148
  bool is_qexported_to(ModuleEntry* m) const;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   149
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   150
  // add the module to the package's qualified exports
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   151
  void add_qexport(ModuleEntry* m);
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents: 39290
diff changeset
   152
  void set_export_walk_required(ClassLoaderData* m_loader_data);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   153
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   154
  PackageEntry* next() const {
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   155
    return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   156
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   157
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   158
  PackageEntry** next_addr() {
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   159
    return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   160
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   161
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   162
  // iteration of qualified exports
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   163
  void package_exports_do(ModuleClosure* const f);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   164
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   165
  TRACE_DEFINE_TRACE_ID_METHODS;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   166
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   167
  // Purge dead weak references out of exported list when any given class loader is unloaded.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   168
  void purge_qualified_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   169
  void delete_qualified_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   170
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   171
  void print(outputStream* st = tty);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   172
  void verify();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   173
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   174
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   175
// The PackageEntryTable is a Hashtable containing a list of all packages defined
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   176
// by a particular class loader.  Each package is represented as a PackageEntry node.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   177
// The PackageEntryTable's lookup is lock free.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   178
//
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   179
class PackageEntryTable : public Hashtable<Symbol*, mtModule> {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   180
  friend class VMStructs;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   181
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   182
  enum Constants {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   183
    _packagetable_entry_size = 1009  // number of entries in package entry table
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   184
  };
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   185
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   186
private:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   187
  PackageEntry* new_entry(unsigned int hash, Symbol* name, ModuleEntry* module);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   188
  void add_entry(int index, PackageEntry* new_entry);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   189
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   190
  int entry_size() const { return BasicHashtable<mtModule>::entry_size(); }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   191
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   192
  PackageEntry** bucket_addr(int i) {
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   193
    return (PackageEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   194
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   195
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   196
  static unsigned int compute_hash(Symbol* name) { return (unsigned int)(name->identity_hash()); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   197
  int index_for(Symbol* name) const { return hash_to_index(compute_hash(name)); }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   198
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   199
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   200
  PackageEntryTable(int table_size);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   201
  ~PackageEntryTable();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   202
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   203
  PackageEntry* bucket(int i) {
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   204
    return (PackageEntry*)Hashtable<Symbol*, mtModule>::bucket(i);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   205
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   206
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   207
  // Create package in loader's package entry table and return the entry.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   208
  // If entry already exists, return null.  Assume Module lock was taken by caller.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   209
  PackageEntry* locked_create_entry_or_null(Symbol* name, ModuleEntry* module);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   210
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   211
  // lookup Package with loader's package entry table, if not found add
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   212
  PackageEntry* lookup(Symbol* name, ModuleEntry* module);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   213
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   214
  // Only lookup Package within loader's package entry table.  The table read is lock-free.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   215
  PackageEntry* lookup_only(Symbol* Package);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   216
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   217
  void verify_javabase_packages(GrowableArray<Symbol*> *pkg_list);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   218
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   219
  // purge dead weak references out of exported list
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   220
  void purge_all_package_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   221
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   222
  void print(outputStream* st = tty);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   223
  void verify();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   224
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   225
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   226
#endif // SHARE_VM_CLASSFILE_PACKAGEENTRY_HPP