Path: blob/master/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.hpp
40975 views
/*1* Copyright (c) 2018, 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#ifndef SHARE_GC_G1_C1_G1BARRIERSETC1_HPP25#define SHARE_GC_G1_C1_G1BARRIERSETC1_HPP2627#include "c1/c1_CodeStubs.hpp"28#include "gc/shared/c1/modRefBarrierSetC1.hpp"2930class G1PreBarrierStub: public CodeStub {31friend class G1BarrierSetC1;32private:33bool _do_load;34LIR_Opr _addr;35LIR_Opr _pre_val;36LIR_PatchCode _patch_code;37CodeEmitInfo* _info;3839public:40// Version that _does_ generate a load of the previous value from addr.41// addr (the address of the field to be read) must be a LIR_Address42// pre_val (a temporary register) must be a register;43G1PreBarrierStub(LIR_Opr addr, LIR_Opr pre_val, LIR_PatchCode patch_code, CodeEmitInfo* info) :44_do_load(true), _addr(addr), _pre_val(pre_val),45_patch_code(patch_code), _info(info)46{47assert(_pre_val->is_register(), "should be temporary register");48assert(_addr->is_address(), "should be the address of the field");49}5051// Version that _does not_ generate load of the previous value; the52// previous value is assumed to have already been loaded into pre_val.53G1PreBarrierStub(LIR_Opr pre_val) :54_do_load(false), _addr(LIR_OprFact::illegalOpr), _pre_val(pre_val),55_patch_code(lir_patch_none), _info(NULL)56{57assert(_pre_val->is_register(), "should be a register");58}5960LIR_Opr addr() const { return _addr; }61LIR_Opr pre_val() const { return _pre_val; }62LIR_PatchCode patch_code() const { return _patch_code; }63CodeEmitInfo* info() const { return _info; }64bool do_load() const { return _do_load; }6566virtual void emit_code(LIR_Assembler* e);67virtual void visit(LIR_OpVisitState* visitor) {68if (_do_load) {69// don't pass in the code emit info since it's processed in the fast70// path71if (_info != NULL)72visitor->do_slow_case(_info);73else74visitor->do_slow_case();7576visitor->do_input(_addr);77visitor->do_temp(_pre_val);78} else {79visitor->do_slow_case();80visitor->do_input(_pre_val);81}82}83#ifndef PRODUCT84virtual void print_name(outputStream* out) const { out->print("G1PreBarrierStub"); }85#endif // PRODUCT86};8788class G1PostBarrierStub: public CodeStub {89friend class G1BarrierSetC1;90private:91LIR_Opr _addr;92LIR_Opr _new_val;9394public:95// addr (the address of the object head) and new_val must be registers.96G1PostBarrierStub(LIR_Opr addr, LIR_Opr new_val): _addr(addr), _new_val(new_val) { }9798LIR_Opr addr() const { return _addr; }99LIR_Opr new_val() const { return _new_val; }100101virtual void emit_code(LIR_Assembler* e);102virtual void visit(LIR_OpVisitState* visitor) {103// don't pass in the code emit info since it's processed in the fast path104visitor->do_slow_case();105visitor->do_input(_addr);106visitor->do_input(_new_val);107}108#ifndef PRODUCT109virtual void print_name(outputStream* out) const { out->print("G1PostBarrierStub"); }110#endif // PRODUCT111};112113class CodeBlob;114115class G1BarrierSetC1 : public ModRefBarrierSetC1 {116protected:117CodeBlob* _pre_barrier_c1_runtime_code_blob;118CodeBlob* _post_barrier_c1_runtime_code_blob;119120virtual void pre_barrier(LIRAccess& access, LIR_Opr addr_opr,121LIR_Opr pre_val, CodeEmitInfo* info);122virtual void post_barrier(LIRAccess& access, LIR_OprDesc* addr, LIR_OprDesc* new_val);123124virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);125126public:127G1BarrierSetC1()128: _pre_barrier_c1_runtime_code_blob(NULL),129_post_barrier_c1_runtime_code_blob(NULL) {}130131CodeBlob* pre_barrier_c1_runtime_code_blob() { return _pre_barrier_c1_runtime_code_blob; }132CodeBlob* post_barrier_c1_runtime_code_blob() { return _post_barrier_c1_runtime_code_blob; }133134virtual void generate_c1_runtime_stubs(BufferBlob* buffer_blob);135};136137#endif // SHARE_GC_G1_C1_G1BARRIERSETC1_HPP138139140