1 /*
2 * Copyright (c) 1997, 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 *
101 os::page_size_for_region(committed_size, reserved_size, 8) :
102 os::vm_page_size();
103 const size_t granularity = os::vm_allocation_granularity();
104 const size_t r_align = MAX2(page_size, granularity);
105 const size_t r_size = align_size_up(reserved_size, r_align);
106 const size_t c_size = align_size_up(committed_size, page_size);
107
108 const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 :
109 MAX2(page_size, granularity);
110 ReservedCodeSpace rs(r_size, rs_align, rs_align > 0);
111 os::trace_page_sizes("code heap", committed_size, reserved_size, page_size,
112 rs.base(), rs.size());
113 if (!_memory.initialize(rs, c_size)) {
114 return false;
115 }
116
117 on_code_mapping(_memory.low(), _memory.committed_size());
118 _number_of_committed_segments = size_to_segments(_memory.committed_size());
119 _number_of_reserved_segments = size_to_segments(_memory.reserved_size());
120 assert(_number_of_reserved_segments >= _number_of_committed_segments, "just checking");
121
122 // reserve space for _segmap
123 if (!_segmap.initialize(align_to_page_size(_number_of_reserved_segments), align_to_page_size(_number_of_committed_segments))) {
124 return false;
125 }
126
127 MemTracker::record_virtual_memory_type((address)_segmap.low_boundary(), mtCode);
128
129 assert(_segmap.committed_size() >= (size_t) _number_of_committed_segments, "could not commit enough space for segment map");
130 assert(_segmap.reserved_size() >= (size_t) _number_of_reserved_segments , "could not reserve enough space for segment map");
131 assert(_segmap.reserved_size() >= _segmap.committed_size() , "just checking");
132
133 // initialize remaining instance variables
134 clear();
135 return true;
136 }
137
138
139 void CodeHeap::release() {
140 Unimplemented();
141 }
142
143
|
1 /*
2 * Copyright (c) 1997, 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 *
101 os::page_size_for_region(committed_size, reserved_size, 8) :
102 os::vm_page_size();
103 const size_t granularity = os::vm_allocation_granularity();
104 const size_t r_align = MAX2(page_size, granularity);
105 const size_t r_size = align_size_up(reserved_size, r_align);
106 const size_t c_size = align_size_up(committed_size, page_size);
107
108 const size_t rs_align = page_size == (size_t) os::vm_page_size() ? 0 :
109 MAX2(page_size, granularity);
110 ReservedCodeSpace rs(r_size, rs_align, rs_align > 0);
111 os::trace_page_sizes("code heap", committed_size, reserved_size, page_size,
112 rs.base(), rs.size());
113 if (!_memory.initialize(rs, c_size)) {
114 return false;
115 }
116
117 on_code_mapping(_memory.low(), _memory.committed_size());
118 _number_of_committed_segments = size_to_segments(_memory.committed_size());
119 _number_of_reserved_segments = size_to_segments(_memory.reserved_size());
120 assert(_number_of_reserved_segments >= _number_of_committed_segments, "just checking");
121 const size_t reserved_segments_alignment = MAX2((size_t)os::vm_page_size(), granularity);
122 const size_t reserved_segments_size = align_size_up(_number_of_reserved_segments, reserved_segments_alignment);
123 const size_t committed_segments_size = align_to_page_size(_number_of_committed_segments);
124
125 // reserve space for _segmap
126 if (!_segmap.initialize(reserved_segments_size, committed_segments_size)) {
127 return false;
128 }
129
130 MemTracker::record_virtual_memory_type((address)_segmap.low_boundary(), mtCode);
131
132 assert(_segmap.committed_size() >= (size_t) _number_of_committed_segments, "could not commit enough space for segment map");
133 assert(_segmap.reserved_size() >= (size_t) _number_of_reserved_segments , "could not reserve enough space for segment map");
134 assert(_segmap.reserved_size() >= _segmap.committed_size() , "just checking");
135
136 // initialize remaining instance variables
137 clear();
138 return true;
139 }
140
141
142 void CodeHeap::release() {
143 Unimplemented();
144 }
145
146
|