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 "asm/macroAssembler.hpp"
26 #include "code/codeBlob.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 40*wordSize
38
39 // Common register usage:
40 // rax/xmm0: result
41 // c_rarg0: jni env
42 // c_rarg1: obj
43 // c_rarg2: jfield id
44
45 static const Register rtmp = rax; // r8 == c_rarg2 on Windows
46 static const Register robj = r9;
47 static const Register roffset = r10;
48 static const Register rcounter = r11;
49
50 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
51 const char *name = nullptr;
63 CodeBuffer cbuf(blob);
64 MacroAssembler* masm = new MacroAssembler(&cbuf);
65 address fast_entry = __ pc();
66
67 Label slow;
68
69 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
70 __ mov32 (rcounter, counter);
71 __ mov (robj, c_rarg1);
72 __ testb (rcounter, 1);
73 __ jcc (Assembler::notZero, slow);
74
75 if (JvmtiExport::can_post_field_access()) {
76 // Check to see if a field access watch has been set before we take the fast path.
77 assert_different_registers(rscratch1, robj, rcounter);
78 __ cmp32(ExternalAddress(JvmtiExport::get_field_access_count_addr()), 0, rscratch1);
79 __ jcc(Assembler::notZero, slow);
80 }
81
82 __ mov (roffset, c_rarg2);
83 __ shrptr(roffset, 2); // offset
84
85 // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
86 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
87 bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
88 DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
89
90 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
91 speculative_load_pclist[count] = __ pc();
92 switch (type) {
93 case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break;
94 case T_BYTE: __ movsbl (rax, Address(robj, roffset, Address::times_1)); break;
95 case T_CHAR: __ movzwl (rax, Address(robj, roffset, Address::times_1)); break;
96 case T_SHORT: __ movswl (rax, Address(robj, roffset, Address::times_1)); break;
97 case T_INT: __ movl (rax, Address(robj, roffset, Address::times_1)); break;
98 case T_LONG: __ movq (rax, Address(robj, roffset, Address::times_1)); break;
99 default: ShouldNotReachHere();
100 }
101
102 __ cmp32 (rcounter, counter, rscratch1);
103 __ jcc (Assembler::notEqual, slow);
165
166 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
167 __ mov32 (rcounter, counter);
168 __ mov (robj, c_rarg1);
169 __ testb (rcounter, 1);
170 __ jcc (Assembler::notZero, slow);
171
172 if (JvmtiExport::can_post_field_access()) {
173 // Check to see if a field access watch has been set before we
174 // take the fast path.
175 __ cmp32(ExternalAddress(JvmtiExport::get_field_access_count_addr()), 0, rscratch1);
176 __ jcc(Assembler::notZero, slow);
177 }
178
179 // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
180 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
181 bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
182 DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
183
184 __ mov (roffset, c_rarg2);
185 __ shrptr(roffset, 2); // offset
186
187 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
188 speculative_load_pclist[count] = __ pc();
189 switch (type) {
190 case T_FLOAT: __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break;
191 case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
192 default: ShouldNotReachHere();
193 }
194 __ cmp32 (rcounter, counter, rscratch1);
195 __ jcc (Assembler::notEqual, slow);
196
197 __ ret (0);
198
199 slowcase_entry_pclist[count++] = __ pc();
200 __ bind (slow);
201 address slow_case_addr = nullptr;
202 switch (type) {
203 case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break;
204 case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
205 default: break;
|
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 "asm/macroAssembler.hpp"
26 #include "code/codeBlob.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 "runtime/jfieldIDWorkaround.hpp"
33 #include "prims/jvmtiExport.hpp"
34 #include "runtime/safepoint.hpp"
35
36 #define __ masm->
37
38 #define BUFFER_SIZE 40*wordSize
39
40 // Common register usage:
41 // rax/xmm0: result
42 // c_rarg0: jni env
43 // c_rarg1: obj
44 // c_rarg2: jfield id
45
46 static const Register rtmp = rax; // r8 == c_rarg2 on Windows
47 static const Register robj = r9;
48 static const Register roffset = r10;
49 static const Register rcounter = r11;
50
51 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
52 const char *name = nullptr;
64 CodeBuffer cbuf(blob);
65 MacroAssembler* masm = new MacroAssembler(&cbuf);
66 address fast_entry = __ pc();
67
68 Label slow;
69
70 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
71 __ mov32 (rcounter, counter);
72 __ mov (robj, c_rarg1);
73 __ testb (rcounter, 1);
74 __ jcc (Assembler::notZero, slow);
75
76 if (JvmtiExport::can_post_field_access()) {
77 // Check to see if a field access watch has been set before we take the fast path.
78 assert_different_registers(rscratch1, robj, rcounter);
79 __ cmp32(ExternalAddress(JvmtiExport::get_field_access_count_addr()), 0, rscratch1);
80 __ jcc(Assembler::notZero, slow);
81 }
82
83 __ mov (roffset, c_rarg2);
84 __ shrptr(roffset, jfieldIDWorkaround::offset_shift); // offset
85
86 // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
87 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
88 bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
89 DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
90
91 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
92 speculative_load_pclist[count] = __ pc();
93 switch (type) {
94 case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break;
95 case T_BYTE: __ movsbl (rax, Address(robj, roffset, Address::times_1)); break;
96 case T_CHAR: __ movzwl (rax, Address(robj, roffset, Address::times_1)); break;
97 case T_SHORT: __ movswl (rax, Address(robj, roffset, Address::times_1)); break;
98 case T_INT: __ movl (rax, Address(robj, roffset, Address::times_1)); break;
99 case T_LONG: __ movq (rax, Address(robj, roffset, Address::times_1)); break;
100 default: ShouldNotReachHere();
101 }
102
103 __ cmp32 (rcounter, counter, rscratch1);
104 __ jcc (Assembler::notEqual, slow);
166
167 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
168 __ mov32 (rcounter, counter);
169 __ mov (robj, c_rarg1);
170 __ testb (rcounter, 1);
171 __ jcc (Assembler::notZero, slow);
172
173 if (JvmtiExport::can_post_field_access()) {
174 // Check to see if a field access watch has been set before we
175 // take the fast path.
176 __ cmp32(ExternalAddress(JvmtiExport::get_field_access_count_addr()), 0, rscratch1);
177 __ jcc(Assembler::notZero, slow);
178 }
179
180 // Both robj and rtmp are clobbered by try_resolve_jobject_in_native.
181 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
182 bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow);
183 DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);)
184
185 __ mov (roffset, c_rarg2);
186 __ shrptr(roffset, jfieldIDWorkaround::offset_shift); // offset
187
188 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
189 speculative_load_pclist[count] = __ pc();
190 switch (type) {
191 case T_FLOAT: __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break;
192 case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break;
193 default: ShouldNotReachHere();
194 }
195 __ cmp32 (rcounter, counter, rscratch1);
196 __ jcc (Assembler::notEqual, slow);
197
198 __ ret (0);
199
200 slowcase_entry_pclist[count++] = __ pc();
201 __ bind (slow);
202 address slow_case_addr = nullptr;
203 switch (type) {
204 case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break;
205 case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
206 default: break;
|