Mercurial > hg > truffle
annotate src/share/vm/memory/metadataFactory.hpp @ 21573:ffdd2ec86f42
Truffle/Debugging: temporary patches so the DebugEngine will work (partially) with the new TruffleVM framework.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 27 May 2015 20:52:21 -0700 |
parents | 4cb90023bf2b |
children |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
12857
d37a0525c0fe
8024667: VM crashes with "assert(method() != NULL) failed: must have set method"
hseigel
parents:
7614
diff
changeset
|
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
6725
da91efe96a93
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. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 * |
da91efe96a93
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 |
da91efe96a93
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, |
da91efe96a93
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. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 * questions. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 */ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #ifndef SHARE_VM_MEMORY_METADATAFACTORY_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 #define SHARE_VM_MEMORY_METADATAFACTORY_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
12857
diff
changeset
|
28 #include "classfile/classLoaderData.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 #include "utilities/array.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 #include "utilities/exceptions.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 #include "utilities/globalDefinitions.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 class MetadataFactory : AllStatic { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 static Array<T>* new_array(ClassLoaderData* loader_data, int length, TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 // The "true" argument is because all metadata arrays are read only when |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 // dumped to the shared archive |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 return new (loader_data, length, /*read_only*/true, THREAD) Array<T>(length); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 static Array<T>* new_array(ClassLoaderData* loader_data, int length, T value, TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 Array<T>* array = new_array<T>(loader_data, length, CHECK_NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 for (int i = 0; i < length; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 array->at_put(i, value); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 return array; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
52 static Array<T>* new_writeable_array(ClassLoaderData* loader_data, int length, TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
53 return new (loader_data, length, /*read_only*/false, THREAD) Array<T>(length); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
56 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 static Array<T>* new_writeable_array(ClassLoaderData* loader_data, int length, T value, TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 Array<T>* array = new_writeable_array<T>(loader_data, length, CHECK_NULL); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 for (int i = 0; i < length; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
60 array->at_put(i, value); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
62 return array; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
63 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 template <typename T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 static void free_array(ClassLoaderData* loader_data, Array<T>* data) { |
20608
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
67 if (DumpSharedSpaces) { |
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
68 // FIXME: the freeing code is buggy, especially when PrintSharedSpaces is enabled. |
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
69 // Disable for now -- this means if you specify bad classes in your classlist you |
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
70 // may have wasted space inside the archive. |
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
71 return; |
4cb90023bf2b
8061651: Interface to the Lookup Index Cache to improve URLClassPath search time
iklam
parents:
20375
diff
changeset
|
72 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 if (data != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 assert(loader_data != NULL, "shouldn't pass null"); |
12857
d37a0525c0fe
8024667: VM crashes with "assert(method() != NULL) failed: must have set method"
hseigel
parents:
7614
diff
changeset
|
75 assert(!data->is_shared(), "cannot deallocate array in shared spaces"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 int size = data->size(); |
7614
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
77 if (DumpSharedSpaces) { |
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
78 loader_data->ro_metaspace()->deallocate((MetaWord*)data, size, false); |
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
79 } else { |
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
80 loader_data->metaspace_non_null()->deallocate((MetaWord*)data, size, false); |
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
81 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 // Deallocation method for metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 template <class T> |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 static void free_metadata(ClassLoaderData* loader_data, T md) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
88 if (DumpSharedSpaces) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
89 // FIXME: the freeing code is buggy, especially when PrintSharedSpaces is enabled. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
90 // Disable for now -- this means if you specify bad classes in your classlist you |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
91 // may have wasted space inside the archive. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
92 return; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
20278
diff
changeset
|
93 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 if (md != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
95 assert(loader_data != NULL, "shouldn't pass null"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 int size = md->size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
97 // Call metadata's deallocate function which will call deallocate fields |
7614
59a58e20dc60
8006537: Assert when dumping archive with default methods
jmasa
parents:
6725
diff
changeset
|
98 assert(!DumpSharedSpaces, "cannot deallocate metadata when dumping CDS archive"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 assert(!md->on_stack(), "can't deallocate things on stack"); |
12857
d37a0525c0fe
8024667: VM crashes with "assert(method() != NULL) failed: must have set method"
hseigel
parents:
7614
diff
changeset
|
100 assert(!md->is_shared(), "cannot deallocate if in shared spaces"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 md->deallocate_contents(loader_data); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 loader_data->metaspace_non_null()->deallocate((MetaWord*)md, size, md->is_klass()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 #endif // SHARE_VM_MEMORY_METADATAFACTORY_HPP |