src/share/vm/memory/metaspaceShared.hpp

Mon, 29 Apr 2013 16:13:57 -0400

author
hseigel
date
Mon, 29 Apr 2013 16:13:57 -0400
changeset 4987
f258c5828eb8
parent 4165
fb19af007ffc
child 6876
710a3c8b516e
child 7089
6e0cb14ce59b
permissions
-rw-r--r--

8011773: Some tests on Interned String crashed JVM with OOM
Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions.
Reviewed-by: coleenp, dholmes

     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    24 #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP
    25 #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP
    27 #include "memory/allocation.hpp"
    28 #include "memory/memRegion.hpp"
    29 #include "runtime/virtualspace.hpp"
    30 #include "utilities/exceptions.hpp"
    31 #include "utilities/macros.hpp"
    33 class FileMapInfo;
    35 // Class Data Sharing Support
    36 class MetaspaceShared : AllStatic {
    38   // CDS support
    39   static ReservedSpace* _shared_rs;
    40   static int _max_alignment;
    42  public:
    43   enum {
    44     vtbl_list_size = 17, // number of entries in the shared space vtable list.
    45     num_virtuals = 200   // maximum number of virtual functions
    46                          // If virtual functions are added to Metadata,
    47                          // this number needs to be increased.  Also,
    48                          // SharedMiscCodeSize will need to be increased.
    49   };
    51   enum {
    52     ro = 0,  // read-only shared space in the heap
    53     rw = 1,  // read-write shared space in the heap
    54     md = 2,  // miscellaneous data for initializing tables, etc.
    55     mc = 3,  // miscellaneous code - vtable replacement.
    56     n_regions = 4
    57   };
    59   // Accessor functions to save shared space created for metadata, which has
    60   // extra space allocated at the end for miscellaneous data and code.
    61   static void set_max_alignment(int alignment) {
    62     CDS_ONLY(_max_alignment = alignment);
    63   }
    65   static int max_alignment() {
    66     CDS_ONLY(return _max_alignment);
    67     NOT_CDS(return 0);
    68   }
    70   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
    72   static ReservedSpace* shared_rs() {
    73     CDS_ONLY(return _shared_rs);
    74     NOT_CDS(return NULL);
    75   }
    77   static void set_shared_rs(ReservedSpace* rs) {
    78     CDS_ONLY(_shared_rs = rs;)
    79   }
    81   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
    82   static void initialize_shared_spaces() NOT_CDS_RETURN;
    84   // Return true if given address is in the mapped shared space.
    85   static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
    87   static void generate_vtable_methods(void** vtbl_list,
    88                                       void** vtable,
    89                                       char** md_top, char* md_end,
    90                                       char** mc_top, char* mc_end);
    91   static void serialize(SerializeClosure* sc);
    93   // JVM/TI RedefineClasses() support:
    94   // Remap the shared readonly space to shared readwrite, private if
    95   // sharing is enabled. Simply returns true if sharing is not enabled
    96   // or if the remapping has already been done by a prior call.
    97   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
    99   static void print_shared_spaces();
   100 };
   101 #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP

mercurial