1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. 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 it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 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 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #ifndef SHARE_GC_Z_C1_ZBARRIERSETC1_HPP
  25 #define SHARE_GC_Z_C1_ZBARRIERSETC1_HPP
  26 
  27 #include "c1/c1_CodeStubs.hpp"
  28 #include "c1/c1_IR.hpp"
  29 #include "c1/c1_LIR.hpp"
  30 #include "gc/shared/c1/barrierSetC1.hpp"
  31 #include "oops/accessDecorators.hpp"
  32 
  33 class ZLoadBarrierStubC1 : public CodeStub {
  34 private:
  35   DecoratorSet  _decorators;
  36   LIR_Opr       _ref_addr;
  37   LIR_Opr       _ref;
  38   LIR_Opr       _tmp;
  39   CodeEmitInfo* _patch_info;
  40   address       _runtime_stub;
  41 
  42 public:
  43   ZLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address runtime_stub);
  44 
  45   DecoratorSet decorators() const;
  46   LIR_Opr ref() const;
  47   LIR_Opr ref_addr() const;
  48   LIR_Opr tmp() const;
  49   LIR_PatchCode patch_code() const;
  50   CodeEmitInfo*& patch_info();
  51   address runtime_stub() const;
  52 
  53   virtual void emit_code(LIR_Assembler* ce);
  54   virtual void visit(LIR_OpVisitState* visitor);
  55 
  56 #ifndef PRODUCT
  57   virtual void print_name(outputStream* out) const;
  58 #endif // PRODUCT
  59 };
  60 
  61 class ZBarrierSetC1 : public BarrierSetC1 {
  62 private:
  63   address _load_barrier_on_oop_field_preloaded_runtime_stub;
  64   address _load_barrier_on_weak_oop_field_preloaded_runtime_stub;
  65 
  66   address load_barrier_on_oop_field_preloaded_runtime_stub(DecoratorSet decorators) const;
  67   void load_barrier(LIRAccess& access, LIR_Opr result) const;
  68 
  69 protected:
  70   virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);
  71   virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value);
  72   virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);
  73 
  74 public:
  75   ZBarrierSetC1();
  76 
  77   virtual void generate_c1_runtime_stubs(BufferBlob* blob);
  78 };
  79 
  80 #endif // SHARE_GC_Z_C1_ZBARRIERSETC1_HPP