annotate src/cpu/x86/vm/jniFastGetField_x86_32.cpp @ 71:3d62cb85208d

6662967: Optimize I2D conversion on new x86 Summary: Use CVTDQ2PS and CVTDQ2PD for integer values conversions to float and double values on new AMD cpu. Reviewed-by: sgoldman, never
author kvn
date Wed, 19 Mar 2008 15:33:25 -0700
parents a61af66fc99e
children dc7f315e41f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_jniFastGetField_x86_32.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #define __ masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #define BUFFER_SIZE 30
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #ifdef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
33 GetBooleanField_t JNI_FastGetField::jni_fast_GetBooleanField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 GetByteField_t JNI_FastGetField::jni_fast_GetByteField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 GetCharField_t JNI_FastGetField::jni_fast_GetCharField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 GetShortField_t JNI_FastGetField::jni_fast_GetShortField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 GetIntField_t JNI_FastGetField::jni_fast_GetIntField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 GetLongField_t JNI_FastGetField::jni_fast_GetLongField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 GetFloatField_t JNI_FastGetField::jni_fast_GetFloatField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 GetDoubleField_t JNI_FastGetField::jni_fast_GetDoubleField_fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Instead of issuing lfence for LoadLoad barrier, we create data dependency
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // between loads, which is much more efficient than lfence.
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 const char *name;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 case T_BOOLEAN: name = "jni_fast_GetBooleanField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 case T_BYTE: name = "jni_fast_GetByteField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 case T_CHAR: name = "jni_fast_GetCharField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 case T_SHORT: name = "jni_fast_GetShortField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 case T_INT: name = "jni_fast_GetIntField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 address fast_entry = b->instructions_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 CodeBuffer cbuf(fast_entry, b->instructions_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
60 MacroAssembler* masm = new MacroAssembler(&cbuf);
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 Label slow;
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // stack layout: offset from rsp (in words):
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // return pc 0
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // jni env 1
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // obj 2
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // jfieldID 3
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
71 __ mov32 (rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 __ testb (rcx, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 __ jcc (Assembler::notZero, slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 __ movl (rax, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 __ andl (rax, 1); // rax, must end up 0
a61af66fc99e Initial load
duke
parents:
diff changeset
77 __ movl (rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // obj, notice rax, is 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // rdx is data dependent on rcx.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 __ movl (rdx, Address(rsp, 2*wordSize)); // obj
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 __ movl (rax, Address(rsp, 3*wordSize)); // jfieldID
a61af66fc99e Initial load
duke
parents:
diff changeset
84 __ movl (rdx, Address(rdx, 0)); // *obj
a61af66fc99e Initial load
duke
parents:
diff changeset
85 __ shrl (rax, 2); // offset
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 speculative_load_pclist[count] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case T_BOOLEAN: __ movzxb (rax, Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 case T_BYTE: __ movsxb (rax, Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 case T_CHAR: __ movzxw (rax, Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 case T_SHORT: __ movsxw (rax, Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 case T_INT: __ movl (rax, Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Address ca1;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 __ lea(rdx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 __ xorl(rdx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 __ xorl(rdx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 __ cmp32(rcx, Address(rdx, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // ca1 is the same as ca because
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // rax, ^ counter_addr ^ rax, = address
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // ca1 is data dependent on rax,.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 __ cmp32(rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 __ jcc (Assembler::notEqual, slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
113 __ ret (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // __stdcall calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
116 __ ret (3*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 slowcase_entry_pclist[count++] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 __ bind (slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 address slow_case_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 case T_BYTE: slow_case_addr = jni_GetByteField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 case T_CHAR: slow_case_addr = jni_GetCharField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 case T_SHORT: slow_case_addr = jni_GetShortField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 case T_INT: slow_case_addr = jni_GetIntField_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // tail call
a61af66fc99e Initial load
duke
parents:
diff changeset
130 __ jump (ExternalAddress(slow_case_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 __ flush ();
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
137 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 case T_BOOLEAN: jni_fast_GetBooleanField_fp = (GetBooleanField_t)fast_entry; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 case T_BYTE: jni_fast_GetByteField_fp = (GetByteField_t)fast_entry; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 case T_CHAR: jni_fast_GetCharField_fp = (GetCharField_t)fast_entry; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 case T_SHORT: jni_fast_GetShortField_fp = (GetShortField_t)fast_entry; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 case T_INT: jni_fast_GetIntField_fp = (GetIntField_t)fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return os::win32::fast_jni_accessor_wrapper(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 address JNI_FastGetField::generate_fast_get_boolean_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return generate_fast_get_int_field0(T_BOOLEAN);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 address JNI_FastGetField::generate_fast_get_byte_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return generate_fast_get_int_field0(T_BYTE);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 address JNI_FastGetField::generate_fast_get_char_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return generate_fast_get_int_field0(T_CHAR);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 address JNI_FastGetField::generate_fast_get_short_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return generate_fast_get_int_field0(T_SHORT);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 address JNI_FastGetField::generate_fast_get_int_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return generate_fast_get_int_field0(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 address JNI_FastGetField::generate_fast_get_long_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 const char *name = "jni_fast_GetLongField";
a61af66fc99e Initial load
duke
parents:
diff changeset
170 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 address fast_entry = b->instructions_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 CodeBuffer cbuf(fast_entry, b->instructions_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
174 MacroAssembler* masm = new MacroAssembler(&cbuf);
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Label slow;
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // stack layout: offset from rsp (in words):
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // old rsi 0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // return pc 1
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // jni env 2
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // obj 3
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // jfieldID 4
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 __ pushl (rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 __ mov32 (rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 __ testb (rcx, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 __ jcc (Assembler::notZero, slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 __ movl (rax, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 __ andl (rax, 1); // rax, must end up 0
a61af66fc99e Initial load
duke
parents:
diff changeset
194 __ movl (rdx, Address(rsp, rax, Address::times_1, 3*wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // obj, notice rax, is 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // rdx is data dependent on rcx.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 __ movl (rdx, Address(rsp, 3*wordSize)); // obj
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 __ movl (rsi, Address(rsp, 4*wordSize)); // jfieldID
a61af66fc99e Initial load
duke
parents:
diff changeset
201 __ movl (rdx, Address(rdx, 0)); // *obj
a61af66fc99e Initial load
duke
parents:
diff changeset
202 __ shrl (rsi, 2); // offset
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert(count < LIST_CAPACITY-1, "LIST_CAPACITY too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 speculative_load_pclist[count++] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 __ movl (rax, Address(rdx, rsi, Address::times_1));
a61af66fc99e Initial load
duke
parents:
diff changeset
207 speculative_load_pclist[count] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 __ movl (rdx, Address(rdx, rsi, Address::times_1, 4));
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 __ lea (rsi, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 __ xorl (rsi, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 __ xorl (rsi, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 __ xorl (rsi, rdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 __ xorl (rsi, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 __ cmp32(rcx, Address(rsi, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // ca1 is the same as ca because
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // rax, ^ rdx ^ counter_addr ^ rax, ^ rdx = address
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // ca1 is data dependent on both rax, and rdx.
a61af66fc99e Initial load
duke
parents:
diff changeset
220 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 __ cmp32(rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 __ jcc (Assembler::notEqual, slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 __ popl (rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
228 __ ret (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // __stdcall calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
231 __ ret (3*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 slowcase_entry_pclist[count-1] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 slowcase_entry_pclist[count++] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
236 __ bind (slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 __ popl (rsi);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 address slow_case_addr = jni_GetLongField_addr();;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // tail call
a61af66fc99e Initial load
duke
parents:
diff changeset
240 __ jump (ExternalAddress(slow_case_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 __ flush ();
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
247 jni_fast_GetLongField_fp = (GetLongField_t)fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return os::win32::fast_jni_accessor_wrapper(T_LONG);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 const char *name;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 case T_FLOAT: name = "jni_fast_GetFloatField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 BufferBlob* b = BufferBlob::create(name, BUFFER_SIZE*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 address fast_entry = b->instructions_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
262 CodeBuffer cbuf(fast_entry, b->instructions_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
263 MacroAssembler* masm = new MacroAssembler(&cbuf);
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 Label slow_with_pop, slow;
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // stack layout: offset from rsp (in words):
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // return pc 0
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // jni env 1
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // obj 2
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // jfieldID 3
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 ExternalAddress counter(SafepointSynchronize::safepoint_counter_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 __ mov32 (rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 __ testb (rcx, 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 __ jcc (Assembler::notZero, slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 __ movl (rax, rcx);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 __ andl (rax, 1); // rax, must end up 0
a61af66fc99e Initial load
duke
parents:
diff changeset
281 __ movl (rdx, Address(rsp, rax, Address::times_1, 2*wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // obj, notice rax, is 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // rdx is data dependent on rcx.
a61af66fc99e Initial load
duke
parents:
diff changeset
284 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 __ movl (rdx, Address(rsp, 2*wordSize)); // obj
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 __ movl (rax, Address(rsp, 3*wordSize)); // jfieldID
a61af66fc99e Initial load
duke
parents:
diff changeset
288 __ movl (rdx, Address(rdx, 0)); // *obj
a61af66fc99e Initial load
duke
parents:
diff changeset
289 __ shrl (rax, 2); // offset
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
292 speculative_load_pclist[count] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 case T_FLOAT: __ fld_s (Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 case T_DOUBLE: __ fld_d (Address(rdx, rax, Address::times_1)); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 Address ca1;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 __ fst_s (Address(rsp, -4));
a61af66fc99e Initial load
duke
parents:
diff changeset
302 __ lea(rdx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 __ movl (rax, Address(rsp, -4));
a61af66fc99e Initial load
duke
parents:
diff changeset
304 __ xorl(rdx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 __ xorl(rdx, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 __ cmp32(rcx, Address(rdx, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // rax, ^ counter_addr ^ rax, = address
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // ca1 is data dependent on the field
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // access.
a61af66fc99e Initial load
duke
parents:
diff changeset
310 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 __ cmp32(rcx, counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 __ jcc (Assembler::notEqual, slow_with_pop);
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
316 __ ret (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // __stdcall calling convention
a61af66fc99e Initial load
duke
parents:
diff changeset
319 __ ret (3*wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 __ bind (slow_with_pop);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // invalid load. pop FPU stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 __ fstp_d (0);
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 slowcase_entry_pclist[count++] = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 __ bind (slow);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 address slow_case_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
329 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 case T_FLOAT: slow_case_addr = jni_GetFloatField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
331 case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
332 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // tail call
a61af66fc99e Initial load
duke
parents:
diff changeset
335 __ jump (ExternalAddress(slow_case_addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 __ flush ();
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
340 return fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
342 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
343 case T_FLOAT: jni_fast_GetFloatField_fp = (GetFloatField_t)fast_entry; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 case T_DOUBLE: jni_fast_GetDoubleField_fp = (GetDoubleField_t)fast_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 return os::win32::fast_jni_accessor_wrapper(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 address JNI_FastGetField::generate_fast_get_float_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return generate_fast_get_float_field0(T_FLOAT);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 address JNI_FastGetField::generate_fast_get_double_field() {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return generate_fast_get_float_field0(T_DOUBLE);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }