Path: blob/master/src/hotspot/cpu/s390/gc/shared/cardTableBarrierSetAssembler_s390.cpp
41153 views
/*1* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2018 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 ":")4243#define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8)4445void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count,46bool do_return) {47CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());48CardTable* ct = ctbs->card_table();4950NearLabel doXC, done;51assert_different_registers(Z_R0, Z_R1, addr, count);5253// Nothing to do if count <= 0.54if (!do_return) {55__ compare64_and_branch(count, (intptr_t) 0, Assembler::bcondNotHigh, done);56} else {57__ z_ltgr(count, count);58__ z_bcr(Assembler::bcondNotPositive, Z_R14);59}6061// Note: We can't combine the shifts. We could lose a carry62// from calculating the array end address.63// count = (count-1)*BytesPerHeapOop + addr64// Count holds addr of last oop in array then.65__ z_sllg(count, count, LogBytesPerHeapOop);66__ add2reg_with_index(count, -BytesPerHeapOop, count, addr);6768// Get base address of card table.69__ load_const_optimized(Z_R1, (address)ct->byte_map_base());7071// count = (count>>shift) - (addr>>shift)72__ z_srlg(addr, addr, CardTable::card_shift);73__ z_srlg(count, count, CardTable::card_shift);7475// Prefetch first elements of card table for update.76if (VM_Version::has_Prefetch()) {77__ z_pfd(0x02, 0, addr, Z_R1);78}7980// Special case: clear just one byte.81__ clear_reg(Z_R0, true, false); // Used for doOneByte.82__ z_sgr(count, addr); // Count = n-1 now, CC used for brc below.83__ z_stc(Z_R0, 0, addr, Z_R1); // Must preserve CC from z_sgr.84if (!do_return) {85__ z_brz(done);86} else {87__ z_bcr(Assembler::bcondZero, Z_R14);88}8990__ z_cghi(count, 255);91__ z_brnh(doXC);9293// MVCLE: clear a long area.94// Start addr of card table range = base + addr.95// # bytes in card table range = (count + 1)96__ add2reg_with_index(Z_R0, 0, Z_R1, addr);97__ add2reg(Z_R1, 1, count);9899// dirty hack:100// There are just two callers. Both pass101// count in Z_ARG3 = Z_R4102// addr in Z_ARG2 = Z_R3103// ==> use Z_ARG2 as src len reg = 0104// Z_ARG1 as src addr (ignored)105assert(count == Z_ARG3, "count: unexpected register number");106assert(addr == Z_ARG2, "addr: unexpected register number");107__ clear_reg(Z_ARG2, true, false);108109__ MacroAssembler::move_long_ext(Z_R0, Z_ARG1, 0);110111if (!do_return) {112__ z_bru(done);113} else {114__ z_bcr(Assembler::bcondAlways, Z_R14);115}116117// XC: clear a short area.118Label XC_template; // Instr template, never exec directly!119__ bind(XC_template);120__ z_xc(0, 0, addr, 0, addr);121122__ bind(doXC);123// start addr of card table range = base + addr124// end addr of card table range = base + addr + count125__ add2reg_with_index(addr, 0, Z_R1, addr);126127if (VM_Version::has_ExecuteExtensions()) {128__ z_exrl(count, XC_template); // Execute XC with var. len.129} else {130__ z_larl(Z_R1, XC_template);131__ z_ex(count, 0, Z_R0, Z_R1); // Execute XC with var. len.132}133if (do_return) {134__ z_br(Z_R14);135}136137__ bind(done);138}139140void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register store_addr, Register tmp) {141// Does a store check for the oop in register obj. The content of142// register obj is destroyed afterwards.143CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(BarrierSet::barrier_set());144CardTable* ct = ctbs->card_table();145146assert_different_registers(store_addr, tmp);147148__ z_srlg(store_addr, store_addr, CardTable::card_shift);149__ load_absolute_address(tmp, (address)ct->byte_map_base());150__ z_agr(store_addr, tmp);151__ z_mvi(0, store_addr, CardTable::dirty_card_val());152}153154void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,155const Address& dst, Register val, Register tmp1, Register tmp2, Register tmp3) {156bool is_array = (decorators & IS_ARRAY) != 0;157bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;158bool precise = is_array || on_anonymous;159160BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2, tmp3);161162// No need for post barrier if storing NULL163if (val != noreg) {164const Register base = dst.base(),165idx = dst.index();166const intptr_t disp = dst.disp();167if (precise && (disp != 0 || idx != noreg)) {168__ add2reg_with_index(base, disp, idx, base);169}170store_check(masm, base, tmp1);171}172}173174175