Path: blob/master/src/hotspot/cpu/aarch64/gc/shared/cardTableBarrierSetAssembler_aarch64.cpp
41155 views
/*1* Copyright (c) 2018, 2021, 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 "asm/macroAssembler.inline.hpp"26#include "gc/shared/barrierSet.hpp"27#include "gc/shared/cardTable.hpp"28#include "gc/shared/cardTableBarrierSet.hpp"29#include "gc/shared/cardTableBarrierSetAssembler.hpp"30#include "gc/shared/gc_globals.hpp"31#include "interpreter/interp_masm.hpp"3233#define __ masm->3435void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Address dst) {3637BarrierSet* bs = BarrierSet::barrier_set();38assert(bs->kind() == BarrierSet::CardTableBarrierSet, "Wrong barrier set kind");3940__ lsr(obj, obj, CardTable::card_shift);4142assert(CardTable::dirty_card_val() == 0, "must be");4344__ load_byte_map_base(rscratch1);4546if (UseCondCardMark) {47Label L_already_dirty;48__ ldrb(rscratch2, Address(obj, rscratch1));49__ cbz(rscratch2, L_already_dirty);50__ strb(zr, Address(obj, rscratch1));51__ bind(L_already_dirty);52} else {53__ strb(zr, Address(obj, rscratch1));54}55}5657void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,58Register start, Register count, Register scratch, RegSet saved_regs) {59Label L_loop, L_done;60const Register end = count;6162__ cbz(count, L_done); // zero count - nothing to do6364__ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop))); // end = start + count << LogBytesPerHeapOop65__ sub(end, end, BytesPerHeapOop); // last element address to make inclusive66__ lsr(start, start, CardTable::card_shift);67__ lsr(end, end, CardTable::card_shift);68__ sub(count, end, start); // number of bytes to copy6970__ load_byte_map_base(scratch);71__ add(start, start, scratch);72__ bind(L_loop);73__ strb(zr, Address(start, count));74__ subs(count, count, 1);75__ br(Assembler::GE, L_loop);76__ bind(L_done);77}7879void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,80Address dst, Register val, Register tmp1, Register tmp2) {81bool in_heap = (decorators & IN_HEAP) != 0;82bool is_array = (decorators & IS_ARRAY) != 0;83bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;84bool precise = is_array || on_anonymous;8586bool needs_post_barrier = val != noreg && in_heap;87BarrierSetAssembler::store_at(masm, decorators, type, dst, val, noreg, noreg);88if (needs_post_barrier) {89// flatten object address if needed90if (!precise || (dst.index() == noreg && dst.offset() == 0)) {91store_check(masm, dst.base(), dst);92} else {93__ lea(r3, dst);94store_check(masm, r3, dst);95}96}97}9899100