1 /* 2 * Copyright (c) 2015, 2019, 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_C2_ZBARRIERSETC2_HPP 25 #define SHARE_GC_Z_C2_ZBARRIERSETC2_HPP 26 27 #include "gc/shared/c2/barrierSetC2.hpp" 28 #include "memory/allocation.hpp" 29 #include "opto/node.hpp" 30 #include "utilities/growableArray.hpp" 31 32 const uint8_t ZLoadBarrierStrong = 1; 33 const uint8_t ZLoadBarrierWeak = 2; 34 const uint8_t ZLoadBarrierElided = 3; 35 36 class ZLoadBarrierStubC2 : public ResourceObj { 37 private: 38 const MachNode* _node; 39 const Address _ref_addr; 40 const Register _ref; 41 const Register _tmp; 42 const bool _weak; 43 Label _entry; 44 Label _continuation; 45 46 ZLoadBarrierStubC2(const MachNode* node, Address ref_addr, Register ref, Register tmp, bool weak); 47 48 public: 49 static ZLoadBarrierStubC2* create(const MachNode* node, Address ref_addr, Register ref, Register tmp, bool weak); 50 51 Address ref_addr() const; 52 Register ref() const; 53 Register tmp() const; 54 address slow_path() const; 55 RegMask& live() const; 56 Label* entry(); 57 Label* continuation(); 58 }; 59 60 class ZBarrierSetC2 : public BarrierSetC2 { 61 private: 62 void compute_liveness_at_stubs() const; 63 void analyze_dominating_barriers() const; 64 65 protected: 66 virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; 67 virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, 68 Node* expected_val, 69 Node* new_val, 70 const Type* val_type) const; 71 virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, 72 Node* expected_val, 73 Node* new_val, 74 const Type* value_type) const; 75 virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, 76 Node* new_val, 77 const Type* val_type) const; 78 79 public: 80 virtual void* create_barrier_state(Arena* comp_arena) const; 81 virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, 82 BasicType type, 83 bool is_clone, 84 ArrayCopyPhase phase) const; 85 86 virtual void late_barrier_analysis() const; 87 virtual size_t estimate_stub_size() const; 88 virtual void emit_stubs(CodeBuffer& cb) const; 89 }; 90 91 #endif // SHARE_GC_Z_C2_ZBARRIERSETC2_HPP