Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/memory/barrierSet.cpp
32285 views
/*1* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc_interface/collectedHeap.hpp"26#include "memory/barrierSet.inline.hpp"27#include "memory/universe.hpp"2829// count is number of array elements being written30void BarrierSet::static_write_ref_array_pre(HeapWord* start, size_t count) {31assert(count <= (size_t)max_intx, "count too large");32#if 033warning("Pre: \t" INTPTR_FORMAT "[" SIZE_FORMAT "]\t",34start, count);35#endif36if (UseCompressedOops) {37Universe::heap()->barrier_set()->write_ref_array_pre((narrowOop*)start, (int)count, false);38} else {39Universe::heap()->barrier_set()->write_ref_array_pre( (oop*)start, (int)count, false);40}41}4243// count is number of array elements being written44void BarrierSet::write_ref_array(HeapWord* start, size_t count) {45assert(count <= (size_t)max_intx, "count too large");46HeapWord* end = (HeapWord*)((char*)start + (count*heapOopSize));47// In the case of compressed oops, start and end may potentially be misaligned;48// so we need to conservatively align the first downward (this is not49// strictly necessary for current uses, but a case of good hygiene and,50// if you will, aesthetics) and the second upward (this is essential for51// current uses) to a HeapWord boundary, so we mark all cards overlapping52// this write. If this evolves in the future to calling a53// logging barrier of narrow oop granularity, like the pre-barrier for G154// (mentioned here merely by way of example), we will need to change this55// interface, so it is "exactly precise" (if i may be allowed the adverbial56// redundancy for emphasis) and does not include narrow oop slots not57// included in the original write interval.58HeapWord* aligned_start = (HeapWord*)align_size_down((uintptr_t)start, HeapWordSize);59HeapWord* aligned_end = (HeapWord*)align_size_up ((uintptr_t)end, HeapWordSize);60// If compressed oops were not being used, these should already be aligned61assert(UseCompressedOops || (aligned_start == start && aligned_end == end),62"Expected heap word alignment of start and end");63#if 064warning("Post:\t" INTPTR_FORMAT "[" SIZE_FORMAT "] : [" INTPTR_FORMAT "," INTPTR_FORMAT ")\t",65start, count, aligned_start, aligned_end);66#endif67write_ref_array_work(MemRegion(aligned_start, aligned_end));68}6970// count is number of array elements being written71void BarrierSet::static_write_ref_array_post(HeapWord* start, size_t count) {72// simply delegate to instance method73Universe::heap()->barrier_set()->write_ref_array(start, count);74}757677