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 "gc/shared/blockOffsetTable.inline.hpp" 27 #include "gc/shared/collectedHeap.inline.hpp" 28 #include "gc/shared/space.inline.hpp" 29 #include "memory/iterator.hpp" 30 #include "memory/universe.hpp" 31 #include "oops/oop.inline.hpp" 32 #include "runtime/java.hpp" 33 #include "services/memTracker.hpp" 34 35 ////////////////////////////////////////////////////////////////////// 36 // BlockOffsetSharedArray 37 ////////////////////////////////////////////////////////////////////// 38 39 BlockOffsetSharedArray::BlockOffsetSharedArray(MemRegion reserved, 40 size_t init_word_size): 41 _reserved(reserved), _end(NULL) 42 { 43 size_t size = compute_size(reserved.word_size()); 44 ReservedSpace rs(size); 45 if (!rs.is_reserved()) { 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 if (!_vs.initialize(rs, 0)) { 52 vm_exit_during_initialization("Could not reserve enough space for heap offset array"); 53 } 54 _offset_array = (u_char*)_vs.low_boundary(); 55 resize(init_word_size); 56 if (TraceBlockOffsetTable) { 57 gclog_or_tty->print_cr("BlockOffsetSharedArray::BlockOffsetSharedArray: "); 58 gclog_or_tty->print_cr(" " 59 " rs.base(): " INTPTR_FORMAT 60 " rs.size(): " INTPTR_FORMAT 61 " rs end(): " INTPTR_FORMAT, 62 p2i(rs.base()), rs.size(), p2i(rs.base() + rs.size())); 63 gclog_or_tty->print_cr(" " 64 " _vs.low_boundary(): " INTPTR_FORMAT 65 " _vs.high_boundary(): " INTPTR_FORMAT, 66 p2i(_vs.low_boundary()), 67 p2i(_vs.high_boundary())); 68 } 69 } 70 71 void BlockOffsetSharedArray::resize(size_t new_word_size) { 72 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved"); 73 size_t new_size = compute_size(new_word_size); 74 size_t old_size = _vs.committed_size(); 75 size_t delta; 76 char* high = _vs.high(); 77 _end = _reserved.start() + new_word_size; 78 if (new_size > old_size) { 79 delta = ReservedSpace::page_align_size_up(new_size - old_size); 80 assert(delta > 0, "just checking"); 81 if (!_vs.expand_by(delta)) { 82 // Do better than this for Merlin 83 vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion"); 84 } 85 assert(_vs.high() == high + delta, "invalid expansion"); 86 } else { 87 delta = ReservedSpace::page_align_size_down(old_size - new_size); 88 if (delta == 0) return; | 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 "gc/shared/blockOffsetTable.inline.hpp" 27 #include "gc/shared/collectedHeap.inline.hpp" 28 #include "gc/shared/space.inline.hpp" 29 #include "memory/iterator.hpp" 30 #include "memory/universe.hpp" 31 #include "logging/log.hpp" 32 #include "oops/oop.inline.hpp" 33 #include "runtime/java.hpp" 34 #include "services/memTracker.hpp" 35 36 ////////////////////////////////////////////////////////////////////// 37 // BlockOffsetSharedArray 38 ////////////////////////////////////////////////////////////////////// 39 40 BlockOffsetSharedArray::BlockOffsetSharedArray(MemRegion reserved, 41 size_t init_word_size): 42 _reserved(reserved), _end(NULL) 43 { 44 size_t size = compute_size(reserved.word_size()); 45 ReservedSpace rs(size); 46 if (!rs.is_reserved()) { 47 vm_exit_during_initialization("Could not reserve enough space for heap offset array"); 48 } 49 50 MemTracker::record_virtual_memory_type((address)rs.base(), mtGC); 51 52 if (!_vs.initialize(rs, 0)) { 53 vm_exit_during_initialization("Could not reserve enough space for heap offset array"); 54 } 55 _offset_array = (u_char*)_vs.low_boundary(); 56 resize(init_word_size); 57 log_trace(gc, bot)("BlockOffsetSharedArray::BlockOffsetSharedArray: "); 58 log_trace(gc, bot)(" rs.base(): " INTPTR_FORMAT " rs.size(): " INTPTR_FORMAT " rs end(): " INTPTR_FORMAT, 59 p2i(rs.base()), rs.size(), p2i(rs.base() + rs.size())); 60 log_trace(gc, bot)(" _vs.low_boundary(): " INTPTR_FORMAT " _vs.high_boundary(): " INTPTR_FORMAT, 61 p2i(_vs.low_boundary()), p2i(_vs.high_boundary())); 62 } 63 64 void BlockOffsetSharedArray::resize(size_t new_word_size) { 65 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved"); 66 size_t new_size = compute_size(new_word_size); 67 size_t old_size = _vs.committed_size(); 68 size_t delta; 69 char* high = _vs.high(); 70 _end = _reserved.start() + new_word_size; 71 if (new_size > old_size) { 72 delta = ReservedSpace::page_align_size_up(new_size - old_size); 73 assert(delta > 0, "just checking"); 74 if (!_vs.expand_by(delta)) { 75 // Do better than this for Merlin 76 vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion"); 77 } 78 assert(_vs.high() == high + delta, "invalid expansion"); 79 } else { 80 delta = ReservedSpace::page_align_size_down(old_size - new_size); 81 if (delta == 0) return; |