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