author | dholmes |
Wed, 03 Oct 2018 03:41:57 -0400 | |
changeset 51996 | 84743156e780 |
parent 50164 | 88bf53770be5 |
child 52105 | 537dbfcef4a7 |
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:
1217
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1217
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:
1217
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
7397
diff
changeset
|
26 |
#include "asm/macroAssembler.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 |
#define __ masm-> |
|
35 |
||
36 |
#define BUFFER_SIZE 30*wordSize |
|
37 |
||
38 |
// Instead of issuing lfence for LoadLoad barrier, we create data dependency |
|
39 |
// between loads, which is more efficient than lfence. |
|
40 |
||
41 |
// Common register usage: |
|
42 |
// rax/xmm0: result |
|
43 |
// c_rarg0: jni env |
|
44 |
// c_rarg1: obj |
|
45 |
// c_rarg2: jfield id |
|
46 |
||
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
47 |
static const Register rtmp = r8; |
1 | 48 |
static const Register robj = r9; |
49 |
static const Register rcounter = r10; |
|
50 |
static const Register roffset = r11; |
|
51 |
static const Register rcounter_addr = r11; |
|
52 |
||
53 |
// Warning: do not use rip relative addressing after the first counter load |
|
54 |
// since that may scratch r10! |
|
55 |
||
56 |
address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
57 |
const char *name = NULL; |
1 | 58 |
switch (type) { |
59 |
case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break; |
|
60 |
case T_BYTE: name = "jni_fast_GetByteField"; break; |
|
61 |
case T_CHAR: name = "jni_fast_GetCharField"; break; |
|
62 |
case T_SHORT: name = "jni_fast_GetShortField"; break; |
|
63 |
case T_INT: name = "jni_fast_GetIntField"; break; |
|
64 |
case T_LONG: name = "jni_fast_GetLongField"; break; |
|
65 |
default: ShouldNotReachHere(); |
|
66 |
} |
|
67 |
ResourceMark rm; |
|
6418 | 68 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE); |
69 |
CodeBuffer cbuf(blob); |
|
1 | 70 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 71 |
address fast_entry = __ pc(); |
1 | 72 |
|
73 |
Label slow; |
|
74 |
||
75 |
ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr()); |
|
76 |
__ mov32 (rcounter, counter); |
|
1066 | 77 |
__ mov (robj, c_rarg1); |
1 | 78 |
__ testb (rcounter, 1); |
79 |
__ jcc (Assembler::notZero, slow); |
|
51996
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
80 |
|
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
81 |
__ xorptr(robj, rcounter); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
82 |
__ xorptr(robj, rcounter); // obj, since |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
83 |
// robj ^ rcounter ^ rcounter == robj |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
84 |
// robj is data dependent on rcounter. |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
85 |
|
1066 | 86 |
__ mov (roffset, c_rarg2); |
87 |
__ shrptr(roffset, 2); // offset |
|
1 | 88 |
|
49929
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
89 |
// Both robj and rtmp are clobbered by try_resolve_jobject_in_native. |
49898
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
90 |
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
|
91 |
bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow); |
f38329fe8055
8202381: (Solaris) SIGBUS in # V [libjvm.so+0xcee494] jni_GetIntField+0x224
eosterlund
parents:
49898
diff
changeset
|
92 |
DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);) |
49898
4745598b307f
8200235: Generalize jniFastGetField jobject/jweak resolve
eosterlund
parents:
47216
diff
changeset
|
93 |
|
1 | 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 |
||
51996
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
106 |
// create data dependency on rax |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
107 |
__ lea(rcounter_addr, counter); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
108 |
__ xorptr(rcounter_addr, rax); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
109 |
__ xorptr(rcounter_addr, rax); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
110 |
__ cmpl (rcounter, Address(rcounter_addr, 0)); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
111 |
|
1 | 112 |
__ jcc (Assembler::notEqual, slow); |
113 |
||
114 |
__ ret (0); |
|
115 |
||
116 |
slowcase_entry_pclist[count++] = __ pc(); |
|
117 |
__ bind (slow); |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
118 |
address slow_case_addr = NULL; |
1 | 119 |
switch (type) { |
120 |
case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break; |
|
121 |
case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break; |
|
122 |
case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break; |
|
123 |
case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break; |
|
124 |
case T_INT: slow_case_addr = jni_GetIntField_addr(); break; |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
44406
diff
changeset
|
125 |
case T_LONG: slow_case_addr = jni_GetLongField_addr(); break; |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
44406
diff
changeset
|
126 |
default: break; |
1 | 127 |
} |
128 |
// tail call |
|
129 |
__ jump (ExternalAddress(slow_case_addr)); |
|
130 |
||
131 |
__ flush (); |
|
132 |
||
133 |
return fast_entry; |
|
134 |
} |
|
135 |
||
136 |
address JNI_FastGetField::generate_fast_get_boolean_field() { |
|
137 |
return generate_fast_get_int_field0(T_BOOLEAN); |
|
138 |
} |
|
139 |
||
140 |
address JNI_FastGetField::generate_fast_get_byte_field() { |
|
141 |
return generate_fast_get_int_field0(T_BYTE); |
|
142 |
} |
|
143 |
||
144 |
address JNI_FastGetField::generate_fast_get_char_field() { |
|
145 |
return generate_fast_get_int_field0(T_CHAR); |
|
146 |
} |
|
147 |
||
148 |
address JNI_FastGetField::generate_fast_get_short_field() { |
|
149 |
return generate_fast_get_int_field0(T_SHORT); |
|
150 |
} |
|
151 |
||
152 |
address JNI_FastGetField::generate_fast_get_int_field() { |
|
153 |
return generate_fast_get_int_field0(T_INT); |
|
154 |
} |
|
155 |
||
156 |
address JNI_FastGetField::generate_fast_get_long_field() { |
|
157 |
return generate_fast_get_int_field0(T_LONG); |
|
158 |
} |
|
159 |
||
160 |
address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) { |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
161 |
const char *name = NULL; |
1 | 162 |
switch (type) { |
163 |
case T_FLOAT: name = "jni_fast_GetFloatField"; break; |
|
164 |
case T_DOUBLE: name = "jni_fast_GetDoubleField"; break; |
|
165 |
default: ShouldNotReachHere(); |
|
166 |
} |
|
167 |
ResourceMark rm; |
|
6418 | 168 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE); |
169 |
CodeBuffer cbuf(blob); |
|
1 | 170 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 171 |
address fast_entry = __ pc(); |
1 | 172 |
|
173 |
Label slow; |
|
174 |
||
175 |
ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr()); |
|
176 |
__ mov32 (rcounter, counter); |
|
1066 | 177 |
__ mov (robj, c_rarg1); |
1 | 178 |
__ testb (rcounter, 1); |
179 |
__ jcc (Assembler::notZero, slow); |
|
51996
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
180 |
|
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
181 |
__ xorptr(robj, rcounter); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
182 |
__ xorptr(robj, rcounter); // obj, since |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
183 |
// robj ^ rcounter ^ rcounter == robj |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
184 |
// robj is data dependent on rcounter. |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
185 |
|
50164
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
186 |
// Both robj and rtmp are clobbered by try_resolve_jobject_in_native. |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
187 |
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
188 |
bs->try_resolve_jobject_in_native(masm, /* jni_env */ c_rarg0, robj, rtmp, slow); |
88bf53770be5
8202479: Add missing try_resolve_jobject_in_native calls
eosterlund
parents:
49929
diff
changeset
|
189 |
DEBUG_ONLY(__ movl(rtmp, 0xDEADC0DE);) |
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
190 |
|
1066 | 191 |
__ mov (roffset, c_rarg2); |
192 |
__ shrptr(roffset, 2); // offset |
|
1 | 193 |
|
194 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
195 |
speculative_load_pclist[count] = __ pc(); |
|
196 |
switch (type) { |
|
197 |
case T_FLOAT: __ movflt (xmm0, Address(robj, roffset, Address::times_1)); break; |
|
198 |
case T_DOUBLE: __ movdbl (xmm0, Address(robj, roffset, Address::times_1)); break; |
|
199 |
default: ShouldNotReachHere(); |
|
200 |
} |
|
201 |
||
51996
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
202 |
__ lea(rcounter_addr, counter); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
203 |
__ movdq (rax, xmm0); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
204 |
// counter address is data dependent on xmm0. |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
205 |
__ xorptr(rcounter_addr, rax); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
206 |
__ xorptr(rcounter_addr, rax); |
84743156e780
8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents:
50164
diff
changeset
|
207 |
__ cmpl (rcounter, Address(rcounter_addr, 0)); |
1 | 208 |
__ jcc (Assembler::notEqual, slow); |
209 |
||
210 |
__ ret (0); |
|
211 |
||
212 |
slowcase_entry_pclist[count++] = __ pc(); |
|
213 |
__ bind (slow); |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
214 |
address slow_case_addr = NULL; |
1 | 215 |
switch (type) { |
216 |
case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break; |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
44406
diff
changeset
|
217 |
case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break; |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
44406
diff
changeset
|
218 |
default: break; |
1 | 219 |
} |
220 |
// tail call |
|
221 |
__ jump (ExternalAddress(slow_case_addr)); |
|
222 |
||
223 |
__ flush (); |
|
224 |
||
225 |
return fast_entry; |
|
226 |
} |
|
227 |
||
228 |
address JNI_FastGetField::generate_fast_get_float_field() { |
|
229 |
return generate_fast_get_float_field0(T_FLOAT); |
|
230 |
} |
|
231 |
||
232 |
address JNI_FastGetField::generate_fast_get_double_field() { |
|
233 |
return generate_fast_get_float_field0(T_DOUBLE); |
|
234 |
} |