1 #ifdef USE_PRAGMA_IDENT_SRC
2 #pragma ident "@(#)psVirtualspace.cpp 1.16 07/05/05 17:05:31 JVM"
3 #endif
4 /*
5 * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
57 set_committed(reserved_low_addr(), reserved_low_addr());
58
59 // Commit to initial size.
60 assert(commit_size <= rs.size(), "commit_size too big");
61 bool result = commit_size > 0 ? expand_by(commit_size) : true;
62 DEBUG_ONLY(verify());
63 return result;
64 }
65
66 PSVirtualSpace::~PSVirtualSpace() {
67 release();
68 }
69
70 bool PSVirtualSpace::contains(void* p) const {
71 char* const cp = (char*)p;
72 return cp >= committed_low_addr() && cp < committed_high_addr();
73 }
74
75 void PSVirtualSpace::release() {
76 DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
77 if (reserved_low_addr() != NULL) {
78 if (special()) {
79 os::release_memory_special(reserved_low_addr(), reserved_size());
80 } else {
81 (void)os::release_memory(reserved_low_addr(), reserved_size());
82 }
83 }
84 _reserved_low_addr = _reserved_high_addr = NULL;
85 _committed_low_addr = _committed_high_addr = NULL;
86 _special = false;
87 }
88
89 bool PSVirtualSpace::expand_by(size_t bytes, bool pre_touch) {
90 assert(is_aligned(bytes), "arg not aligned");
91 DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
92
93 if (uncommitted_size() < bytes) {
94 return false;
95 }
96
97 char* const base_addr = committed_high_addr();
98 bool result = special() || os::commit_memory(base_addr, bytes, alignment());
99 if (result) {
100 _committed_high_addr += bytes;
101 }
102
103 if (pre_touch || AlwaysPreTouch) {
|
1 #ifdef USE_PRAGMA_IDENT_SRC
2 #pragma ident "@(#)psVirtualspace.cpp 1.16 07/05/05 17:05:31 JVM"
3 #endif
4 /*
5 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
57 set_committed(reserved_low_addr(), reserved_low_addr());
58
59 // Commit to initial size.
60 assert(commit_size <= rs.size(), "commit_size too big");
61 bool result = commit_size > 0 ? expand_by(commit_size) : true;
62 DEBUG_ONLY(verify());
63 return result;
64 }
65
66 PSVirtualSpace::~PSVirtualSpace() {
67 release();
68 }
69
70 bool PSVirtualSpace::contains(void* p) const {
71 char* const cp = (char*)p;
72 return cp >= committed_low_addr() && cp < committed_high_addr();
73 }
74
75 void PSVirtualSpace::release() {
76 DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
77 // This may not release memory it didn't reserve.
78 // Use rs.release() to release the underlying memory instead.
79 _reserved_low_addr = _reserved_high_addr = NULL;
80 _committed_low_addr = _committed_high_addr = NULL;
81 _special = false;
82 }
83
84 bool PSVirtualSpace::expand_by(size_t bytes, bool pre_touch) {
85 assert(is_aligned(bytes), "arg not aligned");
86 DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this));
87
88 if (uncommitted_size() < bytes) {
89 return false;
90 }
91
92 char* const base_addr = committed_high_addr();
93 bool result = special() || os::commit_memory(base_addr, bytes, alignment());
94 if (result) {
95 _committed_high_addr += bytes;
96 }
97
98 if (pre_touch || AlwaysPreTouch) {
|