1 /*
2 * Copyright (c) 2011, 2014, 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 *
87 friend class VM_CollectForMetadataAllocation;
88 friend class MetaspaceGC;
89 friend class MetaspaceAux;
90
91 public:
92 enum MetadataType {
93 ClassType,
94 NonClassType,
95 MetadataTypeCount
96 };
97 enum MetaspaceType {
98 StandardMetaspaceType,
99 BootMetaspaceType,
100 ROMetaspaceType,
101 ReadWriteMetaspaceType,
102 AnonymousMetaspaceType,
103 ReflectionMetaspaceType
104 };
105
106 private:
107 void initialize(Mutex* lock, MetaspaceType type);
108
109 // Get the first chunk for a Metaspace. Used for
110 // special cases such as the boot class loader, reflection
111 // class loader and anonymous class loader.
112 Metachunk* get_initialization_chunk(MetadataType mdtype,
113 size_t chunk_word_size,
114 size_t chunk_bunch);
115
116 // Align up the word size to the allocation word size
117 static size_t align_word_size_up(size_t);
118
119 // Aligned size of the metaspace.
120 static size_t _compressed_class_space_size;
121
122 static size_t compressed_class_space_size() {
123 return _compressed_class_space_size;
124 }
125
126 static void set_compressed_class_space_size(size_t size) {
127 _compressed_class_space_size = size;
128 }
129
130 static size_t _first_chunk_word_size;
131 static size_t _first_class_chunk_word_size;
132
133 static size_t _commit_alignment;
134 static size_t _reserve_alignment;
135
136 SpaceManager* _vsm;
137 SpaceManager* vsm() const { return _vsm; }
138
139 SpaceManager* _class_vsm;
140 SpaceManager* class_vsm() const { return _class_vsm; }
141
142 // Allocate space for metadata of type mdtype. This is space
143 // within a Metachunk and is used by
144 // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
145 MetaWord* allocate(size_t word_size, MetadataType mdtype);
146
147 // Virtual Space lists for both classes and other metadata
148 static VirtualSpaceList* _space_list;
149 static VirtualSpaceList* _class_space_list;
150
151 static ChunkManager* _chunk_manager_metadata;
152 static ChunkManager* _chunk_manager_class;
153
154 static const MetaspaceTracer* _tracer;
155
156 public:
157 static VirtualSpaceList* space_list() { return _space_list; }
158 static VirtualSpaceList* class_space_list() { return _class_space_list; }
159 static VirtualSpaceList* get_space_list(MetadataType mdtype) {
160 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
|
1 /*
2 * Copyright (c) 2011, 2017, 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 *
87 friend class VM_CollectForMetadataAllocation;
88 friend class MetaspaceGC;
89 friend class MetaspaceAux;
90
91 public:
92 enum MetadataType {
93 ClassType,
94 NonClassType,
95 MetadataTypeCount
96 };
97 enum MetaspaceType {
98 StandardMetaspaceType,
99 BootMetaspaceType,
100 ROMetaspaceType,
101 ReadWriteMetaspaceType,
102 AnonymousMetaspaceType,
103 ReflectionMetaspaceType
104 };
105
106 private:
107 static void verify_global_initialization();
108
109 void initialize(Mutex* lock, MetaspaceType type);
110
111 // Initialize the first chunk for a Metaspace. Used for
112 // special cases such as the boot class loader, reflection
113 // class loader and anonymous class loader.
114 void initialize_first_chunk(MetaspaceType type, MetadataType mdtype);
115 Metachunk* get_initialization_chunk(MetaspaceType type, MetadataType mdtype);
116
117 // Align up the word size to the allocation word size
118 static size_t align_word_size_up(size_t);
119
120 // Aligned size of the metaspace.
121 static size_t _compressed_class_space_size;
122
123 static size_t compressed_class_space_size() {
124 return _compressed_class_space_size;
125 }
126
127 static void set_compressed_class_space_size(size_t size) {
128 _compressed_class_space_size = size;
129 }
130
131 static size_t _first_chunk_word_size;
132 static size_t _first_class_chunk_word_size;
133
134 static size_t _commit_alignment;
135 static size_t _reserve_alignment;
136
137 SpaceManager* _vsm;
138 SpaceManager* vsm() const { return _vsm; }
139
140 SpaceManager* _class_vsm;
141 SpaceManager* class_vsm() const { return _class_vsm; }
142 SpaceManager* get_space_manager(MetadataType mdtype) {
143 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
144 return mdtype == ClassType ? class_vsm() : vsm();
145 }
146
147 // Allocate space for metadata of type mdtype. This is space
148 // within a Metachunk and is used by
149 // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
150 MetaWord* allocate(size_t word_size, MetadataType mdtype);
151
152 // Virtual Space lists for both classes and other metadata
153 static VirtualSpaceList* _space_list;
154 static VirtualSpaceList* _class_space_list;
155
156 static ChunkManager* _chunk_manager_metadata;
157 static ChunkManager* _chunk_manager_class;
158
159 static const MetaspaceTracer* _tracer;
160
161 public:
162 static VirtualSpaceList* space_list() { return _space_list; }
163 static VirtualSpaceList* class_space_list() { return _class_space_list; }
164 static VirtualSpaceList* get_space_list(MetadataType mdtype) {
165 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
|