1 /*
2 * Copyright (c) 2001, 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 *
29 #include "runtime/java.hpp"
30 #include "services/memTracker.hpp"
31
32 //////////////////////////////////////////////////////////////////////
33 // G1BlockOffsetSharedArray
34 //////////////////////////////////////////////////////////////////////
35
36 G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion reserved,
37 size_t init_word_size) :
38 _reserved(reserved), _end(NULL)
39 {
40 size_t size = compute_size(reserved.word_size());
41 ReservedSpace rs(ReservedSpace::allocation_align_size_up(size));
42 if (!rs.is_reserved()) {
43 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
44 }
45 if (!_vs.initialize(rs, 0)) {
46 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
47 }
48
49 MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
50
51 _offset_array = (u_char*)_vs.low_boundary();
52 resize(init_word_size);
53 if (TraceBlockOffsetTable) {
54 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
55 gclog_or_tty->print_cr(" "
56 " rs.base(): " INTPTR_FORMAT
57 " rs.size(): " INTPTR_FORMAT
58 " rs end(): " INTPTR_FORMAT,
59 rs.base(), rs.size(), rs.base() + rs.size());
60 gclog_or_tty->print_cr(" "
61 " _vs.low_boundary(): " INTPTR_FORMAT
62 " _vs.high_boundary(): " INTPTR_FORMAT,
63 _vs.low_boundary(),
64 _vs.high_boundary());
65 }
66 }
67
68 void G1BlockOffsetSharedArray::resize(size_t new_word_size) {
69 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
|
1 /*
2 * Copyright (c) 2001, 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 *
29 #include "runtime/java.hpp"
30 #include "services/memTracker.hpp"
31
32 //////////////////////////////////////////////////////////////////////
33 // G1BlockOffsetSharedArray
34 //////////////////////////////////////////////////////////////////////
35
36 G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion reserved,
37 size_t init_word_size) :
38 _reserved(reserved), _end(NULL)
39 {
40 size_t size = compute_size(reserved.word_size());
41 ReservedSpace rs(ReservedSpace::allocation_align_size_up(size));
42 if (!rs.is_reserved()) {
43 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
44 }
45 if (!_vs.initialize(rs, 0)) {
46 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
47 }
48
49 NMTTrackOp op(NMTTrackOp::TypeOp);
50 op.execute_op((address)rs.base(), 0, mtGC);
51
52 _offset_array = (u_char*)_vs.low_boundary();
53 resize(init_word_size);
54 if (TraceBlockOffsetTable) {
55 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
56 gclog_or_tty->print_cr(" "
57 " rs.base(): " INTPTR_FORMAT
58 " rs.size(): " INTPTR_FORMAT
59 " rs end(): " INTPTR_FORMAT,
60 rs.base(), rs.size(), rs.base() + rs.size());
61 gclog_or_tty->print_cr(" "
62 " _vs.low_boundary(): " INTPTR_FORMAT
63 " _vs.high_boundary(): " INTPTR_FORMAT,
64 _vs.low_boundary(),
65 _vs.high_boundary());
66 }
67 }
68
69 void G1BlockOffsetSharedArray::resize(size_t new_word_size) {
70 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
|