author | stuefe |
Wed, 27 Mar 2019 14:13:34 +0100 | |
changeset 54437 | 2ae93028bef3 |
parent 50164 | 88bf53770be5 |
child 57570 | d7304cf430f1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
2 |
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2571
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14631
526804361522
8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
7397
diff
changeset
|
26 |
#include "asm/macroAssembler.inline.hpp" |
49898
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
27 |
#include "gc/shared/barrierSet.hpp" |
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
28 |
#include "gc/shared/barrierSetAssembler.hpp" |
7397 | 29 |
#include "memory/resourceArea.hpp" |
30 |
#include "prims/jniFastGetField.hpp" |
|
31 |
#include "prims/jvm_misc.hpp" |
|
32 |
#include "runtime/safepoint.hpp" |
|
1 | 33 |
|
34 |
// TSO ensures that loads are blocking and ordered with respect to |
|
35 |
// to earlier loads, so we don't need LoadLoad membars. |
|
36 |
||
37 |
#define __ masm-> |
|
38 |
||
39 |
#define BUFFER_SIZE 30*sizeof(jint) |
|
40 |
||
41 |
// Common register usage: |
|
42 |
// O0: env |
|
43 |
// O1: obj |
|
44 |
// O2: jfieldID |
|
45 |
// O4: offset (O2 >> 2) |
|
46 |
// G4: old safepoint counter |
|
47 |
||
48 |
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { |
|
49 |
const char *name; |
|
50 |
switch (type) { |
|
51 |
case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break; |
|
52 |
case T_BYTE: name = "jni_fast_GetByteField"; break; |
|
53 |
case T_CHAR: name = "jni_fast_GetCharField"; break; |
|
54 |
case T_SHORT: name = "jni_fast_GetShortField"; break; |
|
55 |
case T_INT: name = "jni_fast_GetIntField"; break; |
|
56 |
default: ShouldNotReachHere(); |
|
57 |
} |
|
58 |
ResourceMark rm; |
|
6418 | 59 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); |
60 |
CodeBuffer cbuf(blob); |
|
1 | 61 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 62 |
address fast_entry = __ pc(); |
1 | 63 |
|
64 |
Label label1, label2; |
|
65 |
||
2571 | 66 |
AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); |
67 |
__ sethi (cnt_addrlit, O3); |
|
68 |
Address cnt_addr(O3, cnt_addrlit.low10()); |
|
69 |
__ ld (cnt_addr, G4); |
|
1 | 70 |
__ andcc (G4, 1, G0); |
71 |
__ br (Assembler::notZero, false, Assembler::pn, label1); |
|
72 |
__ delayed()->srl (O2, 2, O4); |
|
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
73 |
__ mov(O1, O5); |
49898
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
74 |
|
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
75 |
// Both O5 and G3 are clobbered by try_resolve_jobject_in_native. |
49898
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
76 |
BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); |
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
77 |
bs->try_resolve_jobject_in_native(masm, /* jni_env */ O0, /* obj */ O5, /* tmp */ G3, label1); |
1 | 78 |
|
79 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
80 |
speculative_load_pclist[count] = __ pc(); |
|
81 |
switch (type) { |
|
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
82 |
case T_BOOLEAN: __ ldub (O5, O4, G3); break; |
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
83 |
case T_BYTE: __ ldsb (O5, O4, G3); break; |
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
84 |
case T_CHAR: __ lduh (O5, O4, G3); break; |
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
85 |
case T_SHORT: __ ldsh (O5, O4, G3); break; |
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
86 |
case T_INT: __ ld (O5, O4, G3); break; |
1 | 87 |
default: ShouldNotReachHere(); |
88 |
} |
|
89 |
||
2571 | 90 |
__ ld (cnt_addr, O5); |
1 | 91 |
__ cmp (O5, G4); |
92 |
__ br (Assembler::notEqual, false, Assembler::pn, label2); |
|
93 |
__ delayed()->mov (O7, G1); |
|
94 |
__ retl (); |
|
95 |
__ delayed()->mov (G3, O0); |
|
96 |
||
97 |
slowcase_entry_pclist[count++] = __ pc(); |
|
98 |
__ bind (label1); |
|
99 |
__ mov (O7, G1); |
|
100 |
||
101 |
address slow_case_addr; |
|
102 |
switch (type) { |
|
103 |
case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break; |
|
104 |
case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break; |
|
105 |
case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break; |
|
106 |
case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break; |
|
107 |
case T_INT: slow_case_addr = jni_GetIntField_addr(); break; |
|
108 |
default: ShouldNotReachHere(); |
|
109 |
} |
|
110 |
__ bind (label2); |
|
111 |
__ call (slow_case_addr, relocInfo::none); |
|
112 |
__ delayed()->mov (G1, O7); |
|
113 |
||
114 |
__ flush (); |
|
115 |
||
116 |
return fast_entry; |
|
117 |
} |
|
118 |
||
119 |
address JNI_FastGetField::generate_fast_get_boolean_field() { |
|
120 |
return generate_fast_get_int_field0(T_BOOLEAN); |
|
121 |
} |
|
122 |
||
123 |
address JNI_FastGetField::generate_fast_get_byte_field() { |
|
124 |
return generate_fast_get_int_field0(T_BYTE); |
|
125 |
} |
|
126 |
||
127 |
address JNI_FastGetField::generate_fast_get_char_field() { |
|
128 |
return generate_fast_get_int_field0(T_CHAR); |
|
129 |
} |
|
130 |
||
131 |
address JNI_FastGetField::generate_fast_get_short_field() { |
|
132 |
return generate_fast_get_int_field0(T_SHORT); |
|
133 |
} |
|
134 |
||
135 |
address JNI_FastGetField::generate_fast_get_int_field() { |
|
136 |
return generate_fast_get_int_field0(T_INT); |
|
137 |
} |
|
138 |
||
139 |
address JNI_FastGetField::generate_fast_get_long_field() { |
|
140 |
const char *name = "jni_fast_GetLongField"; |
|
141 |
ResourceMark rm; |
|
6418 | 142 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); |
143 |
CodeBuffer cbuf(blob); |
|
1 | 144 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 145 |
address fast_entry = __ pc(); |
1 | 146 |
|
147 |
Label label1, label2; |
|
148 |
||
2571 | 149 |
AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); |
150 |
__ sethi (cnt_addrlit, G3); |
|
151 |
Address cnt_addr(G3, cnt_addrlit.low10()); |
|
152 |
__ ld (cnt_addr, G4); |
|
1 | 153 |
__ andcc (G4, 1, G0); |
154 |
__ br (Assembler::notZero, false, Assembler::pn, label1); |
|
155 |
__ delayed()->srl (O2, 2, O4); |
|
50164
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
156 |
__ mov(O1, O5); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
157 |
|
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
158 |
// Both O5 and G1 are clobbered by try_resolve_jobject_in_native. |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
159 |
BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
160 |
bs->try_resolve_jobject_in_native(masm, /* jni_env */ O0, /* obj */ O5, /* tmp */ G1, label1); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
161 |
DEBUG_ONLY(__ set(0xDEADC0DE, G1);) |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
162 |
|
1 | 163 |
__ add (O5, O4, O5); |
164 |
||
165 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
166 |
speculative_load_pclist[count] = __ pc(); |
|
167 |
__ ldx (O5, 0, O3); |
|
168 |
||
2571 | 169 |
__ ld (cnt_addr, G1); |
1 | 170 |
__ cmp (G1, G4); |
171 |
__ br (Assembler::notEqual, false, Assembler::pn, label2); |
|
172 |
__ delayed()->mov (O7, G1); |
|
173 |
||
174 |
__ retl (); |
|
175 |
__ delayed()->mov (O3, O0); |
|
176 |
||
177 |
slowcase_entry_pclist[count++] = __ pc(); |
|
178 |
||
179 |
__ bind (label1); |
|
180 |
__ mov (O7, G1); |
|
181 |
||
182 |
address slow_case_addr = jni_GetLongField_addr(); |
|
183 |
__ bind (label2); |
|
184 |
__ call (slow_case_addr, relocInfo::none); |
|
185 |
__ delayed()->mov (G1, O7); |
|
186 |
||
187 |
__ flush (); |
|
188 |
||
189 |
return fast_entry; |
|
190 |
} |
|
191 |
||
192 |
address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) { |
|
193 |
const char *name; |
|
194 |
switch (type) { |
|
195 |
case T_FLOAT: name = "jni_fast_GetFloatField"; break; |
|
196 |
case T_DOUBLE: name = "jni_fast_GetDoubleField"; break; |
|
197 |
default: ShouldNotReachHere(); |
|
198 |
} |
|
199 |
ResourceMark rm; |
|
6418 | 200 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize); |
201 |
CodeBuffer cbuf(blob); |
|
1 | 202 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 203 |
address fast_entry = __ pc(); |
1 | 204 |
|
205 |
Label label1, label2; |
|
206 |
||
2571 | 207 |
AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr()); |
208 |
__ sethi (cnt_addrlit, O3); |
|
209 |
Address cnt_addr(O3, cnt_addrlit.low10()); |
|
210 |
__ ld (cnt_addr, G4); |
|
1 | 211 |
__ andcc (G4, 1, G0); |
212 |
__ br (Assembler::notZero, false, Assembler::pn, label1); |
|
213 |
__ delayed()->srl (O2, 2, O4); |
|
50164
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
214 |
__ mov(O1, O5); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
215 |
|
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
216 |
// Both O5 and G3 are clobbered by try_resolve_jobject_in_native. |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
217 |
BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
218 |
bs->try_resolve_jobject_in_native(masm, /* jni_env */ O0, /* obj */ O5, /* tmp */ G3, label1); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
219 |
DEBUG_ONLY(__ set(0xDEADC0DE, G3);) |
1 | 220 |
|
221 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
222 |
speculative_load_pclist[count] = __ pc(); |
|
223 |
switch (type) { |
|
224 |
case T_FLOAT: __ ldf (FloatRegisterImpl::S, O5, O4, F0); break; |
|
225 |
case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break; |
|
226 |
default: ShouldNotReachHere(); |
|
227 |
} |
|
228 |
||
2571 | 229 |
__ ld (cnt_addr, O5); |
1 | 230 |
__ cmp (O5, G4); |
231 |
__ br (Assembler::notEqual, false, Assembler::pn, label2); |
|
232 |
__ delayed()->mov (O7, G1); |
|
233 |
||
234 |
__ retl (); |
|
235 |
__ delayed()-> nop (); |
|
236 |
||
237 |
slowcase_entry_pclist[count++] = __ pc(); |
|
238 |
__ bind (label1); |
|
239 |
__ mov (O7, G1); |
|
240 |
||
241 |
address slow_case_addr; |
|
242 |
switch (type) { |
|
243 |
case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break; |
|
244 |
case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break; |
|
245 |
default: ShouldNotReachHere(); |
|
246 |
} |
|
247 |
__ bind (label2); |
|
248 |
__ call (slow_case_addr, relocInfo::none); |
|
249 |
__ delayed()->mov (G1, O7); |
|
250 |
||
251 |
__ flush (); |
|
252 |
||
253 |
return fast_entry; |
|
254 |
} |
|
255 |
||
256 |
address JNI_FastGetField::generate_fast_get_float_field() { |
|
257 |
return generate_fast_get_float_field0(T_FLOAT); |
|
258 |
} |
|
259 |
||
260 |
address JNI_FastGetField::generate_fast_get_double_field() { |
|
261 |
return generate_fast_get_float_field0(T_DOUBLE); |
|
262 |
} |