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 #ifndef SHARE_VM_UTILITIES_STACK_INLINE_HPP
26 #define SHARE_VM_UTILITIES_STACK_INLINE_HPP
27
28 #include "utilities/stack.hpp"
29
30 template <MEMFLAGS F> StackBase<F>::StackBase(size_t segment_size, size_t max_cache_size,
31 size_t max_size):
32 _seg_size(segment_size),
33 _max_cache_size(max_cache_size),
34 _max_size(adjust_max_size(max_size, segment_size))
35 {
36 assert(_max_size % _seg_size == 0, "not a multiple");
37 }
38
39 template <MEMFLAGS F> size_t StackBase<F>::adjust_max_size(size_t max_size, size_t seg_size)
40 {
41 assert(seg_size > 0, "cannot be 0");
42 assert(max_size >= seg_size || max_size == 0, "max_size too small");
43 const size_t limit = max_uintx - (seg_size - 1);
44 if (max_size == 0 || max_size > limit) {
45 max_size = limit;
46 }
47 return (max_size + seg_size - 1) / seg_size * seg_size;
|
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 #ifndef SHARE_VM_UTILITIES_STACK_INLINE_HPP
26 #define SHARE_VM_UTILITIES_STACK_INLINE_HPP
27
28 #include "utilities/align.hpp"
29 #include "utilities/stack.hpp"
30
31 template <MEMFLAGS F> StackBase<F>::StackBase(size_t segment_size, size_t max_cache_size,
32 size_t max_size):
33 _seg_size(segment_size),
34 _max_cache_size(max_cache_size),
35 _max_size(adjust_max_size(max_size, segment_size))
36 {
37 assert(_max_size % _seg_size == 0, "not a multiple");
38 }
39
40 template <MEMFLAGS F> size_t StackBase<F>::adjust_max_size(size_t max_size, size_t seg_size)
41 {
42 assert(seg_size > 0, "cannot be 0");
43 assert(max_size >= seg_size || max_size == 0, "max_size too small");
44 const size_t limit = max_uintx - (seg_size - 1);
45 if (max_size == 0 || max_size > limit) {
46 max_size = limit;
47 }
48 return (max_size + seg_size - 1) / seg_size * seg_size;
|