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