Thu, 12 Oct 2017 21:27:07 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2001, 2010, 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_BARRIERSET_INLINE_HPP |
aoqi@0 | 26 | #define SHARE_VM_MEMORY_BARRIERSET_INLINE_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "memory/barrierSet.hpp" |
aoqi@0 | 29 | #include "memory/cardTableModRefBS.hpp" |
aoqi@0 | 30 | |
aoqi@0 | 31 | // Inline functions of BarrierSet, which de-virtualize certain |
aoqi@0 | 32 | // performance-critical calls when the barrier is the most common |
aoqi@0 | 33 | // card-table kind. |
aoqi@0 | 34 | |
aoqi@0 | 35 | template <class T> void BarrierSet::write_ref_field_pre(T* field, oop new_val) { |
aoqi@0 | 36 | if (kind() == CardTableModRef) { |
aoqi@0 | 37 | ((CardTableModRefBS*)this)->inline_write_ref_field_pre(field, new_val); |
aoqi@0 | 38 | } else { |
aoqi@0 | 39 | write_ref_field_pre_work(field, new_val); |
aoqi@0 | 40 | } |
aoqi@0 | 41 | } |
aoqi@0 | 42 | |
aoqi@0 | 43 | void BarrierSet::write_ref_field(void* field, oop new_val, bool release) { |
aoqi@0 | 44 | if (kind() == CardTableModRef) { |
aoqi@0 | 45 | ((CardTableModRefBS*)this)->inline_write_ref_field(field, new_val, release); |
aoqi@0 | 46 | } else { |
aoqi@0 | 47 | write_ref_field_work(field, new_val, release); |
aoqi@0 | 48 | } |
aoqi@0 | 49 | } |
aoqi@0 | 50 | |
aoqi@0 | 51 | // count is number of array elements being written |
aoqi@0 | 52 | void BarrierSet::write_ref_array(HeapWord* start, size_t count) { |
aoqi@0 | 53 | assert(count <= (size_t)max_intx, "count too large"); |
aoqi@0 | 54 | HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize)); |
aoqi@0 | 55 | // In the case of compressed oops, start and end may potentially be misaligned; |
aoqi@0 | 56 | // so we need to conservatively align the first downward (this is not |
aoqi@0 | 57 | // strictly necessary for current uses, but a case of good hygiene and, |
aoqi@0 | 58 | // if you will, aesthetics) and the second upward (this is essential for |
aoqi@0 | 59 | // current uses) to a HeapWord boundary, so we mark all cards overlapping |
aoqi@0 | 60 | // this write. If this evolves in the future to calling a |
aoqi@0 | 61 | // logging barrier of narrow oop granularity, like the pre-barrier for G1 |
aoqi@0 | 62 | // (mentioned here merely by way of example), we will need to change this |
aoqi@0 | 63 | // interface, so it is "exactly precise" (if i may be allowed the adverbial |
aoqi@0 | 64 | // redundancy for emphasis) and does not include narrow oop slots not |
aoqi@0 | 65 | // included in the original write interval. |
aoqi@0 | 66 | HeapWord* aligned_start = (HeapWord*)align_size_down((uintptr_t)start, HeapWordSize); |
aoqi@0 | 67 | HeapWord* aligned_end = (HeapWord*)align_size_up ((uintptr_t)end, HeapWordSize); |
aoqi@0 | 68 | // If compressed oops were not being used, these should already be aligned |
aoqi@0 | 69 | assert(UseCompressedOops || (aligned_start == start && aligned_end == end), |
aoqi@0 | 70 | "Expected heap word alignment of start and end"); |
aoqi@0 | 71 | #if 0 |
aoqi@0 | 72 | warning("Post:\t" INTPTR_FORMAT "[" SIZE_FORMAT "] : [" INTPTR_FORMAT","INTPTR_FORMAT")\t", |
aoqi@0 | 73 | start, count, aligned_start, aligned_end); |
aoqi@0 | 74 | #endif |
aoqi@0 | 75 | write_ref_array_work(MemRegion(aligned_start, aligned_end)); |
aoqi@0 | 76 | } |
aoqi@0 | 77 | |
aoqi@0 | 78 | |
aoqi@0 | 79 | void BarrierSet::write_region(MemRegion mr) { |
aoqi@0 | 80 | if (kind() == CardTableModRef) { |
aoqi@0 | 81 | ((CardTableModRefBS*)this)->inline_write_region(mr); |
aoqi@0 | 82 | } else { |
aoqi@0 | 83 | write_region_work(mr); |
aoqi@0 | 84 | } |
aoqi@0 | 85 | } |
aoqi@0 | 86 | |
aoqi@0 | 87 | #endif // SHARE_VM_MEMORY_BARRIERSET_INLINE_HPP |