aoqi@0: /* aoqi@0: * Copyright (c) 2001, 2010, 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_BARRIERSET_INLINE_HPP aoqi@0: #define SHARE_VM_MEMORY_BARRIERSET_INLINE_HPP aoqi@0: aoqi@0: #include "memory/barrierSet.hpp" aoqi@0: #include "memory/cardTableModRefBS.hpp" aoqi@0: aoqi@0: // Inline functions of BarrierSet, which de-virtualize certain aoqi@0: // performance-critical calls when the barrier is the most common aoqi@0: // card-table kind. aoqi@0: aoqi@0: template void BarrierSet::write_ref_field_pre(T* field, oop new_val) { aoqi@0: if (kind() == CardTableModRef) { aoqi@0: ((CardTableModRefBS*)this)->inline_write_ref_field_pre(field, new_val); aoqi@0: } else { aoqi@0: write_ref_field_pre_work(field, new_val); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: void BarrierSet::write_ref_field(void* field, oop new_val, bool release) { aoqi@0: if (kind() == CardTableModRef) { aoqi@0: ((CardTableModRefBS*)this)->inline_write_ref_field(field, new_val, release); aoqi@0: } else { aoqi@0: write_ref_field_work(field, new_val, release); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // count is number of array elements being written aoqi@0: void BarrierSet::write_ref_array(HeapWord* start, size_t count) { aoqi@0: assert(count <= (size_t)max_intx, "count too large"); aoqi@0: HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize)); aoqi@0: // In the case of compressed oops, start and end may potentially be misaligned; aoqi@0: // so we need to conservatively align the first downward (this is not aoqi@0: // strictly necessary for current uses, but a case of good hygiene and, aoqi@0: // if you will, aesthetics) and the second upward (this is essential for aoqi@0: // current uses) to a HeapWord boundary, so we mark all cards overlapping aoqi@0: // this write. If this evolves in the future to calling a aoqi@0: // logging barrier of narrow oop granularity, like the pre-barrier for G1 aoqi@0: // (mentioned here merely by way of example), we will need to change this aoqi@0: // interface, so it is "exactly precise" (if i may be allowed the adverbial aoqi@0: // redundancy for emphasis) and does not include narrow oop slots not aoqi@0: // included in the original write interval. aoqi@0: HeapWord* aligned_start = (HeapWord*)align_size_down((uintptr_t)start, HeapWordSize); aoqi@0: HeapWord* aligned_end = (HeapWord*)align_size_up ((uintptr_t)end, HeapWordSize); aoqi@0: // If compressed oops were not being used, these should already be aligned aoqi@0: assert(UseCompressedOops || (aligned_start == start && aligned_end == end), aoqi@0: "Expected heap word alignment of start and end"); aoqi@0: #if 0 aoqi@0: warning("Post:\t" INTPTR_FORMAT "[" SIZE_FORMAT "] : [" INTPTR_FORMAT","INTPTR_FORMAT")\t", aoqi@0: start, count, aligned_start, aligned_end); aoqi@0: #endif aoqi@0: write_ref_array_work(MemRegion(aligned_start, aligned_end)); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void BarrierSet::write_region(MemRegion mr) { aoqi@0: if (kind() == CardTableModRef) { aoqi@0: ((CardTableModRefBS*)this)->inline_write_region(mr); aoqi@0: } else { aoqi@0: write_region_work(mr); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: #endif // SHARE_VM_MEMORY_BARRIERSET_INLINE_HPP