1 /*
2 * Copyright (c) 2018, 2019, Red Hat, Inc. 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 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
26 #include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp"
27 #include "gc/shenandoah/shenandoahRuntime.hpp"
28 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "runtime/interfaceSupport.inline.hpp"
31 #include "utilities/copy.hpp"
32
33 JRT_LEAF(void, ShenandoahRuntime::arraycopy_barrier_oop(oop* src, oop* dst, size_t length))
34 ShenandoahBarrierSet::barrier_set()->arraycopy_barrier(src, dst, length);
35 JRT_END
36
37 JRT_LEAF(void, ShenandoahRuntime::arraycopy_barrier_narrow_oop(narrowOop* src, narrowOop* dst, size_t length))
38 ShenandoahBarrierSet::barrier_set()->arraycopy_barrier(src, dst, length);
39 JRT_END
40
41 JRT_LEAF(void, ShenandoahRuntime::write_barrier_pre_c2(oopDesc* orig))
42 //log_info(gc)("WB pre C2: " PTR_FORMAT, p2i(orig));
43 write_barrier_pre(orig);
44 JRT_END
45
46 JRT_LEAF(void, ShenandoahRuntime::write_barrier_pre(oopDesc* orig))
47 if (orig == nullptr) {
48 return ;
49 }
50 shenandoah_assert_correct(nullptr, orig);
51 // Capture the original value that was in the field reference.
52 JavaThread* thread = JavaThread::current();
53 assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise");
54 SATBMarkQueue& queue = ShenandoahThreadLocalData::satb_mark_queue(thread);
55 ShenandoahBarrierSet::satb_mark_queue_set().enqueue_known_active(queue, orig);
56 JRT_END
57
58 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_strong(oopDesc* src, oop* load_addr))
59 //tty->print_cr("ShenandoahRuntime::load_reference_barrier_strong: " PTR_FORMAT " [" PTR_FORMAT "]", p2i(src), p2i(load_addr));
60 return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr);
61 JRT_END
62
63 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_strong_narrow(oopDesc* src, narrowOop* load_addr))
64 // tty->print_cr("ShenandoahRuntime::load_reference_barrier_strong_narrow: " PTR_FORMAT " [" PTR_FORMAT "]", p2i(src), p2i(load_addr));
65 return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src, load_addr);
66 JRT_END
67
68 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak(oopDesc* src, oop* load_addr))
69 return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier<oop>(ON_WEAK_OOP_REF, oop(src), load_addr);
70 JRT_END
71
72 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_weak_narrow(oopDesc* src, narrowOop* load_addr))
73 return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier<narrowOop>(ON_WEAK_OOP_REF, oop(src), load_addr);
74 JRT_END
75
76 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom(oopDesc* src, oop* load_addr))
77 return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier<oop>(ON_PHANTOM_OOP_REF, oop(src), load_addr);
78 JRT_END
79
80 JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_phantom_narrow(oopDesc* src, narrowOop* load_addr))
81 return (oopDesc*) ShenandoahBarrierSet::barrier_set()->load_reference_barrier<narrowOop>(ON_PHANTOM_OOP_REF, oop(src), load_addr);
82 JRT_END
83
84 JRT_LEAF(void, ShenandoahRuntime::clone_barrier(oopDesc* src))
85 oop s = oop(src);
86 shenandoah_assert_correct(nullptr, s);
87 ShenandoahBarrierSet::barrier_set()->clone_barrier(s);
88 JRT_END