Path: blob/master/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp
40974 views
/*1* Copyright (c) 2018, 2019, 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_SHARED_C1_BARRIERSETC1_HPP25#define SHARE_GC_SHARED_C1_BARRIERSETC1_HPP2627#include "c1/c1_Decorators.hpp"28#include "c1/c1_LIRGenerator.hpp"29#include "c1/c1_Instruction.hpp"30#include "c1/c1_LIR.hpp"31#include "memory/allocation.hpp"3233class LIRGenerator;34class LIRItem;3536// The LIRAddressOpr comprises either a LIRItem or a LIR_Opr to describe elements37// of an access in the C1 Access API. Both of them allow asking for the opr() which38// will correspond to either _item.result() or _opr if there is no _item.39class LIRAddressOpr: public StackObj {40LIRItem* _item;41LIR_Opr _opr;42public:43LIRAddressOpr(LIRItem& item) : _item(&item), _opr(NULL) {}44LIRAddressOpr(LIR_Opr opr) : _item(NULL), _opr(opr) {}45LIRAddressOpr(const LIRAddressOpr& other) : _item(other._item), _opr(other._opr) {}4647LIRItem& item() const {48assert(_item != NULL, "sanity");49return *_item;50}5152LIR_Opr opr() const {53if (_item == NULL) {54return _opr;55} else {56return _item->result();57}58}59};6061// The LIRAccess class wraps shared context parameters required for performing62// the right access in C1. This includes the address of the offset and the decorators.63class LIRAccess: public StackObj {64LIRGenerator* _gen;65DecoratorSet _decorators;66LIRAddressOpr _base;67LIRAddressOpr _offset;68BasicType _type;69LIR_Opr _resolved_addr;70CodeEmitInfo* _patch_emit_info;71CodeEmitInfo* _access_emit_info;7273public:74LIRAccess(LIRGenerator* gen, DecoratorSet decorators,75LIRAddressOpr base, LIRAddressOpr offset, BasicType type,76CodeEmitInfo* patch_emit_info = NULL, CodeEmitInfo* access_emit_info = NULL) :77_gen(gen),78_decorators(AccessInternal::decorator_fixup(decorators)),79_base(base),80_offset(offset),81_type(type),82_resolved_addr(NULL),83_patch_emit_info(patch_emit_info),84_access_emit_info(access_emit_info) {}8586void load_base() { _base.item().load_item(); }87void load_offset() { _offset.item().load_nonconstant(); }8889void load_address() {90load_base();91load_offset();92}9394LIRGenerator* gen() const { return _gen; }95CodeEmitInfo*& patch_emit_info() { return _patch_emit_info; }96CodeEmitInfo*& access_emit_info() { return _access_emit_info; }97LIRAddressOpr& base() { return _base; }98LIRAddressOpr& offset() { return _offset; }99BasicType type() const { return _type; }100LIR_Opr resolved_addr() const { return _resolved_addr; }101void set_resolved_addr(LIR_Opr addr) { _resolved_addr = addr; }102bool is_oop() const { return is_reference_type(_type); }103DecoratorSet decorators() const { return _decorators; }104void clear_decorators(DecoratorSet ds) { _decorators &= ~ds; }105bool is_raw() const { return (_decorators & AS_RAW) != 0; }106};107108// The BarrierSetC1 class is the main entry point for the GC backend of the Access API in C1.109// It is called by the LIRGenerator::access_* functions, which is the main entry poing for110// access calls in C1.111112class BarrierSetC1: public CHeapObj<mtGC> {113protected:114virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register);115116virtual void generate_referent_check(LIRAccess& access, LabelObj* cont);117118// Accesses with resolved address119virtual void store_at_resolved(LIRAccess& access, LIR_Opr value);120virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);121122virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);123124virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value);125virtual LIR_Opr atomic_add_at_resolved(LIRAccess& access, LIRItem& value);126127public:128virtual void store_at(LIRAccess& access, LIR_Opr value);129virtual void load_at(LIRAccess& access, LIR_Opr result);130virtual void load(LIRAccess& access, LIR_Opr result);131132virtual LIR_Opr atomic_cmpxchg_at(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);133134virtual LIR_Opr atomic_xchg_at(LIRAccess& access, LIRItem& value);135virtual LIR_Opr atomic_add_at(LIRAccess& access, LIRItem& value);136137virtual void generate_c1_runtime_stubs(BufferBlob* buffer_blob) {}138};139140#endif // SHARE_GC_SHARED_C1_BARRIERSETC1_HPP141142143