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.inline.hpp"
27 #include "memory/resourceArea.hpp"
28 #include "prims/jniFastGetField.hpp"
29 #include "prims/jvm_misc.hpp"
30 #include "runtime/safepoint.hpp"
31
32 // TSO ensures that loads are blocking and ordered with respect to
33 // to earlier loads, so we don't need LoadLoad membars.
34
35 #define __ masm->
36
37 #define BUFFER_SIZE 30*sizeof(jint)
38
39 // Common register usage:
40 // O0: env
41 // O1: obj
42 // O2: jfieldID
43 // O4: offset (O2 >> 2)
44 // G4: old safepoint counter
45
46 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
47 const char *name;
48 switch (type) {
49 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
50 case T_BYTE: name = "jni_fast_GetByteField"; break;
51 case T_CHAR: name = "jni_fast_GetCharField"; break;
52 case T_SHORT: name = "jni_fast_GetShortField"; break;
53 case T_INT: name = "jni_fast_GetIntField"; break;
54 default: ShouldNotReachHere();
55 }
56 ResourceMark rm;
57 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
58 CodeBuffer cbuf(blob);
59 MacroAssembler* masm = new MacroAssembler(&cbuf);
60 address fast_entry = __ pc();
61
62 Label label1, label2;
63
64 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
65 __ sethi (cnt_addrlit, O3);
66 Address cnt_addr(O3, cnt_addrlit.low10());
67 __ ld (cnt_addr, G4);
68 __ andcc (G4, 1, G0);
69 __ br (Assembler::notZero, false, Assembler::pn, label1);
70 __ delayed()->srl (O2, 2, O4);
71 __ ld_ptr (O1, 0, O5);
72
73 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
74 speculative_load_pclist[count] = __ pc();
75 switch (type) {
76 case T_BOOLEAN: __ ldub (O5, O4, G3); break;
77 case T_BYTE: __ ldsb (O5, O4, G3); break;
78 case T_CHAR: __ lduh (O5, O4, G3); break;
79 case T_SHORT: __ ldsh (O5, O4, G3); break;
80 case T_INT: __ ld (O5, O4, G3); break;
81 default: ShouldNotReachHere();
82 }
83
84 __ ld (cnt_addr, O5);
85 __ cmp (O5, G4);
86 __ br (Assembler::notEqual, false, Assembler::pn, label2);
87 __ delayed()->mov (O7, G1);
88 __ retl ();
89 __ delayed()->mov (G3, O0);
90
129 address JNI_FastGetField::generate_fast_get_int_field() {
130 return generate_fast_get_int_field0(T_INT);
131 }
132
133 address JNI_FastGetField::generate_fast_get_long_field() {
134 const char *name = "jni_fast_GetLongField";
135 ResourceMark rm;
136 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
137 CodeBuffer cbuf(blob);
138 MacroAssembler* masm = new MacroAssembler(&cbuf);
139 address fast_entry = __ pc();
140
141 Label label1, label2;
142
143 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
144 __ sethi (cnt_addrlit, G3);
145 Address cnt_addr(G3, cnt_addrlit.low10());
146 __ ld (cnt_addr, G4);
147 __ andcc (G4, 1, G0);
148 __ br (Assembler::notZero, false, Assembler::pn, label1);
149 __ delayed()->srl (O2, 2, O4);
150 __ ld_ptr (O1, 0, O5);
151 __ add (O5, O4, O5);
152
153 #ifndef _LP64
154 assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small");
155 speculative_load_pclist[count++] = __ pc();
156 __ ld (O5, 0, G2);
157
158 speculative_load_pclist[count] = __ pc();
159 __ ld (O5, 4, O3);
160 #else
161 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
162 speculative_load_pclist[count] = __ pc();
163 __ ldx (O5, 0, O3);
164 #endif
165
166 __ ld (cnt_addr, G1);
167 __ cmp (G1, G4);
168 __ br (Assembler::notEqual, false, Assembler::pn, label2);
169 __ delayed()->mov (O7, G1);
201 const char *name;
202 switch (type) {
203 case T_FLOAT: name = "jni_fast_GetFloatField"; break;
204 case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
205 default: ShouldNotReachHere();
206 }
207 ResourceMark rm;
208 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
209 CodeBuffer cbuf(blob);
210 MacroAssembler* masm = new MacroAssembler(&cbuf);
211 address fast_entry = __ pc();
212
213 Label label1, label2;
214
215 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
216 __ sethi (cnt_addrlit, O3);
217 Address cnt_addr(O3, cnt_addrlit.low10());
218 __ ld (cnt_addr, G4);
219 __ andcc (G4, 1, G0);
220 __ br (Assembler::notZero, false, Assembler::pn, label1);
221 __ delayed()->srl (O2, 2, O4);
222 __ ld_ptr (O1, 0, O5);
223
224 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
225 speculative_load_pclist[count] = __ pc();
226 switch (type) {
227 case T_FLOAT: __ ldf (FloatRegisterImpl::S, O5, O4, F0); break;
228 case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break;
229 default: ShouldNotReachHere();
230 }
231
232 __ ld (cnt_addr, O5);
233 __ cmp (O5, G4);
234 __ br (Assembler::notEqual, false, Assembler::pn, label2);
235 __ delayed()->mov (O7, G1);
236
237 __ retl ();
238 __ delayed()-> nop ();
239
240 slowcase_entry_pclist[count++] = __ pc();
241 __ bind (label1);
|
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.inline.hpp"
27 #include "memory/resourceArea.hpp"
28 #include "prims/jniFastGetField.hpp"
29 #include "prims/jvm_misc.hpp"
30 #include "runtime/safepoint.hpp"
31 #include "runtime/jfieldIDWorkaround.hpp"
32
33 // TSO ensures that loads are blocking and ordered with respect to
34 // to earlier loads, so we don't need LoadLoad membars.
35
36 #define __ masm->
37
38 #define BUFFER_SIZE 30*sizeof(jint)
39
40 // Common register usage:
41 // O0: env
42 // O1: obj
43 // O2: jfieldID
44 // O4: offset (O2 >> 3)
45 // G4: old safepoint counter
46
47 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
48 const char *name;
49 switch (type) {
50 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
51 case T_BYTE: name = "jni_fast_GetByteField"; break;
52 case T_CHAR: name = "jni_fast_GetCharField"; break;
53 case T_SHORT: name = "jni_fast_GetShortField"; break;
54 case T_INT: name = "jni_fast_GetIntField"; break;
55 default: ShouldNotReachHere();
56 }
57 ResourceMark rm;
58 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
59 CodeBuffer cbuf(blob);
60 MacroAssembler* masm = new MacroAssembler(&cbuf);
61 address fast_entry = __ pc();
62
63 Label label1, label2;
64
65 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
66 __ sethi (cnt_addrlit, O3);
67 Address cnt_addr(O3, cnt_addrlit.low10());
68 __ ld (cnt_addr, G4);
69 __ andcc (G4, 1, G0);
70 __ br (Assembler::notZero, false, Assembler::pn, label1);
71 __ delayed()->srl (O2, jfieldIDWorkaround::offset_shift, O4);
72 __ ld_ptr (O1, 0, O5);
73
74 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
75 speculative_load_pclist[count] = __ pc();
76 switch (type) {
77 case T_BOOLEAN: __ ldub (O5, O4, G3); break;
78 case T_BYTE: __ ldsb (O5, O4, G3); break;
79 case T_CHAR: __ lduh (O5, O4, G3); break;
80 case T_SHORT: __ ldsh (O5, O4, G3); break;
81 case T_INT: __ ld (O5, O4, G3); break;
82 default: ShouldNotReachHere();
83 }
84
85 __ ld (cnt_addr, O5);
86 __ cmp (O5, G4);
87 __ br (Assembler::notEqual, false, Assembler::pn, label2);
88 __ delayed()->mov (O7, G1);
89 __ retl ();
90 __ delayed()->mov (G3, O0);
91
130 address JNI_FastGetField::generate_fast_get_int_field() {
131 return generate_fast_get_int_field0(T_INT);
132 }
133
134 address JNI_FastGetField::generate_fast_get_long_field() {
135 const char *name = "jni_fast_GetLongField";
136 ResourceMark rm;
137 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
138 CodeBuffer cbuf(blob);
139 MacroAssembler* masm = new MacroAssembler(&cbuf);
140 address fast_entry = __ pc();
141
142 Label label1, label2;
143
144 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
145 __ sethi (cnt_addrlit, G3);
146 Address cnt_addr(G3, cnt_addrlit.low10());
147 __ ld (cnt_addr, G4);
148 __ andcc (G4, 1, G0);
149 __ br (Assembler::notZero, false, Assembler::pn, label1);
150 __ delayed()->srl (O2, jfieldIDWorkaround::offset_shift, O4);
151 __ ld_ptr (O1, 0, O5);
152 __ add (O5, O4, O5);
153
154 #ifndef _LP64
155 assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small");
156 speculative_load_pclist[count++] = __ pc();
157 __ ld (O5, 0, G2);
158
159 speculative_load_pclist[count] = __ pc();
160 __ ld (O5, 4, O3);
161 #else
162 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
163 speculative_load_pclist[count] = __ pc();
164 __ ldx (O5, 0, O3);
165 #endif
166
167 __ ld (cnt_addr, G1);
168 __ cmp (G1, G4);
169 __ br (Assembler::notEqual, false, Assembler::pn, label2);
170 __ delayed()->mov (O7, G1);
202 const char *name;
203 switch (type) {
204 case T_FLOAT: name = "jni_fast_GetFloatField"; break;
205 case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
206 default: ShouldNotReachHere();
207 }
208 ResourceMark rm;
209 BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
210 CodeBuffer cbuf(blob);
211 MacroAssembler* masm = new MacroAssembler(&cbuf);
212 address fast_entry = __ pc();
213
214 Label label1, label2;
215
216 AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
217 __ sethi (cnt_addrlit, O3);
218 Address cnt_addr(O3, cnt_addrlit.low10());
219 __ ld (cnt_addr, G4);
220 __ andcc (G4, 1, G0);
221 __ br (Assembler::notZero, false, Assembler::pn, label1);
222 __ delayed()->srl (O2, jfieldIDWorkaround::offset_shift, O4);
223 __ ld_ptr (O1, 0, O5);
224
225 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
226 speculative_load_pclist[count] = __ pc();
227 switch (type) {
228 case T_FLOAT: __ ldf (FloatRegisterImpl::S, O5, O4, F0); break;
229 case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break;
230 default: ShouldNotReachHere();
231 }
232
233 __ ld (cnt_addr, O5);
234 __ cmp (O5, G4);
235 __ br (Assembler::notEqual, false, Assembler::pn, label2);
236 __ delayed()->mov (O7, G1);
237
238 __ retl ();
239 __ delayed()-> nop ();
240
241 slowcase_entry_pclist[count++] = __ pc();
242 __ bind (label1);
|