author | mgerdin |
Wed, 22 Mar 2017 15:25:21 +0100 | |
changeset 44406 | a46a6c4d1dd9 |
parent 44093 | e22e0d071bf9 |
child 46630 | 75aa3e39d02c |
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" |
7397 | 27 |
#include "memory/resourceArea.hpp" |
28 |
#include "prims/jniFastGetField.hpp" |
|
29 |
#include "prims/jvm_misc.hpp" |
|
30 |
#include "runtime/safepoint.hpp" |
|
1 | 31 |
|
32 |
#define __ masm-> |
|
33 |
||
34 |
#define BUFFER_SIZE 30*wordSize |
|
35 |
||
36 |
// Instead of issuing lfence for LoadLoad barrier, we create data dependency |
|
37 |
// between loads, which is more efficient than lfence. |
|
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 robj = r9; |
|
46 |
static const Register rcounter = r10; |
|
47 |
static const Register roffset = r11; |
|
48 |
static const Register rcounter_addr = r11; |
|
49 |
||
50 |
// Warning: do not use rip relative addressing after the first counter load |
|
51 |
// since that may scratch r10! |
|
52 |
||
53 |
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
|
54 |
const char *name = NULL; |
1 | 55 |
switch (type) { |
56 |
case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break; |
|
57 |
case T_BYTE: name = "jni_fast_GetByteField"; break; |
|
58 |
case T_CHAR: name = "jni_fast_GetCharField"; break; |
|
59 |
case T_SHORT: name = "jni_fast_GetShortField"; break; |
|
60 |
case T_INT: name = "jni_fast_GetIntField"; break; |
|
61 |
case T_LONG: name = "jni_fast_GetLongField"; break; |
|
62 |
default: ShouldNotReachHere(); |
|
63 |
} |
|
64 |
ResourceMark rm; |
|
6418 | 65 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE); |
66 |
CodeBuffer cbuf(blob); |
|
1 | 67 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 68 |
address fast_entry = __ pc(); |
1 | 69 |
|
70 |
Label slow; |
|
71 |
||
72 |
ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr()); |
|
73 |
__ mov32 (rcounter, counter); |
|
1066 | 74 |
__ mov (robj, c_rarg1); |
1 | 75 |
__ testb (rcounter, 1); |
76 |
__ jcc (Assembler::notZero, slow); |
|
77 |
if (os::is_MP()) { |
|
1066 | 78 |
__ xorptr(robj, rcounter); |
79 |
__ xorptr(robj, rcounter); // obj, since |
|
1 | 80 |
// robj ^ rcounter ^ rcounter == robj |
81 |
// robj is data dependent on rcounter. |
|
82 |
} |
|
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
83 |
|
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
84 |
__ clear_jweak_tag(robj); |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
85 |
|
1066 | 86 |
__ movptr(robj, Address(robj, 0)); // *obj |
87 |
__ mov (roffset, c_rarg2); |
|
88 |
__ shrptr(roffset, 2); // offset |
|
1 | 89 |
|
90 |
assert(count < LIST_CAPACITY, "LIST_CAPACITY too small"); |
|
91 |
speculative_load_pclist[count] = __ pc(); |
|
92 |
switch (type) { |
|
93 |
case T_BOOLEAN: __ movzbl (rax, Address(robj, roffset, Address::times_1)); break; |
|
94 |
case T_BYTE: __ movsbl (rax, Address(robj, roffset, Address::times_1)); break; |
|
95 |
case T_CHAR: __ movzwl (rax, Address(robj, roffset, Address::times_1)); break; |
|
96 |
case T_SHORT: __ movswl (rax, Address(robj, roffset, Address::times_1)); break; |
|
97 |
case T_INT: __ movl (rax, Address(robj, roffset, Address::times_1)); break; |
|
98 |
case T_LONG: __ movq (rax, Address(robj, roffset, Address::times_1)); break; |
|
99 |
default: ShouldNotReachHere(); |
|
100 |
} |
|
101 |
||
102 |
if (os::is_MP()) { |
|
103 |
__ lea(rcounter_addr, counter); |
|
104 |
// ca is data dependent on rax. |
|
1066 | 105 |
__ xorptr(rcounter_addr, rax); |
106 |
__ xorptr(rcounter_addr, rax); |
|
1 | 107 |
__ cmpl (rcounter, Address(rcounter_addr, 0)); |
108 |
} else { |
|
109 |
__ cmp32 (rcounter, counter); |
|
110 |
} |
|
111 |
__ jcc (Assembler::notEqual, slow); |
|
112 |
||
113 |
__ ret (0); |
|
114 |
||
115 |
slowcase_entry_pclist[count++] = __ pc(); |
|
116 |
__ bind (slow); |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
117 |
address slow_case_addr = NULL; |
1 | 118 |
switch (type) { |
119 |
case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break; |
|
120 |
case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break; |
|
121 |
case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break; |
|
122 |
case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break; |
|
123 |
case T_INT: slow_case_addr = jni_GetIntField_addr(); break; |
|
124 |
case T_LONG: slow_case_addr = jni_GetLongField_addr(); |
|
125 |
} |
|
126 |
// tail call |
|
127 |
__ jump (ExternalAddress(slow_case_addr)); |
|
128 |
||
129 |
__ flush (); |
|
130 |
||
131 |
return fast_entry; |
|
132 |
} |
|
133 |
||
134 |
address JNI_FastGetField::generate_fast_get_boolean_field() { |
|
135 |
return generate_fast_get_int_field0(T_BOOLEAN); |
|
136 |
} |
|
137 |
||
138 |
address JNI_FastGetField::generate_fast_get_byte_field() { |
|
139 |
return generate_fast_get_int_field0(T_BYTE); |
|
140 |
} |
|
141 |
||
142 |
address JNI_FastGetField::generate_fast_get_char_field() { |
|
143 |
return generate_fast_get_int_field0(T_CHAR); |
|
144 |
} |
|
145 |
||
146 |
address JNI_FastGetField::generate_fast_get_short_field() { |
|
147 |
return generate_fast_get_int_field0(T_SHORT); |
|
148 |
} |
|
149 |
||
150 |
address JNI_FastGetField::generate_fast_get_int_field() { |
|
151 |
return generate_fast_get_int_field0(T_INT); |
|
152 |
} |
|
153 |
||
154 |
address JNI_FastGetField::generate_fast_get_long_field() { |
|
155 |
return generate_fast_get_int_field0(T_LONG); |
|
156 |
} |
|
157 |
||
158 |
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
|
159 |
const char *name = NULL; |
1 | 160 |
switch (type) { |
161 |
case T_FLOAT: name = "jni_fast_GetFloatField"; break; |
|
162 |
case T_DOUBLE: name = "jni_fast_GetDoubleField"; break; |
|
163 |
default: ShouldNotReachHere(); |
|
164 |
} |
|
165 |
ResourceMark rm; |
|
6418 | 166 |
BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE); |
167 |
CodeBuffer cbuf(blob); |
|
1 | 168 |
MacroAssembler* masm = new MacroAssembler(&cbuf); |
6418 | 169 |
address fast_entry = __ pc(); |
1 | 170 |
|
171 |
Label slow; |
|
172 |
||
173 |
ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr()); |
|
174 |
__ mov32 (rcounter, counter); |
|
1066 | 175 |
__ mov (robj, c_rarg1); |
1 | 176 |
__ testb (rcounter, 1); |
177 |
__ jcc (Assembler::notZero, slow); |
|
178 |
if (os::is_MP()) { |
|
1066 | 179 |
__ xorptr(robj, rcounter); |
180 |
__ xorptr(robj, rcounter); // obj, since |
|
1 | 181 |
// robj ^ rcounter ^ rcounter == robj |
182 |
// robj is data dependent on rcounter. |
|
183 |
} |
|
44406
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
184 |
|
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
185 |
__ clear_jweak_tag(robj); |
a46a6c4d1dd9
8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
mgerdin
parents:
44093
diff
changeset
|
186 |
|
1066 | 187 |
__ movptr(robj, Address(robj, 0)); // *obj |
188 |
__ mov (roffset, c_rarg2); |
|
189 |
__ shrptr(roffset, 2); // offset |
|
1 | 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 |
||
199 |
if (os::is_MP()) { |
|
200 |
__ lea(rcounter_addr, counter); |
|
201 |
__ movdq (rax, xmm0); |
|
202 |
// counter address is data dependent on xmm0. |
|
1066 | 203 |
__ xorptr(rcounter_addr, rax); |
204 |
__ xorptr(rcounter_addr, rax); |
|
1 | 205 |
__ cmpl (rcounter, Address(rcounter_addr, 0)); |
206 |
} else { |
|
207 |
__ cmp32 (rcounter, counter); |
|
208 |
} |
|
209 |
__ jcc (Assembler::notEqual, slow); |
|
210 |
||
211 |
__ ret (0); |
|
212 |
||
213 |
slowcase_entry_pclist[count++] = __ pc(); |
|
214 |
__ bind (slow); |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
14626
diff
changeset
|
215 |
address slow_case_addr = NULL; |
1 | 216 |
switch (type) { |
217 |
case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break; |
|
218 |
case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); |
|
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 |
} |