1 /*
   2  * Copyright (c) 2017, 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 
  25 #ifndef SHARE_VM_GC_SHARED_C2BARRIERSETCODEGEN_HPP
  26 #define SHARE_VM_GC_SHARED_C2BARRIERSETCODEGEN_HPP
  27 
  28 enum C2Decorator {
  29   C2_EMPTY_DECORATOR     = UCONST64(0),
  30   C2_ACCESS_ON_HEAP      = UCONST64(1) << 0,
  31   C2_ACCESS_ON_ARRAY     = UCONST64(1) << 1,
  32   C2_ACCESS_ON_WEAK      = UCONST64(1) << 2,
  33   C2_ACCESS_ON_ANONYMOUS = UCONST64(1) << 3,
  34   C2_MISMATCHED          = UCONST64(1) << 4,
  35   C2_ACCESS_UNALIGNED    = UCONST64(1) << 5,
  36   C2_IS_FIELD            = UCONST64(1) << 6,
  37   C2_MO_VOLATILE         = UCONST64(1) << 7,
  38   C2_MO_RELAXED          = UCONST64(1) << 8,
  39   C2_MO_RELEASE          = UCONST64(1) << 9,
  40   C2_MO_ACQUIRE          = UCONST64(1) << 10,
  41   C2_MO_OPAQUE           = UCONST64(1) << 11,
  42   C2_ACCESS_ATOMIC       = UCONST64(1) << 12,
  43   C2_WEAK_CAS            = UCONST64(1) << 13,
  44   C2_ACCESS_FREE_CONTROL = UCONST64(1) << 14
  45 };
  46 
  47 typedef uint64_t C2DecoratorSet;
  48 
  49 class GraphKit;
  50 class IdealKit;
  51 class Node;
  52 class Type;
  53 class TypePtr;
  54 class PhaseMacroExpand;
  55 
  56 class C2BarrierSetCodeGen: public CHeapObj<mtGC> {
  57 protected:
  58   virtual Node* store_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, Node* val, const Type* val_type, BasicType bt, C2DecoratorSet decorators);
  59   virtual Node* load_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, const Type* val_type, BasicType bt, C2DecoratorSet decorators);
  60 
  61   virtual Node* cas_val_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* expected_val, Node* new_val, const Type* value_type, Node* mem, Node*& load_store, BasicType bt, C2DecoratorSet decorators);
  62   virtual Node* cas_bool_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* expected_val, Node* new_val, const Type* value_type, Node* mem, BasicType bt, C2DecoratorSet decorators);
  63   virtual Node* swap_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* new_val, const Type* value_type, Node* mem, Node*& load_store, BasicType bt, C2DecoratorSet decorators);
  64   virtual Node* fetch_and_add_at_resolved(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* new_val, const Type* value_type, Node* mem, BasicType bt, C2DecoratorSet decorators);
  65 
  66   virtual C2DecoratorSet fixup_decorators(C2DecoratorSet decorators);
  67 
  68 public:
  69   virtual Node* store_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, Node* val, const Type* val_type, BasicType bt, C2DecoratorSet decorators);
  70   virtual Node* load_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, const Type* val_type, BasicType bt, C2DecoratorSet decorators);
  71 
  72   virtual Node* cas_val_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* expected_val, Node* new_val, const Type* value_type, BasicType bt, C2DecoratorSet decorators);
  73   virtual Node* cas_bool_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* expected_val, Node* new_val, const Type* value_type, BasicType bt, C2DecoratorSet decorators);
  74   virtual Node* swap_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* new_val, const Type* value_type, BasicType bt, C2DecoratorSet decorators);
  75   virtual Node* fetch_and_add_at(GraphKit* kit, Node* obj, Node* adr, const TypePtr* adr_type, int alias_idx, Node* new_val, const Type* value_type, BasicType bt, C2DecoratorSet decorators);
  76 
  77   virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array);
  78 
  79   virtual bool is_gc_barrier_node(Node* node) { return false; }
  80   virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) { }
  81   virtual bool array_copy_requires_gc_barriers(BasicType type) { return false; }
  82 };
  83 
  84 #endif // SHARE_VM_GC_SHARED_C2BARRIERSETCODEGEN_HPP