Mercurial > hg > graal-jvmci-8
annotate src/cpu/x86/vm/stubGenerator_x86_32.cpp @ 2245:638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
Reviewed-by: kvn, never
author | twisti |
---|---|
date | Tue, 01 Feb 2011 03:38:44 -0800 |
parents | f95d63e2154a |
children | d89a22843c62 |
rev | line source |
---|---|
0 | 1 /* |
2245
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | |
27 #include "assembler_x86.inline.hpp" | |
28 #include "interpreter/interpreter.hpp" | |
29 #include "nativeInst_x86.hpp" | |
30 #include "oops/instanceOop.hpp" | |
31 #include "oops/methodOop.hpp" | |
32 #include "oops/objArrayKlass.hpp" | |
33 #include "oops/oop.inline.hpp" | |
34 #include "prims/methodHandles.hpp" | |
35 #include "runtime/frame.inline.hpp" | |
36 #include "runtime/handles.inline.hpp" | |
37 #include "runtime/sharedRuntime.hpp" | |
38 #include "runtime/stubCodeGenerator.hpp" | |
39 #include "runtime/stubRoutines.hpp" | |
40 #include "utilities/top.hpp" | |
41 #ifdef TARGET_OS_FAMILY_linux | |
42 # include "thread_linux.inline.hpp" | |
43 #endif | |
44 #ifdef TARGET_OS_FAMILY_solaris | |
45 # include "thread_solaris.inline.hpp" | |
46 #endif | |
47 #ifdef TARGET_OS_FAMILY_windows | |
48 # include "thread_windows.inline.hpp" | |
49 #endif | |
50 #ifdef COMPILER2 | |
51 #include "opto/runtime.hpp" | |
52 #endif | |
0 | 53 |
54 // Declaration and definition of StubGenerator (no .hpp file). | |
55 // For a more detailed description of the stub routine structure | |
56 // see the comment in stubRoutines.hpp | |
57 | |
58 #define __ _masm-> | |
304 | 59 #define a__ ((Assembler*)_masm)-> |
0 | 60 |
61 #ifdef PRODUCT | |
62 #define BLOCK_COMMENT(str) /* nothing */ | |
63 #else | |
64 #define BLOCK_COMMENT(str) __ block_comment(str) | |
65 #endif | |
66 | |
67 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") | |
68 | |
69 const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions | |
70 const int FPU_CNTRL_WRD_MASK = 0xFFFF; | |
71 | |
72 // ------------------------------------------------------------------------------------------------------------------------- | |
73 // Stub Code definitions | |
74 | |
75 static address handle_unsafe_access() { | |
76 JavaThread* thread = JavaThread::current(); | |
77 address pc = thread->saved_exception_pc(); | |
78 // pc is the instruction which we must emulate | |
79 // doing a no-op is fine: return garbage from the load | |
80 // therefore, compute npc | |
81 address npc = Assembler::locate_next_instruction(pc); | |
82 | |
83 // request an async exception | |
84 thread->set_pending_unsafe_access_error(); | |
85 | |
86 // return address of next instruction to execute | |
87 return npc; | |
88 } | |
89 | |
90 class StubGenerator: public StubCodeGenerator { | |
91 private: | |
92 | |
93 #ifdef PRODUCT | |
94 #define inc_counter_np(counter) (0) | |
95 #else | |
96 void inc_counter_np_(int& counter) { | |
304 | 97 __ incrementl(ExternalAddress((address)&counter)); |
0 | 98 } |
99 #define inc_counter_np(counter) \ | |
100 BLOCK_COMMENT("inc_counter " #counter); \ | |
101 inc_counter_np_(counter); | |
102 #endif //PRODUCT | |
103 | |
104 void inc_copy_counter_np(BasicType t) { | |
105 #ifndef PRODUCT | |
106 switch (t) { | |
107 case T_BYTE: inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); return; | |
108 case T_SHORT: inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); return; | |
109 case T_INT: inc_counter_np(SharedRuntime::_jint_array_copy_ctr); return; | |
110 case T_LONG: inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); return; | |
111 case T_OBJECT: inc_counter_np(SharedRuntime::_oop_array_copy_ctr); return; | |
112 } | |
113 ShouldNotReachHere(); | |
114 #endif //PRODUCT | |
115 } | |
116 | |
117 //------------------------------------------------------------------------------------------------------------------------ | |
118 // Call stubs are used to call Java from C | |
119 // | |
120 // [ return_from_Java ] <--- rsp | |
121 // [ argument word n ] | |
122 // ... | |
123 // -N [ argument word 1 ] | |
124 // -7 [ Possible padding for stack alignment ] | |
125 // -6 [ Possible padding for stack alignment ] | |
126 // -5 [ Possible padding for stack alignment ] | |
127 // -4 [ mxcsr save ] <--- rsp_after_call | |
128 // -3 [ saved rbx, ] | |
129 // -2 [ saved rsi ] | |
130 // -1 [ saved rdi ] | |
131 // 0 [ saved rbp, ] <--- rbp, | |
132 // 1 [ return address ] | |
133 // 2 [ ptr. to call wrapper ] | |
134 // 3 [ result ] | |
135 // 4 [ result_type ] | |
136 // 5 [ method ] | |
137 // 6 [ entry_point ] | |
138 // 7 [ parameters ] | |
139 // 8 [ parameter_size ] | |
140 // 9 [ thread ] | |
141 | |
142 | |
143 address generate_call_stub(address& return_address) { | |
144 StubCodeMark mark(this, "StubRoutines", "call_stub"); | |
145 address start = __ pc(); | |
146 | |
147 // stub code parameters / addresses | |
148 assert(frame::entry_frame_call_wrapper_offset == 2, "adjust this code"); | |
149 bool sse_save = false; | |
150 const Address rsp_after_call(rbp, -4 * wordSize); // same as in generate_catch_exception()! | |
151 const int locals_count_in_bytes (4*wordSize); | |
152 const Address mxcsr_save (rbp, -4 * wordSize); | |
153 const Address saved_rbx (rbp, -3 * wordSize); | |
154 const Address saved_rsi (rbp, -2 * wordSize); | |
155 const Address saved_rdi (rbp, -1 * wordSize); | |
156 const Address result (rbp, 3 * wordSize); | |
157 const Address result_type (rbp, 4 * wordSize); | |
158 const Address method (rbp, 5 * wordSize); | |
159 const Address entry_point (rbp, 6 * wordSize); | |
160 const Address parameters (rbp, 7 * wordSize); | |
161 const Address parameter_size(rbp, 8 * wordSize); | |
162 const Address thread (rbp, 9 * wordSize); // same as in generate_catch_exception()! | |
163 sse_save = UseSSE > 0; | |
164 | |
165 // stub code | |
166 __ enter(); | |
304 | 167 __ movptr(rcx, parameter_size); // parameter counter |
1506 | 168 __ shlptr(rcx, Interpreter::logStackElementSize); // convert parameter count to bytes |
304 | 169 __ addptr(rcx, locals_count_in_bytes); // reserve space for register saves |
170 __ subptr(rsp, rcx); | |
171 __ andptr(rsp, -(StackAlignmentInBytes)); // Align stack | |
0 | 172 |
173 // save rdi, rsi, & rbx, according to C calling conventions | |
304 | 174 __ movptr(saved_rdi, rdi); |
175 __ movptr(saved_rsi, rsi); | |
176 __ movptr(saved_rbx, rbx); | |
0 | 177 // save and initialize %mxcsr |
178 if (sse_save) { | |
179 Label skip_ldmx; | |
180 __ stmxcsr(mxcsr_save); | |
181 __ movl(rax, mxcsr_save); | |
182 __ andl(rax, MXCSR_MASK); // Only check control and mask bits | |
183 ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std()); | |
184 __ cmp32(rax, mxcsr_std); | |
185 __ jcc(Assembler::equal, skip_ldmx); | |
186 __ ldmxcsr(mxcsr_std); | |
187 __ bind(skip_ldmx); | |
188 } | |
189 | |
190 // make sure the control word is correct. | |
191 __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); | |
192 | |
193 #ifdef ASSERT | |
194 // make sure we have no pending exceptions | |
195 { Label L; | |
304 | 196 __ movptr(rcx, thread); |
197 __ cmpptr(Address(rcx, Thread::pending_exception_offset()), (int32_t)NULL_WORD); | |
0 | 198 __ jcc(Assembler::equal, L); |
199 __ stop("StubRoutines::call_stub: entered with pending exception"); | |
200 __ bind(L); | |
201 } | |
202 #endif | |
203 | |
204 // pass parameters if any | |
205 BLOCK_COMMENT("pass parameters if any"); | |
206 Label parameters_done; | |
207 __ movl(rcx, parameter_size); // parameter counter | |
208 __ testl(rcx, rcx); | |
209 __ jcc(Assembler::zero, parameters_done); | |
210 | |
211 // parameter passing loop | |
212 | |
213 Label loop; | |
214 // Copy Java parameters in reverse order (receiver last) | |
215 // Note that the argument order is inverted in the process | |
216 // source is rdx[rcx: N-1..0] | |
217 // dest is rsp[rbx: 0..N-1] | |
218 | |
304 | 219 __ movptr(rdx, parameters); // parameter pointer |
220 __ xorptr(rbx, rbx); | |
0 | 221 |
222 __ BIND(loop); | |
223 | |
224 // get parameter | |
304 | 225 __ movptr(rax, Address(rdx, rcx, Interpreter::stackElementScale(), -wordSize)); |
226 __ movptr(Address(rsp, rbx, Interpreter::stackElementScale(), | |
0 | 227 Interpreter::expr_offset_in_bytes(0)), rax); // store parameter |
228 __ increment(rbx); | |
229 __ decrement(rcx); | |
230 __ jcc(Assembler::notZero, loop); | |
231 | |
232 // call Java function | |
233 __ BIND(parameters_done); | |
304 | 234 __ movptr(rbx, method); // get methodOop |
235 __ movptr(rax, entry_point); // get entry_point | |
236 __ mov(rsi, rsp); // set sender sp | |
0 | 237 BLOCK_COMMENT("call Java function"); |
238 __ call(rax); | |
239 | |
240 BLOCK_COMMENT("call_stub_return_address:"); | |
241 return_address = __ pc(); | |
242 | |
2245
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
243 #ifdef COMPILER2 |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
244 { |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
245 Label L_skip; |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
246 if (UseSSE >= 2) { |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
247 __ verify_FPU(0, "call_stub_return"); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
248 } else { |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
249 for (int i = 1; i < 8; i++) { |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
250 __ ffree(i); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
251 } |
0 | 252 |
2245
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
253 // UseSSE <= 1 so double result should be left on TOS |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
254 __ movl(rsi, result_type); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
255 __ cmpl(rsi, T_DOUBLE); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
256 __ jcc(Assembler::equal, L_skip); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
257 if (UseSSE == 0) { |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
258 // UseSSE == 0 so float result should be left on TOS |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
259 __ cmpl(rsi, T_FLOAT); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
260 __ jcc(Assembler::equal, L_skip); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
261 } |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
262 __ ffree(0); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
263 } |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
264 __ BIND(L_skip); |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
265 } |
638119ce7cfd
7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents:
1972
diff
changeset
|
266 #endif // COMPILER2 |
0 | 267 |
268 // store result depending on type | |
269 // (everything that is not T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT) | |
304 | 270 __ movptr(rdi, result); |
0 | 271 Label is_long, is_float, is_double, exit; |
272 __ movl(rsi, result_type); | |
273 __ cmpl(rsi, T_LONG); | |
274 __ jcc(Assembler::equal, is_long); | |
275 __ cmpl(rsi, T_FLOAT); | |
276 __ jcc(Assembler::equal, is_float); | |
277 __ cmpl(rsi, T_DOUBLE); | |
278 __ jcc(Assembler::equal, is_double); | |
279 | |
280 // handle T_INT case | |
281 __ movl(Address(rdi, 0), rax); | |
282 __ BIND(exit); | |
283 | |
284 // check that FPU stack is empty | |
285 __ verify_FPU(0, "generate_call_stub"); | |
286 | |
287 // pop parameters | |
304 | 288 __ lea(rsp, rsp_after_call); |
0 | 289 |
290 // restore %mxcsr | |
291 if (sse_save) { | |
292 __ ldmxcsr(mxcsr_save); | |
293 } | |
294 | |
295 // restore rdi, rsi and rbx, | |
304 | 296 __ movptr(rbx, saved_rbx); |
297 __ movptr(rsi, saved_rsi); | |
298 __ movptr(rdi, saved_rdi); | |
299 __ addptr(rsp, 4*wordSize); | |
0 | 300 |
301 // return | |
304 | 302 __ pop(rbp); |
0 | 303 __ ret(0); |
304 | |
305 // handle return types different from T_INT | |
306 __ BIND(is_long); | |
307 __ movl(Address(rdi, 0 * wordSize), rax); | |
308 __ movl(Address(rdi, 1 * wordSize), rdx); | |
309 __ jmp(exit); | |
310 | |
311 __ BIND(is_float); | |
312 // interpreter uses xmm0 for return values | |
313 if (UseSSE >= 1) { | |
314 __ movflt(Address(rdi, 0), xmm0); | |
315 } else { | |
316 __ fstp_s(Address(rdi, 0)); | |
317 } | |
318 __ jmp(exit); | |
319 | |
320 __ BIND(is_double); | |
321 // interpreter uses xmm0 for return values | |
322 if (UseSSE >= 2) { | |
323 __ movdbl(Address(rdi, 0), xmm0); | |
324 } else { | |
325 __ fstp_d(Address(rdi, 0)); | |
326 } | |
327 __ jmp(exit); | |
328 | |
329 return start; | |
330 } | |
331 | |
332 | |
333 //------------------------------------------------------------------------------------------------------------------------ | |
334 // Return point for a Java call if there's an exception thrown in Java code. | |
335 // The exception is caught and transformed into a pending exception stored in | |
336 // JavaThread that can be tested from within the VM. | |
337 // | |
338 // Note: Usually the parameters are removed by the callee. In case of an exception | |
339 // crossing an activation frame boundary, that is not the case if the callee | |
340 // is compiled code => need to setup the rsp. | |
341 // | |
342 // rax,: exception oop | |
343 | |
344 address generate_catch_exception() { | |
345 StubCodeMark mark(this, "StubRoutines", "catch_exception"); | |
346 const Address rsp_after_call(rbp, -4 * wordSize); // same as in generate_call_stub()! | |
347 const Address thread (rbp, 9 * wordSize); // same as in generate_call_stub()! | |
348 address start = __ pc(); | |
349 | |
350 // get thread directly | |
304 | 351 __ movptr(rcx, thread); |
0 | 352 #ifdef ASSERT |
353 // verify that threads correspond | |
354 { Label L; | |
355 __ get_thread(rbx); | |
304 | 356 __ cmpptr(rbx, rcx); |
0 | 357 __ jcc(Assembler::equal, L); |
358 __ stop("StubRoutines::catch_exception: threads must correspond"); | |
359 __ bind(L); | |
360 } | |
361 #endif | |
362 // set pending exception | |
363 __ verify_oop(rax); | |
304 | 364 __ movptr(Address(rcx, Thread::pending_exception_offset()), rax ); |
0 | 365 __ lea(Address(rcx, Thread::exception_file_offset ()), |
366 ExternalAddress((address)__FILE__)); | |
367 __ movl(Address(rcx, Thread::exception_line_offset ()), __LINE__ ); | |
368 // complete return to VM | |
369 assert(StubRoutines::_call_stub_return_address != NULL, "_call_stub_return_address must have been generated before"); | |
370 __ jump(RuntimeAddress(StubRoutines::_call_stub_return_address)); | |
371 | |
372 return start; | |
373 } | |
374 | |
375 | |
376 //------------------------------------------------------------------------------------------------------------------------ | |
377 // Continuation point for runtime calls returning with a pending exception. | |
378 // The pending exception check happened in the runtime or native call stub. | |
379 // The pending exception in Thread is converted into a Java-level exception. | |
380 // | |
381 // Contract with Java-level exception handlers: | |
1295 | 382 // rax: exception |
0 | 383 // rdx: throwing pc |
384 // | |
385 // NOTE: At entry of this stub, exception-pc must be on stack !! | |
386 | |
387 address generate_forward_exception() { | |
388 StubCodeMark mark(this, "StubRoutines", "forward exception"); | |
389 address start = __ pc(); | |
1295 | 390 const Register thread = rcx; |
391 | |
392 // other registers used in this stub | |
393 const Register exception_oop = rax; | |
394 const Register handler_addr = rbx; | |
395 const Register exception_pc = rdx; | |
0 | 396 |
397 // Upon entry, the sp points to the return address returning into Java | |
398 // (interpreted or compiled) code; i.e., the return address becomes the | |
399 // throwing pc. | |
400 // | |
401 // Arguments pushed before the runtime call are still on the stack but | |
402 // the exception handler will reset the stack pointer -> ignore them. | |
403 // A potential result in registers can be ignored as well. | |
404 | |
405 #ifdef ASSERT | |
406 // make sure this code is only executed if there is a pending exception | |
407 { Label L; | |
1295 | 408 __ get_thread(thread); |
409 __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); | |
0 | 410 __ jcc(Assembler::notEqual, L); |
411 __ stop("StubRoutines::forward exception: no pending exception (1)"); | |
412 __ bind(L); | |
413 } | |
414 #endif | |
415 | |
416 // compute exception handler into rbx, | |
1295 | 417 __ get_thread(thread); |
418 __ movptr(exception_pc, Address(rsp, 0)); | |
0 | 419 BLOCK_COMMENT("call exception_handler_for_return_address"); |
1295 | 420 __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, exception_pc); |
421 __ mov(handler_addr, rax); | |
0 | 422 |
1295 | 423 // setup rax & rdx, remove return address & clear pending exception |
424 __ get_thread(thread); | |
425 __ pop(exception_pc); | |
426 __ movptr(exception_oop, Address(thread, Thread::pending_exception_offset())); | |
427 __ movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD); | |
0 | 428 |
429 #ifdef ASSERT | |
430 // make sure exception is set | |
431 { Label L; | |
1295 | 432 __ testptr(exception_oop, exception_oop); |
0 | 433 __ jcc(Assembler::notEqual, L); |
434 __ stop("StubRoutines::forward exception: no pending exception (2)"); | |
435 __ bind(L); | |
436 } | |
437 #endif | |
438 | |
1295 | 439 // Verify that there is really a valid exception in RAX. |
440 __ verify_oop(exception_oop); | |
441 | |
442 // Restore SP from BP if the exception PC is a MethodHandle call site. | |
1368
93767e6a2dfd
6941529: SharedRuntime::raw_exception_handler_for_return_address must reset thread MethodHandle flag
twisti
parents:
1365
diff
changeset
|
443 __ cmpl(Address(thread, JavaThread::is_method_handle_return_offset()), 0); |
1295 | 444 __ cmovptr(Assembler::notEqual, rsp, rbp); |
445 | |
0 | 446 // continue at exception handler (return address removed) |
1295 | 447 // rax: exception |
448 // rbx: exception handler | |
0 | 449 // rdx: throwing pc |
1295 | 450 __ jmp(handler_addr); |
0 | 451 |
452 return start; | |
453 } | |
454 | |
455 | |
456 //---------------------------------------------------------------------------------------------------- | |
457 // Support for jint Atomic::xchg(jint exchange_value, volatile jint* dest) | |
458 // | |
459 // xchg exists as far back as 8086, lock needed for MP only | |
460 // Stack layout immediately after call: | |
461 // | |
462 // 0 [ret addr ] <--- rsp | |
463 // 1 [ ex ] | |
464 // 2 [ dest ] | |
465 // | |
466 // Result: *dest <- ex, return (old *dest) | |
467 // | |
468 // Note: win32 does not currently use this code | |
469 | |
470 address generate_atomic_xchg() { | |
471 StubCodeMark mark(this, "StubRoutines", "atomic_xchg"); | |
472 address start = __ pc(); | |
473 | |
304 | 474 __ push(rdx); |
0 | 475 Address exchange(rsp, 2 * wordSize); |
476 Address dest_addr(rsp, 3 * wordSize); | |
477 __ movl(rax, exchange); | |
304 | 478 __ movptr(rdx, dest_addr); |
479 __ xchgl(rax, Address(rdx, 0)); | |
480 __ pop(rdx); | |
0 | 481 __ ret(0); |
482 | |
483 return start; | |
484 } | |
485 | |
486 //---------------------------------------------------------------------------------------------------- | |
487 // Support for void verify_mxcsr() | |
488 // | |
489 // This routine is used with -Xcheck:jni to verify that native | |
490 // JNI code does not return to Java code without restoring the | |
491 // MXCSR register to our expected state. | |
492 | |
493 | |
494 address generate_verify_mxcsr() { | |
495 StubCodeMark mark(this, "StubRoutines", "verify_mxcsr"); | |
496 address start = __ pc(); | |
497 | |
498 const Address mxcsr_save(rsp, 0); | |
499 | |
500 if (CheckJNICalls && UseSSE > 0 ) { | |
501 Label ok_ret; | |
502 ExternalAddress mxcsr_std(StubRoutines::addr_mxcsr_std()); | |
304 | 503 __ push(rax); |
504 __ subptr(rsp, wordSize); // allocate a temp location | |
0 | 505 __ stmxcsr(mxcsr_save); |
506 __ movl(rax, mxcsr_save); | |
507 __ andl(rax, MXCSR_MASK); | |
508 __ cmp32(rax, mxcsr_std); | |
509 __ jcc(Assembler::equal, ok_ret); | |
510 | |
511 __ warn("MXCSR changed by native JNI code."); | |
512 | |
513 __ ldmxcsr(mxcsr_std); | |
514 | |
515 __ bind(ok_ret); | |
304 | 516 __ addptr(rsp, wordSize); |
517 __ pop(rax); | |
0 | 518 } |
519 | |
520 __ ret(0); | |
521 | |
522 return start; | |
523 } | |
524 | |
525 | |
526 //--------------------------------------------------------------------------- | |
527 // Support for void verify_fpu_cntrl_wrd() | |
528 // | |
529 // This routine is used with -Xcheck:jni to verify that native | |
530 // JNI code does not return to Java code without restoring the | |
531 // FP control word to our expected state. | |
532 | |
533 address generate_verify_fpu_cntrl_wrd() { | |
534 StubCodeMark mark(this, "StubRoutines", "verify_spcw"); | |
535 address start = __ pc(); | |
536 | |
537 const Address fpu_cntrl_wrd_save(rsp, 0); | |
538 | |
539 if (CheckJNICalls) { | |
540 Label ok_ret; | |
304 | 541 __ push(rax); |
542 __ subptr(rsp, wordSize); // allocate a temp location | |
0 | 543 __ fnstcw(fpu_cntrl_wrd_save); |
544 __ movl(rax, fpu_cntrl_wrd_save); | |
545 __ andl(rax, FPU_CNTRL_WRD_MASK); | |
546 ExternalAddress fpu_std(StubRoutines::addr_fpu_cntrl_wrd_std()); | |
547 __ cmp32(rax, fpu_std); | |
548 __ jcc(Assembler::equal, ok_ret); | |
549 | |
550 __ warn("Floating point control word changed by native JNI code."); | |
551 | |
552 __ fldcw(fpu_std); | |
553 | |
554 __ bind(ok_ret); | |
304 | 555 __ addptr(rsp, wordSize); |
556 __ pop(rax); | |
0 | 557 } |
558 | |
559 __ ret(0); | |
560 | |
561 return start; | |
562 } | |
563 | |
564 //--------------------------------------------------------------------------- | |
565 // Wrapper for slow-case handling of double-to-integer conversion | |
566 // d2i or f2i fast case failed either because it is nan or because | |
567 // of under/overflow. | |
568 // Input: FPU TOS: float value | |
569 // Output: rax, (rdx): integer (long) result | |
570 | |
571 address generate_d2i_wrapper(BasicType t, address fcn) { | |
572 StubCodeMark mark(this, "StubRoutines", "d2i_wrapper"); | |
573 address start = __ pc(); | |
574 | |
575 // Capture info about frame layout | |
576 enum layout { FPUState_off = 0, | |
577 rbp_off = FPUStateSizeInWords, | |
578 rdi_off, | |
579 rsi_off, | |
580 rcx_off, | |
581 rbx_off, | |
582 saved_argument_off, | |
583 saved_argument_off2, // 2nd half of double | |
584 framesize | |
585 }; | |
586 | |
587 assert(FPUStateSizeInWords == 27, "update stack layout"); | |
588 | |
589 // Save outgoing argument to stack across push_FPU_state() | |
304 | 590 __ subptr(rsp, wordSize * 2); |
0 | 591 __ fstp_d(Address(rsp, 0)); |
592 | |
593 // Save CPU & FPU state | |
304 | 594 __ push(rbx); |
595 __ push(rcx); | |
596 __ push(rsi); | |
597 __ push(rdi); | |
598 __ push(rbp); | |
0 | 599 __ push_FPU_state(); |
600 | |
601 // push_FPU_state() resets the FP top of stack | |
602 // Load original double into FP top of stack | |
603 __ fld_d(Address(rsp, saved_argument_off * wordSize)); | |
604 // Store double into stack as outgoing argument | |
304 | 605 __ subptr(rsp, wordSize*2); |
0 | 606 __ fst_d(Address(rsp, 0)); |
607 | |
608 // Prepare FPU for doing math in C-land | |
609 __ empty_FPU_stack(); | |
610 // Call the C code to massage the double. Result in EAX | |
611 if (t == T_INT) | |
612 { BLOCK_COMMENT("SharedRuntime::d2i"); } | |
613 else if (t == T_LONG) | |
614 { BLOCK_COMMENT("SharedRuntime::d2l"); } | |
615 __ call_VM_leaf( fcn, 2 ); | |
616 | |
617 // Restore CPU & FPU state | |
618 __ pop_FPU_state(); | |
304 | 619 __ pop(rbp); |
620 __ pop(rdi); | |
621 __ pop(rsi); | |
622 __ pop(rcx); | |
623 __ pop(rbx); | |
624 __ addptr(rsp, wordSize * 2); | |
0 | 625 |
626 __ ret(0); | |
627 | |
628 return start; | |
629 } | |
630 | |
631 | |
632 //--------------------------------------------------------------------------- | |
633 // The following routine generates a subroutine to throw an asynchronous | |
634 // UnknownError when an unsafe access gets a fault that could not be | |
635 // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) | |
636 address generate_handler_for_unsafe_access() { | |
637 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); | |
638 address start = __ pc(); | |
639 | |
304 | 640 __ push(0); // hole for return address-to-be |
641 __ pusha(); // push registers | |
0 | 642 Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); |
643 BLOCK_COMMENT("call handle_unsafe_access"); | |
644 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); | |
304 | 645 __ movptr(next_pc, rax); // stuff next address |
646 __ popa(); | |
0 | 647 __ ret(0); // jump to next address |
648 | |
649 return start; | |
650 } | |
651 | |
652 | |
653 //---------------------------------------------------------------------------------------------------- | |
654 // Non-destructive plausibility checks for oops | |
655 | |
656 address generate_verify_oop() { | |
657 StubCodeMark mark(this, "StubRoutines", "verify_oop"); | |
658 address start = __ pc(); | |
659 | |
660 // Incoming arguments on stack after saving rax,: | |
661 // | |
662 // [tos ]: saved rdx | |
663 // [tos + 1]: saved EFLAGS | |
664 // [tos + 2]: return address | |
665 // [tos + 3]: char* error message | |
666 // [tos + 4]: oop object to verify | |
667 // [tos + 5]: saved rax, - saved by caller and bashed | |
668 | |
669 Label exit, error; | |
304 | 670 __ pushf(); |
671 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); | |
672 __ push(rdx); // save rdx | |
0 | 673 // make sure object is 'reasonable' |
304 | 674 __ movptr(rax, Address(rsp, 4 * wordSize)); // get object |
675 __ testptr(rax, rax); | |
0 | 676 __ jcc(Assembler::zero, exit); // if obj is NULL it is ok |
677 | |
678 // Check if the oop is in the right area of memory | |
679 const int oop_mask = Universe::verify_oop_mask(); | |
680 const int oop_bits = Universe::verify_oop_bits(); | |
304 | 681 __ mov(rdx, rax); |
682 __ andptr(rdx, oop_mask); | |
683 __ cmpptr(rdx, oop_bits); | |
0 | 684 __ jcc(Assembler::notZero, error); |
685 | |
686 // make sure klass is 'reasonable' | |
304 | 687 __ movptr(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass |
688 __ testptr(rax, rax); | |
0 | 689 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
690 | |
691 // Check if the klass is in the right area of memory | |
692 const int klass_mask = Universe::verify_klass_mask(); | |
693 const int klass_bits = Universe::verify_klass_bits(); | |
304 | 694 __ mov(rdx, rax); |
695 __ andptr(rdx, klass_mask); | |
696 __ cmpptr(rdx, klass_bits); | |
0 | 697 __ jcc(Assembler::notZero, error); |
698 | |
699 // make sure klass' klass is 'reasonable' | |
304 | 700 __ movptr(rax, Address(rax, oopDesc::klass_offset_in_bytes())); // get klass' klass |
701 __ testptr(rax, rax); | |
0 | 702 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken |
703 | |
304 | 704 __ mov(rdx, rax); |
705 __ andptr(rdx, klass_mask); | |
706 __ cmpptr(rdx, klass_bits); | |
0 | 707 __ jcc(Assembler::notZero, error); // if klass not in right area |
708 // of memory it is broken too. | |
709 | |
710 // return if everything seems ok | |
711 __ bind(exit); | |
304 | 712 __ movptr(rax, Address(rsp, 5 * wordSize)); // get saved rax, back |
713 __ pop(rdx); // restore rdx | |
714 __ popf(); // restore EFLAGS | |
0 | 715 __ ret(3 * wordSize); // pop arguments |
716 | |
717 // handle errors | |
718 __ bind(error); | |
304 | 719 __ movptr(rax, Address(rsp, 5 * wordSize)); // get saved rax, back |
720 __ pop(rdx); // get saved rdx back | |
721 __ popf(); // get saved EFLAGS off stack -- will be ignored | |
722 __ pusha(); // push registers (eip = return address & msg are already pushed) | |
0 | 723 BLOCK_COMMENT("call MacroAssembler::debug"); |
304 | 724 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug32))); |
725 __ popa(); | |
0 | 726 __ ret(3 * wordSize); // pop arguments |
727 return start; | |
728 } | |
729 | |
730 // | |
731 // Generate pre-barrier for array stores | |
732 // | |
733 // Input: | |
734 // start - starting address | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
710
diff
changeset
|
735 // count - element count |
0 | 736 void gen_write_ref_array_pre_barrier(Register start, Register count) { |
737 assert_different_registers(start, count); | |
738 BarrierSet* bs = Universe::heap()->barrier_set(); | |
739 switch (bs->kind()) { | |
740 case BarrierSet::G1SATBCT: | |
741 case BarrierSet::G1SATBCTLogging: | |
742 { | |
304 | 743 __ pusha(); // push registers |
1192
776fb94f33cc
6918006: G1: spill space must be reserved on the stack for barrier calls on Windows x64
apetrusenko
parents:
1174
diff
changeset
|
744 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), |
776fb94f33cc
6918006: G1: spill space must be reserved on the stack for barrier calls on Windows x64
apetrusenko
parents:
1174
diff
changeset
|
745 start, count); |
304 | 746 __ popa(); |
0 | 747 } |
748 break; | |
749 case BarrierSet::CardTableModRef: | |
750 case BarrierSet::CardTableExtension: | |
751 case BarrierSet::ModRef: | |
752 break; | |
753 default : | |
754 ShouldNotReachHere(); | |
755 | |
756 } | |
757 } | |
758 | |
759 | |
760 // | |
761 // Generate a post-barrier for an array store | |
762 // | |
763 // start - starting address | |
764 // count - element count | |
765 // | |
766 // The two input registers are overwritten. | |
767 // | |
768 void gen_write_ref_array_post_barrier(Register start, Register count) { | |
769 BarrierSet* bs = Universe::heap()->barrier_set(); | |
770 assert_different_registers(start, count); | |
771 switch (bs->kind()) { | |
772 case BarrierSet::G1SATBCT: | |
773 case BarrierSet::G1SATBCTLogging: | |
774 { | |
304 | 775 __ pusha(); // push registers |
1192
776fb94f33cc
6918006: G1: spill space must be reserved on the stack for barrier calls on Windows x64
apetrusenko
parents:
1174
diff
changeset
|
776 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), |
776fb94f33cc
6918006: G1: spill space must be reserved on the stack for barrier calls on Windows x64
apetrusenko
parents:
1174
diff
changeset
|
777 start, count); |
304 | 778 __ popa(); |
0 | 779 } |
780 break; | |
781 | |
782 case BarrierSet::CardTableModRef: | |
783 case BarrierSet::CardTableExtension: | |
784 { | |
785 CardTableModRefBS* ct = (CardTableModRefBS*)bs; | |
786 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); | |
787 | |
788 Label L_loop; | |
789 const Register end = count; // elements count; end == start+count-1 | |
790 assert_different_registers(start, end); | |
791 | |
304 | 792 __ lea(end, Address(start, count, Address::times_ptr, -wordSize)); |
793 __ shrptr(start, CardTableModRefBS::card_shift); | |
794 __ shrptr(end, CardTableModRefBS::card_shift); | |
795 __ subptr(end, start); // end --> count | |
0 | 796 __ BIND(L_loop); |
249
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
19
diff
changeset
|
797 intptr_t disp = (intptr_t) ct->byte_map_base; |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
19
diff
changeset
|
798 Address cardtable(start, count, Address::times_1, disp); |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
19
diff
changeset
|
799 __ movb(cardtable, 0); |
0 | 800 __ decrement(count); |
801 __ jcc(Assembler::greaterEqual, L_loop); | |
802 } | |
803 break; | |
804 case BarrierSet::ModRef: | |
805 break; | |
806 default : | |
807 ShouldNotReachHere(); | |
808 | |
809 } | |
810 } | |
811 | |
405 | 812 |
813 // Copy 64 bytes chunks | |
814 // | |
815 // Inputs: | |
816 // from - source array address | |
817 // to_from - destination array address - from | |
818 // qword_count - 8-bytes element count, negative | |
819 // | |
820 void xmm_copy_forward(Register from, Register to_from, Register qword_count) { | |
821 assert( UseSSE >= 2, "supported cpu only" ); | |
822 Label L_copy_64_bytes_loop, L_copy_64_bytes, L_copy_8_bytes, L_exit; | |
823 // Copy 64-byte chunks | |
824 __ jmpb(L_copy_64_bytes); | |
1365 | 825 __ align(OptoLoopAlignment); |
405 | 826 __ BIND(L_copy_64_bytes_loop); |
827 | |
828 if(UseUnalignedLoadStores) { | |
829 __ movdqu(xmm0, Address(from, 0)); | |
830 __ movdqu(Address(from, to_from, Address::times_1, 0), xmm0); | |
831 __ movdqu(xmm1, Address(from, 16)); | |
832 __ movdqu(Address(from, to_from, Address::times_1, 16), xmm1); | |
833 __ movdqu(xmm2, Address(from, 32)); | |
834 __ movdqu(Address(from, to_from, Address::times_1, 32), xmm2); | |
835 __ movdqu(xmm3, Address(from, 48)); | |
836 __ movdqu(Address(from, to_from, Address::times_1, 48), xmm3); | |
837 | |
838 } else { | |
839 __ movq(xmm0, Address(from, 0)); | |
840 __ movq(Address(from, to_from, Address::times_1, 0), xmm0); | |
841 __ movq(xmm1, Address(from, 8)); | |
842 __ movq(Address(from, to_from, Address::times_1, 8), xmm1); | |
843 __ movq(xmm2, Address(from, 16)); | |
844 __ movq(Address(from, to_from, Address::times_1, 16), xmm2); | |
845 __ movq(xmm3, Address(from, 24)); | |
846 __ movq(Address(from, to_from, Address::times_1, 24), xmm3); | |
847 __ movq(xmm4, Address(from, 32)); | |
848 __ movq(Address(from, to_from, Address::times_1, 32), xmm4); | |
849 __ movq(xmm5, Address(from, 40)); | |
850 __ movq(Address(from, to_from, Address::times_1, 40), xmm5); | |
851 __ movq(xmm6, Address(from, 48)); | |
852 __ movq(Address(from, to_from, Address::times_1, 48), xmm6); | |
853 __ movq(xmm7, Address(from, 56)); | |
854 __ movq(Address(from, to_from, Address::times_1, 56), xmm7); | |
855 } | |
856 | |
857 __ addl(from, 64); | |
858 __ BIND(L_copy_64_bytes); | |
859 __ subl(qword_count, 8); | |
860 __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); | |
861 __ addl(qword_count, 8); | |
862 __ jccb(Assembler::zero, L_exit); | |
863 // | |
864 // length is too short, just copy qwords | |
865 // | |
866 __ BIND(L_copy_8_bytes); | |
867 __ movq(xmm0, Address(from, 0)); | |
868 __ movq(Address(from, to_from, Address::times_1), xmm0); | |
869 __ addl(from, 8); | |
870 __ decrement(qword_count); | |
871 __ jcc(Assembler::greater, L_copy_8_bytes); | |
872 __ BIND(L_exit); | |
873 } | |
874 | |
0 | 875 // Copy 64 bytes chunks |
876 // | |
877 // Inputs: | |
878 // from - source array address | |
879 // to_from - destination array address - from | |
880 // qword_count - 8-bytes element count, negative | |
881 // | |
882 void mmx_copy_forward(Register from, Register to_from, Register qword_count) { | |
405 | 883 assert( VM_Version::supports_mmx(), "supported cpu only" ); |
0 | 884 Label L_copy_64_bytes_loop, L_copy_64_bytes, L_copy_8_bytes, L_exit; |
885 // Copy 64-byte chunks | |
886 __ jmpb(L_copy_64_bytes); | |
1365 | 887 __ align(OptoLoopAlignment); |
0 | 888 __ BIND(L_copy_64_bytes_loop); |
889 __ movq(mmx0, Address(from, 0)); | |
890 __ movq(mmx1, Address(from, 8)); | |
891 __ movq(mmx2, Address(from, 16)); | |
892 __ movq(Address(from, to_from, Address::times_1, 0), mmx0); | |
893 __ movq(mmx3, Address(from, 24)); | |
894 __ movq(Address(from, to_from, Address::times_1, 8), mmx1); | |
895 __ movq(mmx4, Address(from, 32)); | |
896 __ movq(Address(from, to_from, Address::times_1, 16), mmx2); | |
897 __ movq(mmx5, Address(from, 40)); | |
898 __ movq(Address(from, to_from, Address::times_1, 24), mmx3); | |
899 __ movq(mmx6, Address(from, 48)); | |
900 __ movq(Address(from, to_from, Address::times_1, 32), mmx4); | |
901 __ movq(mmx7, Address(from, 56)); | |
902 __ movq(Address(from, to_from, Address::times_1, 40), mmx5); | |
903 __ movq(Address(from, to_from, Address::times_1, 48), mmx6); | |
904 __ movq(Address(from, to_from, Address::times_1, 56), mmx7); | |
304 | 905 __ addptr(from, 64); |
0 | 906 __ BIND(L_copy_64_bytes); |
907 __ subl(qword_count, 8); | |
908 __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); | |
909 __ addl(qword_count, 8); | |
910 __ jccb(Assembler::zero, L_exit); | |
911 // | |
912 // length is too short, just copy qwords | |
913 // | |
914 __ BIND(L_copy_8_bytes); | |
915 __ movq(mmx0, Address(from, 0)); | |
916 __ movq(Address(from, to_from, Address::times_1), mmx0); | |
304 | 917 __ addptr(from, 8); |
0 | 918 __ decrement(qword_count); |
919 __ jcc(Assembler::greater, L_copy_8_bytes); | |
920 __ BIND(L_exit); | |
921 __ emms(); | |
922 } | |
923 | |
924 address generate_disjoint_copy(BasicType t, bool aligned, | |
925 Address::ScaleFactor sf, | |
926 address* entry, const char *name) { | |
927 __ align(CodeEntryAlignment); | |
928 StubCodeMark mark(this, "StubRoutines", name); | |
929 address start = __ pc(); | |
930 | |
931 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; | |
932 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_64_bytes; | |
933 | |
304 | 934 int shift = Address::times_ptr - sf; |
0 | 935 |
936 const Register from = rsi; // source array address | |
937 const Register to = rdi; // destination array address | |
938 const Register count = rcx; // elements count | |
939 const Register to_from = to; // (to - from) | |
940 const Register saved_to = rdx; // saved destination array address | |
941 | |
942 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 943 __ push(rsi); |
944 __ push(rdi); | |
945 __ movptr(from , Address(rsp, 12+ 4)); | |
946 __ movptr(to , Address(rsp, 12+ 8)); | |
0 | 947 __ movl(count, Address(rsp, 12+ 12)); |
948 if (t == T_OBJECT) { | |
949 __ testl(count, count); | |
950 __ jcc(Assembler::zero, L_0_count); | |
951 gen_write_ref_array_pre_barrier(to, count); | |
304 | 952 __ mov(saved_to, to); // save 'to' |
0 | 953 } |
954 | |
955 *entry = __ pc(); // Entry point from conjoint arraycopy stub. | |
956 BLOCK_COMMENT("Entry:"); | |
957 | |
304 | 958 __ subptr(to, from); // to --> to_from |
0 | 959 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element |
960 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp | |
405 | 961 if (!UseUnalignedLoadStores && !aligned && (t == T_BYTE || t == T_SHORT)) { |
0 | 962 // align source address at 4 bytes address boundary |
963 if (t == T_BYTE) { | |
964 // One byte misalignment happens only for byte arrays | |
965 __ testl(from, 1); | |
966 __ jccb(Assembler::zero, L_skip_align1); | |
967 __ movb(rax, Address(from, 0)); | |
968 __ movb(Address(from, to_from, Address::times_1, 0), rax); | |
969 __ increment(from); | |
970 __ decrement(count); | |
971 __ BIND(L_skip_align1); | |
972 } | |
973 // Two bytes misalignment happens only for byte and short (char) arrays | |
974 __ testl(from, 2); | |
975 __ jccb(Assembler::zero, L_skip_align2); | |
976 __ movw(rax, Address(from, 0)); | |
977 __ movw(Address(from, to_from, Address::times_1, 0), rax); | |
304 | 978 __ addptr(from, 2); |
0 | 979 __ subl(count, 1<<(shift-1)); |
980 __ BIND(L_skip_align2); | |
981 } | |
982 if (!VM_Version::supports_mmx()) { | |
304 | 983 __ mov(rax, count); // save 'count' |
984 __ shrl(count, shift); // bytes count | |
985 __ addptr(to_from, from);// restore 'to' | |
986 __ rep_mov(); | |
987 __ subptr(to_from, from);// restore 'to_from' | |
988 __ mov(count, rax); // restore 'count' | |
0 | 989 __ jmpb(L_copy_2_bytes); // all dwords were copied |
990 } else { | |
405 | 991 if (!UseUnalignedLoadStores) { |
992 // align to 8 bytes, we know we are 4 byte aligned to start | |
993 __ testptr(from, 4); | |
994 __ jccb(Assembler::zero, L_copy_64_bytes); | |
995 __ movl(rax, Address(from, 0)); | |
996 __ movl(Address(from, to_from, Address::times_1, 0), rax); | |
997 __ addptr(from, 4); | |
998 __ subl(count, 1<<shift); | |
999 } | |
0 | 1000 __ BIND(L_copy_64_bytes); |
304 | 1001 __ mov(rax, count); |
0 | 1002 __ shrl(rax, shift+1); // 8 bytes chunk count |
1003 // | |
1004 // Copy 8-byte chunks through MMX registers, 8 per iteration of the loop | |
1005 // | |
405 | 1006 if (UseXMMForArrayCopy) { |
1007 xmm_copy_forward(from, to_from, rax); | |
1008 } else { | |
1009 mmx_copy_forward(from, to_from, rax); | |
1010 } | |
0 | 1011 } |
1012 // copy tailing dword | |
1013 __ BIND(L_copy_4_bytes); | |
1014 __ testl(count, 1<<shift); | |
1015 __ jccb(Assembler::zero, L_copy_2_bytes); | |
1016 __ movl(rax, Address(from, 0)); | |
1017 __ movl(Address(from, to_from, Address::times_1, 0), rax); | |
1018 if (t == T_BYTE || t == T_SHORT) { | |
304 | 1019 __ addptr(from, 4); |
0 | 1020 __ BIND(L_copy_2_bytes); |
1021 // copy tailing word | |
1022 __ testl(count, 1<<(shift-1)); | |
1023 __ jccb(Assembler::zero, L_copy_byte); | |
1024 __ movw(rax, Address(from, 0)); | |
1025 __ movw(Address(from, to_from, Address::times_1, 0), rax); | |
1026 if (t == T_BYTE) { | |
304 | 1027 __ addptr(from, 2); |
0 | 1028 __ BIND(L_copy_byte); |
1029 // copy tailing byte | |
1030 __ testl(count, 1); | |
1031 __ jccb(Assembler::zero, L_exit); | |
1032 __ movb(rax, Address(from, 0)); | |
1033 __ movb(Address(from, to_from, Address::times_1, 0), rax); | |
1034 __ BIND(L_exit); | |
1035 } else { | |
1036 __ BIND(L_copy_byte); | |
1037 } | |
1038 } else { | |
1039 __ BIND(L_copy_2_bytes); | |
1040 } | |
1041 | |
1042 if (t == T_OBJECT) { | |
1043 __ movl(count, Address(rsp, 12+12)); // reread 'count' | |
304 | 1044 __ mov(to, saved_to); // restore 'to' |
0 | 1045 gen_write_ref_array_post_barrier(to, count); |
1046 __ BIND(L_0_count); | |
1047 } | |
1048 inc_copy_counter_np(t); | |
304 | 1049 __ pop(rdi); |
1050 __ pop(rsi); | |
0 | 1051 __ leave(); // required for proper stackwalking of RuntimeStub frame |
304 | 1052 __ xorptr(rax, rax); // return 0 |
0 | 1053 __ ret(0); |
1054 return start; | |
1055 } | |
1056 | |
1057 | |
1763 | 1058 address generate_fill(BasicType t, bool aligned, const char *name) { |
1059 __ align(CodeEntryAlignment); | |
1060 StubCodeMark mark(this, "StubRoutines", name); | |
1061 address start = __ pc(); | |
1062 | |
1063 BLOCK_COMMENT("Entry:"); | |
1064 | |
1065 const Register to = rdi; // source array address | |
1066 const Register value = rdx; // value | |
1067 const Register count = rsi; // elements count | |
1068 | |
1069 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1070 __ push(rsi); | |
1071 __ push(rdi); | |
1072 __ movptr(to , Address(rsp, 12+ 4)); | |
1073 __ movl(value, Address(rsp, 12+ 8)); | |
1074 __ movl(count, Address(rsp, 12+ 12)); | |
1075 | |
1076 __ generate_fill(t, aligned, to, value, count, rax, xmm0); | |
1077 | |
1078 __ pop(rdi); | |
1079 __ pop(rsi); | |
1080 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
1081 __ ret(0); | |
1082 return start; | |
1083 } | |
1084 | |
0 | 1085 address generate_conjoint_copy(BasicType t, bool aligned, |
1086 Address::ScaleFactor sf, | |
1087 address nooverlap_target, | |
1088 address* entry, const char *name) { | |
1089 __ align(CodeEntryAlignment); | |
1090 StubCodeMark mark(this, "StubRoutines", name); | |
1091 address start = __ pc(); | |
1092 | |
1093 Label L_0_count, L_exit, L_skip_align1, L_skip_align2, L_copy_byte; | |
1094 Label L_copy_2_bytes, L_copy_4_bytes, L_copy_8_bytes, L_copy_8_bytes_loop; | |
1095 | |
304 | 1096 int shift = Address::times_ptr - sf; |
0 | 1097 |
1098 const Register src = rax; // source array address | |
1099 const Register dst = rdx; // destination array address | |
1100 const Register from = rsi; // source array address | |
1101 const Register to = rdi; // destination array address | |
1102 const Register count = rcx; // elements count | |
1103 const Register end = rax; // array end address | |
1104 | |
1105 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1106 __ push(rsi); |
1107 __ push(rdi); | |
1108 __ movptr(src , Address(rsp, 12+ 4)); // from | |
1109 __ movptr(dst , Address(rsp, 12+ 8)); // to | |
1110 __ movl2ptr(count, Address(rsp, 12+12)); // count | |
0 | 1111 if (t == T_OBJECT) { |
1112 gen_write_ref_array_pre_barrier(dst, count); | |
1113 } | |
1114 | |
1115 if (entry != NULL) { | |
1116 *entry = __ pc(); // Entry point from generic arraycopy stub. | |
1117 BLOCK_COMMENT("Entry:"); | |
1118 } | |
1119 | |
1120 if (t == T_OBJECT) { | |
1121 __ testl(count, count); | |
1122 __ jcc(Assembler::zero, L_0_count); | |
1123 } | |
304 | 1124 __ mov(from, src); |
1125 __ mov(to , dst); | |
0 | 1126 |
1127 // arrays overlap test | |
1128 RuntimeAddress nooverlap(nooverlap_target); | |
304 | 1129 __ cmpptr(dst, src); |
1130 __ lea(end, Address(src, count, sf, 0)); // src + count * elem_size | |
0 | 1131 __ jump_cc(Assembler::belowEqual, nooverlap); |
304 | 1132 __ cmpptr(dst, end); |
0 | 1133 __ jump_cc(Assembler::aboveEqual, nooverlap); |
1134 | |
1135 // copy from high to low | |
1136 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element | |
1137 __ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp | |
1138 if (t == T_BYTE || t == T_SHORT) { | |
1139 // Align the end of destination array at 4 bytes address boundary | |
304 | 1140 __ lea(end, Address(dst, count, sf, 0)); |
0 | 1141 if (t == T_BYTE) { |
1142 // One byte misalignment happens only for byte arrays | |
1143 __ testl(end, 1); | |
1144 __ jccb(Assembler::zero, L_skip_align1); | |
1145 __ decrement(count); | |
1146 __ movb(rdx, Address(from, count, sf, 0)); | |
1147 __ movb(Address(to, count, sf, 0), rdx); | |
1148 __ BIND(L_skip_align1); | |
1149 } | |
1150 // Two bytes misalignment happens only for byte and short (char) arrays | |
1151 __ testl(end, 2); | |
1152 __ jccb(Assembler::zero, L_skip_align2); | |
304 | 1153 __ subptr(count, 1<<(shift-1)); |
0 | 1154 __ movw(rdx, Address(from, count, sf, 0)); |
1155 __ movw(Address(to, count, sf, 0), rdx); | |
1156 __ BIND(L_skip_align2); | |
1157 __ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element | |
1158 __ jcc(Assembler::below, L_copy_4_bytes); | |
1159 } | |
1160 | |
1161 if (!VM_Version::supports_mmx()) { | |
1162 __ std(); | |
304 | 1163 __ mov(rax, count); // Save 'count' |
1164 __ mov(rdx, to); // Save 'to' | |
1165 __ lea(rsi, Address(from, count, sf, -4)); | |
1166 __ lea(rdi, Address(to , count, sf, -4)); | |
1167 __ shrptr(count, shift); // bytes count | |
1168 __ rep_mov(); | |
0 | 1169 __ cld(); |
304 | 1170 __ mov(count, rax); // restore 'count' |
0 | 1171 __ andl(count, (1<<shift)-1); // mask the number of rest elements |
304 | 1172 __ movptr(from, Address(rsp, 12+4)); // reread 'from' |
1173 __ mov(to, rdx); // restore 'to' | |
0 | 1174 __ jmpb(L_copy_2_bytes); // all dword were copied |
1175 } else { | |
1176 // Align to 8 bytes the end of array. It is aligned to 4 bytes already. | |
304 | 1177 __ testptr(end, 4); |
0 | 1178 __ jccb(Assembler::zero, L_copy_8_bytes); |
1179 __ subl(count, 1<<shift); | |
1180 __ movl(rdx, Address(from, count, sf, 0)); | |
1181 __ movl(Address(to, count, sf, 0), rdx); | |
1182 __ jmpb(L_copy_8_bytes); | |
1183 | |
1365 | 1184 __ align(OptoLoopAlignment); |
0 | 1185 // Move 8 bytes |
1186 __ BIND(L_copy_8_bytes_loop); | |
405 | 1187 if (UseXMMForArrayCopy) { |
1188 __ movq(xmm0, Address(from, count, sf, 0)); | |
1189 __ movq(Address(to, count, sf, 0), xmm0); | |
1190 } else { | |
1191 __ movq(mmx0, Address(from, count, sf, 0)); | |
1192 __ movq(Address(to, count, sf, 0), mmx0); | |
1193 } | |
0 | 1194 __ BIND(L_copy_8_bytes); |
1195 __ subl(count, 2<<shift); | |
1196 __ jcc(Assembler::greaterEqual, L_copy_8_bytes_loop); | |
1197 __ addl(count, 2<<shift); | |
405 | 1198 if (!UseXMMForArrayCopy) { |
1199 __ emms(); | |
1200 } | |
0 | 1201 } |
1202 __ BIND(L_copy_4_bytes); | |
1203 // copy prefix qword | |
1204 __ testl(count, 1<<shift); | |
1205 __ jccb(Assembler::zero, L_copy_2_bytes); | |
1206 __ movl(rdx, Address(from, count, sf, -4)); | |
1207 __ movl(Address(to, count, sf, -4), rdx); | |
1208 | |
1209 if (t == T_BYTE || t == T_SHORT) { | |
1210 __ subl(count, (1<<shift)); | |
1211 __ BIND(L_copy_2_bytes); | |
1212 // copy prefix dword | |
1213 __ testl(count, 1<<(shift-1)); | |
1214 __ jccb(Assembler::zero, L_copy_byte); | |
1215 __ movw(rdx, Address(from, count, sf, -2)); | |
1216 __ movw(Address(to, count, sf, -2), rdx); | |
1217 if (t == T_BYTE) { | |
1218 __ subl(count, 1<<(shift-1)); | |
1219 __ BIND(L_copy_byte); | |
1220 // copy prefix byte | |
1221 __ testl(count, 1); | |
1222 __ jccb(Assembler::zero, L_exit); | |
1223 __ movb(rdx, Address(from, 0)); | |
1224 __ movb(Address(to, 0), rdx); | |
1225 __ BIND(L_exit); | |
1226 } else { | |
1227 __ BIND(L_copy_byte); | |
1228 } | |
1229 } else { | |
1230 __ BIND(L_copy_2_bytes); | |
1231 } | |
1232 if (t == T_OBJECT) { | |
304 | 1233 __ movl2ptr(count, Address(rsp, 12+12)); // reread count |
0 | 1234 gen_write_ref_array_post_barrier(to, count); |
1235 __ BIND(L_0_count); | |
1236 } | |
1237 inc_copy_counter_np(t); | |
304 | 1238 __ pop(rdi); |
1239 __ pop(rsi); | |
0 | 1240 __ leave(); // required for proper stackwalking of RuntimeStub frame |
304 | 1241 __ xorptr(rax, rax); // return 0 |
0 | 1242 __ ret(0); |
1243 return start; | |
1244 } | |
1245 | |
1246 | |
1247 address generate_disjoint_long_copy(address* entry, const char *name) { | |
1248 __ align(CodeEntryAlignment); | |
1249 StubCodeMark mark(this, "StubRoutines", name); | |
1250 address start = __ pc(); | |
1251 | |
1252 Label L_copy_8_bytes, L_copy_8_bytes_loop; | |
1253 const Register from = rax; // source array address | |
1254 const Register to = rdx; // destination array address | |
1255 const Register count = rcx; // elements count | |
1256 const Register to_from = rdx; // (to - from) | |
1257 | |
1258 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1259 __ movptr(from , Address(rsp, 8+0)); // from |
1260 __ movptr(to , Address(rsp, 8+4)); // to | |
1261 __ movl2ptr(count, Address(rsp, 8+8)); // count | |
0 | 1262 |
1263 *entry = __ pc(); // Entry point from conjoint arraycopy stub. | |
1264 BLOCK_COMMENT("Entry:"); | |
1265 | |
304 | 1266 __ subptr(to, from); // to --> to_from |
0 | 1267 if (VM_Version::supports_mmx()) { |
405 | 1268 if (UseXMMForArrayCopy) { |
1269 xmm_copy_forward(from, to_from, count); | |
1270 } else { | |
1271 mmx_copy_forward(from, to_from, count); | |
1272 } | |
0 | 1273 } else { |
1274 __ jmpb(L_copy_8_bytes); | |
1365 | 1275 __ align(OptoLoopAlignment); |
0 | 1276 __ BIND(L_copy_8_bytes_loop); |
1277 __ fild_d(Address(from, 0)); | |
1278 __ fistp_d(Address(from, to_from, Address::times_1)); | |
304 | 1279 __ addptr(from, 8); |
0 | 1280 __ BIND(L_copy_8_bytes); |
1281 __ decrement(count); | |
1282 __ jcc(Assembler::greaterEqual, L_copy_8_bytes_loop); | |
1283 } | |
1284 inc_copy_counter_np(T_LONG); | |
1285 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1286 __ xorptr(rax, rax); // return 0 |
0 | 1287 __ ret(0); |
1288 return start; | |
1289 } | |
1290 | |
1291 address generate_conjoint_long_copy(address nooverlap_target, | |
1292 address* entry, const char *name) { | |
1293 __ align(CodeEntryAlignment); | |
1294 StubCodeMark mark(this, "StubRoutines", name); | |
1295 address start = __ pc(); | |
1296 | |
1297 Label L_copy_8_bytes, L_copy_8_bytes_loop; | |
1298 const Register from = rax; // source array address | |
1299 const Register to = rdx; // destination array address | |
1300 const Register count = rcx; // elements count | |
1301 const Register end_from = rax; // source array end address | |
1302 | |
1303 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1304 __ movptr(from , Address(rsp, 8+0)); // from |
1305 __ movptr(to , Address(rsp, 8+4)); // to | |
1306 __ movl2ptr(count, Address(rsp, 8+8)); // count | |
0 | 1307 |
1308 *entry = __ pc(); // Entry point from generic arraycopy stub. | |
1309 BLOCK_COMMENT("Entry:"); | |
1310 | |
1311 // arrays overlap test | |
304 | 1312 __ cmpptr(to, from); |
0 | 1313 RuntimeAddress nooverlap(nooverlap_target); |
1314 __ jump_cc(Assembler::belowEqual, nooverlap); | |
304 | 1315 __ lea(end_from, Address(from, count, Address::times_8, 0)); |
1316 __ cmpptr(to, end_from); | |
1317 __ movptr(from, Address(rsp, 8)); // from | |
0 | 1318 __ jump_cc(Assembler::aboveEqual, nooverlap); |
1319 | |
1320 __ jmpb(L_copy_8_bytes); | |
1321 | |
1365 | 1322 __ align(OptoLoopAlignment); |
0 | 1323 __ BIND(L_copy_8_bytes_loop); |
1324 if (VM_Version::supports_mmx()) { | |
405 | 1325 if (UseXMMForArrayCopy) { |
1326 __ movq(xmm0, Address(from, count, Address::times_8)); | |
1327 __ movq(Address(to, count, Address::times_8), xmm0); | |
1328 } else { | |
1329 __ movq(mmx0, Address(from, count, Address::times_8)); | |
1330 __ movq(Address(to, count, Address::times_8), mmx0); | |
1331 } | |
0 | 1332 } else { |
1333 __ fild_d(Address(from, count, Address::times_8)); | |
1334 __ fistp_d(Address(to, count, Address::times_8)); | |
1335 } | |
1336 __ BIND(L_copy_8_bytes); | |
1337 __ decrement(count); | |
1338 __ jcc(Assembler::greaterEqual, L_copy_8_bytes_loop); | |
1339 | |
405 | 1340 if (VM_Version::supports_mmx() && !UseXMMForArrayCopy) { |
0 | 1341 __ emms(); |
1342 } | |
1343 inc_copy_counter_np(T_LONG); | |
1344 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1345 __ xorptr(rax, rax); // return 0 |
0 | 1346 __ ret(0); |
1347 return start; | |
1348 } | |
1349 | |
1350 | |
1351 // Helper for generating a dynamic type check. | |
1352 // The sub_klass must be one of {rbx, rdx, rsi}. | |
1353 // The temp is killed. | |
1354 void generate_type_check(Register sub_klass, | |
1355 Address& super_check_offset_addr, | |
1356 Address& super_klass_addr, | |
1357 Register temp, | |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1358 Label* L_success, Label* L_failure) { |
0 | 1359 BLOCK_COMMENT("type_check:"); |
1360 | |
1361 Label L_fallthrough; | |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1362 #define LOCAL_JCC(assembler_con, label_ptr) \ |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1363 if (label_ptr != NULL) __ jcc(assembler_con, *(label_ptr)); \ |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1364 else __ jcc(assembler_con, L_fallthrough) /*omit semi*/ |
0 | 1365 |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1366 // The following is a strange variation of the fast path which requires |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1367 // one less register, because needed values are on the argument stack. |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1368 // __ check_klass_subtype_fast_path(sub_klass, *super_klass*, temp, |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1369 // L_success, L_failure, NULL); |
0 | 1370 assert_different_registers(sub_klass, temp); |
1371 | |
1372 int sc_offset = (klassOopDesc::header_size() * HeapWordSize + | |
1373 Klass::secondary_super_cache_offset_in_bytes()); | |
1374 | |
1375 // if the pointers are equal, we are done (e.g., String[] elements) | |
304 | 1376 __ cmpptr(sub_klass, super_klass_addr); |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1377 LOCAL_JCC(Assembler::equal, L_success); |
0 | 1378 |
1379 // check the supertype display: | |
304 | 1380 __ movl2ptr(temp, super_check_offset_addr); |
0 | 1381 Address super_check_addr(sub_klass, temp, Address::times_1, 0); |
304 | 1382 __ movptr(temp, super_check_addr); // load displayed supertype |
1383 __ cmpptr(temp, super_klass_addr); // test the super type | |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1384 LOCAL_JCC(Assembler::equal, L_success); |
0 | 1385 |
1386 // if it was a primary super, we can just fail immediately | |
1387 __ cmpl(super_check_offset_addr, sc_offset); | |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1388 LOCAL_JCC(Assembler::notEqual, L_failure); |
0 | 1389 |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1390 // The repne_scan instruction uses fixed registers, which will get spilled. |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1391 // We happen to know this works best when super_klass is in rax. |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1392 Register super_klass = temp; |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1393 __ movptr(super_klass, super_klass_addr); |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1394 __ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1395 L_success, L_failure); |
0 | 1396 |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1397 __ bind(L_fallthrough); |
0 | 1398 |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1399 if (L_success == NULL) { BLOCK_COMMENT("L_success:"); } |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1400 if (L_failure == NULL) { BLOCK_COMMENT("L_failure:"); } |
0 | 1401 |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
533
diff
changeset
|
1402 #undef LOCAL_JCC |
0 | 1403 } |
1404 | |
1405 // | |
1406 // Generate checkcasting array copy stub | |
1407 // | |
1408 // Input: | |
1409 // 4(rsp) - source array address | |
1410 // 8(rsp) - destination array address | |
1411 // 12(rsp) - element count, can be zero | |
1412 // 16(rsp) - size_t ckoff (super_check_offset) | |
1413 // 20(rsp) - oop ckval (super_klass) | |
1414 // | |
1415 // Output: | |
1416 // rax, == 0 - success | |
1417 // rax, == -1^K - failure, where K is partial transfer count | |
1418 // | |
1419 address generate_checkcast_copy(const char *name, address* entry) { | |
1420 __ align(CodeEntryAlignment); | |
1421 StubCodeMark mark(this, "StubRoutines", name); | |
1422 address start = __ pc(); | |
1423 | |
1424 Label L_load_element, L_store_element, L_do_card_marks, L_done; | |
1425 | |
1426 // register use: | |
1427 // rax, rdx, rcx -- loop control (end_from, end_to, count) | |
1428 // rdi, rsi -- element access (oop, klass) | |
1429 // rbx, -- temp | |
1430 const Register from = rax; // source array address | |
1431 const Register to = rdx; // destination array address | |
1432 const Register length = rcx; // elements count | |
1433 const Register elem = rdi; // each oop copied | |
1434 const Register elem_klass = rsi; // each elem._klass (sub_klass) | |
1435 const Register temp = rbx; // lone remaining temp | |
1436 | |
1437 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1438 | |
304 | 1439 __ push(rsi); |
1440 __ push(rdi); | |
1441 __ push(rbx); | |
0 | 1442 |
1443 Address from_arg(rsp, 16+ 4); // from | |
1444 Address to_arg(rsp, 16+ 8); // to | |
1445 Address length_arg(rsp, 16+12); // elements count | |
1446 Address ckoff_arg(rsp, 16+16); // super_check_offset | |
1447 Address ckval_arg(rsp, 16+20); // super_klass | |
1448 | |
1449 // Load up: | |
304 | 1450 __ movptr(from, from_arg); |
1451 __ movptr(to, to_arg); | |
1452 __ movl2ptr(length, length_arg); | |
0 | 1453 |
1454 *entry = __ pc(); // Entry point from generic arraycopy stub. | |
1455 BLOCK_COMMENT("Entry:"); | |
1456 | |
1457 //--------------------------------------------------------------- | |
1458 // Assembler stub will be used for this call to arraycopy | |
1459 // if the two arrays are subtypes of Object[] but the | |
1460 // destination array type is not equal to or a supertype | |
1461 // of the source type. Each element must be separately | |
1462 // checked. | |
1463 | |
1464 // Loop-invariant addresses. They are exclusive end pointers. | |
304 | 1465 Address end_from_addr(from, length, Address::times_ptr, 0); |
1466 Address end_to_addr(to, length, Address::times_ptr, 0); | |
0 | 1467 |
1468 Register end_from = from; // re-use | |
1469 Register end_to = to; // re-use | |
1470 Register count = length; // re-use | |
1471 | |
1472 // Loop-variant addresses. They assume post-incremented count < 0. | |
304 | 1473 Address from_element_addr(end_from, count, Address::times_ptr, 0); |
1474 Address to_element_addr(end_to, count, Address::times_ptr, 0); | |
0 | 1475 Address elem_klass_addr(elem, oopDesc::klass_offset_in_bytes()); |
1476 | |
1477 // Copy from low to high addresses, indexed from the end of each array. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
19
diff
changeset
|
1478 gen_write_ref_array_pre_barrier(to, count); |
304 | 1479 __ lea(end_from, end_from_addr); |
1480 __ lea(end_to, end_to_addr); | |
0 | 1481 assert(length == count, ""); // else fix next line: |
304 | 1482 __ negptr(count); // negate and test the length |
0 | 1483 __ jccb(Assembler::notZero, L_load_element); |
1484 | |
1485 // Empty array: Nothing to do. | |
304 | 1486 __ xorptr(rax, rax); // return 0 on (trivial) success |
0 | 1487 __ jmp(L_done); |
1488 | |
1489 // ======== begin loop ======== | |
1490 // (Loop is rotated; its entry is L_load_element.) | |
1491 // Loop control: | |
1492 // for (count = -count; count != 0; count++) | |
1493 // Base pointers src, dst are biased by 8*count,to last element. | |
1365 | 1494 __ align(OptoLoopAlignment); |
0 | 1495 |
1496 __ BIND(L_store_element); | |
304 | 1497 __ movptr(to_element_addr, elem); // store the oop |
0 | 1498 __ increment(count); // increment the count toward zero |
1499 __ jccb(Assembler::zero, L_do_card_marks); | |
1500 | |
1501 // ======== loop entry is here ======== | |
1502 __ BIND(L_load_element); | |
304 | 1503 __ movptr(elem, from_element_addr); // load the oop |
1504 __ testptr(elem, elem); | |
0 | 1505 __ jccb(Assembler::zero, L_store_element); |
1506 | |
1507 // (Could do a trick here: Remember last successful non-null | |
1508 // element stored and make a quick oop equality check on it.) | |
1509 | |
304 | 1510 __ movptr(elem_klass, elem_klass_addr); // query the object klass |
0 | 1511 generate_type_check(elem_klass, ckoff_arg, ckval_arg, temp, |
1512 &L_store_element, NULL); | |
1513 // (On fall-through, we have failed the element type check.) | |
1514 // ======== end loop ======== | |
1515 | |
1516 // It was a real error; we must depend on the caller to finish the job. | |
19
a73cc31728fe
6614036: REGRESSION: Java server x86 VM intermittently crash with SIGSEGV (0xb)
rasbold
parents:
16
diff
changeset
|
1517 // Register "count" = -1 * number of *remaining* oops, length_arg = *total* oops. |
a73cc31728fe
6614036: REGRESSION: Java server x86 VM intermittently crash with SIGSEGV (0xb)
rasbold
parents:
16
diff
changeset
|
1518 // Emit GC store barriers for the oops we have copied (length_arg + count), |
0 | 1519 // and report their number to the caller. |
1520 __ addl(count, length_arg); // transfers = (length - remaining) | |
304 | 1521 __ movl2ptr(rax, count); // save the value |
1522 __ notptr(rax); // report (-1^K) to caller | |
1523 __ movptr(to, to_arg); // reload | |
0 | 1524 assert_different_registers(to, count, rax); |
1525 gen_write_ref_array_post_barrier(to, count); | |
1526 __ jmpb(L_done); | |
1527 | |
1528 // Come here on success only. | |
1529 __ BIND(L_do_card_marks); | |
304 | 1530 __ movl2ptr(count, length_arg); |
1531 __ movptr(to, to_arg); // reload | |
0 | 1532 gen_write_ref_array_post_barrier(to, count); |
304 | 1533 __ xorptr(rax, rax); // return 0 on success |
0 | 1534 |
1535 // Common exit point (success or failure). | |
1536 __ BIND(L_done); | |
304 | 1537 __ pop(rbx); |
1538 __ pop(rdi); | |
1539 __ pop(rsi); | |
0 | 1540 inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr); |
1541 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
1542 __ ret(0); | |
1543 | |
1544 return start; | |
1545 } | |
1546 | |
1547 // | |
1548 // Generate 'unsafe' array copy stub | |
1549 // Though just as safe as the other stubs, it takes an unscaled | |
1550 // size_t argument instead of an element count. | |
1551 // | |
1552 // Input: | |
1553 // 4(rsp) - source array address | |
1554 // 8(rsp) - destination array address | |
1555 // 12(rsp) - byte count, can be zero | |
1556 // | |
1557 // Output: | |
1558 // rax, == 0 - success | |
1559 // rax, == -1 - need to call System.arraycopy | |
1560 // | |
1561 // Examines the alignment of the operands and dispatches | |
1562 // to a long, int, short, or byte copy loop. | |
1563 // | |
1564 address generate_unsafe_copy(const char *name, | |
1565 address byte_copy_entry, | |
1566 address short_copy_entry, | |
1567 address int_copy_entry, | |
1568 address long_copy_entry) { | |
1569 | |
1570 Label L_long_aligned, L_int_aligned, L_short_aligned; | |
1571 | |
1572 __ align(CodeEntryAlignment); | |
1573 StubCodeMark mark(this, "StubRoutines", name); | |
1574 address start = __ pc(); | |
1575 | |
1576 const Register from = rax; // source array address | |
1577 const Register to = rdx; // destination array address | |
1578 const Register count = rcx; // elements count | |
1579 | |
1580 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1581 __ push(rsi); |
1582 __ push(rdi); | |
0 | 1583 Address from_arg(rsp, 12+ 4); // from |
1584 Address to_arg(rsp, 12+ 8); // to | |
1585 Address count_arg(rsp, 12+12); // byte count | |
1586 | |
1587 // Load up: | |
304 | 1588 __ movptr(from , from_arg); |
1589 __ movptr(to , to_arg); | |
1590 __ movl2ptr(count, count_arg); | |
0 | 1591 |
1592 // bump this on entry, not on exit: | |
1593 inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr); | |
1594 | |
1595 const Register bits = rsi; | |
304 | 1596 __ mov(bits, from); |
1597 __ orptr(bits, to); | |
1598 __ orptr(bits, count); | |
0 | 1599 |
1600 __ testl(bits, BytesPerLong-1); | |
1601 __ jccb(Assembler::zero, L_long_aligned); | |
1602 | |
1603 __ testl(bits, BytesPerInt-1); | |
1604 __ jccb(Assembler::zero, L_int_aligned); | |
1605 | |
1606 __ testl(bits, BytesPerShort-1); | |
1607 __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry)); | |
1608 | |
1609 __ BIND(L_short_aligned); | |
304 | 1610 __ shrptr(count, LogBytesPerShort); // size => short_count |
0 | 1611 __ movl(count_arg, count); // update 'count' |
1612 __ jump(RuntimeAddress(short_copy_entry)); | |
1613 | |
1614 __ BIND(L_int_aligned); | |
304 | 1615 __ shrptr(count, LogBytesPerInt); // size => int_count |
0 | 1616 __ movl(count_arg, count); // update 'count' |
1617 __ jump(RuntimeAddress(int_copy_entry)); | |
1618 | |
1619 __ BIND(L_long_aligned); | |
304 | 1620 __ shrptr(count, LogBytesPerLong); // size => qword_count |
0 | 1621 __ movl(count_arg, count); // update 'count' |
304 | 1622 __ pop(rdi); // Do pops here since jlong_arraycopy stub does not do it. |
1623 __ pop(rsi); | |
0 | 1624 __ jump(RuntimeAddress(long_copy_entry)); |
1625 | |
1626 return start; | |
1627 } | |
1628 | |
1629 | |
1630 // Perform range checks on the proposed arraycopy. | |
1631 // Smashes src_pos and dst_pos. (Uses them up for temps.) | |
1632 void arraycopy_range_checks(Register src, | |
1633 Register src_pos, | |
1634 Register dst, | |
1635 Register dst_pos, | |
1636 Address& length, | |
1637 Label& L_failed) { | |
1638 BLOCK_COMMENT("arraycopy_range_checks:"); | |
1639 const Register src_end = src_pos; // source array end position | |
1640 const Register dst_end = dst_pos; // destination array end position | |
1641 __ addl(src_end, length); // src_pos + length | |
1642 __ addl(dst_end, length); // dst_pos + length | |
1643 | |
1644 // if (src_pos + length > arrayOop(src)->length() ) FAIL; | |
1645 __ cmpl(src_end, Address(src, arrayOopDesc::length_offset_in_bytes())); | |
1646 __ jcc(Assembler::above, L_failed); | |
1647 | |
1648 // if (dst_pos + length > arrayOop(dst)->length() ) FAIL; | |
1649 __ cmpl(dst_end, Address(dst, arrayOopDesc::length_offset_in_bytes())); | |
1650 __ jcc(Assembler::above, L_failed); | |
1651 | |
1652 BLOCK_COMMENT("arraycopy_range_checks done"); | |
1653 } | |
1654 | |
1655 | |
1656 // | |
1657 // Generate generic array copy stubs | |
1658 // | |
1659 // Input: | |
1660 // 4(rsp) - src oop | |
1661 // 8(rsp) - src_pos | |
1662 // 12(rsp) - dst oop | |
1663 // 16(rsp) - dst_pos | |
1664 // 20(rsp) - element count | |
1665 // | |
1666 // Output: | |
1667 // rax, == 0 - success | |
1668 // rax, == -1^K - failure, where K is partial transfer count | |
1669 // | |
1670 address generate_generic_copy(const char *name, | |
1671 address entry_jbyte_arraycopy, | |
1672 address entry_jshort_arraycopy, | |
1673 address entry_jint_arraycopy, | |
1674 address entry_oop_arraycopy, | |
1675 address entry_jlong_arraycopy, | |
1676 address entry_checkcast_arraycopy) { | |
1677 Label L_failed, L_failed_0, L_objArray; | |
1678 | |
1679 { int modulus = CodeEntryAlignment; | |
1680 int target = modulus - 5; // 5 = sizeof jmp(L_failed) | |
1681 int advance = target - (__ offset() % modulus); | |
1682 if (advance < 0) advance += modulus; | |
1683 if (advance > 0) __ nop(advance); | |
1684 } | |
1685 StubCodeMark mark(this, "StubRoutines", name); | |
1686 | |
1687 // Short-hop target to L_failed. Makes for denser prologue code. | |
1688 __ BIND(L_failed_0); | |
1689 __ jmp(L_failed); | |
1690 assert(__ offset() % CodeEntryAlignment == 0, "no further alignment needed"); | |
1691 | |
1692 __ align(CodeEntryAlignment); | |
1693 address start = __ pc(); | |
1694 | |
1695 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
304 | 1696 __ push(rsi); |
1697 __ push(rdi); | |
0 | 1698 |
1699 // bump this on entry, not on exit: | |
1700 inc_counter_np(SharedRuntime::_generic_array_copy_ctr); | |
1701 | |
1702 // Input values | |
1703 Address SRC (rsp, 12+ 4); | |
1704 Address SRC_POS (rsp, 12+ 8); | |
1705 Address DST (rsp, 12+12); | |
1706 Address DST_POS (rsp, 12+16); | |
1707 Address LENGTH (rsp, 12+20); | |
1708 | |
1709 //----------------------------------------------------------------------- | |
1710 // Assembler stub will be used for this call to arraycopy | |
1711 // if the following conditions are met: | |
1712 // | |
1713 // (1) src and dst must not be null. | |
1714 // (2) src_pos must not be negative. | |
1715 // (3) dst_pos must not be negative. | |
1716 // (4) length must not be negative. | |
1717 // (5) src klass and dst klass should be the same and not NULL. | |
1718 // (6) src and dst should be arrays. | |
1719 // (7) src_pos + length must not exceed length of src. | |
1720 // (8) dst_pos + length must not exceed length of dst. | |
1721 // | |
1722 | |
1723 const Register src = rax; // source array oop | |
1724 const Register src_pos = rsi; | |
1725 const Register dst = rdx; // destination array oop | |
1726 const Register dst_pos = rdi; | |
1727 const Register length = rcx; // transfer count | |
1728 | |
1729 // if (src == NULL) return -1; | |
304 | 1730 __ movptr(src, SRC); // src oop |
1731 __ testptr(src, src); | |
0 | 1732 __ jccb(Assembler::zero, L_failed_0); |
1733 | |
1734 // if (src_pos < 0) return -1; | |
304 | 1735 __ movl2ptr(src_pos, SRC_POS); // src_pos |
0 | 1736 __ testl(src_pos, src_pos); |
1737 __ jccb(Assembler::negative, L_failed_0); | |
1738 | |
1739 // if (dst == NULL) return -1; | |
304 | 1740 __ movptr(dst, DST); // dst oop |
1741 __ testptr(dst, dst); | |
0 | 1742 __ jccb(Assembler::zero, L_failed_0); |
1743 | |
1744 // if (dst_pos < 0) return -1; | |
304 | 1745 __ movl2ptr(dst_pos, DST_POS); // dst_pos |
0 | 1746 __ testl(dst_pos, dst_pos); |
1747 __ jccb(Assembler::negative, L_failed_0); | |
1748 | |
1749 // if (length < 0) return -1; | |
304 | 1750 __ movl2ptr(length, LENGTH); // length |
0 | 1751 __ testl(length, length); |
1752 __ jccb(Assembler::negative, L_failed_0); | |
1753 | |
1754 // if (src->klass() == NULL) return -1; | |
1755 Address src_klass_addr(src, oopDesc::klass_offset_in_bytes()); | |
1756 Address dst_klass_addr(dst, oopDesc::klass_offset_in_bytes()); | |
1757 const Register rcx_src_klass = rcx; // array klass | |
304 | 1758 __ movptr(rcx_src_klass, Address(src, oopDesc::klass_offset_in_bytes())); |
0 | 1759 |
1760 #ifdef ASSERT | |
1761 // assert(src->klass() != NULL); | |
1762 BLOCK_COMMENT("assert klasses not null"); | |
1763 { Label L1, L2; | |
304 | 1764 __ testptr(rcx_src_klass, rcx_src_klass); |
0 | 1765 __ jccb(Assembler::notZero, L2); // it is broken if klass is NULL |
1766 __ bind(L1); | |
1767 __ stop("broken null klass"); | |
1768 __ bind(L2); | |
304 | 1769 __ cmpptr(dst_klass_addr, (int32_t)NULL_WORD); |
0 | 1770 __ jccb(Assembler::equal, L1); // this would be broken also |
1771 BLOCK_COMMENT("assert done"); | |
1772 } | |
1773 #endif //ASSERT | |
1774 | |
1775 // Load layout helper (32-bits) | |
1776 // | |
1777 // |array_tag| | header_size | element_type | |log2_element_size| | |
1778 // 32 30 24 16 8 2 0 | |
1779 // | |
1780 // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0 | |
1781 // | |
1782 | |
1783 int lh_offset = klassOopDesc::header_size() * HeapWordSize + | |
1784 Klass::layout_helper_offset_in_bytes(); | |
1785 Address src_klass_lh_addr(rcx_src_klass, lh_offset); | |
1786 | |
1787 // Handle objArrays completely differently... | |
1788 jint objArray_lh = Klass::array_layout_helper(T_OBJECT); | |
1789 __ cmpl(src_klass_lh_addr, objArray_lh); | |
1790 __ jcc(Assembler::equal, L_objArray); | |
1791 | |
1792 // if (src->klass() != dst->klass()) return -1; | |
304 | 1793 __ cmpptr(rcx_src_klass, dst_klass_addr); |
0 | 1794 __ jccb(Assembler::notEqual, L_failed_0); |
1795 | |
1796 const Register rcx_lh = rcx; // layout helper | |
1797 assert(rcx_lh == rcx_src_klass, "known alias"); | |
1798 __ movl(rcx_lh, src_klass_lh_addr); | |
1799 | |
1800 // if (!src->is_Array()) return -1; | |
1801 __ cmpl(rcx_lh, Klass::_lh_neutral_value); | |
1802 __ jcc(Assembler::greaterEqual, L_failed_0); // signed cmp | |
1803 | |
1804 // At this point, it is known to be a typeArray (array_tag 0x3). | |
1805 #ifdef ASSERT | |
1806 { Label L; | |
1807 __ cmpl(rcx_lh, (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift)); | |
1808 __ jcc(Assembler::greaterEqual, L); // signed cmp | |
1809 __ stop("must be a primitive array"); | |
1810 __ bind(L); | |
1811 } | |
1812 #endif | |
1813 | |
1814 assert_different_registers(src, src_pos, dst, dst_pos, rcx_lh); | |
1815 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); | |
1816 | |
1817 // typeArrayKlass | |
1818 // | |
1819 // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize); | |
1820 // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize); | |
1821 // | |
1822 const Register rsi_offset = rsi; // array offset | |
1823 const Register src_array = src; // src array offset | |
1824 const Register dst_array = dst; // dst array offset | |
1825 const Register rdi_elsize = rdi; // log2 element size | |
1826 | |
304 | 1827 __ mov(rsi_offset, rcx_lh); |
1828 __ shrptr(rsi_offset, Klass::_lh_header_size_shift); | |
1829 __ andptr(rsi_offset, Klass::_lh_header_size_mask); // array_offset | |
1830 __ addptr(src_array, rsi_offset); // src array offset | |
1831 __ addptr(dst_array, rsi_offset); // dst array offset | |
1832 __ andptr(rcx_lh, Klass::_lh_log2_element_size_mask); // log2 elsize | |
0 | 1833 |
1834 // next registers should be set before the jump to corresponding stub | |
1835 const Register from = src; // source array address | |
1836 const Register to = dst; // destination array address | |
1837 const Register count = rcx; // elements count | |
1838 // some of them should be duplicated on stack | |
1839 #define FROM Address(rsp, 12+ 4) | |
1840 #define TO Address(rsp, 12+ 8) // Not used now | |
1841 #define COUNT Address(rsp, 12+12) // Only for oop arraycopy | |
1842 | |
1843 BLOCK_COMMENT("scale indexes to element size"); | |
304 | 1844 __ movl2ptr(rsi, SRC_POS); // src_pos |
1845 __ shlptr(rsi); // src_pos << rcx (log2 elsize) | |
0 | 1846 assert(src_array == from, ""); |
304 | 1847 __ addptr(from, rsi); // from = src_array + SRC_POS << log2 elsize |
1848 __ movl2ptr(rdi, DST_POS); // dst_pos | |
1849 __ shlptr(rdi); // dst_pos << rcx (log2 elsize) | |
0 | 1850 assert(dst_array == to, ""); |
304 | 1851 __ addptr(to, rdi); // to = dst_array + DST_POS << log2 elsize |
1852 __ movptr(FROM, from); // src_addr | |
1853 __ mov(rdi_elsize, rcx_lh); // log2 elsize | |
1854 __ movl2ptr(count, LENGTH); // elements count | |
0 | 1855 |
1856 BLOCK_COMMENT("choose copy loop based on element size"); | |
1857 __ cmpl(rdi_elsize, 0); | |
1858 | |
1859 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jbyte_arraycopy)); | |
1860 __ cmpl(rdi_elsize, LogBytesPerShort); | |
1861 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jshort_arraycopy)); | |
1862 __ cmpl(rdi_elsize, LogBytesPerInt); | |
1863 __ jump_cc(Assembler::equal, RuntimeAddress(entry_jint_arraycopy)); | |
1864 #ifdef ASSERT | |
1865 __ cmpl(rdi_elsize, LogBytesPerLong); | |
1866 __ jccb(Assembler::notEqual, L_failed); | |
1867 #endif | |
304 | 1868 __ pop(rdi); // Do pops here since jlong_arraycopy stub does not do it. |
1869 __ pop(rsi); | |
0 | 1870 __ jump(RuntimeAddress(entry_jlong_arraycopy)); |
1871 | |
1872 __ BIND(L_failed); | |
304 | 1873 __ xorptr(rax, rax); |
1874 __ notptr(rax); // return -1 | |
1875 __ pop(rdi); | |
1876 __ pop(rsi); | |
0 | 1877 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1878 __ ret(0); | |
1879 | |
1880 // objArrayKlass | |
1881 __ BIND(L_objArray); | |
1882 // live at this point: rcx_src_klass, src[_pos], dst[_pos] | |
1883 | |
1884 Label L_plain_copy, L_checkcast_copy; | |
1885 // test array classes for subtyping | |
304 | 1886 __ cmpptr(rcx_src_klass, dst_klass_addr); // usual case is exact equality |
0 | 1887 __ jccb(Assembler::notEqual, L_checkcast_copy); |
1888 | |
1889 // Identically typed arrays can be copied without element-wise checks. | |
1890 assert_different_registers(src, src_pos, dst, dst_pos, rcx_src_klass); | |
1891 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); | |
1892 | |
1893 __ BIND(L_plain_copy); | |
304 | 1894 __ movl2ptr(count, LENGTH); // elements count |
1895 __ movl2ptr(src_pos, SRC_POS); // reload src_pos | |
1896 __ lea(from, Address(src, src_pos, Address::times_ptr, | |
1897 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr | |
1898 __ movl2ptr(dst_pos, DST_POS); // reload dst_pos | |
1899 __ lea(to, Address(dst, dst_pos, Address::times_ptr, | |
1900 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr | |
1901 __ movptr(FROM, from); // src_addr | |
1902 __ movptr(TO, to); // dst_addr | |
0 | 1903 __ movl(COUNT, count); // count |
1904 __ jump(RuntimeAddress(entry_oop_arraycopy)); | |
1905 | |
1906 __ BIND(L_checkcast_copy); | |
1907 // live at this point: rcx_src_klass, dst[_pos], src[_pos] | |
1908 { | |
1909 // Handy offsets: | |
1910 int ek_offset = (klassOopDesc::header_size() * HeapWordSize + | |
1911 objArrayKlass::element_klass_offset_in_bytes()); | |
1912 int sco_offset = (klassOopDesc::header_size() * HeapWordSize + | |
1913 Klass::super_check_offset_offset_in_bytes()); | |
1914 | |
1915 Register rsi_dst_klass = rsi; | |
1916 Register rdi_temp = rdi; | |
1917 assert(rsi_dst_klass == src_pos, "expected alias w/ src_pos"); | |
1918 assert(rdi_temp == dst_pos, "expected alias w/ dst_pos"); | |
1919 Address dst_klass_lh_addr(rsi_dst_klass, lh_offset); | |
1920 | |
1921 // Before looking at dst.length, make sure dst is also an objArray. | |
304 | 1922 __ movptr(rsi_dst_klass, dst_klass_addr); |
0 | 1923 __ cmpl(dst_klass_lh_addr, objArray_lh); |
1924 __ jccb(Assembler::notEqual, L_failed); | |
1925 | |
1926 // It is safe to examine both src.length and dst.length. | |
304 | 1927 __ movl2ptr(src_pos, SRC_POS); // reload rsi |
0 | 1928 arraycopy_range_checks(src, src_pos, dst, dst_pos, LENGTH, L_failed); |
1929 // (Now src_pos and dst_pos are killed, but not src and dst.) | |
1930 | |
1931 // We'll need this temp (don't forget to pop it after the type check). | |
304 | 1932 __ push(rbx); |
0 | 1933 Register rbx_src_klass = rbx; |
1934 | |
304 | 1935 __ mov(rbx_src_klass, rcx_src_klass); // spill away from rcx |
1936 __ movptr(rsi_dst_klass, dst_klass_addr); | |
0 | 1937 Address super_check_offset_addr(rsi_dst_klass, sco_offset); |
1938 Label L_fail_array_check; | |
1939 generate_type_check(rbx_src_klass, | |
1940 super_check_offset_addr, dst_klass_addr, | |
1941 rdi_temp, NULL, &L_fail_array_check); | |
1942 // (On fall-through, we have passed the array type check.) | |
304 | 1943 __ pop(rbx); |
0 | 1944 __ jmp(L_plain_copy); |
1945 | |
1946 __ BIND(L_fail_array_check); | |
1947 // Reshuffle arguments so we can call checkcast_arraycopy: | |
1948 | |
1949 // match initial saves for checkcast_arraycopy | |
304 | 1950 // push(rsi); // already done; see above |
1951 // push(rdi); // already done; see above | |
1952 // push(rbx); // already done; see above | |
0 | 1953 |
1954 // Marshal outgoing arguments now, freeing registers. | |
1955 Address from_arg(rsp, 16+ 4); // from | |
1956 Address to_arg(rsp, 16+ 8); // to | |
1957 Address length_arg(rsp, 16+12); // elements count | |
1958 Address ckoff_arg(rsp, 16+16); // super_check_offset | |
1959 Address ckval_arg(rsp, 16+20); // super_klass | |
1960 | |
1961 Address SRC_POS_arg(rsp, 16+ 8); | |
1962 Address DST_POS_arg(rsp, 16+16); | |
1963 Address LENGTH_arg(rsp, 16+20); | |
1964 // push rbx, changed the incoming offsets (why not just use rbp,??) | |
1965 // assert(SRC_POS_arg.disp() == SRC_POS.disp() + 4, ""); | |
1966 | |
304 | 1967 __ movptr(rbx, Address(rsi_dst_klass, ek_offset)); |
1968 __ movl2ptr(length, LENGTH_arg); // reload elements count | |
1969 __ movl2ptr(src_pos, SRC_POS_arg); // reload src_pos | |
1970 __ movl2ptr(dst_pos, DST_POS_arg); // reload dst_pos | |
0 | 1971 |
304 | 1972 __ movptr(ckval_arg, rbx); // destination element type |
0 | 1973 __ movl(rbx, Address(rbx, sco_offset)); |
1974 __ movl(ckoff_arg, rbx); // corresponding class check offset | |
1975 | |
1976 __ movl(length_arg, length); // outgoing length argument | |
1977 | |
304 | 1978 __ lea(from, Address(src, src_pos, Address::times_ptr, |
0 | 1979 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
304 | 1980 __ movptr(from_arg, from); |
0 | 1981 |
304 | 1982 __ lea(to, Address(dst, dst_pos, Address::times_ptr, |
0 | 1983 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
304 | 1984 __ movptr(to_arg, to); |
0 | 1985 __ jump(RuntimeAddress(entry_checkcast_arraycopy)); |
1986 } | |
1987 | |
1988 return start; | |
1989 } | |
1990 | |
1991 void generate_arraycopy_stubs() { | |
1992 address entry; | |
1993 address entry_jbyte_arraycopy; | |
1994 address entry_jshort_arraycopy; | |
1995 address entry_jint_arraycopy; | |
1996 address entry_oop_arraycopy; | |
1997 address entry_jlong_arraycopy; | |
1998 address entry_checkcast_arraycopy; | |
1999 | |
2000 StubRoutines::_arrayof_jbyte_disjoint_arraycopy = | |
2001 generate_disjoint_copy(T_BYTE, true, Address::times_1, &entry, | |
2002 "arrayof_jbyte_disjoint_arraycopy"); | |
2003 StubRoutines::_arrayof_jbyte_arraycopy = | |
2004 generate_conjoint_copy(T_BYTE, true, Address::times_1, entry, | |
2005 NULL, "arrayof_jbyte_arraycopy"); | |
2006 StubRoutines::_jbyte_disjoint_arraycopy = | |
2007 generate_disjoint_copy(T_BYTE, false, Address::times_1, &entry, | |
2008 "jbyte_disjoint_arraycopy"); | |
2009 StubRoutines::_jbyte_arraycopy = | |
2010 generate_conjoint_copy(T_BYTE, false, Address::times_1, entry, | |
2011 &entry_jbyte_arraycopy, "jbyte_arraycopy"); | |
2012 | |
2013 StubRoutines::_arrayof_jshort_disjoint_arraycopy = | |
2014 generate_disjoint_copy(T_SHORT, true, Address::times_2, &entry, | |
2015 "arrayof_jshort_disjoint_arraycopy"); | |
2016 StubRoutines::_arrayof_jshort_arraycopy = | |
2017 generate_conjoint_copy(T_SHORT, true, Address::times_2, entry, | |
2018 NULL, "arrayof_jshort_arraycopy"); | |
2019 StubRoutines::_jshort_disjoint_arraycopy = | |
2020 generate_disjoint_copy(T_SHORT, false, Address::times_2, &entry, | |
2021 "jshort_disjoint_arraycopy"); | |
2022 StubRoutines::_jshort_arraycopy = | |
2023 generate_conjoint_copy(T_SHORT, false, Address::times_2, entry, | |
2024 &entry_jshort_arraycopy, "jshort_arraycopy"); | |
2025 | |
2026 // Next arrays are always aligned on 4 bytes at least. | |
2027 StubRoutines::_jint_disjoint_arraycopy = | |
2028 generate_disjoint_copy(T_INT, true, Address::times_4, &entry, | |
2029 "jint_disjoint_arraycopy"); | |
2030 StubRoutines::_jint_arraycopy = | |
2031 generate_conjoint_copy(T_INT, true, Address::times_4, entry, | |
2032 &entry_jint_arraycopy, "jint_arraycopy"); | |
2033 | |
2034 StubRoutines::_oop_disjoint_arraycopy = | |
304 | 2035 generate_disjoint_copy(T_OBJECT, true, Address::times_ptr, &entry, |
0 | 2036 "oop_disjoint_arraycopy"); |
2037 StubRoutines::_oop_arraycopy = | |
304 | 2038 generate_conjoint_copy(T_OBJECT, true, Address::times_ptr, entry, |
0 | 2039 &entry_oop_arraycopy, "oop_arraycopy"); |
2040 | |
2041 StubRoutines::_jlong_disjoint_arraycopy = | |
2042 generate_disjoint_long_copy(&entry, "jlong_disjoint_arraycopy"); | |
2043 StubRoutines::_jlong_arraycopy = | |
2044 generate_conjoint_long_copy(entry, &entry_jlong_arraycopy, | |
2045 "jlong_arraycopy"); | |
2046 | |
1763 | 2047 StubRoutines::_jbyte_fill = generate_fill(T_BYTE, false, "jbyte_fill"); |
2048 StubRoutines::_jshort_fill = generate_fill(T_SHORT, false, "jshort_fill"); | |
2049 StubRoutines::_jint_fill = generate_fill(T_INT, false, "jint_fill"); | |
2050 StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill"); | |
2051 StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill"); | |
2052 StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill"); | |
2053 | |
0 | 2054 StubRoutines::_arrayof_jint_disjoint_arraycopy = |
2055 StubRoutines::_jint_disjoint_arraycopy; | |
2056 StubRoutines::_arrayof_oop_disjoint_arraycopy = | |
2057 StubRoutines::_oop_disjoint_arraycopy; | |
2058 StubRoutines::_arrayof_jlong_disjoint_arraycopy = | |
2059 StubRoutines::_jlong_disjoint_arraycopy; | |
2060 | |
2061 StubRoutines::_arrayof_jint_arraycopy = StubRoutines::_jint_arraycopy; | |
2062 StubRoutines::_arrayof_oop_arraycopy = StubRoutines::_oop_arraycopy; | |
2063 StubRoutines::_arrayof_jlong_arraycopy = StubRoutines::_jlong_arraycopy; | |
2064 | |
2065 StubRoutines::_checkcast_arraycopy = | |
2066 generate_checkcast_copy("checkcast_arraycopy", | |
2067 &entry_checkcast_arraycopy); | |
2068 | |
2069 StubRoutines::_unsafe_arraycopy = | |
2070 generate_unsafe_copy("unsafe_arraycopy", | |
2071 entry_jbyte_arraycopy, | |
2072 entry_jshort_arraycopy, | |
2073 entry_jint_arraycopy, | |
2074 entry_jlong_arraycopy); | |
2075 | |
2076 StubRoutines::_generic_arraycopy = | |
2077 generate_generic_copy("generic_arraycopy", | |
2078 entry_jbyte_arraycopy, | |
2079 entry_jshort_arraycopy, | |
2080 entry_jint_arraycopy, | |
2081 entry_oop_arraycopy, | |
2082 entry_jlong_arraycopy, | |
2083 entry_checkcast_arraycopy); | |
2084 } | |
2085 | |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2086 void generate_math_stubs() { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2087 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2088 StubCodeMark mark(this, "StubRoutines", "log"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2089 StubRoutines::_intrinsic_log = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2090 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2091 __ fld_d(Address(rsp, 4)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2092 __ flog(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2093 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2094 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2095 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2096 StubCodeMark mark(this, "StubRoutines", "log10"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2097 StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2098 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2099 __ fld_d(Address(rsp, 4)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2100 __ flog10(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2101 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2102 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2103 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2104 StubCodeMark mark(this, "StubRoutines", "sin"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2105 StubRoutines::_intrinsic_sin = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2106 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2107 __ fld_d(Address(rsp, 4)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2108 __ trigfunc('s'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2109 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2110 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2111 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2112 StubCodeMark mark(this, "StubRoutines", "cos"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2113 StubRoutines::_intrinsic_cos = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2114 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2115 __ fld_d(Address(rsp, 4)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2116 __ trigfunc('c'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2117 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2118 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2119 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2120 StubCodeMark mark(this, "StubRoutines", "tan"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2121 StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2122 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2123 __ fld_d(Address(rsp, 4)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2124 __ trigfunc('t'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2125 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2126 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2127 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2128 // The intrinsic version of these seem to return the same value as |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2129 // the strict version. |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2130 StubRoutines::_intrinsic_exp = SharedRuntime::dexp; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2131 StubRoutines::_intrinsic_pow = SharedRuntime::dpow; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2132 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2133 |
0 | 2134 public: |
2135 // Information about frame layout at time of blocking runtime call. | |
2136 // Note that we only have to preserve callee-saved registers since | |
2137 // the compilers are responsible for supplying a continuation point | |
2138 // if they expect all registers to be preserved. | |
2139 enum layout { | |
2140 thread_off, // last_java_sp | |
2141 rbp_off, // callee saved register | |
2142 ret_pc, | |
2143 framesize | |
2144 }; | |
2145 | |
2146 private: | |
2147 | |
2148 #undef __ | |
2149 #define __ masm-> | |
2150 | |
2151 //------------------------------------------------------------------------------------------------------------------------ | |
2152 // Continuation point for throwing of implicit exceptions that are not handled in | |
2153 // the current activation. Fabricates an exception oop and initiates normal | |
2154 // exception dispatching in this frame. | |
2155 // | |
2156 // Previously the compiler (c2) allowed for callee save registers on Java calls. | |
2157 // This is no longer true after adapter frames were removed but could possibly | |
2158 // be brought back in the future if the interpreter code was reworked and it | |
2159 // was deemed worthwhile. The comment below was left to describe what must | |
2160 // happen here if callee saves were resurrected. As it stands now this stub | |
2161 // could actually be a vanilla BufferBlob and have now oopMap at all. | |
2162 // Since it doesn't make much difference we've chosen to leave it the | |
2163 // way it was in the callee save days and keep the comment. | |
2164 | |
2165 // If we need to preserve callee-saved values we need a callee-saved oop map and | |
2166 // therefore have to make these stubs into RuntimeStubs rather than BufferBlobs. | |
2167 // If the compiler needs all registers to be preserved between the fault | |
2168 // point and the exception handler then it must assume responsibility for that in | |
2169 // AbstractCompiler::continuation_for_implicit_null_exception or | |
2170 // continuation_for_implicit_division_by_zero_exception. All other implicit | |
2171 // exceptions (e.g., NullPointerException or AbstractMethodError on entry) are | |
2172 // either at call sites or otherwise assume that stack unwinding will be initiated, | |
2173 // so caller saved registers were assumed volatile in the compiler. | |
2174 address generate_throw_exception(const char* name, address runtime_entry, | |
2175 bool restore_saved_exception_pc) { | |
2176 | |
2177 int insts_size = 256; | |
2178 int locs_size = 32; | |
2179 | |
2180 CodeBuffer code(name, insts_size, locs_size); | |
2181 OopMapSet* oop_maps = new OopMapSet(); | |
2182 MacroAssembler* masm = new MacroAssembler(&code); | |
2183 | |
2184 address start = __ pc(); | |
2185 | |
2186 // This is an inlined and slightly modified version of call_VM | |
2187 // which has the ability to fetch the return PC out of | |
2188 // thread-local storage and also sets up last_Java_sp slightly | |
2189 // differently than the real call_VM | |
2190 Register java_thread = rbx; | |
2191 __ get_thread(java_thread); | |
2192 if (restore_saved_exception_pc) { | |
304 | 2193 __ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset()))); |
2194 __ push(rax); | |
0 | 2195 } |
2196 | |
2197 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2198 | |
2199 // pc and rbp, already pushed | |
304 | 2200 __ subptr(rsp, (framesize-2) * wordSize); // prolog |
0 | 2201 |
2202 // Frame is now completed as far as size and linkage. | |
2203 | |
2204 int frame_complete = __ pc() - start; | |
2205 | |
2206 // push java thread (becomes first argument of C function) | |
304 | 2207 __ movptr(Address(rsp, thread_off * wordSize), java_thread); |
0 | 2208 |
2209 // Set up last_Java_sp and last_Java_fp | |
2210 __ set_last_Java_frame(java_thread, rsp, rbp, NULL); | |
2211 | |
2212 // Call runtime | |
2213 BLOCK_COMMENT("call runtime_entry"); | |
2214 __ call(RuntimeAddress(runtime_entry)); | |
2215 // Generate oop map | |
2216 OopMap* map = new OopMap(framesize, 0); | |
2217 oop_maps->add_gc_map(__ pc() - start, map); | |
2218 | |
2219 // restore the thread (cannot use the pushed argument since arguments | |
2220 // may be overwritten by C code generated by an optimizing compiler); | |
2221 // however can use the register value directly if it is callee saved. | |
2222 __ get_thread(java_thread); | |
2223 | |
2224 __ reset_last_Java_frame(java_thread, true, false); | |
2225 | |
2226 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
2227 | |
2228 // check for pending exceptions | |
2229 #ifdef ASSERT | |
2230 Label L; | |
304 | 2231 __ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
0 | 2232 __ jcc(Assembler::notEqual, L); |
2233 __ should_not_reach_here(); | |
2234 __ bind(L); | |
2235 #endif /* ASSERT */ | |
2236 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); | |
2237 | |
2238 | |
2239 RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &code, frame_complete, framesize, oop_maps, false); | |
2240 return stub->entry_point(); | |
2241 } | |
2242 | |
2243 | |
2244 void create_control_words() { | |
2245 // Round to nearest, 53-bit mode, exceptions masked | |
2246 StubRoutines::_fpu_cntrl_wrd_std = 0x027F; | |
2247 // Round to zero, 53-bit mode, exception mased | |
2248 StubRoutines::_fpu_cntrl_wrd_trunc = 0x0D7F; | |
2249 // Round to nearest, 24-bit mode, exceptions masked | |
2250 StubRoutines::_fpu_cntrl_wrd_24 = 0x007F; | |
2251 // Round to nearest, 64-bit mode, exceptions masked | |
2252 StubRoutines::_fpu_cntrl_wrd_64 = 0x037F; | |
2253 // Round to nearest, 64-bit mode, exceptions masked | |
2254 StubRoutines::_mxcsr_std = 0x1F80; | |
2255 // Note: the following two constants are 80-bit values | |
2256 // layout is critical for correct loading by FPU. | |
2257 // Bias for strict fp multiply/divide | |
2258 StubRoutines::_fpu_subnormal_bias1[0]= 0x00000000; // 2^(-15360) == 0x03ff 8000 0000 0000 0000 | |
2259 StubRoutines::_fpu_subnormal_bias1[1]= 0x80000000; | |
2260 StubRoutines::_fpu_subnormal_bias1[2]= 0x03ff; | |
2261 // Un-Bias for strict fp multiply/divide | |
2262 StubRoutines::_fpu_subnormal_bias2[0]= 0x00000000; // 2^(+15360) == 0x7bff 8000 0000 0000 0000 | |
2263 StubRoutines::_fpu_subnormal_bias2[1]= 0x80000000; | |
2264 StubRoutines::_fpu_subnormal_bias2[2]= 0x7bff; | |
2265 } | |
2266 | |
2267 //--------------------------------------------------------------------------- | |
2268 // Initialization | |
2269 | |
2270 void generate_initial() { | |
2271 // Generates all stubs and initializes the entry points | |
2272 | |
2273 //------------------------------------------------------------------------------------------------------------------------ | |
2274 // entry points that exist in all platforms | |
2275 // Note: This is code that could be shared among different platforms - however the benefit seems to be smaller than | |
2276 // the disadvantage of having a much more complicated generator structure. See also comment in stubRoutines.hpp. | |
2277 StubRoutines::_forward_exception_entry = generate_forward_exception(); | |
2278 | |
2279 StubRoutines::_call_stub_entry = | |
2280 generate_call_stub(StubRoutines::_call_stub_return_address); | |
2281 // is referenced by megamorphic call | |
2282 StubRoutines::_catch_exception_entry = generate_catch_exception(); | |
2283 | |
2284 // These are currently used by Solaris/Intel | |
2285 StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); | |
2286 | |
2287 StubRoutines::_handler_for_unsafe_access_entry = | |
2288 generate_handler_for_unsafe_access(); | |
2289 | |
2290 // platform dependent | |
2291 create_control_words(); | |
2292 | |
304 | 2293 StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr(); |
2294 StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = generate_verify_fpu_cntrl_wrd(); | |
0 | 2295 StubRoutines::_d2i_wrapper = generate_d2i_wrapper(T_INT, |
2296 CAST_FROM_FN_PTR(address, SharedRuntime::d2i)); | |
2297 StubRoutines::_d2l_wrapper = generate_d2i_wrapper(T_LONG, | |
2298 CAST_FROM_FN_PTR(address, SharedRuntime::d2l)); | |
2299 } | |
2300 | |
2301 | |
2302 void generate_all() { | |
2303 // Generates all stubs and initializes the entry points | |
2304 | |
2305 // These entry points require SharedInfo::stack0 to be set up in non-core builds | |
2306 // and need to be relocatable, so they each fabricate a RuntimeStub internally. | |
2307 StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError), false); | |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
2308 StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); |
0 | 2309 StubRoutines::_throw_ArithmeticException_entry = generate_throw_exception("ArithmeticException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException), true); |
2310 StubRoutines::_throw_NullPointerException_entry = generate_throw_exception("NullPointerException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true); | |
2311 StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false); | |
2312 StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false); | |
2313 | |
2314 //------------------------------------------------------------------------------------------------------------------------ | |
2315 // entry points that are platform specific | |
2316 | |
2317 // support for verify_oop (must happen after universe_init) | |
2318 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); | |
2319 | |
2320 // arraycopy stubs used by compilers | |
2321 generate_arraycopy_stubs(); | |
710 | 2322 |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
845
diff
changeset
|
2323 generate_math_stubs(); |
0 | 2324 } |
2325 | |
2326 | |
2327 public: | |
2328 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { | |
2329 if (all) { | |
2330 generate_all(); | |
2331 } else { | |
2332 generate_initial(); | |
2333 } | |
2334 } | |
2335 }; // end class declaration | |
2336 | |
2337 | |
2338 void StubGenerator_generate(CodeBuffer* code, bool all) { | |
2339 StubGenerator g(code, all); | |
2340 } |