--- /dev/null 2018-04-03 12:55:20.301839954 +0200 +++ new/src/hotspot/share/gc/z/zBarrierSet.hpp 2018-06-08 19:45:56.254681918 +0200 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef SHARE_GC_Z_ZBARRIERSET_HPP +#define SHARE_GC_Z_ZBARRIERSET_HPP + +#include "gc/shared/barrierSet.hpp" + +class ZBarrierSetAssembler; + +class ZBarrierSet : public BarrierSet { +public: + ZBarrierSet(); + + static ZBarrierSetAssembler* assembler(); + static bool barrier_needed(DecoratorSet decorators, BasicType type); + + virtual void on_thread_create(Thread* thread); + virtual void on_thread_destroy(Thread* thread); + virtual void on_thread_attach(JavaThread* thread); + virtual void on_thread_detach(JavaThread* thread); + + virtual void print_on(outputStream* st) const {} + + template + class AccessBarrier : public BarrierSet::AccessBarrier { + private: + typedef BarrierSet::AccessBarrier Raw; + + template + static void verify_decorators_present(); + + template + static void verify_decorators_absent(); + + static oop* field_addr(oop base, ptrdiff_t offset); + + template + static oop load_barrier_on_oop_field_preloaded(T* addr, oop o); + + template + static oop load_barrier_on_unknown_oop_field_preloaded(oop base, ptrdiff_t offset, T* addr, oop o); + + public: + // + // In heap + // + template + static oop oop_load_in_heap(T* addr); + static oop oop_load_in_heap_at(oop base, ptrdiff_t offset); + + template + static oop oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value); + static oop oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value); + + template + static oop oop_atomic_xchg_in_heap(oop new_value, T* addr); + static oop oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset); + + template + static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, + arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, + size_t length); + + static void clone_in_heap(oop src, oop dst, size_t size); + + // + // Not in heap + // + template + static oop oop_load_not_in_heap(T* addr); + + template + static oop oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value); + + template + static oop oop_atomic_xchg_not_in_heap(oop new_value, T* addr); + }; +}; + +template<> struct BarrierSet::GetName { + static const BarrierSet::Name value = BarrierSet::ZBarrierSet; +}; + +template<> struct BarrierSet::GetType { + typedef ::ZBarrierSet type; +}; + +#endif // SHARE_GC_Z_ZBARRIERSET_HPP