1 /* 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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_interface/collectedHeap.hpp" 27 #include "memory/barrierSet.inline.hpp" 28 #include "memory/universe.hpp" 29 30 // count is number of array elements being written 31 void BarrierSet::static_write_ref_array_pre(HeapWord* start, size_t count) { 32 assert(count <= (size_t)max_intx, "count too large"); 33 #if 0 34 warning("Pre: \t" INTPTR_FORMAT "[" SIZE_FORMAT "]\t", 35 start, count); 36 #endif 37 if (UseCompressedOops) { 38 Universe::heap()->barrier_set()->write_ref_array_pre((narrowOop*)start, (int)count, false); 39 } else { 40 Universe::heap()->barrier_set()->write_ref_array_pre( (oop*)start, (int)count, false); 41 } 42 } 43 44 // count is number of array elements being written 45 void BarrierSet::write_ref_array(HeapWord* start, size_t count) { 46 assert(count <= (size_t)max_intx, "count too large"); 47 HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize)); 48 // In the case of compressed oops, start and end may potentially be misaligned; 49 // so we need to conservatively align the first downward (this is not 50 // strictly necessary for current uses, but a case of good hygiene and, 51 // if you will, aesthetics) and the second upward (this is essential for 52 // current uses) to a HeapWord boundary, so we mark all cards overlapping 53 // this write. If this evolves in the future to calling a 54 // logging barrier of narrow oop granularity, like the pre-barrier for G1 55 // (mentioned here merely by way of example), we will need to change this 56 // interface, so it is "exactly precise" (if i may be allowed the adverbial 57 // redundancy for emphasis) and does not include narrow oop slots not 58 // included in the original write interval. 59 HeapWord* aligned_start = (HeapWord*)align_size_down((uintptr_t)start, HeapWordSize); 60 HeapWord* aligned_end = (HeapWord*)align_size_up ((uintptr_t)end, HeapWordSize); 61 // If compressed oops were not being used, these should already be aligned 62 assert(UseCompressedOops || (aligned_start == start && aligned_end == end), 63 "Expected heap word alignment of start and end"); 64 #if 0 65 warning("Post:\t" INTPTR_FORMAT "[" SIZE_FORMAT "] : [" INTPTR_FORMAT "," INTPTR_FORMAT ")\t", 66 start, count, aligned_start, aligned_end); 67 #endif 68 write_ref_array_work(MemRegion(aligned_start, aligned_end)); 69 } 70 71 // count is number of array elements being written 72 void BarrierSet::static_write_ref_array_post(HeapWord* start, size_t count) { 73 // simply delegate to instance method 74 Universe::heap()->barrier_set()->write_ref_array(start, count); 75 }