Path: blob/master/src/hotspot/share/gc/shared/c1/cardTableBarrierSetC1.cpp
40974 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 "gc/shared/c1/cardTableBarrierSetC1.hpp"26#include "gc/shared/cardTable.hpp"27#include "gc/shared/cardTableBarrierSet.hpp"28#include "gc/shared/gc_globals.hpp"29#include "utilities/macros.hpp"3031#ifdef ASSERT32#define __ gen->lir(__FILE__, __LINE__)->33#else34#define __ gen->lir()->35#endif3637void CardTableBarrierSetC1::post_barrier(LIRAccess& access, LIR_OprDesc* addr, LIR_OprDesc* new_val) {38DecoratorSet decorators = access.decorators();39LIRGenerator* gen = access.gen();40bool in_heap = (decorators & IN_HEAP) != 0;41if (!in_heap) {42return;43}4445BarrierSet* bs = BarrierSet::barrier_set();46CardTableBarrierSet* ctbs = barrier_set_cast<CardTableBarrierSet>(bs);47CardTable* ct = ctbs->card_table();48LIR_Const* card_table_base = new LIR_Const(ct->byte_map_base());49if (addr->is_address()) {50LIR_Address* address = addr->as_address_ptr();51// ptr cannot be an object because we use this barrier for array card marks52// and addr can point in the middle of an array.53LIR_Opr ptr = gen->new_pointer_register();54if (!address->index()->is_valid() && address->disp() == 0) {55__ move(address->base(), ptr);56} else {57assert(address->disp() != max_jint, "lea doesn't support patched addresses!");58__ leal(addr, ptr);59}60addr = ptr;61}62assert(addr->is_register(), "must be a register at this point");6364#ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER65gen->CardTableBarrierSet_post_barrier_helper(addr, card_table_base);66#else67LIR_Opr tmp = gen->new_pointer_register();68if (TwoOperandLIRForm) {69__ move(addr, tmp);70__ unsigned_shift_right(tmp, CardTable::card_shift, tmp);71} else {72__ unsigned_shift_right(addr, CardTable::card_shift, tmp);73}7475LIR_Address* card_addr;76if (gen->can_inline_as_constant(card_table_base)) {77card_addr = new LIR_Address(tmp, card_table_base->as_jint(), T_BYTE);78} else {79card_addr = new LIR_Address(tmp, gen->load_constant(card_table_base), T_BYTE);80}8182LIR_Opr dirty = LIR_OprFact::intConst(CardTable::dirty_card_val());83if (UseCondCardMark) {84LIR_Opr cur_value = gen->new_register(T_INT);85__ move(card_addr, cur_value);8687LabelObj* L_already_dirty = new LabelObj();88__ cmp(lir_cond_equal, cur_value, dirty);89__ branch(lir_cond_equal, L_already_dirty->label());90__ move(dirty, card_addr);91__ branch_destination(L_already_dirty->label());92} else {93__ move(dirty, card_addr);94}95#endif96}979899