aoqi@0: /* aoqi@0: * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP aoqi@0: #define SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP aoqi@0: aoqi@0: #include "memory/blockOffsetTable.hpp" aoqi@0: #include "memory/space.hpp" aoqi@0: #include "runtime/safepoint.hpp" aoqi@0: aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: // BlockOffsetTable inlines aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: inline HeapWord* BlockOffsetTable::block_start(const void* addr) const { aoqi@0: if (addr >= _bottom && addr < _end) { aoqi@0: return block_start_unsafe(addr); aoqi@0: } else { aoqi@0: return NULL; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: // BlockOffsetSharedArray inlines aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: inline size_t BlockOffsetSharedArray::index_for(const void* p) const { aoqi@0: char* pc = (char*)p; aoqi@0: assert(pc >= (char*)_reserved.start() && aoqi@0: pc < (char*)_reserved.end(), aoqi@0: "p not in range."); aoqi@0: size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char)); aoqi@0: size_t result = delta >> LogN; aoqi@0: assert(result < _vs.committed_size(), "bad index from address"); aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* BlockOffsetSharedArray::address_for_index(size_t index) const { aoqi@0: assert(index < _vs.committed_size(), "bad index"); aoqi@0: HeapWord* result = _reserved.start() + (index << LogN_words); aoqi@0: assert(result >= _reserved.start() && result < _reserved.end(), aoqi@0: "bad address from index"); aoqi@0: return result; aoqi@0: } aoqi@0: aoqi@0: inline void BlockOffsetSharedArray::check_reducing_assertion(bool reducing) { aoqi@0: assert(reducing || !SafepointSynchronize::is_at_safepoint() || init_to_zero() || aoqi@0: Thread::current()->is_VM_thread() || aoqi@0: Thread::current()->is_ConcurrentGC_thread() || aoqi@0: ((!Thread::current()->is_ConcurrentGC_thread()) && aoqi@0: ParGCRareEvent_lock->owned_by_self()), "Crack"); aoqi@0: } aoqi@0: aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: // BlockOffsetArrayNonContigSpace inlines aoqi@0: ////////////////////////////////////////////////////////////////////////// aoqi@0: inline void BlockOffsetArrayNonContigSpace::freed(HeapWord* blk, aoqi@0: size_t size) { aoqi@0: freed(blk, blk + size); aoqi@0: } aoqi@0: aoqi@0: inline void BlockOffsetArrayNonContigSpace::freed(HeapWord* blk_start, aoqi@0: HeapWord* blk_end) { aoqi@0: // Verify that the BOT shows [blk_start, blk_end) to be one block. aoqi@0: verify_single_block(blk_start, blk_end); aoqi@0: // adjust _unallocated_block upward or downward aoqi@0: // as appropriate aoqi@0: if (BlockOffsetArrayUseUnallocatedBlock) { aoqi@0: assert(_unallocated_block <= _end, aoqi@0: "Inconsistent value for _unallocated_block"); aoqi@0: if (blk_end >= _unallocated_block && blk_start <= _unallocated_block) { aoqi@0: // CMS-specific note: a block abutting _unallocated_block to aoqi@0: // its left is being freed, a new block is being added or aoqi@0: // we are resetting following a compaction aoqi@0: _unallocated_block = blk_start; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: #endif // SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP