src/share/vm/memory/metadataFactory.hpp

Tue, 16 Feb 2016 21:42:29 +0000

author
poonam
date
Tue, 16 Feb 2016 21:42:29 +0000
changeset 8308
6acf14e730dd
parent 7322
4cb90023bf2b
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8072725: Provide more granular levels for GC verification
Summary: Add option VerifySubSet to selectively verify the memory sub-systems
Reviewed-by: kevinw, jmasa

coleenp@4037 1 /*
hseigel@5896 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
coleenp@4037 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
coleenp@4037 4 *
coleenp@4037 5 * This code is free software; you can redistribute it and/or modify it
coleenp@4037 6 * under the terms of the GNU General Public License version 2 only, as
coleenp@4037 7 * published by the Free Software Foundation.
coleenp@4037 8 *
coleenp@4037 9 * This code is distributed in the hope that it will be useful, but WITHOUT
coleenp@4037 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
coleenp@4037 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
coleenp@4037 12 * version 2 for more details (a copy is included in the LICENSE file that
coleenp@4037 13 * accompanied this code).
coleenp@4037 14 *
coleenp@4037 15 * You should have received a copy of the GNU General Public License version
coleenp@4037 16 * 2 along with this work; if not, write to the Free Software Foundation,
coleenp@4037 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
coleenp@4037 18 *
coleenp@4037 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
coleenp@4037 20 * or visit www.oracle.com if you need additional information or have any
coleenp@4037 21 * questions.
coleenp@4037 22 *
coleenp@4037 23 */
coleenp@4037 24
coleenp@4037 25 #ifndef SHARE_VM_MEMORY_METADATAFACTORY_HPP
coleenp@4037 26 #define SHARE_VM_MEMORY_METADATAFACTORY_HPP
coleenp@4037 27
stefank@6992 28 #include "classfile/classLoaderData.hpp"
coleenp@4037 29 #include "utilities/array.hpp"
coleenp@4037 30 #include "utilities/exceptions.hpp"
coleenp@4037 31 #include "utilities/globalDefinitions.hpp"
coleenp@4037 32
coleenp@4037 33 class MetadataFactory : AllStatic {
coleenp@4037 34 public:
coleenp@4037 35 template <typename T>
coleenp@4037 36 static Array<T>* new_array(ClassLoaderData* loader_data, int length, TRAPS) {
coleenp@4037 37 // The "true" argument is because all metadata arrays are read only when
coleenp@4037 38 // dumped to the shared archive
coleenp@4037 39 return new (loader_data, length, /*read_only*/true, THREAD) Array<T>(length);
coleenp@4037 40 }
coleenp@4037 41
coleenp@4037 42 template <typename T>
coleenp@4037 43 static Array<T>* new_array(ClassLoaderData* loader_data, int length, T value, TRAPS) {
coleenp@4037 44 Array<T>* array = new_array<T>(loader_data, length, CHECK_NULL);
coleenp@4037 45 for (int i = 0; i < length; i++) {
coleenp@4037 46 array->at_put(i, value);
coleenp@4037 47 }
coleenp@4037 48 return array;
coleenp@4037 49 }
coleenp@4037 50
coleenp@4037 51 template <typename T>
coleenp@4037 52 static Array<T>* new_writeable_array(ClassLoaderData* loader_data, int length, TRAPS) {
coleenp@4037 53 return new (loader_data, length, /*read_only*/false, THREAD) Array<T>(length);
coleenp@4037 54 }
coleenp@4037 55
coleenp@4037 56 template <typename T>
coleenp@4037 57 static Array<T>* new_writeable_array(ClassLoaderData* loader_data, int length, T value, TRAPS) {
coleenp@4037 58 Array<T>* array = new_writeable_array<T>(loader_data, length, CHECK_NULL);
coleenp@4037 59 for (int i = 0; i < length; i++) {
coleenp@4037 60 array->at_put(i, value);
coleenp@4037 61 }
coleenp@4037 62 return array;
coleenp@4037 63 }
coleenp@4037 64
coleenp@4037 65 template <typename T>
coleenp@4037 66 static void free_array(ClassLoaderData* loader_data, Array<T>* data) {
iklam@7322 67 if (DumpSharedSpaces) {
iklam@7322 68 // FIXME: the freeing code is buggy, especially when PrintSharedSpaces is enabled.
iklam@7322 69 // Disable for now -- this means if you specify bad classes in your classlist you
iklam@7322 70 // may have wasted space inside the archive.
iklam@7322 71 return;
iklam@7322 72 }
coleenp@4037 73 if (data != NULL) {
coleenp@4037 74 assert(loader_data != NULL, "shouldn't pass null");
hseigel@5896 75 assert(!data->is_shared(), "cannot deallocate array in shared spaces");
coleenp@4037 76 int size = data->size();
jmasa@4457 77 if (DumpSharedSpaces) {
jmasa@4457 78 loader_data->ro_metaspace()->deallocate((MetaWord*)data, size, false);
jmasa@4457 79 } else {
jmasa@4457 80 loader_data->metaspace_non_null()->deallocate((MetaWord*)data, size, false);
jmasa@4457 81 }
coleenp@4037 82 }
coleenp@4037 83 }
coleenp@4037 84
coleenp@4037 85 // Deallocation method for metadata
coleenp@4037 86 template <class T>
coleenp@4037 87 static void free_metadata(ClassLoaderData* loader_data, T md) {
iklam@7089 88 if (DumpSharedSpaces) {
iklam@7089 89 // FIXME: the freeing code is buggy, especially when PrintSharedSpaces is enabled.
iklam@7089 90 // Disable for now -- this means if you specify bad classes in your classlist you
iklam@7089 91 // may have wasted space inside the archive.
iklam@7089 92 return;
iklam@7089 93 }
coleenp@4037 94 if (md != NULL) {
coleenp@4037 95 assert(loader_data != NULL, "shouldn't pass null");
coleenp@4037 96 int size = md->size();
coleenp@4037 97 // Call metadata's deallocate function which will call deallocate fields
jmasa@4457 98 assert(!DumpSharedSpaces, "cannot deallocate metadata when dumping CDS archive");
coleenp@4037 99 assert(!md->on_stack(), "can't deallocate things on stack");
hseigel@5896 100 assert(!md->is_shared(), "cannot deallocate if in shared spaces");
coleenp@4037 101 md->deallocate_contents(loader_data);
coleenp@4037 102 loader_data->metaspace_non_null()->deallocate((MetaWord*)md, size, md->is_klass());
coleenp@4037 103 }
coleenp@4037 104 }
coleenp@4037 105 };
coleenp@4037 106
coleenp@4037 107 #endif // SHARE_VM_MEMORY_METADATAFACTORY_HPP

mercurial