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
25 #include "precompiled.hpp"
26 #include "memory/allocation.hpp"
27 #include "memory/metachunk.hpp"
28 #include "utilities/align.hpp"
29 #include "utilities/copy.hpp"
30 #include "utilities/debug.hpp"
31
32 class VirtualSpaceNode;
33
34 size_t Metachunk::object_alignment() {
35 // Must align pointers and sizes to 8,
36 // so that 64 bit types get correctly aligned.
37 const size_t alignment = 8;
38
39 // Make sure that the Klass alignment also agree.
40 STATIC_ASSERT(alignment == (size_t)KlassAlignmentInBytes);
41
42 return alignment;
43 }
44
45 size_t Metachunk::overhead() {
46 return align_up(sizeof(Metachunk), object_alignment()) / BytesPerWord;
47 }
48
49 // Metachunk methods
50
51 Metachunk::Metachunk(ChunkIndex chunktype, bool is_class, size_t word_size,
52 VirtualSpaceNode* container)
130 p2i(this), word_size() * sizeof(MetaWord), required_alignment);
131 }
132
133 #endif // ASSERT
134
135 // Helper, returns a descriptive name for the given index.
136 const char* chunk_size_name(ChunkIndex index) {
137 switch (index) {
138 case SpecializedIndex:
139 return "specialized";
140 case SmallIndex:
141 return "small";
142 case MediumIndex:
143 return "medium";
144 case HumongousIndex:
145 return "humongous";
146 default:
147 return "Invalid index";
148 }
149 }
|
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
25 #include "precompiled.hpp"
26 #include "memory/allocation.hpp"
27 #include "memory/metaspace/metachunk.hpp"
28 #include "memory/metaspace/occupancyMap.hpp"
29 #include "memory/metaspace/virtualSpaceNode.hpp"
30 #include "utilities/align.hpp"
31 #include "utilities/copy.hpp"
32 #include "utilities/debug.hpp"
33
34 namespace metaspace {
35 namespace internals {
36
37 size_t Metachunk::object_alignment() {
38 // Must align pointers and sizes to 8,
39 // so that 64 bit types get correctly aligned.
40 const size_t alignment = 8;
41
42 // Make sure that the Klass alignment also agree.
43 STATIC_ASSERT(alignment == (size_t)KlassAlignmentInBytes);
44
45 return alignment;
46 }
47
48 size_t Metachunk::overhead() {
49 return align_up(sizeof(Metachunk), object_alignment()) / BytesPerWord;
50 }
51
52 // Metachunk methods
53
54 Metachunk::Metachunk(ChunkIndex chunktype, bool is_class, size_t word_size,
55 VirtualSpaceNode* container)
133 p2i(this), word_size() * sizeof(MetaWord), required_alignment);
134 }
135
136 #endif // ASSERT
137
138 // Helper, returns a descriptive name for the given index.
139 const char* chunk_size_name(ChunkIndex index) {
140 switch (index) {
141 case SpecializedIndex:
142 return "specialized";
143 case SmallIndex:
144 return "small";
145 case MediumIndex:
146 return "medium";
147 case HumongousIndex:
148 return "humongous";
149 default:
150 return "Invalid index";
151 }
152 }
153
154 #ifdef ASSERT
155 void do_verify_chunk(Metachunk* chunk) {
156 guarantee(chunk != NULL, "Sanity");
157 // Verify chunk itself; then verify that it is consistent with the
158 // occupany map of its containing node.
159 chunk->verify();
160 VirtualSpaceNode* const vsn = chunk->container();
161 OccupancyMap* const ocmap = vsn->occupancy_map();
162 ocmap->verify_for_chunk(chunk);
163 }
164 #endif
165
166 void do_update_in_use_info_for_chunk(Metachunk* chunk, bool inuse) {
167 chunk->set_is_tagged_free(!inuse);
168 OccupancyMap* const ocmap = chunk->container()->occupancy_map();
169 ocmap->set_region_in_use((MetaWord*)chunk, chunk->word_size(), inuse);
170 }
171
172 } // namespace metaspace
173 } // namespace internals
|