src/hotspot/share/classfile/systemDictionaryShared.cpp
author iklam
Wed, 13 Nov 2019 16:36:54 -0800
changeset 59070 22ee476cc664
parent 58542 94fe833a244b
permissions -rw-r--r--
8231610: Relocate the CDS archive if it cannot be mapped to the requested address Reviewed-by: jiangli, coleenp, ccheung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     1
/*
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     4
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     8
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    13
 * accompanied this code).
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    14
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    18
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    21
 * questions.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    22
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    23
 */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    24
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    25
#include "precompiled.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    26
#include "classfile/classFileStream.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    27
#include "classfile/classListParser.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    28
#include "classfile/classLoader.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    29
#include "classfile/classLoaderData.inline.hpp"
52468
e0fd97beab7e 8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents: 51823
diff changeset
    30
#include "classfile/classLoaderDataGraph.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    31
#include "classfile/classLoaderExt.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    32
#include "classfile/dictionary.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    33
#include "classfile/javaClasses.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    34
#include "classfile/symbolTable.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    35
#include "classfile/systemDictionary.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    36
#include "classfile/systemDictionaryShared.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    37
#include "classfile/verificationType.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    38
#include "classfile/vmSymbols.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    39
#include "logging/log.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    40
#include "memory/allocation.hpp"
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
    41
#include "memory/archiveUtils.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    42
#include "memory/filemap.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    43
#include "memory/metadataFactory.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    44
#include "memory/metaspaceClosure.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    45
#include "memory/oopFactory.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    46
#include "memory/resourceArea.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 53884
diff changeset
    47
#include "memory/universe.hpp"
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
    48
#include "memory/dynamicArchive.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    49
#include "oops/instanceKlass.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    50
#include "oops/klass.inline.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    51
#include "oops/objArrayOop.inline.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    52
#include "oops/oop.inline.hpp"
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48138
diff changeset
    53
#include "oops/typeArrayOop.inline.hpp"
49393
93fe2fc5c093 8199472: Fix non-PCH build after JDK-8199319
simonis
parents: 49348
diff changeset
    54
#include "runtime/handles.inline.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    55
#include "runtime/java.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    56
#include "runtime/javaCalls.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    57
#include "runtime/mutexLocker.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    58
#include "utilities/hashtable.inline.hpp"
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    59
#include "utilities/resourceHash.hpp"
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    60
#include "utilities/stringUtils.hpp"
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    61
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    62
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    63
objArrayOop SystemDictionaryShared::_shared_protection_domains  =  NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    64
objArrayOop SystemDictionaryShared::_shared_jar_urls            =  NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    65
objArrayOop SystemDictionaryShared::_shared_jar_manifests       =  NULL;
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
    66
