1 /*
2 * Copyright (c) 2005, 2012, 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 *
46 bool
47 ParMarkBitMap::initialize(MemRegion covered_region)
48 {
49 const idx_t bits = bits_required(covered_region);
50 // The bits will be divided evenly between two bitmaps; each of them should be
51 // an integral number of words.
52 assert(bits % (BitsPerWord * 2) == 0, "region size unaligned");
53
54 const size_t words = bits / BitsPerWord;
55 const size_t raw_bytes = words * sizeof(idx_t);
56 const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
57 const size_t granularity = os::vm_allocation_granularity();
58 const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
59
60 const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
61 MAX2(page_sz, granularity);
62 ReservedSpace rs(bytes, rs_align, rs_align > 0);
63 os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
64 rs.base(), rs.size());
65
66 MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
67
68 _virtual_space = new PSVirtualSpace(rs, page_sz);
69 if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) {
70 _region_start = covered_region.start();
71 _region_size = covered_region.word_size();
72 idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
73 _beg_bits.set_map(map);
74 _beg_bits.set_size(bits / 2);
75 _end_bits.set_map(map + words / 2);
76 _end_bits.set_size(bits / 2);
77 return true;
78 }
79
80 _region_start = 0;
81 _region_size = 0;
82 if (_virtual_space != NULL) {
83 delete _virtual_space;
84 _virtual_space = NULL;
85 // Release memory reserved in the space.
86 rs.release();
|
1 /*
2 * Copyright (c) 2005, 2013, 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 *
46 bool
47 ParMarkBitMap::initialize(MemRegion covered_region)
48 {
49 const idx_t bits = bits_required(covered_region);
50 // The bits will be divided evenly between two bitmaps; each of them should be
51 // an integral number of words.
52 assert(bits % (BitsPerWord * 2) == 0, "region size unaligned");
53
54 const size_t words = bits / BitsPerWord;
55 const size_t raw_bytes = words * sizeof(idx_t);
56 const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
57 const size_t granularity = os::vm_allocation_granularity();
58 const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
59
60 const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
61 MAX2(page_sz, granularity);
62 ReservedSpace rs(bytes, rs_align, rs_align > 0);
63 os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
64 rs.base(), rs.size());
65
66 NMTTrackOp op(NMTTrackOp::TypeOp);
67 op.execute_op((address)rs.base(), 0, mtGC);
68
69 _virtual_space = new PSVirtualSpace(rs, page_sz);
70 if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) {
71 _region_start = covered_region.start();
72 _region_size = covered_region.word_size();
73 idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
74 _beg_bits.set_map(map);
75 _beg_bits.set_size(bits / 2);
76 _end_bits.set_map(map + words / 2);
77 _end_bits.set_size(bits / 2);
78 return true;
79 }
80
81 _region_start = 0;
82 _region_size = 0;
83 if (_virtual_space != NULL) {
84 delete _virtual_space;
85 _virtual_space = NULL;
86 // Release memory reserved in the space.
87 rs.release();
|