src/hotspot/share/classfile/packageEntry.cpp
author lfoltan
Mon, 21 Oct 2019 13:13:16 -0400
changeset 58722 cba8afa5cfed
parent 54623 1126f0607c70
permissions -rw-r--r--
8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently Summary: Increase the use of type signature constants instead of hard coded characters within the JVM. Reviewed-by: coleenp, dholmes, fparain Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
53441
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
36508
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
#include "precompiled.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    26
#include "classfile/moduleEntry.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
#include "classfile/packageEntry.hpp"
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
    28
#include "logging/log.hpp"
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    29
#include "memory/resourceArea.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
#include "oops/symbol.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
#include "runtime/handles.inline.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    32
#include "utilities/events.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
#include "utilities/growableArray.hpp"
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
#include "utilities/hashtable.inline.hpp"
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
    35
#include "utilities/ostream.hpp"
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    36
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    37
// Returns true if this package specifies m as a qualified export, including through an unnamed export
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
bool PackageEntry::is_qexported_to(ModuleEntry* m) const {
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
    39
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
  assert(m != NULL, "No module to lookup in this package's qualified exports list");
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    41
  if (is_exported_allUnnamed() && !m->is_named()) {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    42
    return true;
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    43
  } else if (!has_qual_exports_list()) {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    44
    return false;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    45
  } else {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    46
    return _qualified_exports->contains(m);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    47
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    48
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    49
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    50
// Add a module to the package's qualified export list.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    51
void PackageEntry::add_qexport(ModuleEntry* m) {
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
    52
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    53
  if (!has_qual_exports_list()) {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    // Lazily create a package's qualified exports list.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    // Initial size is small, do not anticipate export lists to be large.
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
    56
    _qualified_exports = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleEntry*>(QUAL_EXP_SIZE, true);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    57
  }
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
    58
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
    59
  // Determine, based on this newly established export to module m,
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
    60
  // if this package's export list should be walked at a GC safepoint.
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
    61
  set_export_walk_required(m->loader_data());
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
    62
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
    63
  // Establish exportability to module m
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    64
  _qualified_exports->append_if_missing(m);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    65
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    66
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
    67
// If the module's loader, that an export is being established to, is
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
    68
// not the same loader as this module's and is not one of the 3 builtin
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
    69
// class loaders, then this package's export list must be walked at GC
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
    70
// safepoint. Modules have the same life cycle as their defining class
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
    71
// loaders and should be removed if dead.
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
void PackageEntry::set_export_walk_required(ClassLoaderData* m_loader_data) {
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
    73
  assert_locked_or_safepoint(Module_lock);
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
    74
  ModuleEntry* this_pkg_mod = module();
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
    75
  if (!_must_walk_exports &&
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
    76
      (this_pkg_mod == NULL || this_pkg_mod->loader_data() != m_loader_data) &&
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
    77
      !m_loader_data->is_builtin_class_loader_data()) {
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
    78
    _must_walk_exports = true;
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
    79
    if (log_is_enabled(Trace, module)) {
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
    80
      ResourceMark rm;
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
    81
      assert(name() != NULL, "PackageEntry without a valid name");
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
    82
      log_trace(module)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
    83
                        name()->as_C_string(),
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
    84
                        (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
    85
                          UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
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
    }
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
    87
  }
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
    88
}
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
    89
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
    90
// Set the package's exported states based on the value of the ModuleEntry.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    91
void PackageEntry::set_exported(ModuleEntry* m) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    92
  MutexLocker m1(Module_lock);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    93
  if (is_unqual_exported()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    94
    // An exception could be thrown, but choose to simply ignore.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    95
    // Illegal to convert an unqualified exported package to be qualifiedly exported
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    96
    return;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    97
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    98
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    99
  if (m == NULL) {
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   100
    // NULL indicates the package is being unqualifiedly exported.  Clean up
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   101
    // the qualified list at the next safepoint.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   102
    set_unqual_exported();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   103
  } else {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   104
    // Add the exported module
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   105
    add_qexport(m);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   106
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   107
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   108
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   109
// Set the package as exported to all unnamed modules unless the package is
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   110
// already unqualifiedly exported.
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   111
void PackageEntry::set_is_exported_allUnnamed() {
46404
ae62ba99a1a7 8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents: 43471
diff changeset
   112
  if (module()->is_open()) {
ae62ba99a1a7 8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents: 43471
diff changeset
   113
    // No-op for open modules since all packages are unqualifiedly exported
ae62ba99a1a7 8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents: 43471
diff changeset
   114
    return;
ae62ba99a1a7 8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents: 43471
diff changeset
   115
  }
ae62ba99a1a7 8165896: Use "open" flag from JVM_DefineModule to export all module packages
rprotacio
parents: 43471
diff changeset
   116
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   117
  MutexLocker m1(Module_lock);
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   118
  if (!is_unqual_exported()) {
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   119
   _export_flags = PKG_EXP_ALLUNNAMED;
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   120
  }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   121
}
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   122
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   123
// Remove dead module entries within the package's exported list.  Note that
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   124
// if all of the modules on the _qualified_exports get purged the list does not
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   125
// get deleted.  This prevents the package from illegally transitioning from
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   126
// exported to non-exported.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   127
void PackageEntry::purge_qualified_exports() {
52587
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   128
  assert_locked_or_safepoint(Module_lock);
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
   129
  if (_must_walk_exports &&
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
   130
      _qualified_exports != NULL &&
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
   131
      !_qualified_exports->is_empty()) {
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
   132
    ModuleEntry* pkg_module = module();
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
   133
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
   134
    // This package's _must_walk_exports flag will be reset based
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
   135
    // on the remaining live modules on the exports list.
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
   136
    _must_walk_exports = false;
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
   137
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
   138
    if (log_is_enabled(Trace, module)) {
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
   139
      ResourceMark rm;
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
   140
      assert(name() != NULL, "PackageEntry without a valid name");
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
   141
      ModuleEntry* pkg_mod = module();
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
   142
      log_trace(module)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked",
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
   143
                        name()->as_C_string(),
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43471
diff changeset
   144
                        (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
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
   145
    }
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
   146
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   147
    // Go backwards because this removes entries that are dead.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   148
    int len = _qualified_exports->length();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   149
    for (int idx = len - 1; idx >= 0; idx--) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   150
      ModuleEntry* module_idx = _qualified_exports->at(idx);
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
   151
      ClassLoaderData* cld_idx = module_idx->loader_data();
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
      if (cld_idx->is_unloading()) {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   153
        _qualified_exports->delete_at(idx);
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
   154
      } else {
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
   155
        // Update the need to walk this package's exports based on live modules
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
   156
        set_export_walk_required(cld_idx);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   157
      }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   158
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   159
  }
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
void PackageEntry::delete_qualified_exports() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   163
  if (_qualified_exports != NULL) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   164
    delete _qualified_exports;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   165
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   166
  _qualified_exports = NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   167
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   168
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   169
PackageEntryTable::PackageEntryTable(int table_size)
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   170
  : Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   171
{
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   172
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   173
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   174
PackageEntryTable::~PackageEntryTable() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   175
  // Walk through all buckets and all entries in each bucket,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   176
  // freeing each entry.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   177
  for (int i = 0; i < table_size(); ++i) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   178
    for (PackageEntry* p = bucket(i); p != NULL;) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   179
      PackageEntry* to_remove = p;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   180
      // read next before freeing.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   181
      p = p->next();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   182
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   183
      // Clean out the C heap allocated qualified exports list first before freeing the entry
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   184
      to_remove->delete_qualified_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   185
      to_remove->name()->decrement_refcount();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   186
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   187
      // Unlink from the Hashtable prior to freeing
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   188
      unlink_entry(to_remove);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   189
      FREE_C_HEAP_ARRAY(char, to_remove);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   190
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   191
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   192
  assert(number_of_entries() == 0, "should have removed all entries");
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   193
  assert(new_entry_free_list() == NULL, "entry present on PackageEntryTable's free list");
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
PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, ModuleEntry* module) {
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
   197
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
46729
c62d2e8b2728 7133093: Improve system dictionary performance
coleenp
parents: 46475
diff changeset
   198
  PackageEntry* entry = (PackageEntry*)Hashtable<Symbol*, mtModule>::allocate_new_entry(hash, name);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   199
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 47216
diff changeset
   200
  JFR_ONLY(INIT_ID(entry);)
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   201
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   202
  // Initialize fields specific to a PackageEntry
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   203
  entry->init();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   204
  entry->name()->increment_refcount();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   205
  entry->set_module(module);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   206
  return entry;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   207
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   208
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   209
void PackageEntryTable::add_entry(int index, PackageEntry* new_entry) {
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
   210
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
38733
2b65f4db449e 8156156: Add module specific NMT MemoryType
hseigel
parents: 37503
diff changeset
   211
  Hashtable<Symbol*, mtModule>::add_entry(index, (HashtableEntry<Symbol*, mtModule>*)new_entry);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   212
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   213
53471
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   214
// Create package entry in loader's package entry table.  Assume Module lock
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   215
// was taken by caller.
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   216
void PackageEntryTable::locked_create_entry(Symbol* name, ModuleEntry* module) {
39290
0cc9f5028562 8156871: Possible concurrency issue with JVM_AddModuleExports
lfoltan
parents: 38940
diff changeset
   217
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
53471
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   218
  assert(locked_lookup_only(name) == NULL, "Package entry already exists");
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   219
  PackageEntry* entry = new_entry(compute_hash(name), name, module);
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   220
  add_entry(index_for(name), entry);
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   221
}
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   222
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   223
// Create package entry in loader's package entry table if it does not already
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   224
// exist.  Assume Module lock was taken by caller.
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   225
void PackageEntryTable::locked_create_entry_if_not_exist(Symbol* name, ModuleEntry* module) {
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   226
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   227
  // Check if package entry already exists.  If not, create it.
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   228
  if (locked_lookup_only(name) == NULL) {
525f212f1bda 8217660: Refactor module related locked_create_entry_or_null() functions
hseigel
parents: 53441
diff changeset
   229
    locked_create_entry(name, module);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   230
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   231
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   232
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   233
PackageEntry* PackageEntryTable::lookup(Symbol* name, ModuleEntry* module) {
52587
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   234
  MutexLocker ml(Module_lock);
53441
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   235
  PackageEntry* p = locked_lookup_only(name);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   236
  if (p != NULL) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   237
    return p;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   238
  } else {
52587
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   239
    assert(module != NULL, "module should never be null");
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   240
    PackageEntry* entry = new_entry(compute_hash(name), name, module);
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   241
    add_entry(index_for(name), entry);
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   242
    return entry;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   243
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   244
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   245
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   246
PackageEntry* PackageEntryTable::lookup_only(Symbol* name) {
53441
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   247
  assert(!Module_lock->owned_by_self(), "should not have the Module_lock - use locked_lookup_only");
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53471
diff changeset
   248
  MutexLocker ml(Module_lock);
53441
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   249
  return locked_lookup_only(name);
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   250
}
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   251
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   252
PackageEntry* PackageEntryTable::locked_lookup_only(Symbol* name) {
5c2c9555afc1 8217450: Add PackageEntry::locked_lookup_only
redestad
parents: 52631
diff changeset
   253
  assert(Module_lock->owned_by_self(), "should have the Module_lock");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   254
  int index = index_for(name);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   255
  for (PackageEntry* p = bucket(index); p != NULL; p = p->next()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   256
    if (p->name()->fast_compare(name) == 0) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   257
      return p;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   258
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   259
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   260
  return NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   261
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   262
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   263
// Called when a define module for java.base is being processed.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   264
// Verify the packages loaded thus far are in java.base's package list.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   265
void PackageEntryTable::verify_javabase_packages(GrowableArray<Symbol*> *pkg_list) {
46420
227f72691ac1 8179235: PackageEntryTables should be created eagerly
hseigel
parents: 46404
diff changeset
   266
  assert_lock_strong(Module_lock);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   267
  for (int i = 0; i < table_size(); i++) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   268
    for (PackageEntry* entry = bucket(i);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   269
                       entry != NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   270
                       entry = entry->next()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   271
      ModuleEntry* m = entry->module();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   272
      Symbol* module_name = (m == NULL ? NULL : m->name());
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   273
      if (module_name != NULL &&
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   274
          (module_name->fast_compare(vmSymbols::java_base()) == 0) &&
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   275
          !pkg_list->contains(entry->name())) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   276
        ResourceMark rm;
42636
aafc434ba580 8169734: Update uses of string "java.base" to macro
rprotacio
parents: 42073
diff changeset
   277
        vm_exit_during_initialization("A non-" JAVA_BASE_NAME " package was loaded prior to module system initialization", entry->name()->as_C_string());
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   278
      }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   279
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   280
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   281
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   282
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   283
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   284
// iteration of qualified exports
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 47216
diff changeset
   285
void PackageEntry::package_exports_do(ModuleClosure* f) {
38940
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   286
  assert_locked_or_safepoint(Module_lock);
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   287
  assert(f != NULL, "invariant");
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   288
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   289
  if (has_qual_exports_list()) {
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   290
    int qe_len = _qualified_exports->length();
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   291
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   292
    for (int i = 0; i < qe_len; ++i) {
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   293
      f->do_module(_qualified_exports->at(i));
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   294
    }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   295
  }
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   296
}
7de797f32b5f 8152404: Stabilize PackageEntry::package_exports_do
rprotacio
parents: 38733
diff changeset
   297
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   298
bool PackageEntry::exported_pending_delete() const {
52587
6cd56deebb0d 8213092: Add more runtime locks for concurrent class unloading
coleenp
parents: 51375
diff changeset
   299
  assert_locked_or_safepoint(Module_lock);
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   300
  return (is_unqual_exported() && _qualified_exports != NULL);
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   301
}
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   302
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   303
// Remove dead entries from all packages' exported list
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   304
void PackageEntryTable::purge_all_package_exports() {
51375
b812a85b3aa4 8207778: Add locking to ModuleEntry and PackageEntry tables
hseigel
parents: 50113
diff changeset
   305
  assert_locked_or_safepoint(Module_lock);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   306
  for (int i = 0; i < table_size(); i++) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   307
    for (PackageEntry* entry = bucket(i);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   308
                       entry != NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   309
                       entry = entry->next()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   310
      if (entry->exported_pending_delete()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   311
        // exported list is pending deletion due to a transition
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   312
        // from qualified to unqualified
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   313
        entry->delete_qualified_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   314
      } else if (entry->is_qual_exported()) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   315
        entry->purge_qualified_exports();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   316
      }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   317
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   318
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   319
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   320
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   321
void PackageEntryTable::print(outputStream* st) {
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   322
  st->print_cr("Package Entry Table (table_size=%d, entries=%d)",
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   323
               table_size(), number_of_entries());
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   324
  for (int i = 0; i < table_size(); i++) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   325
    for (PackageEntry* probe = bucket(i);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   326
                       probe != NULL;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   327
                       probe = probe->next()) {
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   328
      probe->print(st);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   329
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   330
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   331
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   332
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   333
// This function may be called from debuggers so access private fields directly
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   334
// to prevent triggering locking-related asserts that could result from calling
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   335
// getter methods.
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   336
void PackageEntry::print(outputStream* st) {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   337
  ResourceMark rm;
39625
8702e5b9bfed 8160356: invalid suffix on literal warning is occurred with GCC 6
kbarrett
parents: 39616
diff changeset
   338
  st->print_cr("package entry " PTR_FORMAT " name %s module %s classpath_index "
8702e5b9bfed 8160356: invalid suffix on literal warning is occurred with GCC 6
kbarrett
parents: 39616
diff changeset
   339
               INT32_FORMAT " is_exported_unqualified %d is_exported_allUnnamed %d " "next " PTR_FORMAT,
37503
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   340
               p2i(this), name()->as_C_string(),
77531df4dad3 8152845: Improve PackageEntry and ModuleEntry print methods for future logging
rprotacio
parents: 36508
diff changeset
   341
               (module()->is_named() ? module()->name()->as_C_string() : UNNAMED_MODULE),
43471
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   342
               _classpath_index, _export_flags == PKG_EXP_UNQUALIFIED,
bfb383279a16 8171971: Fix timing bug in JVM management of package export lists
hseigel
parents: 42639
diff changeset
   343
               _export_flags == PKG_EXP_ALLUNNAMED, p2i(next()));
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   344
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   345
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   346
void PackageEntryTable::verify() {
46475
75902cea18af 8166848: Performance bug: SystemDictionary - optimization
coleenp
parents: 46458
diff changeset
   347
  verify_table<PackageEntry>("Package Entry Table");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   348
}
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   349
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   350
void PackageEntry::verify() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   351
  guarantee(name() != NULL, "A package entry must have a corresponding symbol name.");
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   352
}