author | jwilhelm |
Thu, 12 Sep 2019 03:21:11 +0200 | |
changeset 58094 | 0f6c749acd15 |
parent 57570 | d7304cf430f1 |
permissions | -rw-r--r-- |
42664 | 1 |
/* |
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
2 |
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. |
42664 | 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.hpp" |
|
27 |
#include "assembler_arm.inline.hpp" |
|
28 |
#include "memory/resourceArea.hpp" |
|
29 |
#include "prims/jniFastGetField.hpp" |
|
30 |
#include "prims/jvm_misc.hpp" |
|
31 |
#include "runtime/safepoint.hpp" |
|
32 |
||
33 |
#define __ masm-> |
|
34 |
||
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
35 |
#define BUFFER_SIZE 120 |
42664 | 36 |
|
37 |
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { |
|
38 |
const char* name = NULL; |
|
39 |
address slow_case_addr = NULL; |
|
40 |
switch (type) { |
|
41 |
case T_BOOLEAN: |
|
42 |
name = "jni_fast_GetBooleanField"; |
|
43 |
slow_case_addr = jni_GetBooleanField_addr(); |
|
44 |
break; |
|
45 |
case T_BYTE: |
|
46 |
name = "jni_fast_GetByteField"; |
|
47 |
slow_case_addr = jni_GetByteField_addr(); |
|
48 |
break; |
|
49 |
case T_CHAR: |
|
50 |
name = "jni_fast_GetCharField"; |
|
51 |
slow_case_addr = jni_GetCharField_addr(); |
|
52 |
break; |
|
53 |
case T_SHORT: |
|
54 |
name = "jni_fast_GetShortField"; |
|
55 |
slow_case_addr = jni_GetShortField_addr(); |
|
56 |
break; |
|
57 |
case T_INT: |
|
58 |
name = "jni_fast_GetIntField"; |
|
59 |
slow_case_addr = jni_GetIntField_addr(); |
|
60 |
break; |
|
61 |
case T_LONG: |
|
62 |
name = "jni_fast_GetLongField"; |
|
63 |
slow_case_addr = jni_GetLongField_addr(); |
|
64 |
break; |
|
65 |
case T_FLOAT: |
|
66 |
name = "jni_fast_GetFloatField"; |
|
67 |
slow_case_addr = jni_GetFloatField_addr(); |
|
68 |
break; |
|
69 |
case T_DOUBLE: |
|
70 |
name = "jni_fast_GetDoubleField"; |
|
71 |
slow_case_addr = jni_GetDoubleField_addr(); |
|
72 |
break; |
|
73 |
default: |
|
74 |
ShouldNotReachHere(); |
|
75 |
} |
|
76 |
||
77 |
// R0 - jni env |
|
78 |
// R1 - object handle |
|
79 |
// R2 - jfieldID |
|
80 |
||
52351 | 81 |
const Register Rsafepoint_counter_addr = R3; |
82 |
const Register Robj = R1; |
|
83 |
const Register Rres = R0; |
|
42664 | 84 |
const Register Rres_hi = R1; |
85 |
const Register Rsafept_cnt = Rtemp; |
|
86 |
const Register Rsafept_cnt2 = Rsafepoint_counter_addr; |
|
52351 | 87 |
const Register Rtmp1 = R3; // same as Rsafepoint_counter_addr |
88 |
const Register Rtmp2 = R2; // same as jfieldID |
|
42664 | 89 |
|
90 |
assert_different_registers(Rsafepoint_counter_addr, Rsafept_cnt, Robj, Rres, LR); |
|
91 |
assert_different_registers(Rsafept_cnt, R1, R2, Rtmp1, LR); |
|
92 |
assert_different_registers(Rsafepoint_counter_addr, Rsafept_cnt, Rres, Rres_hi, Rtmp2, LR); |
|
93 |
assert_different_registers(Rsafept_cnt2, Rsafept_cnt, Rres, Rres_hi, LR); |
|
94 |
||
95 |
address fast_entry; |
|
96 |
||
97 |
ResourceMark rm; |
|
98 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE); |
|
99 |
CodeBuffer cbuf(blob); |
|
100 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
|
101 |
fast_entry = __ pc(); |
|
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
102 |
Label slow_case; |
42664 | 103 |
|
104 |
// Safepoint check |
|
105 |
InlinedAddress safepoint_counter_addr(SafepointSynchronize::safepoint_counter_addr()); |
|
106 |
__ ldr_literal(Rsafepoint_counter_addr, safepoint_counter_addr); |
|
107 |
||
108 |
__ push(RegisterSet(R0, R3)); // save incoming arguments for slow case |
|
109 |
||
110 |
__ ldr_s32(Rsafept_cnt, Address(Rsafepoint_counter_addr)); |
|
111 |
__ tbnz(Rsafept_cnt, 0, slow_case); |
|
112 |
||
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
113 |
__ bic(R1, R1, JNIHandles::weak_tag_mask); |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
114 |
|
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
115 |
if (JvmtiExport::can_post_field_access()) { |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
116 |
// Using barrier to order wrt. JVMTI check and load of result. |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
117 |
__ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::LoadLoad), Rtmp1); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
118 |
|
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
119 |
// Check to see if a field access watch has been set before we |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
120 |
// take the fast path. |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
121 |
__ ldr_global_s32(Rtmp1, (address)JvmtiExport::get_field_access_count_addr()); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
122 |
__ cbnz(Rtmp1, slow_case); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
123 |
|
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
124 |
__ ldr(Robj, Address(R1)); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
125 |
} else { |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
126 |
// Address dependency restricts memory access ordering. It's cheaper than explicit LoadLoad barrier |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
127 |
__ andr(Rtmp1, Rsafept_cnt, (unsigned)1); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
128 |
__ ldr(Robj, Address(R1, Rtmp1)); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
129 |
} |
42664 | 130 |
|
131 |
Address field_addr; |
|
132 |
if (type != T_BOOLEAN |
|
133 |
&& type != T_INT |
|
134 |
#ifndef __ABI_HARD__ |
|
135 |
&& type != T_FLOAT |
|
136 |
#endif // !__ABI_HARD__ |
|
137 |
) { |
|
138 |
// Only ldr and ldrb support embedded shift, other loads do not |
|
139 |
__ add(Robj, Robj, AsmOperand(R2, lsr, 2)); |
|
140 |
field_addr = Address(Robj); |
|
141 |
} else { |
|
142 |
field_addr = Address(Robj, R2, lsr, 2); |
|
143 |
} |
|
144 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
145 |
speculative_load_pclist[count] = __ pc(); |
|
146 |
||
147 |
switch (type) { |
|
148 |
case T_BOOLEAN: |
|
149 |
__ ldrb(Rres, field_addr); |
|
150 |
break; |
|
151 |
case T_BYTE: |
|
152 |
__ ldrsb(Rres, field_addr); |
|
153 |
break; |
|
154 |
case T_CHAR: |
|
155 |
__ ldrh(Rres, field_addr); |
|
156 |
break; |
|
157 |
case T_SHORT: |
|
158 |
__ ldrsh(Rres, field_addr); |
|
159 |
break; |
|
160 |
case T_INT: |
|
161 |
#ifndef __ABI_HARD__ |
|
162 |
case T_FLOAT: |
|
163 |
#endif |
|
164 |
__ ldr_s32(Rres, field_addr); |
|
165 |
break; |
|
166 |
case T_LONG: |
|
167 |
#ifndef __ABI_HARD__ |
|
168 |
case T_DOUBLE: |
|
169 |
#endif |
|
170 |
// Safe to use ldrd since long and double fields are 8-byte aligned |
|
171 |
__ ldrd(Rres, field_addr); |
|
172 |
break; |
|
173 |
#ifdef __ABI_HARD__ |
|
174 |
case T_FLOAT: |
|
175 |
__ ldr_float(S0, field_addr); |
|
176 |
break; |
|
177 |
case T_DOUBLE: |
|
178 |
__ ldr_double(D0, field_addr); |
|
179 |
break; |
|
180 |
#endif // __ABI_HARD__ |
|
181 |
default: |
|
182 |
ShouldNotReachHere(); |
|
183 |
} |
|
184 |
||
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
185 |
__ ldr_literal(Rsafepoint_counter_addr, safepoint_counter_addr); |
52351 | 186 |
#ifdef __ABI_HARD__ |
51996
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
47216
diff
changeset
|
187 |
if (type == T_FLOAT || type == T_DOUBLE) { |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
47216
diff
changeset
|
188 |
__ fmrrd(Rres, Rres_hi, D0); |
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
189 |
} |
52351 | 190 |
#endif // __ABI_HARD__ |
57570
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
191 |
|
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
192 |
// Order JVMTI check and load of result wrt. succeeding check |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
193 |
// (LoadStore for volatile field). |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
194 |
__ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::LoadLoad | MacroAssembler::LoadStore), Rtmp2); |
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
195 |
|
d7304cf430f1
8227680: FastJNIAccessors: Check for JVMTI field access event requests at runtime
mdoerr
parents:
52351
diff
changeset
|
196 |
__ ldr_s32(Rsafept_cnt2, Address(Rsafepoint_counter_addr)); |
42664 | 197 |
__ cmp(Rsafept_cnt2, Rsafept_cnt); |
198 |
// discards saved R0 R1 R2 R3 |
|
199 |
__ add(SP, SP, 4 * wordSize, eq); |
|
200 |
__ bx(LR, eq); |
|
201 |
||
202 |
slowcase_entry_pclist[count++] = __ pc(); |
|
203 |
||
204 |
__ bind(slow_case); |
|
205 |
__ pop(RegisterSet(R0, R3)); |
|
206 |
// thumb mode switch handled by MacroAssembler::jump if needed |
|
207 |
__ jump(slow_case_addr, relocInfo::none, Rtemp); |
|
208 |
||
209 |
__ bind_literal(safepoint_counter_addr); |
|
210 |
||
211 |
__ flush(); |
|
212 |
||
213 |
guarantee((__ pc() - fast_entry) <= BUFFER_SIZE, "BUFFER_SIZE too small"); |
|
214 |
||
215 |
return fast_entry; |
|
216 |
} |
|
217 |
||
218 |
address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) { |
|
219 |
ShouldNotReachHere(); |
|
220 |
return NULL; |
|
221 |
} |
|
222 |
||
223 |
address JNI_FastGetField::generate_fast_get_boolean_field() { |
|
224 |
return generate_fast_get_int_field0(T_BOOLEAN); |
|
225 |
} |
|
226 |
||
227 |
address JNI_FastGetField::generate_fast_get_byte_field() { |
|
228 |
return generate_fast_get_int_field0(T_BYTE); |
|
229 |
} |
|
230 |
||
231 |
address JNI_FastGetField::generate_fast_get_char_field() { |
|
232 |
return generate_fast_get_int_field0(T_CHAR); |
|
233 |
} |
|
234 |
||
235 |
address JNI_FastGetField::generate_fast_get_short_field() { |
|
236 |
return generate_fast_get_int_field0(T_SHORT); |
|
237 |
} |
|
238 |
||
239 |
address JNI_FastGetField::generate_fast_get_int_field() { |
|
240 |
return generate_fast_get_int_field0(T_INT); |
|
241 |
} |
|
242 |
||
243 |
address JNI_FastGetField::generate_fast_get_long_field() { |
|
244 |
return generate_fast_get_int_field0(T_LONG); |
|
245 |
} |
|
246 |
||
247 |
address JNI_FastGetField::generate_fast_get_float_field() { |
|
248 |
return generate_fast_get_int_field0(T_FLOAT); |
|
249 |
} |
|
250 |
||
251 |
address JNI_FastGetField::generate_fast_get_double_field() { |
|
252 |
return generate_fast_get_int_field0(T_DOUBLE); |
|
253 |
} |