hotspot/src/share/vm/memory/metaspaceShared.hpp
author iklam
Tue, 12 Aug 2014 17:29:00 -0700
changeset 26135 82b516c550f7
parent 13975 2f7431485cfa
child 26304 a28e6335ce60
permissions -rw-r--r--
8046070: Class Data Sharing clean up and refactoring Summary: Cleaned up CDS to be more configurable, maintainable and extensible Reviewed-by: dholmes, coleenp, acorn, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    24
#ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    25
#define SHARE_VM_MEMORY_METASPACE_SHARED_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    26
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    27
#include "memory/allocation.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    28
#include "memory/memRegion.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    29
#include "runtime/virtualspace.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    30
#include "utilities/exceptions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    31
#include "utilities/macros.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    32
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    33
class FileMapInfo;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    34
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    35
// Class Data Sharing Support
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    36
class MetaspaceShared : AllStatic {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    37
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    38
  // CDS support
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    39
  static ReservedSpace* _shared_rs;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    40
  static int _max_alignment;
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    41
  static bool _link_classes_made_progress;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    42
  static bool _check_classes_made_progress;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    43
  static bool _has_error_classes;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    44
  static bool _archive_loading_failed;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    45
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    46
  enum {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    47
    vtbl_list_size = 17, // number of entries in the shared space vtable list.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    48
    num_virtuals = 200   // maximum number of virtual functions
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    49
                         // If virtual functions are added to Metadata,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    50
                         // this number needs to be increased.  Also,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    51
                         // SharedMiscCodeSize will need to be increased.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
  };
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    53
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    54
  enum {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    55
    ro = 0,  // read-only shared space in the heap
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    56
    rw = 1,  // read-write shared space in the heap
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    57
    md = 2,  // miscellaneous data for initializing tables, etc.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    58
    mc = 3,  // miscellaneous code - vtable replacement.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    59
    n_regions = 4
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    60
  };
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    61
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    62
  // Accessor functions to save shared space created for metadata, which has
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    63
  // extra space allocated at the end for miscellaneous data and code.
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    64
  static void set_max_alignment(int alignment) {
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    65
    CDS_ONLY(_max_alignment = alignment);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    66
  }
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    67
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    68
  static int max_alignment() {
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    69
    CDS_ONLY(return _max_alignment);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    70
    NOT_CDS(return 0);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    71
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    72
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    73
  static void prepare_for_dumping() NOT_CDS_RETURN;
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    74
  static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    75
  static int preload_and_dump(const char * class_list_path,
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    76
                              GrowableArray<Klass*>* class_promote_order,
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    77
                              TRAPS) NOT_CDS_RETURN;
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    78
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    79
  static ReservedSpace* shared_rs() {
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    80
    CDS_ONLY(return _shared_rs);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    81
    NOT_CDS(return NULL);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    82
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    83
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    84
  static void set_shared_rs(ReservedSpace* rs) {
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    85
    CDS_ONLY(_shared_rs = rs;)
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    86
  }
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    87
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    88
  static void set_archive_loading_failed() {
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    89
    _archive_loading_failed = true;
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
    90
  }
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    91
  static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    92
  static void initialize_shared_spaces() NOT_CDS_RETURN;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    93
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    94
  // Return true if given address is in the mapped shared space.
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    95
  static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    96
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    97
  static void generate_vtable_methods(void** vtbl_list,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    98
                                      void** vtable,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    99
                                      char** md_top, char* md_end,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   100
                                      char** mc_top, char* mc_end);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   101
  static void serialize(SerializeClosure* sc);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   102
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   103
  // JVM/TI RedefineClasses() support:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   104
  // Remap the shared readonly space to shared readwrite, private if
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   105
  // sharing is enabled. Simply returns true if sharing is not enabled
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   106
  // or if the remapping has already been done by a prior call.
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   107
  static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   108
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   109
  static void print_shared_spaces();
26135
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
   110
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
   111
  static bool try_link_class(InstanceKlass* ik, TRAPS);
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
   112
  static void link_one_shared_class(Klass* obj, TRAPS);
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
   113
  static void check_one_shared_class(Klass* obj);
82b516c550f7 8046070: Class Data Sharing clean up and refactoring
iklam
parents: 13975
diff changeset
   114
  static void link_and_cleanup_shared_classes(TRAPS);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   115
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   116
#endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP