1 /*
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2018, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
83 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
84 Register addr, Register count, bool do_return) {
85 address entry_point = CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry);
86 if (!do_return) {
87 assert_different_registers(addr, Z_R0_scratch); // would be destroyed by push_frame()
88 assert_different_registers(count, Z_R0_scratch); // would be destroyed by push_frame()
89 RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame.
90 __ call_VM_leaf(entry_point, addr, count);
91 RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers);
92 } else {
93 // Tail call: call c and return to stub caller.
94 __ lgr_if_needed(Z_ARG1, addr);
95 __ lgr_if_needed(Z_ARG2, count);
96 __ load_const(Z_R1, entry_point);
97 __ z_br(Z_R1); // Branch without linking, callee will return to stub caller.
98 }
99 }
100
101 void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
102 const Address& src, Register dst, Register tmp1, Register tmp2, Label *L_handle_null) {
103 bool on_oop = type == T_OBJECT || type == T_ARRAY;
104 bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
105 bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
106 bool on_reference = on_weak || on_phantom;
107 Label done;
108 if (on_oop && on_reference && L_handle_null == NULL) { L_handle_null = &done; }
109 ModRefBarrierSetAssembler::load_at(masm, decorators, type, src, dst, tmp1, tmp2, L_handle_null);
110 if (on_oop && on_reference) {
111 // Generate the G1 pre-barrier code to log the value of
112 // the referent field in an SATB buffer.
113 g1_write_barrier_pre(masm, decorators | IS_NOT_NULL,
114 NULL /* obj */,
115 dst /* pre_val */,
116 noreg/* preserve */ ,
117 tmp1, tmp2 /* tmp */,
118 true /* pre_val_needed */);
119 }
120 __ bind(done);
121 }
122
123 void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators,
|
1 /*
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2018, 2019, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
83 void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
84 Register addr, Register count, bool do_return) {
85 address entry_point = CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_array_post_entry);
86 if (!do_return) {
87 assert_different_registers(addr, Z_R0_scratch); // would be destroyed by push_frame()
88 assert_different_registers(count, Z_R0_scratch); // would be destroyed by push_frame()
89 RegisterSaver::save_live_registers(masm, RegisterSaver::arg_registers); // Creates frame.
90 __ call_VM_leaf(entry_point, addr, count);
91 RegisterSaver::restore_live_registers(masm, RegisterSaver::arg_registers);
92 } else {
93 // Tail call: call c and return to stub caller.
94 __ lgr_if_needed(Z_ARG1, addr);
95 __ lgr_if_needed(Z_ARG2, count);
96 __ load_const(Z_R1, entry_point);
97 __ z_br(Z_R1); // Branch without linking, callee will return to stub caller.
98 }
99 }
100
101 void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
102 const Address& src, Register dst, Register tmp1, Register tmp2, Label *L_handle_null) {
103 bool on_oop = is_reference_type(type);
104 bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
105 bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
106 bool on_reference = on_weak || on_phantom;
107 Label done;
108 if (on_oop && on_reference && L_handle_null == NULL) { L_handle_null = &done; }
109 ModRefBarrierSetAssembler::load_at(masm, decorators, type, src, dst, tmp1, tmp2, L_handle_null);
110 if (on_oop && on_reference) {
111 // Generate the G1 pre-barrier code to log the value of
112 // the referent field in an SATB buffer.
113 g1_write_barrier_pre(masm, decorators | IS_NOT_NULL,
114 NULL /* obj */,
115 dst /* pre_val */,
116 noreg/* preserve */ ,
117 tmp1, tmp2 /* tmp */,
118 true /* pre_val_needed */);
119 }
120 __ bind(done);
121 }
122
123 void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators,
|