src/share/vm/memory/blockOffsetTable.inline.hpp

Thu, 12 Oct 2017 21:27:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 21:27:07 +0800
changeset 7535
7ae4e26cb1e0
parent 6876
710a3c8b516e
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP
aoqi@0 27
aoqi@0 28 #include "memory/blockOffsetTable.hpp"
aoqi@0 29 #include "memory/space.hpp"
aoqi@0 30 #include "runtime/safepoint.hpp"
aoqi@0 31
aoqi@0 32 //////////////////////////////////////////////////////////////////////////
aoqi@0 33 // BlockOffsetTable inlines
aoqi@0 34 //////////////////////////////////////////////////////////////////////////
aoqi@0 35 inline HeapWord* BlockOffsetTable::block_start(const void* addr) const {
aoqi@0 36 if (addr >= _bottom && addr < _end) {
aoqi@0 37 return block_start_unsafe(addr);
aoqi@0 38 } else {
aoqi@0 39 return NULL;
aoqi@0 40 }
aoqi@0 41 }
aoqi@0 42
aoqi@0 43 //////////////////////////////////////////////////////////////////////////
aoqi@0 44 // BlockOffsetSharedArray inlines
aoqi@0 45 //////////////////////////////////////////////////////////////////////////
aoqi@0 46 inline size_t BlockOffsetSharedArray::index_for(const void* p) const {
aoqi@0 47 char* pc = (char*)p;
aoqi@0 48 assert(pc >= (char*)_reserved.start() &&
aoqi@0 49 pc < (char*)_reserved.end(),
aoqi@0 50 "p not in range.");
aoqi@0 51 size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char));
aoqi@0 52 size_t result = delta >> LogN;
aoqi@0 53 assert(result < _vs.committed_size(), "bad index from address");
aoqi@0 54 return result;
aoqi@0 55 }
aoqi@0 56
aoqi@0 57 inline HeapWord* BlockOffsetSharedArray::address_for_index(size_t index) const {
aoqi@0 58 assert(index < _vs.committed_size(), "bad index");
aoqi@0 59 HeapWord* result = _reserved.start() + (index << LogN_words);
aoqi@0 60 assert(result >= _reserved.start() && result < _reserved.end(),
aoqi@0 61 "bad address from index");
aoqi@0 62 return result;
aoqi@0 63 }
aoqi@0 64
aoqi@0 65 inline void BlockOffsetSharedArray::check_reducing_assertion(bool reducing) {
aoqi@0 66 assert(reducing || !SafepointSynchronize::is_at_safepoint() || init_to_zero() ||
aoqi@0 67 Thread::current()->is_VM_thread() ||
aoqi@0 68 Thread::current()->is_ConcurrentGC_thread() ||
aoqi@0 69 ((!Thread::current()->is_ConcurrentGC_thread()) &&
aoqi@0 70 ParGCRareEvent_lock->owned_by_self()), "Crack");
aoqi@0 71 }
aoqi@0 72
aoqi@0 73 //////////////////////////////////////////////////////////////////////////
aoqi@0 74 // BlockOffsetArrayNonContigSpace inlines
aoqi@0 75 //////////////////////////////////////////////////////////////////////////
aoqi@0 76 inline void BlockOffsetArrayNonContigSpace::freed(HeapWord* blk,
aoqi@0 77 size_t size) {
aoqi@0 78 freed(blk, blk + size);
aoqi@0 79 }
aoqi@0 80
aoqi@0 81 inline void BlockOffsetArrayNonContigSpace::freed(HeapWord* blk_start,
aoqi@0 82 HeapWord* blk_end) {
aoqi@0 83 // Verify that the BOT shows [blk_start, blk_end) to be one block.
aoqi@0 84 verify_single_block(blk_start, blk_end);
aoqi@0 85 // adjust _unallocated_block upward or downward
aoqi@0 86 // as appropriate
aoqi@0 87 if (BlockOffsetArrayUseUnallocatedBlock) {
aoqi@0 88 assert(_unallocated_block <= _end,
aoqi@0 89 "Inconsistent value for _unallocated_block");
aoqi@0 90 if (blk_end >= _unallocated_block && blk_start <= _unallocated_block) {
aoqi@0 91 // CMS-specific note: a block abutting _unallocated_block to
aoqi@0 92 // its left is being freed, a new block is being added or
aoqi@0 93 // we are resetting following a compaction
aoqi@0 94 _unallocated_block = blk_start;
aoqi@0 95 }
aoqi@0 96 }
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 #endif // SHARE_VM_MEMORY_BLOCKOFFSETTABLE_INLINE_HPP

mercurial