DEBUG_ONLY(bool SystemDictionaryShared::_no_class_loading_should_happen = false;)
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    67
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    68
class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
    69
  bool                         _excluded;
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    70
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    71
  struct DTConstraint {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    72
    Symbol* _name;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    73
    Symbol* _from_name;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    74
    DTConstraint() : _name(NULL), _from_name(NULL) {}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    75
    DTConstraint(Symbol* n, Symbol* fn) : _name(n), _from_name(fn) {}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    76
  };
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    77
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    78
  InstanceKlass*               _klass;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    79
  int                          _id;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    80
  int                          _clsfile_size;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    81
  int                          _clsfile_crc32;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    82
  GrowableArray<DTConstraint>* _verifier_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    83
  GrowableArray<char>*         _verifier_constraint_flags;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    84
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    85
  DumpTimeSharedClassInfo() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    86
    _klass = NULL;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    87
    _id = -1;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    88
    _clsfile_size = -1;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    89
    _clsfile_crc32 = -1;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    90
    _excluded = false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    91
    _verifier_constraints = NULL;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    92
    _verifier_constraint_flags = NULL;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    93
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    94
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    95
  void add_verification_constraint(InstanceKlass* k, Symbol* name,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    96
         Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    97
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    98
  bool is_builtin() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
    99
    return SystemDictionaryShared::is_builtin(_klass);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   100
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   101
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   102
  int num_constraints() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   103
    if (_verifier_constraint_flags != NULL) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   104
      return _verifier_constraint_flags->length();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   105
    } else {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   106
      return 0;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   107
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   108
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   109
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   110
  void metaspace_pointers_do(MetaspaceClosure* it) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   111
    it->push(&_klass);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   112
    if (_verifier_constraints != NULL) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   113
      for (int i = 0; i < _verifier_constraints->length(); i++) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   114
        DTConstraint* cons = _verifier_constraints->adr_at(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   115
        it->push(&cons->_name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   116
        it->push(&cons->_from_name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   117
      }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   118
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   119
  }
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   120
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   121
  void set_excluded() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   122
    _excluded = true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   123
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   124
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   125
  bool is_excluded() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   126
    // _klass may become NULL due to DynamicArchiveBuilder::set_to_null
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   127
    return _excluded || _klass == NULL;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   128
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   129
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   130
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   131
class DumpTimeSharedClassTable: public ResourceHashtable<
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   132
  InstanceKlass*,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   133
  DumpTimeSharedClassInfo,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   134
  primitive_hash<InstanceKlass*>,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   135
  primitive_equals<InstanceKlass*>,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   136
  15889, // prime number
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   137
  ResourceObj::C_HEAP>
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   138
{
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   139
  int _builtin_count;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   140
  int _unregistered_count;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   141
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   142
  DumpTimeSharedClassInfo* find_or_allocate_info_for(InstanceKlass* k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   143
    DumpTimeSharedClassInfo* p = get(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   144
    if (p == NULL) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   145
      assert(!SystemDictionaryShared::no_class_loading_should_happen(),
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   146
             "no new classes can be loaded while dumping archive");
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   147
      put(k, DumpTimeSharedClassInfo());
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   148
      p = get(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   149
      assert(p != NULL, "sanity");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   150
      p->_klass = k;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   151
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   152
    return p;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   153
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   154
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   155
  class CountClassByCategory : StackObj {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   156
    DumpTimeSharedClassTable* _table;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   157
  public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   158
    CountClassByCategory(DumpTimeSharedClassTable* table) : _table(table) {}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   159
    bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   160
      if (!info.is_excluded()) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   161
        if (info.is_builtin()) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   162
          ++ _table->_builtin_count;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   163
        } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   164
          ++ _table->_unregistered_count;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   165
        }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   166
      }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   167
      return true; // keep on iterating
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   168
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   169
  };
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   170
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   171
  void update_counts() {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   172
    _builtin_count = 0;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   173
    _unregistered_count = 0;
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   174
    CountClassByCategory counter(this);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   175
    iterate(&counter);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   176
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   177
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   178
  int count_of(bool is_builtin) const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   179
    if (is_builtin) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   180
      return _builtin_count;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   181
    } else {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   182
      return _unregistered_count;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   183
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   184
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   185
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   186
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   187
class RunTimeSharedClassInfo {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   188
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   189
  struct CrcInfo {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   190
    int _clsfile_size;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   191
    int _clsfile_crc32;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   192
  };
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   193
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   194
  // This is different than  DumpTimeSharedClassInfo::DTConstraint. We use
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   195
  // u4 instead of Symbol* to save space on 64-bit CPU.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   196
  struct RTConstraint {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   197
    u4 _name;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   198
    u4 _from_name;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   199
  };
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   200
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   201
  InstanceKlass* _klass;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   202
  int _num_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   203
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   204
  // optional CrcInfo      _crc;  (only for UNREGISTERED classes)
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   205
  // optional RTConstraint _verifier_constraints[_num_constraints]
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   206
  // optional char         _verifier_constraint_flags[_num_constraints]
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   207
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   208
private:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   209
  static size_t header_size_size() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   210
    return sizeof(RunTimeSharedClassInfo);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   211
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   212
  static size_t crc_size(InstanceKlass* klass) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   213
    if (!SystemDictionaryShared::is_builtin(klass)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   214
      return sizeof(CrcInfo);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   215
    } else {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   216
      return 0;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   217
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   218
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   219
  static size_t verifier_constraints_size(int num_constraints) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   220
    return sizeof(RTConstraint) * num_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   221
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   222
  static size_t verifier_constraint_flags_size(int num_constraints) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   223
    return sizeof(char) * num_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   224
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   225
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   226
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   227
  static size_t byte_size(InstanceKlass* klass, int num_constraints) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   228
    return header_size_size() +
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   229
           crc_size(klass) +
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   230
           verifier_constraints_size(num_constraints) +
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   231
           verifier_constraint_flags_size(num_constraints);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   232
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   233
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   234
private:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   235
  size_t crc_offset() const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   236
    return header_size_size();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   237
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   238
  size_t verifier_constraints_offset() const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   239
    return crc_offset() + crc_size(_klass);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   240
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   241
  size_t verifier_constraint_flags_offset() const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   242
    return verifier_constraints_offset() + verifier_constraints_size(_num_constraints);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   243
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   244
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   245
  void check_constraint_offset(int i) const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   246
    assert(0 <= i && i < _num_constraints, "sanity");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   247
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   248
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   249
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   250
  CrcInfo* crc() const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   251
    assert(crc_size(_klass) > 0, "must be");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   252
    return (CrcInfo*)(address(this) + crc_offset());
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   253
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   254
  RTConstraint* verifier_constraints() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   255
    assert(_num_constraints > 0, "sanity");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   256
    return (RTConstraint*)(address(this) + verifier_constraints_offset());
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   257
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   258
  RTConstraint* verifier_constraint_at(int i) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   259
    check_constraint_offset(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   260
    return verifier_constraints() + i;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   261
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   262
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   263
  char* verifier_constraint_flags() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   264
    assert(_num_constraints > 0, "sanity");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   265
    return (char*)(address(this) + verifier_constraint_flags_offset());
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   266
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   267
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   268
  static u4 object_delta_u4(Symbol* sym) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   269
    if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   270
      sym = DynamicArchive::original_to_target(sym);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   271
    }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   272
    return MetaspaceShared::object_delta_u4(sym);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   273
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   274
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   275
  void init(DumpTimeSharedClassInfo& info) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   276
    _klass = info._klass;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   277
    if (!SystemDictionaryShared::is_builtin(_klass)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   278
      CrcInfo* c = crc();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   279
      c->_clsfile_size = info._clsfile_size;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   280
      c->_clsfile_crc32 = info._clsfile_crc32;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   281
    }
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   282
    _num_constraints = info.num_constraints();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   283
    if (_num_constraints > 0) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   284
      RTConstraint* constraints = verifier_constraints();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   285
      char* flags = verifier_constraint_flags();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   286
      int i;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   287
      for (i = 0; i < _num_constraints; i++) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   288
        constraints[i]._name      = object_delta_u4(info._verifier_constraints->at(i)._name);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   289
        constraints[i]._from_name = object_delta_u4(info._verifier_constraints->at(i)._from_name);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   290
      }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   291
      for (i = 0; i < _num_constraints; i++) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   292
        flags[i] = info._verifier_constraint_flags->at(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   293
      }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   294
    }
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   295
    if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   296
      _klass = DynamicArchive::original_to_target(info._klass);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   297
    }
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
   298
    ArchivePtrMarker::mark_pointer(&_klass);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   299
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   300
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   301
  bool matches(int clsfile_size, int clsfile_crc32) const {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   302
    return crc()->_clsfile_size  == clsfile_size &&
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   303
           crc()->_clsfile_crc32 == clsfile_crc32;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   304
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   305
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   306
  Symbol* get_constraint_name(int i) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   307
    return (Symbol*)(SharedBaseAddress + verifier_constraint_at(i)->_name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   308
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   309
  Symbol* get_constraint_from_name(int i) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   310
    return (Symbol*)(SharedBaseAddress + verifier_constraint_at(i)->_from_name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   311
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   312
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   313
  char get_constraint_flag(int i) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   314
    check_constraint_offset(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   315
    return verifier_constraint_flags()[i];
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   316
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   317
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   318
private:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   319
  // ArchiveCompactor::allocate() has reserved a pointer immediately before
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   320
  // archived InstanceKlasses. We can use this slot to do a quick
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   321
  // lookup of InstanceKlass* -> RunTimeSharedClassInfo* without
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   322
  // building a new hashtable.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   323
  //
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   324
  //  info_pointer_addr(klass) --> 0x0100   RunTimeSharedClassInfo*
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   325
  //  InstanceKlass* klass     --> 0x0108   <C++ vtbl>
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   326
  //                               0x0110   fields from Klass ...
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   327
  static RunTimeSharedClassInfo** info_pointer_addr(InstanceKlass* klass) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   328
    return &((RunTimeSharedClassInfo**)klass)[-1];
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   329
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   330
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   331
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   332
  static RunTimeSharedClassInfo* get_for(InstanceKlass* klass) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   333
    return *info_pointer_addr(klass);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   334
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   335
  static void set_for(InstanceKlass* klass, RunTimeSharedClassInfo* record) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   336
    if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   337
      klass = DynamicArchive::original_to_buffer(klass);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   338
      *info_pointer_addr(klass) = DynamicArchive::buffer_to_target(record);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   339
    } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   340
      *info_pointer_addr(klass) = record;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   341
    }
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
   342
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
   343
    ArchivePtrMarker::mark_pointer(info_pointer_addr(klass));
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   344
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   345
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   346
  // Used by RunTimeSharedDictionary to implement OffsetCompactHashtable::EQUALS
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   347
  static inline bool EQUALS(
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   348
       const RunTimeSharedClassInfo* value, Symbol* key, int len_unused) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   349
    return (value->_klass->name() == key);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   350
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   351
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   352
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   353
class RunTimeSharedDictionary : public OffsetCompactHashtable<
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   354
  Symbol*,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   355
  const RunTimeSharedClassInfo*,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   356
  RunTimeSharedClassInfo::EQUALS> {};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   357
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   358
static DumpTimeSharedClassTable* _dumptime_table = NULL;
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   359
// SystemDictionaries in the base layer static archive
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   360
static RunTimeSharedDictionary _builtin_dictionary;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   361
static RunTimeSharedDictionary _unregistered_dictionary;
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   362
// SystemDictionaries in the top layer dynamic archive
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   363
static RunTimeSharedDictionary _dynamic_builtin_dictionary;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   364
static RunTimeSharedDictionary _dynamic_unregistered_dictionary;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   365
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   366
oop SystemDictionaryShared::shared_protection_domain(int index) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   367
  return _shared_protection_domains->obj_at(index);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   368
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   369
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   370
oop SystemDictionaryShared::shared_jar_url(int index) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   371
  return _shared_jar_urls->obj_at(index);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   372
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   373
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   374
oop SystemDictionaryShared::shared_jar_manifest(int index) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   375
  return _shared_jar_manifests->obj_at(index);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   376
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   377
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   378
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   379
Handle SystemDictionaryShared::get_shared_jar_manifest(int shared_path_index, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   380
  Handle manifest ;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   381
  if (shared_jar_manifest(shared_path_index) == NULL) {
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   382
    SharedClassPathEntry* ent = FileMapInfo::shared_path(shared_path_index);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   383
    long size = ent->manifest_size();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   384
    if (size <= 0) {
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   385
      return Handle();
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   386
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   387
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   388
    // ByteArrayInputStream bais = new ByteArrayInputStream(buf);
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   389
    const char* src = ent->manifest();
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   390
    assert(src != NULL, "No Manifest data");
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   391
    typeArrayOop buf = oopFactory::new_byteArray(size, CHECK_NH);
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   392
    typeArrayHandle bufhandle(THREAD, buf);
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50152
diff changeset
   393
    ArrayAccess<>::arraycopy_from_native(reinterpret_cast<const jbyte*>(src),
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 50152
diff changeset
   394
                                         buf, typeArrayOopDesc::element_offset<jbyte>(0), size);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   395
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   396
    Handle bais = JavaCalls::construct_new_instance(SystemDictionary::ByteArrayInputStream_klass(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   397
                      vmSymbols::byte_array_void_signature(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   398
                      bufhandle, CHECK_NH);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   399
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   400
    // manifest = new Manifest(bais)
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   401
    manifest = JavaCalls::construct_new_instance(SystemDictionary::Jar_Manifest_klass(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   402
                      vmSymbols::input_stream_void_signature(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   403
                      bais, CHECK_NH);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   404
    atomic_set_shared_jar_manifest(shared_path_index, manifest());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   405
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   406
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   407
  manifest = Handle(THREAD, shared_jar_manifest(shared_path_index));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   408
  assert(manifest.not_null(), "sanity");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   409
  return manifest;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   410
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   411
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   412
Handle SystemDictionaryShared::get_shared_jar_url(int shared_path_index, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   413
  Handle url_h;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   414
  if (shared_jar_url(shared_path_index) == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   415
    JavaValue result(T_OBJECT);
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   416
    const char* path = FileMapInfo::shared_path_name(shared_path_index);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   417
    Handle path_string = java_lang_String::create_from_str(path, CHECK_(url_h));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   418
    Klass* classLoaders_klass =
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   419
        SystemDictionary::jdk_internal_loader_ClassLoaders_klass();
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   420
    JavaCalls::call_static(&result, classLoaders_klass,
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   421
                           vmSymbols::toFileURL_name(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   422
                           vmSymbols::toFileURL_signature(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   423
                           path_string, CHECK_(url_h));
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   424
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   425
    atomic_set_shared_jar_url(shared_path_index, (oop)result.get_jobject());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   426
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   427
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   428
  url_h = Handle(THREAD, shared_jar_url(shared_path_index));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   429
  assert(url_h.not_null(), "sanity");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   430
  return url_h;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   431
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   432
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   433
Handle SystemDictionaryShared::get_package_name(Symbol* class_name, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   434
  ResourceMark rm(THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   435
  Handle pkgname_string;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   436
  char* pkgname = (char*) ClassLoader::package_from_name((const char*) class_name->as_C_string());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   437
  if (pkgname != NULL) { // Package prefix found
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   438
    StringUtils::replace_no_expand(pkgname, "/", ".");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   439
    pkgname_string = java_lang_String::create_from_str(pkgname,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   440
                                                       CHECK_(pkgname_string));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   441
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   442
  return pkgname_string;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   443
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   444
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   445
// Define Package for shared app classes from JAR file and also checks for
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   446
// package sealing (all done in Java code)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   447
// See http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   448
void SystemDictionaryShared::define_shared_package(Symbol*  class_name,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   449
                                                   Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   450
                                                   Handle manifest,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   451
                                                   Handle url,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   452
                                                   TRAPS) {
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   453
  assert(SystemDictionary::is_system_class_loader(class_loader()), "unexpected class loader");
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   454
  // get_package_name() returns a NULL handle if the class is in unnamed package
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   455
  Handle pkgname_string = get_package_name(class_name, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   456
  if (pkgname_string.not_null()) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   457
    Klass* app_classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   458
    JavaValue result(T_OBJECT);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   459
    JavaCallArguments args(3);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   460
    args.set_receiver(class_loader);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   461
    args.push_oop(pkgname_string);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   462
    args.push_oop(manifest);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   463
    args.push_oop(url);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   464
    JavaCalls::call_virtual(&result, app_classLoader_klass,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   465
                            vmSymbols::defineOrCheckPackage_name(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   466
                            vmSymbols::defineOrCheckPackage_signature(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   467
                            &args,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   468
                            CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   469
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   470
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   471
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   472
// Define Package for shared app/platform classes from named module
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   473
void SystemDictionaryShared::define_shared_package(Symbol* class_name,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   474
                                                   Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   475
                                                   ModuleEntry* mod_entry,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   476
                                                   TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   477
  assert(mod_entry != NULL, "module_entry should not be NULL");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   478
  Handle module_handle(THREAD, mod_entry->module());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   479
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   480
  Handle pkg_name = get_package_name(class_name, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   481
  assert(pkg_name.not_null(), "Package should not be null for class in named module");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   482
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   483
  Klass* classLoader_klass;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   484
  if (SystemDictionary::is_system_class_loader(class_loader())) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   485
    classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   486
  } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   487
    assert(SystemDictionary::is_platform_class_loader(class_loader()), "unexpected classloader");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   488
    classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   489
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   490
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   491
  JavaValue result(T_OBJECT);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   492
  JavaCallArguments args(2);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   493
  args.set_receiver(class_loader);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   494
  args.push_oop(pkg_name);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   495
  args.push_oop(module_handle);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   496
  JavaCalls::call_virtual(&result, classLoader_klass,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   497
                          vmSymbols::definePackage_name(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   498
                          vmSymbols::definePackage_signature(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   499
                          &args,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   500
                          CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   501
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   502
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   503
// Get the ProtectionDomain associated with the CodeSource from the classloader.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   504
Handle SystemDictionaryShared::get_protection_domain_from_classloader(Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   505
                                                                      Handle url, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   506
  // CodeSource cs = new CodeSource(url, null);
50152
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   507
  Handle cs = JavaCalls::construct_new_instance(SystemDictionary::CodeSource_klass(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   508
                  vmSymbols::url_code_signer_array_void_signature(),
b5023063346d 8189140: SystemDictionaryShared::initialize() should be renamed to be more meaningful
iklam
parents: 50039
diff changeset
   509
                  url, Handle(), CHECK_NH);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   510
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   511
  // protection_domain = SecureClassLoader.getProtectionDomain(cs);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   512
  Klass* secureClassLoader_klass = SystemDictionary::SecureClassLoader_klass();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   513
  JavaValue obj_result(T_OBJECT);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   514
  JavaCalls::call_virtual(&obj_result, class_loader, secureClassLoader_klass,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   515
                          vmSymbols::getProtectionDomain_name(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   516
                          vmSymbols::getProtectionDomain_signature(),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   517
                          cs, CHECK_NH);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   518
  return Handle(THREAD, (oop)obj_result.get_jobject());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   519
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   520
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   521
// Returns the ProtectionDomain associated with the JAR file identified by the url.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   522
Handle SystemDictionaryShared::get_shared_protection_domain(Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   523
                                                            int shared_path_index,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   524
                                                            Handle url,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   525
                                                            TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   526
  Handle protection_domain;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   527
  if (shared_protection_domain(shared_path_index) == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   528
    Handle pd = get_protection_domain_from_classloader(class_loader, url, THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   529
    atomic_set_shared_protection_domain(shared_path_index, pd());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   530
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   531
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   532
  // Acquire from the cache because if another thread beats the current one to
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   533
  // set the shared protection_domain and the atomic_set fails, the current thread
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   534
  // needs to get the updated protection_domain from the cache.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   535
  protection_domain = Handle(THREAD, shared_protection_domain(shared_path_index));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   536
  assert(protection_domain.not_null(), "sanity");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   537
  return protection_domain;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   538
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   539
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   540
// Returns the ProtectionDomain associated with the moduleEntry.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   541
Handle SystemDictionaryShared::get_shared_protection_domain(Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   542
                                                            ModuleEntry* mod, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   543
  ClassLoaderData *loader_data = mod->loader_data();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   544
  if (mod->shared_protection_domain() == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   545
    Symbol* location = mod->location();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   546
    if (location != NULL) {
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   547
      Handle location_string = java_lang_String::create_from_symbol(
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   548
                                     location, CHECK_NH);
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   549
      Handle url;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   550
      JavaValue result(T_OBJECT);
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   551
      if (location->starts_with("jrt:/")) {
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   552
        url = JavaCalls::construct_new_instance(SystemDictionary::URL_klass(),
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   553
                                                vmSymbols::string_void_signature(),
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   554
                                                location_string, CHECK_NH);
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   555
      } else {
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   556
        Klass* classLoaders_klass =
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   557
          SystemDictionary::jdk_internal_loader_ClassLoaders_klass();
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   558
        JavaCalls::call_static(&result, classLoaders_klass, vmSymbols::toFileURL_name(),
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   559
                               vmSymbols::toFileURL_signature(),
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   560
                               location_string, CHECK_NH);
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   561
        url = Handle(THREAD, (oop)result.get_jobject());
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   562
      }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   563
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   564
      Handle pd = get_protection_domain_from_classloader(class_loader, url,
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   565
                                                         CHECK_NH);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   566
      mod->set_shared_protection_domain(loader_data, pd);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   567
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   568
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   569
53249
fbab5d82f3d7 8214827: Incorrect call ClassLoaders.toFileURL("jrt:/java.compiler")
jiangli
parents: 52514
diff changeset
   570
  Handle protection_domain(THREAD, mod->shared_protection_domain());
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   571
  assert(protection_domain.not_null(), "sanity");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   572
  return protection_domain;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   573
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   574
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   575
// Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   576
// the given InstanceKlass.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   577
// Returns the ProtectionDomain for the InstanceKlass.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   578
Handle SystemDictionaryShared::init_security_info(Handle class_loader, InstanceKlass* ik, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   579
  Handle pd;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   580
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   581
  if (ik != NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   582
    int index = ik->shared_classpath_index();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   583
    assert(index >= 0, "Sanity");
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   584
    SharedClassPathEntry* ent = FileMapInfo::shared_path(index);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   585
    Symbol* class_name = ik->name();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   586
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   587
    if (ent->is_modules_image()) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   588
      // For shared app/platform classes originated from the run-time image:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   589
      //   The ProtectionDomains are cached in the corresponding ModuleEntries
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   590
      //   for fast access by the VM.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   591
      ResourceMark rm;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   592
      ClassLoaderData *loader_data =
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   593
                ClassLoaderData::class_loader_data(class_loader());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   594
      PackageEntryTable* pkgEntryTable = loader_data->packages();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   595
      TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   596
      if (pkg_name != NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   597
        PackageEntry* pkg_entry = pkgEntryTable->lookup_only(pkg_name);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   598
        if (pkg_entry != NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   599
          ModuleEntry* mod_entry = pkg_entry->module();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   600
          pd = get_shared_protection_domain(class_loader, mod_entry, THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   601
          define_shared_package(class_name, class_loader, mod_entry, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   602
        }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   603
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   604
    } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   605
      // For shared app/platform classes originated from JAR files on the class path:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   606
      //   Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   607
      //   as the shared classpath table in the shared archive (see
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   608
      //   FileMap::_shared_path_table in filemap.hpp for details).
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   609
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   610
      //   If a shared InstanceKlass k is loaded from the class path, let
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   611
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   612
      //     index = k->shared_classpath_index():
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   613
      //
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   614
      //   FileMap::_shared_path_table[index] identifies the JAR file that contains k.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   615
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   616
      //   k's protection domain is:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   617
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   618
      //     ProtectionDomain pd = _shared_protection_domains[index];
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   619
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   620
      //   and k's Package is initialized using
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   621
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   622
      //     manifest = _shared_jar_manifests[index];
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   623
      //     url = _shared_jar_urls[index];
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   624
      //     define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   625
      //
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   626
      //   Note that if an element of these 3 _shared_xxx arrays is NULL, it will be initialized by
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   627
      //   the corresponding SystemDictionaryShared::get_shared_xxx() function.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   628
      Handle manifest = get_shared_jar_manifest(index, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   629
      Handle url = get_shared_jar_url(index, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   630
      define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   631
      pd = get_shared_protection_domain(class_loader, index, url, CHECK_(pd));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   632
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   633
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   634
  return pd;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   635
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   636
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49739
diff changeset
   637
bool SystemDictionaryShared::is_sharing_possible(ClassLoaderData* loader_data) {
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49739
diff changeset
   638
  oop class_loader = loader_data->class_loader();
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49739
diff changeset
   639
  return (class_loader == NULL ||
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   640
          SystemDictionary::is_system_class_loader(class_loader) ||
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   641
          SystemDictionary::is_platform_class_loader(class_loader));
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49739
diff changeset
   642
}
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49739
diff changeset
   643
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   644
// Currently AppCDS only archives classes from the run-time image, the
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   645
// -Xbootclasspath/a path, the class path, and the module path.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   646
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   647
// Check if a shared class can be loaded by the specific classloader. Following
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   648
// are the "visible" archived classes for different classloaders.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   649
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   650
// NULL classloader:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   651
//   - see SystemDictionary::is_shared_class_visible()
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   652
// Platform classloader:
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   653
//   - Module class from runtime image. ModuleEntry must be defined in the
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   654
//     classloader.
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   655
// App classloader:
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   656
//   - Module Class from runtime image and module path. ModuleEntry must be defined in the
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   657
//     classloader.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   658
//   - Class from -cp. The class must have no PackageEntry defined in any of the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   659
//     boot/platform/app classloader, or must be in the unnamed module defined in the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   660
//     AppClassLoader.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   661
bool SystemDictionaryShared::is_shared_class_visible_for_classloader(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   662
                                                     InstanceKlass* ik,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   663
                                                     Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   664
                                                     Symbol* pkg_name,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   665
                                                     PackageEntry* pkg_entry,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   666
                                                     ModuleEntry* mod_entry,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   667
                                                     TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   668
  assert(class_loader.not_null(), "Class loader should not be NULL");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   669
  assert(Universe::is_module_initialized(), "Module system is not initialized");
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   670
  ResourceMark rm(THREAD);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   671
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   672
  int path_index = ik->shared_classpath_index();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   673
  SharedClassPathEntry* ent =
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   674
            (SharedClassPathEntry*)FileMapInfo::shared_path(path_index);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   675
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   676
  if (SystemDictionary::is_platform_class_loader(class_loader())) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   677
    assert(ent != NULL, "shared class for PlatformClassLoader should have valid SharedClassPathEntry");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   678
    // The PlatformClassLoader can only load archived class originated from the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   679
    // run-time image. The class' PackageEntry/ModuleEntry must be
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   680
    // defined by the PlatformClassLoader.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   681
    if (mod_entry != NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   682
      // PackageEntry/ModuleEntry is found in the classloader. Check if the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   683
      // ModuleEntry's location agrees with the archived class' origination.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   684
      if (ent->is_modules_image() && mod_entry->location()->starts_with("jrt:")) {
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   685
        return true; // Module class from the runtime image
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   686
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   687
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   688
  } else if (SystemDictionary::is_system_class_loader(class_loader())) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   689
    assert(ent != NULL, "shared class for system loader should have valid SharedClassPathEntry");
58499
d62c7224d5b7 8231993: Remove redundant pkg_str param from is_shared_class_visible_for_classloader
redestad
parents: 58447
diff changeset
   690
    if (pkg_name == NULL) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   691
      // The archived class is in the unnamed package. Currently, the boot image
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   692
      // does not contain any class in the unnamed package.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   693
      assert(!ent->is_modules_image(), "Class in the unnamed package must be from the classpath");
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   694
      if (path_index >= ClassLoaderExt::app_class_paths_start_index()) {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   695
        assert(path_index < ClassLoaderExt::app_module_paths_start_index(), "invalid path_index");
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   696
        return true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   697
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   698
    } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   699
      // Check if this is from a PackageEntry/ModuleEntry defined in the AppClassloader.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   700
      if (pkg_entry == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   701
        // It's not guaranteed that the class is from the classpath if the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   702
        // PackageEntry cannot be found from the AppClassloader. Need to check
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   703
        // the boot and platform classloader as well.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   704
        if (get_package_entry(pkg_name, ClassLoaderData::class_loader_data_or_null(SystemDictionary::java_platform_loader())) == NULL &&
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   705
            get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()) == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   706
          // The PackageEntry is not defined in any of the boot/platform/app classloaders.
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   707
          // The archived class must from -cp path and not from the runtime image.
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   708
          if (!ent->is_modules_image() && path_index >= ClassLoaderExt::app_class_paths_start_index() &&
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   709
                                          path_index < ClassLoaderExt::app_module_paths_start_index()) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   710
            return true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   711
          }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   712
        }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   713
      } else if (mod_entry != NULL) {
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   714
        // The package/module is defined in the AppClassLoader. We support
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   715
        // archiving application module class from the runtime image or from
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   716
        // a named module from a module path.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   717
        // Packages from the -cp path are in the unnamed_module.
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   718
        if (ent->is_modules_image() && mod_entry->location()->starts_with("jrt:")) {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   719
          // shared module class from runtime image
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   720
          return true;
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   721
        } else if (pkg_entry->in_unnamed_module() && path_index >= ClassLoaderExt::app_class_paths_start_index() &&
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   722
            path_index < ClassLoaderExt::app_module_paths_start_index()) {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   723
          // shared class from -cp
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   724
          DEBUG_ONLY( \
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   725
            ClassLoaderData* loader_data = class_loader_data(class_loader); \
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   726
            assert(mod_entry == loader_data->unnamed_module(), "the unnamed module is not defined in the classloader");)
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   727
          return true;
49739
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   728
        } else {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   729
          if(!pkg_entry->in_unnamed_module() &&
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   730
              (path_index >= ClassLoaderExt::app_module_paths_start_index())&&
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   731
              (path_index < FileMapInfo::get_number_of_shared_paths()) &&
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   732
              (strcmp(ent->name(), ClassLoader::skip_uri_protocol(mod_entry->location()->as_C_string())) == 0)) {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   733
            // shared module class from module path
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   734
            return true;
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   735
          } else {
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   736
            assert(path_index < FileMapInfo::get_number_of_shared_paths(), "invalid path_index");
00805b129186 8194812: Extend class-data sharing to support the module path
ccheung
parents: 49393
diff changeset
   737
          }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   738
        }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   739
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   740
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   741
  } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   742
    // TEMP: if a shared class can be found by a custom loader, consider it visible now.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   743
    // FIXME: is this actually correct?
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   744
    return true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   745
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   746
  return false;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   747
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   748
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   749
bool SystemDictionaryShared::has_platform_or_app_classes() {
58096
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 58084
diff changeset
   750
  if (FileMapInfo::current_info()->has_platform_or_app_classes()) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   751
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   752
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   753
  if (DynamicArchive::is_mapped() &&
58096
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 58084
diff changeset
   754
      FileMapInfo::dynamic_info()->has_platform_or_app_classes()) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   755
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   756
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   757
  return false;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   758
}
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   759
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   760
// The following stack shows how this code is reached:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   761
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   762
//   [0] SystemDictionaryShared::find_or_load_shared_class()
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   763
//   [1] JVM_FindLoadedClass
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   764
//   [2] java.lang.ClassLoader.findLoadedClass0()
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   765
//   [3] java.lang.ClassLoader.findLoadedClass()
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   766
//   [4] jdk.internal.loader.BuiltinClassLoader.loadClassOrNull()
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   767
//   [5] jdk.internal.loader.BuiltinClassLoader.loadClass()
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   768
//   [6] jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(), or
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   769
//       jdk.internal.loader.ClassLoaders$PlatformClassLoader.loadClass()
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   770
//
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   771
// AppCDS supports fast class loading for these 2 built-in class loaders:
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   772
//    jdk.internal.loader.ClassLoaders$PlatformClassLoader
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   773
//    jdk.internal.loader.ClassLoaders$AppClassLoader
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   774
// with the following assumptions (based on the JDK core library source code):
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   775
//
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   776
// [a] these two loaders use the BuiltinClassLoader.loadClassOrNull() to
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   777
//     load the named class.
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   778
// [b] BuiltinClassLoader.loadClassOrNull() first calls findLoadedClass(name).
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   779
// [c] At this point, if we can find the named class inside the
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   780
//     shared_dictionary, we can perform further checks (see
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   781
//     is_shared_class_visible_for_classloader() to ensure that this class
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   782
//     was loaded by the same class loader during dump time.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   783
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   784
// Given these assumptions, we intercept the findLoadedClass() call to invoke
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   785
// SystemDictionaryShared::find_or_load_shared_class() to load the shared class from
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   786
// the archive for the 2 built-in class loaders. This way,
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   787
// we can improve start-up because we avoid decoding the classfile,
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   788
// and avoid delegating to the parent loader.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   789
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   790
// NOTE: there's a lot of assumption about the Java code. If any of that change, this
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   791
// needs to be redesigned.
50039
9fec54fe663d 8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents: 49931
diff changeset
   792
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   793
InstanceKlass* SystemDictionaryShared::find_or_load_shared_class(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   794
                 Symbol* name, Handle class_loader, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   795
  InstanceKlass* k = NULL;
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   796
  if (UseSharedSpaces) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   797
    if (!has_platform_or_app_classes()) {
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   798
      return NULL;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   799
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   800
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   801
    if (SystemDictionary::is_system_class_loader(class_loader()) ||
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   802
        SystemDictionary::is_platform_class_loader(class_loader())) {
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   803
      // Fix for 4474172; see evaluation for more details
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   804
      class_loader = Handle(
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   805
        THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader()));
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   806
      ClassLoaderData *loader_data = register_loader(class_loader);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   807
      Dictionary* dictionary = loader_data->dictionary();
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   808
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   809
      unsigned int d_hash = dictionary->compute_hash(name);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   810
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   811
      bool DoObjectLock = true;
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   812
      if (is_parallelCapable(class_loader)) {
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   813
        DoObjectLock = false;
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   814
      }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   815
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   816
      // Make sure we are synchronized on the class loader before we proceed
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   817
      //
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   818
      // Note: currently, find_or_load_shared_class is called only from
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   819
      // JVM_FindLoadedClass and used for PlatformClassLoader and AppClassLoader,
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   820
      // which are parallel-capable loaders, so this lock is NOT taken.
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   821
      Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   822
      check_loader_lock_contention(lockObject, THREAD);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   823
      ObjectLocker ol(lockObject, THREAD, DoObjectLock);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   824
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   825
      {
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   826
        MutexLocker mu(SystemDictionary_lock, THREAD);
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
   827
        InstanceKlass* check = find_class(d_hash, name, dictionary);
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   828
        if (check != NULL) {
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
   829
          return check;
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   830
        }
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   831
      }
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   832
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   833
      k = load_shared_class_for_builtin_loader(name, class_loader, THREAD);
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   834
      if (k != NULL) {
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   835
        define_instance_class(k, CHECK_NULL);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   836
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   837
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   838
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   839
  return k;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   840
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   841
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   842
InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   843
                 Symbol* class_name, Handle class_loader, TRAPS) {
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   844
  assert(UseSharedSpaces, "must be");
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   845
  InstanceKlass* ik = find_builtin_class(class_name);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   846
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
   847
  if (ik != NULL) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   848
    if ((ik->is_shared_app_class() &&
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   849
         SystemDictionary::is_system_class_loader(class_loader()))  ||
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   850
        (ik->is_shared_platform_class() &&
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   851
         SystemDictionary::is_platform_class_loader(class_loader()))) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   852
      Handle protection_domain =
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   853
        SystemDictionaryShared::init_security_info(class_loader, ik, CHECK_NULL);
53884
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   854
      return load_shared_class(ik, class_loader, protection_domain, NULL, THREAD);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   855
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   856
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   857
  return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   858
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   859
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   860
void SystemDictionaryShared::oops_do(OopClosure* f) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   861
  f->do_oop((oop*)&_shared_protection_domains);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   862
  f->do_oop((oop*)&_shared_jar_urls);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   863
  f->do_oop((oop*)&_shared_jar_manifests);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   864
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   865
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   866
void SystemDictionaryShared::allocate_shared_protection_domain_array(int size, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   867
  if (_shared_protection_domains == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   868
    _shared_protection_domains = oopFactory::new_objArray(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   869
        SystemDictionary::ProtectionDomain_klass(), size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   870
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   871
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   872
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   873
void SystemDictionaryShared::allocate_shared_jar_url_array(int size, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   874
  if (_shared_jar_urls == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   875
    _shared_jar_urls = oopFactory::new_objArray(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   876
        SystemDictionary::URL_klass(), size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   877
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   878
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   879
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   880
void SystemDictionaryShared::allocate_shared_jar_manifest_array(int size, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   881
  if (_shared_jar_manifests == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   882
    _shared_jar_manifests = oopFactory::new_objArray(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   883
        SystemDictionary::Jar_Manifest_klass(), size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   884
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   885
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   886
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   887
void SystemDictionaryShared::allocate_shared_data_arrays(int size, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   888
  allocate_shared_protection_domain_array(size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   889
  allocate_shared_jar_url_array(size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   890
  allocate_shared_jar_manifest_array(size, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   891
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   892
49931
840e26123940 8193213: Make the UseAppCDS option obsolete.
jiangli
parents: 49824
diff changeset
   893
// This function is called for loading only UNREGISTERED classes
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   894
InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name,
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   895
                                                          Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   896
                                                          Handle protection_domain,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   897
                                                          const ClassFileStream* cfs,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   898
                                                          TRAPS) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   899
  if (!UseSharedSpaces) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   900
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   901
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   902
  if (class_name == NULL) {  // don't do this for anonymous classes
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   903
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   904
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   905
  if (class_loader.is_null() ||
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   906
      SystemDictionary::is_system_class_loader(class_loader()) ||
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   907
      SystemDictionary::is_platform_class_loader(class_loader())) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   908
    // Do nothing for the BUILTIN loaders.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   909
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   910
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   911
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
   912
  const RunTimeSharedClassInfo* record = find_record(&_unregistered_dictionary, &_dynamic_unregistered_dictionary, class_name);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   913
  if (record == NULL) {
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
   914
    return NULL;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   915
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   916
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   917
  int clsfile_size  = cfs->length();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   918
  int clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
   919
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   920
  if (!record->matches(clsfile_size, clsfile_crc32)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   921
    return NULL;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   922
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   923
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   924
  return acquire_class_for_current_thread(record->_klass, class_loader,
53884
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   925
                                          protection_domain, cfs,
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   926
                                          THREAD);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   927
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   928
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   929
InstanceKlass* SystemDictionaryShared::acquire_class_for_current_thread(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   930
                   InstanceKlass *ik,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   931
                   Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   932
                   Handle protection_domain,
53884
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   933
                   const ClassFileStream *cfs,
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   934
                   TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   935
  ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   936
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   937
  {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   938
    MutexLocker mu(SharedDictionary_lock, THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   939
    if (ik->class_loader_data() != NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   940
      //    ik is already loaded (by this loader or by a different loader)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   941
      // or ik is being loaded by a different thread (by this loader or by a different loader)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   942
      return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   943
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   944
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   945
    // No other thread has acquired this yet, so give it to *this thread*
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   946
    ik->set_class_loader_data(loader_data);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   947
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   948
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   949
  // No longer holding SharedDictionary_lock
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   950
  // No need to lock, as <ik> can be held only by a single thread.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   951
  loader_data->add_class(ik);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   952
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   953
  // Load and check super/interfaces, restore unsharable info
53884
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   954
  InstanceKlass* shared_klass = load_shared_class(ik, class_loader, protection_domain,
1a7b57d02107 8218751: Do not store original classfiles inside the CDS archive
iklam
parents: 53249
diff changeset
   955
                                                  cfs, THREAD);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   956
  if (shared_klass == NULL || HAS_PENDING_EXCEPTION) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   957
    // TODO: clean up <ik> so it can be used again
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   958
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   959
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   960
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   961
  return shared_klass;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   962
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   963
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   964
static ResourceHashtable<
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   965
  Symbol*, bool,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   966
  primitive_hash<Symbol*>,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   967
  primitive_equals<Symbol*>,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   968
  6661,                             // prime number
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   969
  ResourceObj::C_HEAP> _loaded_unregistered_classes;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   970
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   971
bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   972
  assert(DumpSharedSpaces, "only when dumping");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   973
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   974
  Symbol* name = k->name();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   975
  if (_loaded_unregistered_classes.get(name) != NULL) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   976
    // We don't allow duplicated unregistered classes of the same name.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   977
    return false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   978
  } else {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   979
    bool isnew = _loaded_unregistered_classes.put(name, true);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   980
    assert(isnew, "sanity");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   981
    MutexLocker mu_r(Compile_lock, THREAD); // add_to_hierarchy asserts this.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
   982
    SystemDictionary::add_to_hierarchy(k, CHECK_0);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   983
    return true;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   984
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   985
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   986
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   987
// This function is called to resolve the super/interfaces of shared classes for
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   988
// non-built-in loaders. E.g., ChildClass in the below example
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   989
// where "super:" (and optionally "interface:") have been specified.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   990
//
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   991
// java/lang/Object id: 0
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   992
// Interface   id: 2 super: 0 source: cust.jar
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   993
// ChildClass  id: 4 super: 0 interfaces: 2 source: cust.jar
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
   994
InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail(
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   995
    Symbol* child_name, Symbol* class_name, Handle class_loader,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   996
    Handle protection_domain, bool is_superclass, TRAPS) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   997
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   998
  assert(DumpSharedSpaces, "only when dumping");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   999
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1000
  ClassListParser* parser = ClassListParser::instance();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1001
  if (parser == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1002
    // We're still loading the well-known classes, before the ClassListParser is created.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1003
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1004
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1005
  if (child_name->equals(parser->current_class_name())) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1006
    // When this function is called, all the numbered super and interface types
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1007
    // must have already been loaded. Hence this function is never recursively called.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1008
    if (is_superclass) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1009
      return parser->lookup_super_for_current_class(class_name);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1010
    } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1011
      return parser->lookup_interface_for_current_class(class_name);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1012
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1013
  } else {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1014
    // The VM is not trying to resolve a super type of parser->current_class_name().
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1015
    // Instead, it's resolving an error class (because parser->current_class_name() has
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1016
    // failed parsing or verification). Don't do anything here.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1017
    return NULL;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1018
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1019
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1020
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1021
DumpTimeSharedClassInfo* SystemDictionaryShared::find_or_allocate_info_for(InstanceKlass* k) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1022
  MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1023
  if (_dumptime_table == NULL) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1024
    _dumptime_table = new (ResourceObj::C_HEAP, mtClass)DumpTimeSharedClassTable();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1025
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1026
  return _dumptime_table->find_or_allocate_info_for(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1027
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1028
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
  1029
void SystemDictionaryShared::set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs) {
58447
319173c62caa 8231606: _method_ordering is not set during CDS dynamic dump time
ccheung
parents: 58096
diff changeset
  1030
  Arguments::assert_is_dumping_archive();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1031
  assert(!is_builtin(k), "must be unregistered class");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1032
  DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1033
  info->_clsfile_size  = cfs->length();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1034
  info->_clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1035
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1036
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1037
void SystemDictionaryShared::init_dumptime_info(InstanceKlass* k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1038
  (void)find_or_allocate_info_for(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1039
}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1040
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1041
void SystemDictionaryShared::remove_dumptime_info(InstanceKlass* k) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1042
  MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1043
  DumpTimeSharedClassInfo* p = _dumptime_table->get(k);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1044
  if (p == NULL) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1045
    return;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1046
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1047
  if (p->_verifier_constraints != NULL) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1048
    for (int i = 0; i < p->_verifier_constraints->length(); i++) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1049
      DumpTimeSharedClassInfo::DTConstraint constraint = p->_verifier_constraints->at(i);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1050
      if (constraint._name != NULL ) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1051
        constraint._name->decrement_refcount();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1052
      }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1053
      if (constraint._from_name != NULL ) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1054
        constraint._from_name->decrement_refcount();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1055
      }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1056
    }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1057
    FREE_C_HEAP_ARRAY(DTConstraint, p->_verifier_constraints);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1058
    p->_verifier_constraints = NULL;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1059
  }
58084
cddef3bde924 8230398: Remove NULL checks before FREE_C_HEAP_ARRAY
lkorinth
parents: 54927
diff changeset
  1060
  FREE_C_HEAP_ARRAY(char, p->_verifier_constraint_flags);
cddef3bde924 8230398: Remove NULL checks before FREE_C_HEAP_ARRAY
lkorinth
parents: 54927
diff changeset
  1061
  p->_verifier_constraint_flags = NULL;
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1062
  _dumptime_table->remove(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1063
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1064
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1065
bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1066
  while (k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1067
    if (k->name()->equals("jdk/internal/event/Event")) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1068
      return true;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1069
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1070
    k = k->java_super();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1071
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1072
  return false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1073
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1074
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1075
void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1076
  ResourceMark rm;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1077
  log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1078
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1079
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1080
bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1081
  if (k->class_loader_data()->is_unsafe_anonymous()) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1082
    warn_excluded(k, "Unsafe anonymous class");
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1083
    return true; // unsafe anonymous classes are not archived, skip
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1084
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1085
  if (k->is_in_error_state()) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1086
    warn_excluded(k, "In error state");
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1087
    return true;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1088
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1089
  if (k->shared_classpath_index() < 0 && is_builtin(k)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1090
    // These are classes loaded from unsupported locations (such as those loaded by JVMTI native
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1091
    // agent during dump time).
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1092
    warn_excluded(k, "Unsupported location");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1093
    return true;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1094
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1095
  if (k->signers() != NULL) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1096
    // We cannot include signed classes in the archive because the certificates
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1097
    // used during dump time may be different than those used during
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1098
    // runtime (due to expiration, etc).
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1099
    warn_excluded(k, "Signed JAR");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1100
    return true;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1101
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1102
  if (is_jfr_event_class(k)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1103
    // We cannot include JFR event classes because they need runtime-specific
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1104
    // instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1105
    // There are only a small number of these classes, so it's not worthwhile to
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1106
    // support them and make CDS more complicated.
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1107
    warn_excluded(k, "JFR event class");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1108
    return true;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1109
  }
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1110
  if (k->init_state() < InstanceKlass::linked) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1111
    // In static dumping, we will attempt to link all classes. Those that fail to link will
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1112
    // be marked as in error state.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1113
    assert(DynamicDumpSharedSpaces, "must be");
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1114
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1115
    // TODO -- rethink how this can be handled.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1116
    // We should try to link ik, however, we can't do it here because
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1117
    // 1. We are at VM exit
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1118
    // 2. linking a class may cause other classes to be loaded, which means
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1119
    //    a custom ClassLoader.loadClass() may be called, at a point where the
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1120
    //    class loader doesn't expect it.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1121
    warn_excluded(k, "Not linked");
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1122
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1123
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1124
  if (k->major_version() < 50 /*JAVA_6_VERSION*/) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1125
    ResourceMark rm;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1126
    log_warning(cds)("Pre JDK 6 class not supported by CDS: %u.%u %s",
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1127
                     k->major_version(),  k->minor_version(), k->name()->as_C_string());
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1128
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1129
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1130
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1131
  InstanceKlass* super = k->java_super();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1132
  if (super != NULL && should_be_excluded(super)) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1133
    ResourceMark rm;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1134
    log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1135
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1136
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1137
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1138
  Array<InstanceKlass*>* interfaces = k->local_interfaces();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1139
  int len = interfaces->length();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1140
  for (int i = 0; i < len; i++) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1141
    InstanceKlass* intf = interfaces->at(i);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1142
    if (should_be_excluded(intf)) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1143
      log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1144
      return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1145
    }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1146
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1147
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1148
  return false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1149
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1150
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1151
// k is a class before relocating by ArchiveCompactor
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1152
void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1153
  ResourceMark rm;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1154
  const char* name = k->name()->as_C_string();
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1155
  DumpTimeSharedClassInfo* info = _dumptime_table->get(k);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1156
  assert(_no_class_loading_should_happen, "class loading must be disabled");
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1157
  guarantee(info != NULL, "Class %s must be entered into _dumptime_table", name);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1158
  guarantee(!info->is_excluded(), "Should not attempt to archive excluded class %s", name);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1159
  if (is_builtin(k)) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1160
    guarantee(k->loader_type() != 0,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1161
              "Class loader type must be set for BUILTIN class %s", name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1162
  } else {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1163
    guarantee(k->loader_type() == 0,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1164
              "Class loader type must not be set for UNREGISTERED class %s", name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1165
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1166
}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1167
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1168
class ExcludeDumpTimeSharedClasses : StackObj {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1169
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1170
  bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1171
    if (SystemDictionaryShared::should_be_excluded(k)) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1172
      info.set_excluded();
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1173
    }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1174
    return true; // keep on iterating
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1175
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1176
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1177
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1178
void SystemDictionaryShared::check_excluded_classes() {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1179
  ExcludeDumpTimeSharedClasses excl;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1180
  _dumptime_table->iterate(&excl);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1181
  _dumptime_table->update_counts();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1182
}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1183
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1184
bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1185
  assert(_no_class_loading_should_happen, "sanity");
58447
319173c62caa 8231606: _method_ordering is not set during CDS dynamic dump time
ccheung
parents: 58096
diff changeset
  1186
  Arguments::assert_is_dumping_archive();
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1187
  return find_or_allocate_info_for(k)->is_excluded();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1188
}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1189
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1190
class IterateDumpTimeSharedClassTable : StackObj {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1191
  MetaspaceClosure *_it;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1192
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1193
  IterateDumpTimeSharedClassTable(MetaspaceClosure* it) : _it(it) {}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1194
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1195
  bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1196
    if (!info.is_excluded()) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1197
      info.metaspace_pointers_do(_it);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1198
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1199
    return true; // keep on iterating
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1200
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1201
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1202
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1203
void SystemDictionaryShared::dumptime_classes_do(class MetaspaceClosure* it) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1204
  IterateDumpTimeSharedClassTable iter(it);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1205
  _dumptime_table->iterate(&iter);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1206
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1207
51329
9c68699bebe5 8208999: Some use of Klass* should be replaced by InstanceKlass*
iklam
parents: 51070
diff changeset
  1208
bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1209
         Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
58447
319173c62caa 8231606: _method_ordering is not set during CDS dynamic dump time
ccheung
parents: 58096
diff changeset
  1210
  Arguments::assert_is_dumping_archive();
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1211
  DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1212
  info->add_verification_constraint(k, name, from_name, from_field_is_protected,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1213
                                    from_is_array, from_is_object);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1214
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1215
  if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1216
    // For dynamic dumping, we can resolve all the constraint classes for all class loaders during
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1217
    // the initial run prior to creating the archive before vm exit. We will also perform verification
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1218
    // check when running with the archive.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1219
    return false;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1220
  } else {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1221
    if (is_builtin(k)) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1222
      // For builtin class loaders, we can try to complete the verification check at dump time,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1223
      // because we can resolve all the constraint classes. We will also perform verification check
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1224
      // when running with the archive.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1225
      return false;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1226
    } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1227
      // For non-builtin class loaders, we cannot complete the verification check at dump time,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1228
      // because at dump time we don't know how to resolve classes for such loaders.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1229
      return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1230
    }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1231
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1232
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1233
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1234
void DumpTimeSharedClassInfo::add_verification_constraint(InstanceKlass* k, Symbol* name,
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1235
         Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1236
  if (_verifier_constraints == NULL) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1237
    _verifier_constraints = new(ResourceObj::C_HEAP, mtClass) GrowableArray<DTConstraint>(4, true, mtClass);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1238
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1239
  if (_verifier_constraint_flags == NULL) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1240
    _verifier_constraint_flags = new(ResourceObj::C_HEAP, mtClass) GrowableArray<char>(4, true, mtClass);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1241
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1242
  GrowableArray<DTConstraint>* vc_array = _verifier_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1243
  for (int i = 0; i < vc_array->length(); i++) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1244
    DTConstraint* p = vc_array->adr_at(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1245
    if (name == p->_name && from_name == p->_from_name) {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1246
      return;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1247
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1248
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1249
  DTConstraint cons(name, from_name);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1250
  vc_array->append(cons);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1251
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1252
  GrowableArray<char>* vcflags_array = _verifier_constraint_flags;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1253
  char c = 0;
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1254
  c |= from_field_is_protected ? SystemDictionaryShared::FROM_FIELD_IS_PROTECTED : 0;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1255
  c |= from_is_array           ? SystemDictionaryShared::FROM_IS_ARRAY           : 0;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1256
  c |= from_is_object          ? SystemDictionaryShared::FROM_IS_OBJECT          : 0;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1257
  vcflags_array->append(c);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1258
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1259
  if (log_is_enabled(Trace, cds, verification)) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1260
    ResourceMark rm;
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1261
    log_trace(cds, verification)("add_verification_constraint: %s: %s must be subclass of %s [0x%x]",
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1262
                                 k->external_name(), from_name->as_klass_external_name(),
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1263
                                 name->as_klass_external_name(), c);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1264
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1265
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1266
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1267
void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass,
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1268
                                                            TRAPS) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1269
  assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1270
  RunTimeSharedClassInfo* record = RunTimeSharedClassInfo::get_for(klass);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1271
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1272
  int length = record->_num_constraints;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1273
  if (length > 0) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1274
    for (int i = 0; i < length; i++) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1275
      Symbol* name      = record->get_constraint_name(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1276
      Symbol* from_name = record->get_constraint_from_name(i);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1277
      char c            = record->get_constraint_flag(i);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1278
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1279
      if (log_is_enabled(Trace, cds, verification)) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1280
        ResourceMark rm(THREAD);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1281
        log_trace(cds, verification)("check_verification_constraint: %s: %s must be subclass of %s [0x%x]",
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1282
                                     klass->external_name(), from_name->as_klass_external_name(),
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1283
                                     name->as_klass_external_name(), c);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1284
      }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1285
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1286
      bool from_field_is_protected = (c & SystemDictionaryShared::FROM_FIELD_IS_PROTECTED) ? true : false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1287
      bool from_is_array           = (c & SystemDictionaryShared::FROM_IS_ARRAY)           ? true : false;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1288
      bool from_is_object          = (c & SystemDictionaryShared::FROM_IS_OBJECT)          ? true : false;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1289
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1290
      bool ok = VerificationType::resolve_and_check_assignability(klass, name,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1291
         from_name, from_field_is_protected, from_is_array, from_is_object, CHECK);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1292
      if (!ok) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1293
        ResourceMark rm(THREAD);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1294
        stringStream ss;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1295
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1296
        ss.print_cr("Bad type on operand stack");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1297
        ss.print_cr("Exception Details:");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1298
        ss.print_cr("  Location:\n    %s", klass->name()->as_C_string());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1299
        ss.print_cr("  Reason:\n    Type '%s' is not assignable to '%s'",
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1300
                    from_name->as_quoted_ascii(), name->as_quoted_ascii());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1301
        THROW_MSG(vmSymbols::java_lang_VerifyError(), ss.as_string());
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1302
      }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1303
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1304
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1305
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1306
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1307
class EstimateSizeForArchive : StackObj {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1308
  size_t _shared_class_info_size;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1309
  int _num_builtin_klasses;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1310
  int _num_unregistered_klasses;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1311
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1312
public:
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1313
  EstimateSizeForArchive() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1314
    _shared_class_info_size = 0;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1315
    _num_builtin_klasses = 0;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1316
    _num_unregistered_klasses = 0;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1317
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1318
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1319
  bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1320
    if (!info.is_excluded()) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1321
      size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_constraints());
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1322
      _shared_class_info_size += align_up(byte_size, BytesPerWord);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1323
    }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1324
    return true; // keep on iterating
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1325
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1326
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1327
  size_t total() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1328
    return _shared_class_info_size;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1329
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1330
};
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1331
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1332
size_t SystemDictionaryShared::estimate_size_for_archive() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1333
  EstimateSizeForArchive est;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1334
  _dumptime_table->iterate(&est);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1335
  return est.total() +
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1336
    CompactHashtableWriter::estimate_size(_dumptime_table->count_of(true)) +
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1337
    CompactHashtableWriter::estimate_size(_dumptime_table->count_of(false));
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1338
}
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1339
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1340
class CopySharedClassInfoToArchive : StackObj {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1341
  CompactHashtableWriter* _writer;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1342
  bool _is_builtin;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1343
public:
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1344
  CopySharedClassInfoToArchive(CompactHashtableWriter* writer,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1345
                               bool is_builtin,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1346
                               bool is_static_archive)
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1347
    : _writer(writer), _is_builtin(is_builtin) {}
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1348
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1349
  bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1350
    if (!info.is_excluded() && info.is_builtin() == _is_builtin) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1351
      size_t byte_size = RunTimeSharedClassInfo::byte_size(info._klass, info.num_constraints());
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1352
      RunTimeSharedClassInfo* record;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1353
      record = (RunTimeSharedClassInfo*)MetaspaceShared::read_only_space_alloc(byte_size);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1354
      record->init(info);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1355
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1356
      unsigned int hash;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1357
      Symbol* name = info._klass->name();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1358
      if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1359
        name = DynamicArchive::original_to_target(name);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1360
      }
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
  1361
      hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1362
      u4 delta;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1363
      if (DynamicDumpSharedSpaces) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1364
        delta = MetaspaceShared::object_delta_u4(DynamicArchive::buffer_to_target(record));
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1365
      } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1366
        delta = MetaspaceShared::object_delta_u4(record);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1367
      }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1368
      _writer->add(hash, delta);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1369
      if (log_is_enabled(Trace, cds, hashtables)) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1370
        ResourceMark rm;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1371
        log_trace(cds,hashtables)("%s dictionary: %s", (_is_builtin ? "builtin" : "unregistered"), info._klass->external_name());
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1372
      }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1373
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1374
      // Save this for quick runtime lookup of InstanceKlass* -> RunTimeSharedClassInfo*
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1375
      RunTimeSharedClassInfo::set_for(info._klass, record);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1376
    }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1377
    return true; // keep on iterating
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1378
  }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1379
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1380
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1381
void SystemDictionaryShared::write_dictionary(RunTimeSharedDictionary* dictionary,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1382
                                              bool is_builtin,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1383
                                              bool is_static_archive) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1384
  CompactHashtableStats stats;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1385
  dictionary->reset();
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1386
  CompactHashtableWriter writer(_dumptime_table->count_of(is_builtin), &stats);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1387
  CopySharedClassInfoToArchive copy(&writer, is_builtin, is_static_archive);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1388
  _dumptime_table->iterate(&copy);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1389
  writer.dump(dictionary, is_builtin ? "builtin dictionary" : "unregistered dictionary");
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1390
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1391
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1392
void SystemDictionaryShared::write_to_archive(bool is_static_archive) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1393
  if (is_static_archive) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1394
    write_dictionary(&_builtin_dictionary, true);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1395
    write_dictionary(&_unregistered_dictionary, false);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1396
  } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1397
    write_dictionary(&_dynamic_builtin_dictionary, true);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1398
    write_dictionary(&_dynamic_unregistered_dictionary, false);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1399
  }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1400
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1401
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1402
void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1403
                                                          bool is_static_archive) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1404
  if (is_static_archive) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1405
    _builtin_dictionary.serialize_header(soc);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1406
    _unregistered_dictionary.serialize_header(soc);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1407
  } else {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1408
    _dynamic_builtin_dictionary.serialize_header(soc);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1409
    _dynamic_unregistered_dictionary.serialize_header(soc);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1410
  }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1411
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1412
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1413
const RunTimeSharedClassInfo*
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1414
SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTimeSharedDictionary* dynamic_dict, Symbol* name) {
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1415
  if (!UseSharedSpaces || !name->is_shared()) {
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1416
    // The names of all shared classes must also be a shared Symbol.
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1417
    return NULL;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1418
  }
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1419
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58542
diff changeset
  1420
  unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary(name);
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1421
  const RunTimeSharedClassInfo* record = NULL;
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1422
  if (!MetaspaceShared::is_shared_dynamic(name)) {
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1423
    // The names of all shared classes in the static dict must also be in the
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1424
    // static archive
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1425
    record = static_dict->lookup(name, hash, 0);
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1426
  }
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1427
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1428
  if (record == NULL && DynamicArchive::is_mapped()) {
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1429
    record = dynamic_dict->lookup(name, hash, 0);
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1430
  }
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1431
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1432
  return record;
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1433
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1434
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1435
InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1436
  const RunTimeSharedClassInfo* record = find_record(&_builtin_dictionary, &_dynamic_builtin_dictionary, name);
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1437
  if (record != NULL) {
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1438
    return record->_klass;
58542
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1439
  } else {
94fe833a244b 8232071: Avoid shared dictionary lookup when the class name is not shared
iklam
parents: 58499
diff changeset
  1440
    return NULL;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1441
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1442
}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1443
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1444
void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1445
  assert(DumpSharedSpaces, "supported only when dumping");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1446
  DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1447
  info->_id = id;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1448
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1449
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1450
class SharedDictionaryPrinter : StackObj {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1451
  outputStream* _st;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1452
  int _index;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1453
public:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1454
  SharedDictionaryPrinter(outputStream* st) : _st(st), _index(0) {}
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1455
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1456
  void do_value(const RunTimeSharedClassInfo* record) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1457
    ResourceMark rm;
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1458
    _st->print_cr("%4d:  %s", (_index++), record->_klass->external_name());
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1459
  }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1460
};
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1461
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1462
void SystemDictionaryShared::print_on(outputStream* st) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1463
  if (UseSharedSpaces) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1464
    st->print_cr("Shared Dictionary");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1465
    SharedDictionaryPrinter p(st);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1466
    _builtin_dictionary.iterate(&p);
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1467
    _unregistered_dictionary.iterate(&p);
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1468
    if (DynamicArchive::is_mapped()) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1469
      _dynamic_builtin_dictionary.iterate(&p);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1470
      _unregistered_dictionary.iterate(&p);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1471
    }
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1472
  }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1473
}
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1474
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1475
void SystemDictionaryShared::print_table_statistics(outputStream* st) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1476
  if (UseSharedSpaces) {
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1477
    _builtin_dictionary.print_table_statistics(st, "Builtin Shared Dictionary");
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52468
diff changeset
  1478
    _unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1479
    if (DynamicArchive::is_mapped()) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1480
      _dynamic_builtin_dictionary.print_table_statistics(st, "Dynamic Builtin Shared Dictionary");
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1481
      _dynamic_unregistered_dictionary.print_table_statistics(st, "Unregistered Shared Dictionary");
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1482
    }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1483
  }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
  1484
}
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1485
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1486
bool SystemDictionaryShared::empty_dumptime_table() {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1487
  if (_dumptime_table == NULL) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1488
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1489
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1490
  _dumptime_table->update_counts();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1491
  if (_dumptime_table->count_of(true) == 0 && _dumptime_table->count_of(false) == 0){
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1492
    return true;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1493
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1494
  return false;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 54807
diff changeset
  1495
}