Path: blob/master/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.cpp
40948 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2018, 2021 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "asm/macroAssembler.inline.hpp"27#include "gc/shared/barrierSet.hpp"28#include "gc/shared/cardTable.hpp"29#include "gc/shared/cardTableBarrierSet.hpp"30#include "gc/shared/cardTableBarrierSetAssembler.hpp"31#include "interpreter/interp_masm.hpp"3233#define __ masm->3435#ifdef PRODUCT36#define BLOCK_COMMENT(str) /* nothing */37#else38#define BLOCK_COMMENT(str) __ block_comment(str)39#endif4041#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")4243void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr,44Register count, Register preserve) {45CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());46CardTable* ct = ctbs->card_table();47assert_different_registers(addr, count, R0);4849Label Lskip_loop, Lstore_loop;5051__ sldi_(count, count, LogBytesPerHeapOop);52__ beq(CCR0, Lskip_loop); // zero length53__ addi(count, count, -BytesPerHeapOop);54__ add(count, addr, count);55// Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)56__ srdi(addr, addr, CardTable::card_shift);57__ srdi(count, count, CardTable::card_shift);58__ subf(count, addr, count);59__ add_const_optimized(addr, addr, (address)ct->byte_map_base(), R0);60__ addi(count, count, 1);61__ li(R0, 0);62__ mtctr(count);63// Byte store loop64__ bind(Lstore_loop);65__ stb(R0, 0, addr);66__ addi(addr, addr, 1);67__ bdnz(Lstore_loop);68__ bind(Lskip_loop);69}7071void CardTableBarrierSetAssembler::card_table_write(MacroAssembler* masm,72CardTable::CardValue* byte_map_base,73Register tmp, Register obj) {74assert_different_registers(obj, tmp, R0);75__ load_const_optimized(tmp, (address)byte_map_base, R0);76__ srdi(obj, obj, CardTable::card_shift);77__ li(R0, CardTable::dirty_card_val());78__ stbx(R0, tmp, obj);79}8081void CardTableBarrierSetAssembler::card_write_barrier_post(MacroAssembler* masm, Register store_addr, Register tmp) {82CardTableBarrierSet* bs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());83card_table_write(masm, bs->card_table()->byte_map_base(), tmp, store_addr);84}8586void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,87Register base, RegisterOrConstant ind_or_offs, Register val,88Register tmp1, Register tmp2, Register tmp3,89MacroAssembler::PreservationLevel preservation_level) {90bool is_array = (decorators & IS_ARRAY) != 0;91bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;92bool precise = is_array || on_anonymous;9394BarrierSetAssembler::store_at(masm, decorators, type,95base, ind_or_offs, val,96tmp1, tmp2, tmp3,97preservation_level);9899// No need for post barrier if storing NULL100if (val != noreg) {101if (precise) {102if (ind_or_offs.is_constant()) {103__ add_const_optimized(base, base, ind_or_offs.as_constant(), tmp1);104} else {105__ add(base, ind_or_offs.as_register(), base);106}107}108card_write_barrier_post(masm, base, tmp1);109}110}111112113