1 /*
2 * Copyright (c) 2018, 2024, 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 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "interpreter/interp_masm.hpp"
32 #include "memory/universe.hpp"
33 #include "runtime/javaThread.hpp"
34 #include "runtime/jniHandles.hpp"
35 #include "runtime/sharedRuntime.hpp"
36 #include "runtime/stubRoutines.hpp"
37 #ifdef COMPILER2
38 #include "gc/shared/c2/barrierSetC2.hpp"
39 #endif // COMPILER2
40
41 #define __ masm->
42
43 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
44 Register dst, Address src, Register tmp1, Register tmp_thread) {
45 bool in_heap = (decorators & IN_HEAP) != 0;
46 bool in_native = (decorators & IN_NATIVE) != 0;
47 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
48 bool atomic = (decorators & MO_RELAXED) != 0;
49
181 __ movptr(dst, rax);
182 __ movptr(dst.plus_disp(wordSize), rdx);
183 }
184 #endif
185 break;
186 case T_FLOAT:
187 assert(val == noreg, "only tos");
188 __ store_float(dst);
189 break;
190 case T_DOUBLE:
191 assert(val == noreg, "only tos");
192 __ store_double(dst);
193 break;
194 case T_ADDRESS:
195 __ movptr(dst, val);
196 break;
197 default: Unimplemented();
198 }
199 }
200
201 void BarrierSetAssembler::copy_load_at(MacroAssembler* masm,
202 DecoratorSet decorators,
203 BasicType type,
204 size_t bytes,
205 Register dst,
206 Address src,
207 Register tmp) {
208 assert(bytes <= 8, "can only deal with non-vector registers");
209 switch (bytes) {
210 case 1:
211 __ movb(dst, src);
212 break;
213 case 2:
214 __ movw(dst, src);
215 break;
216 case 4:
217 __ movl(dst, src);
218 break;
219 case 8:
220 #ifdef _LP64
|
1 /*
2 * Copyright (c) 2018, 2025, 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 #include "precompiled.hpp"
26 #include "asm/macroAssembler.inline.hpp"
27 #include "classfile/classLoaderData.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/barrierSetAssembler.hpp"
30 #include "gc/shared/barrierSetNMethod.hpp"
31 #include "gc/shared/barrierSetRuntime.hpp"
32 #include "gc/shared/collectedHeap.hpp"
33 #include "interpreter/interp_masm.hpp"
34 #include "memory/universe.hpp"
35 #include "runtime/javaThread.hpp"
36 #include "runtime/jniHandles.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #ifdef COMPILER2
40 #include "gc/shared/c2/barrierSetC2.hpp"
41 #endif // COMPILER2
42
43 #define __ masm->
44
45 void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
46 Register dst, Address src, Register tmp1, Register tmp_thread) {
47 bool in_heap = (decorators & IN_HEAP) != 0;
48 bool in_native = (decorators & IN_NATIVE) != 0;
49 bool is_not_null = (decorators & IS_NOT_NULL) != 0;
50 bool atomic = (decorators & MO_RELAXED) != 0;
51
183 __ movptr(dst, rax);
184 __ movptr(dst.plus_disp(wordSize), rdx);
185 }
186 #endif
187 break;
188 case T_FLOAT:
189 assert(val == noreg, "only tos");
190 __ store_float(dst);
191 break;
192 case T_DOUBLE:
193 assert(val == noreg, "only tos");
194 __ store_double(dst);
195 break;
196 case T_ADDRESS:
197 __ movptr(dst, val);
198 break;
199 default: Unimplemented();
200 }
201 }
202
203 void BarrierSetAssembler::flat_field_copy(MacroAssembler* masm, DecoratorSet decorators,
204 Register src, Register dst, Register inline_layout_info) {
205 // flat_field_copy implementation is fairly complex, and there are not any
206 // "short-cuts" to be made from asm. What there is, appears to have the same
207 // cost in C++, so just "call_VM_leaf" for now rather than maintain hundreds
208 // of hand-rolled instructions...
209 if (decorators & IS_DEST_UNINITIALIZED) {
210 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy_is_dest_uninitialized), src, dst, inline_layout_info);
211 } else {
212 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSetRuntime::value_copy), src, dst, inline_layout_info);
213 }
214 }
215
216 void BarrierSetAssembler::copy_load_at(MacroAssembler* masm,
217 DecoratorSet decorators,
218 BasicType type,
219 size_t bytes,
220 Register dst,
221 Address src,
222 Register tmp) {
223 assert(bytes <= 8, "can only deal with non-vector registers");
224 switch (bytes) {
225 case 1:
226 __ movb(dst, src);
227 break;
228 case 2:
229 __ movw(dst, src);
230 break;
231 case 4:
232 __ movl(dst, src);
233 break;
234 case 8:
235 #ifdef _LP64
|