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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCacheExtensions.hpp"
27 #include "logging/log.hpp"
28 #include "memory/resourceArea.hpp"
29 #include "memory/virtualspace.hpp"
30 #include "oops/markOop.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "services/memTracker.hpp"
33
34 // ReservedSpace
35
36 // Dummy constructor
37 ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0),
38 _alignment(0), _special(false), _executable(false) {
39 }
40
41 ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) {
42 bool has_preferred_page_size = preferred_page_size != 0;
43 // Want to use large pages where possible and pad with small pages.
44 size_t page_size = has_preferred_page_size ? preferred_page_size : os::page_size_for_region_unaligned(size, 1);
45 bool large_pages = page_size != (size_t)os::vm_page_size();
46 size_t alignment;
575 }
576 } else {
577 initialize(size, alignment, large, NULL, false);
578 }
579
580 assert(markOopDesc::encode_pointer_as_mark(_base)->decode_pointer() == _base,
581 "area must be distinguishable from marks for mark-sweep");
582 assert(markOopDesc::encode_pointer_as_mark(&_base[size])->decode_pointer() == &_base[size],
583 "area must be distinguishable from marks for mark-sweep");
584
585 if (base() > 0) {
586 MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap);
587 }
588 }
589
590 // Reserve space for code segment. Same as Java heap only we mark this as
591 // executable.
592 ReservedCodeSpace::ReservedCodeSpace(size_t r_size,
593 size_t rs_align,
594 bool large) :
595 ReservedSpace(r_size, rs_align, large, /*executable*/ CodeCacheExtensions::support_dynamic_code()) {
596 MemTracker::record_virtual_memory_type((address)base(), mtCode);
597 }
598
599 // VirtualSpace
600
601 VirtualSpace::VirtualSpace() {
602 _low_boundary = NULL;
603 _high_boundary = NULL;
604 _low = NULL;
605 _high = NULL;
606 _lower_high = NULL;
607 _middle_high = NULL;
608 _upper_high = NULL;
609 _lower_high_boundary = NULL;
610 _middle_high_boundary = NULL;
611 _upper_high_boundary = NULL;
612 _lower_alignment = 0;
613 _middle_alignment = 0;
614 _upper_alignment = 0;
615 _special = false;
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "logging/log.hpp"
27 #include "memory/resourceArea.hpp"
28 #include "memory/virtualspace.hpp"
29 #include "oops/markOop.hpp"
30 #include "oops/oop.inline.hpp"
31 #include "services/memTracker.hpp"
32
33 // ReservedSpace
34
35 // Dummy constructor
36 ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0),
37 _alignment(0), _special(false), _executable(false) {
38 }
39
40 ReservedSpace::ReservedSpace(size_t size, size_t preferred_page_size) {
41 bool has_preferred_page_size = preferred_page_size != 0;
42 // Want to use large pages where possible and pad with small pages.
43 size_t page_size = has_preferred_page_size ? preferred_page_size : os::page_size_for_region_unaligned(size, 1);
44 bool large_pages = page_size != (size_t)os::vm_page_size();
45 size_t alignment;
574 }
575 } else {
576 initialize(size, alignment, large, NULL, false);
577 }
578
579 assert(markOopDesc::encode_pointer_as_mark(_base)->decode_pointer() == _base,
580 "area must be distinguishable from marks for mark-sweep");
581 assert(markOopDesc::encode_pointer_as_mark(&_base[size])->decode_pointer() == &_base[size],
582 "area must be distinguishable from marks for mark-sweep");
583
584 if (base() > 0) {
585 MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap);
586 }
587 }
588
589 // Reserve space for code segment. Same as Java heap only we mark this as
590 // executable.
591 ReservedCodeSpace::ReservedCodeSpace(size_t r_size,
592 size_t rs_align,
593 bool large) :
594 ReservedSpace(r_size, rs_align, large, /*executable*/ true) {
595 MemTracker::record_virtual_memory_type((address)base(), mtCode);
596 }
597
598 // VirtualSpace
599
600 VirtualSpace::VirtualSpace() {
601 _low_boundary = NULL;
602 _high_boundary = NULL;
603 _low = NULL;
604 _high = NULL;
605 _lower_high = NULL;
606 _middle_high = NULL;
607 _upper_high = NULL;
608 _lower_high_boundary = NULL;
609 _middle_high_boundary = NULL;
610 _upper_high_boundary = NULL;
611 _lower_alignment = 0;
612 _middle_alignment = 0;
613 _upper_alignment = 0;
614 _special = false;
|