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