1 /*
2 * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2025 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 *
24 */
25
26 #include "asm/macroAssembler.inline.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "prims/jniFastGetField.hpp"
31 #include "prims/jvm_misc.hpp"
32 #include "prims/jvmtiExport.hpp"
33 #include "runtime/safepoint.hpp"
34
35 #define __ masm->
36
37 #define BUFFER_SIZE 48*BytesPerInstWord
38
39
40 // Common register usage:
41 // R3/F0: result
42 // R3_ARG1: jni env
43 // R4_ARG2: obj
44 // R5_ARG3: jfield id
45
46 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
47 const char *name;
48 switch (type) {
49 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
50 case T_BYTE: name = "jni_fast_GetByteField"; break;
51 case T_CHAR: name = "jni_fast_GetCharField"; break;
52 case T_SHORT: name = "jni_fast_GetShortField"; break;
81 // Field may be volatile.
82 __ fence();
83 } else {
84 // Using acquire to order wrt. JVMTI check and load of result.
85 __ isync(); // order wrt. to following load(s)
86 }
87
88 if (JvmtiExport::can_post_field_access()) {
89 // Check to see if a field access watch has been set before we
90 // take the fast path.
91 int fac_offs = __ load_const_optimized(Rtmp, JvmtiExport::get_field_access_count_addr(),
92 R0, true);
93 __ lwa(Rtmp, fac_offs, Rtmp);
94 __ cmpwi(CR0, Rtmp, 0);
95 __ bne(CR0, slow);
96 }
97
98 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
99 bs->try_resolve_jobject_in_native(masm, Robj, R3_ARG1, R4_ARG2, Rtmp, slow);
100
101 __ srwi(Rtmp, R5_ARG3, 2); // offset
102
103 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
104 speculative_load_pclist[count] = __ pc(); // Used by the segfault handler
105 bool is_fp = false;
106 switch (type) {
107 case T_BOOLEAN: __ lbzx(Rtmp, Rtmp, Robj); break;
108 case T_BYTE: __ lbzx(Rtmp, Rtmp, Robj); __ extsb(Rtmp, Rtmp); break;
109 case T_CHAR: __ lhzx(Rtmp, Rtmp, Robj); break;
110 case T_SHORT: __ lhax(Rtmp, Rtmp, Robj); break;
111 case T_INT: __ lwax(Rtmp, Rtmp, Robj); break;
112 case T_LONG: __ ldx( Rtmp, Rtmp, Robj); break;
113 case T_FLOAT: __ lfsx(F1_RET, Rtmp, Robj); is_fp = true; break;
114 case T_DOUBLE: __ lfdx(F1_RET, Rtmp, Robj); is_fp = true; break;
115 default: ShouldNotReachHere();
116 }
117
118 // Order preceding load(s) wrt. succeeding check (LoadStore for volatile field).
119 if (is_fp) {
120 Label next;
121 __ fcmpu(CR0, F1_RET, F1_RET);
|
1 /*
2 * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2026 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 *
24 */
25
26 #include "asm/macroAssembler.inline.hpp"
27 #include "gc/shared/barrierSet.hpp"
28 #include "gc/shared/barrierSetAssembler.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "prims/jniFastGetField.hpp"
31 #include "prims/jvm_misc.hpp"
32 #include "prims/jvmtiExport.hpp"
33 #include "runtime/jfieldIDWorkaround.hpp"
34 #include "runtime/safepoint.hpp"
35
36 #define __ masm->
37
38 #define BUFFER_SIZE 48*BytesPerInstWord
39
40
41 // Common register usage:
42 // R3/F0: result
43 // R3_ARG1: jni env
44 // R4_ARG2: obj
45 // R5_ARG3: jfield id
46
47 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
48 const char *name;
49 switch (type) {
50 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
51 case T_BYTE: name = "jni_fast_GetByteField"; break;
52 case T_CHAR: name = "jni_fast_GetCharField"; break;
53 case T_SHORT: name = "jni_fast_GetShortField"; break;
82 // Field may be volatile.
83 __ fence();
84 } else {
85 // Using acquire to order wrt. JVMTI check and load of result.
86 __ isync(); // order wrt. to following load(s)
87 }
88
89 if (JvmtiExport::can_post_field_access()) {
90 // Check to see if a field access watch has been set before we
91 // take the fast path.
92 int fac_offs = __ load_const_optimized(Rtmp, JvmtiExport::get_field_access_count_addr(),
93 R0, true);
94 __ lwa(Rtmp, fac_offs, Rtmp);
95 __ cmpwi(CR0, Rtmp, 0);
96 __ bne(CR0, slow);
97 }
98
99 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
100 bs->try_resolve_jobject_in_native(masm, Robj, R3_ARG1, R4_ARG2, Rtmp, slow);
101
102 __ srwi(Rtmp, R5_ARG3, jfieldIDWorkaround::offset_shift); // offset
103
104 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
105 speculative_load_pclist[count] = __ pc(); // Used by the segfault handler
106 bool is_fp = false;
107 switch (type) {
108 case T_BOOLEAN: __ lbzx(Rtmp, Rtmp, Robj); break;
109 case T_BYTE: __ lbzx(Rtmp, Rtmp, Robj); __ extsb(Rtmp, Rtmp); break;
110 case T_CHAR: __ lhzx(Rtmp, Rtmp, Robj); break;
111 case T_SHORT: __ lhax(Rtmp, Rtmp, Robj); break;
112 case T_INT: __ lwax(Rtmp, Rtmp, Robj); break;
113 case T_LONG: __ ldx( Rtmp, Rtmp, Robj); break;
114 case T_FLOAT: __ lfsx(F1_RET, Rtmp, Robj); is_fp = true; break;
115 case T_DOUBLE: __ lfdx(F1_RET, Rtmp, Robj); is_fp = true; break;
116 default: ShouldNotReachHere();
117 }
118
119 // Order preceding load(s) wrt. succeeding check (LoadStore for volatile field).
120 if (is_fp) {
121 Label next;
122 __ fcmpu(CR0, F1_RET, F1_RET);
|