Mercurial > hg > truffle
annotate src/cpu/x86/vm/stubGenerator_x86_64.cpp @ 4114:6729bbc1fcd6
7003454: order constants in constant table by number of references in code
Reviewed-by: kvn, never, bdelsart
author | twisti |
---|---|
date | Wed, 16 Nov 2011 01:39:50 -0800 |
parents | f08d439fab8c |
children | 59bc0d4d9ea3 |
rev | line source |
---|---|
0 | 1 /* |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2 * Copyright (c) 2003, 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 | |
3960 | 50 #ifdef TARGET_OS_FAMILY_bsd |
51 # include "thread_bsd.inline.hpp" | |
52 #endif | |
1972 | 53 #ifdef COMPILER2 |
54 #include "opto/runtime.hpp" | |
55 #endif | |
0 | 56 |
57 // Declaration and definition of StubGenerator (no .hpp file). | |
58 // For a more detailed description of the stub routine structure | |
59 // see the comment in stubRoutines.hpp | |
60 | |
61 #define __ _masm-> | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
62 #define TIMES_OOP (UseCompressedOops ? Address::times_4 : Address::times_8) |
304 | 63 #define a__ ((Assembler*)_masm)-> |
0 | 64 |
65 #ifdef PRODUCT | |
66 #define BLOCK_COMMENT(str) /* nothing */ | |
67 #else | |
68 #define BLOCK_COMMENT(str) __ block_comment(str) | |
69 #endif | |
70 | |
71 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") | |
72 const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions | |
73 | |
74 // Stub Code definitions | |
75 | |
76 static address handle_unsafe_access() { | |
77 JavaThread* thread = JavaThread::current(); | |
78 address pc = thread->saved_exception_pc(); | |
79 // pc is the instruction which we must emulate | |
80 // doing a no-op is fine: return garbage from the load | |
81 // therefore, compute npc | |
82 address npc = Assembler::locate_next_instruction(pc); | |
83 | |
84 // request an async exception | |
85 thread->set_pending_unsafe_access_error(); | |
86 | |
87 // return address of next instruction to execute | |
88 return npc; | |
89 } | |
90 | |
91 class StubGenerator: public StubCodeGenerator { | |
92 private: | |
93 | |
94 #ifdef PRODUCT | |
95 #define inc_counter_np(counter) (0) | |
96 #else | |
97 void inc_counter_np_(int& counter) { | |
98 __ incrementl(ExternalAddress((address)&counter)); | |
99 } | |
100 #define inc_counter_np(counter) \ | |
101 BLOCK_COMMENT("inc_counter " #counter); \ | |
102 inc_counter_np_(counter); | |
103 #endif | |
104 | |
105 // Call stubs are used to call Java from C | |
106 // | |
107 // Linux Arguments: | |
108 // c_rarg0: call wrapper address address | |
109 // c_rarg1: result address | |
110 // c_rarg2: result type BasicType | |
111 // c_rarg3: method methodOop | |
112 // c_rarg4: (interpreter) entry point address | |
113 // c_rarg5: parameters intptr_t* | |
114 // 16(rbp): parameter size (in words) int | |
115 // 24(rbp): thread Thread* | |
116 // | |
117 // [ return_from_Java ] <--- rsp | |
118 // [ argument word n ] | |
119 // ... | |
120 // -12 [ argument word 1 ] | |
121 // -11 [ saved r15 ] <--- rsp_after_call | |
122 // -10 [ saved r14 ] | |
123 // -9 [ saved r13 ] | |
124 // -8 [ saved r12 ] | |
125 // -7 [ saved rbx ] | |
126 // -6 [ call wrapper ] | |
127 // -5 [ result ] | |
128 // -4 [ result type ] | |
129 // -3 [ method ] | |
130 // -2 [ entry point ] | |
131 // -1 [ parameters ] | |
132 // 0 [ saved rbp ] <--- rbp | |
133 // 1 [ return address ] | |
134 // 2 [ parameter size ] | |
135 // 3 [ thread ] | |
136 // | |
137 // Windows Arguments: | |
138 // c_rarg0: call wrapper address address | |
139 // c_rarg1: result address | |
140 // c_rarg2: result type BasicType | |
141 // c_rarg3: method methodOop | |
142 // 48(rbp): (interpreter) entry point address | |
143 // 56(rbp): parameters intptr_t* | |
144 // 64(rbp): parameter size (in words) int | |
145 // 72(rbp): thread Thread* | |
146 // | |
147 // [ return_from_Java ] <--- rsp | |
148 // [ argument word n ] | |
149 // ... | |
2407
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
150 // -28 [ argument word 1 ] |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
151 // -27 [ saved xmm15 ] <--- rsp_after_call |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
152 // [ saved xmm7-xmm14 ] |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
153 // -9 [ saved xmm6 ] (each xmm register takes 2 slots) |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
154 // -7 [ saved r15 ] |
0 | 155 // -6 [ saved r14 ] |
156 // -5 [ saved r13 ] | |
157 // -4 [ saved r12 ] | |
158 // -3 [ saved rdi ] | |
159 // -2 [ saved rsi ] | |
160 // -1 [ saved rbx ] | |
161 // 0 [ saved rbp ] <--- rbp | |
162 // 1 [ return address ] | |
163 // 2 [ call wrapper ] | |
164 // 3 [ result ] | |
165 // 4 [ result type ] | |
166 // 5 [ method ] | |
167 // 6 [ entry point ] | |
168 // 7 [ parameters ] | |
169 // 8 [ parameter size ] | |
170 // 9 [ thread ] | |
171 // | |
172 // Windows reserves the callers stack space for arguments 1-4. | |
173 // We spill c_rarg0-c_rarg3 to this space. | |
174 | |
175 // Call stub stack layout word offsets from rbp | |
176 enum call_stub_layout { | |
177 #ifdef _WIN64 | |
2407
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
178 xmm_save_first = 6, // save from xmm6 |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
179 xmm_save_last = 15, // to xmm15 |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
180 xmm_save_base = -9, |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
181 rsp_after_call_off = xmm_save_base - 2 * (xmm_save_last - xmm_save_first), // -27 |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
182 r15_off = -7, |
0 | 183 r14_off = -6, |
184 r13_off = -5, | |
185 r12_off = -4, | |
186 rdi_off = -3, | |
187 rsi_off = -2, | |
188 rbx_off = -1, | |
189 rbp_off = 0, | |
190 retaddr_off = 1, | |
191 call_wrapper_off = 2, | |
192 result_off = 3, | |
193 result_type_off = 4, | |
194 method_off = 5, | |
195 entry_point_off = 6, | |
196 parameters_off = 7, | |
197 parameter_size_off = 8, | |
198 thread_off = 9 | |
199 #else | |
200 rsp_after_call_off = -12, | |
201 mxcsr_off = rsp_after_call_off, | |
202 r15_off = -11, | |
203 r14_off = -10, | |
204 r13_off = -9, | |
205 r12_off = -8, | |
206 rbx_off = -7, | |
207 call_wrapper_off = -6, | |
208 result_off = -5, | |
209 result_type_off = -4, | |
210 method_off = -3, | |
211 entry_point_off = -2, | |
212 parameters_off = -1, | |
213 rbp_off = 0, | |
214 retaddr_off = 1, | |
215 parameter_size_off = 2, | |
216 thread_off = 3 | |
217 #endif | |
218 }; | |
219 | |
2407
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
220 #ifdef _WIN64 |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
221 Address xmm_save(int reg) { |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
222 assert(reg >= xmm_save_first && reg <= xmm_save_last, "XMM register number out of range"); |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
223 return Address(rbp, (xmm_save_base - (reg - xmm_save_first) * 2) * wordSize); |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
224 } |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
225 #endif |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
226 |
0 | 227 address generate_call_stub(address& return_address) { |
228 assert((int)frame::entry_frame_after_call_words == -(int)rsp_after_call_off + 1 && | |
229 (int)frame::entry_frame_call_wrapper_offset == (int)call_wrapper_off, | |
230 "adjust this code"); | |
231 StubCodeMark mark(this, "StubRoutines", "call_stub"); | |
232 address start = __ pc(); | |
233 | |
234 // same as in generate_catch_exception()! | |
235 const Address rsp_after_call(rbp, rsp_after_call_off * wordSize); | |
236 | |
237 const Address call_wrapper (rbp, call_wrapper_off * wordSize); | |
238 const Address result (rbp, result_off * wordSize); | |
239 const Address result_type (rbp, result_type_off * wordSize); | |
240 const Address method (rbp, method_off * wordSize); | |
241 const Address entry_point (rbp, entry_point_off * wordSize); | |
242 const Address parameters (rbp, parameters_off * wordSize); | |
243 const Address parameter_size(rbp, parameter_size_off * wordSize); | |
244 | |
245 // same as in generate_catch_exception()! | |
246 const Address thread (rbp, thread_off * wordSize); | |
247 | |
248 const Address r15_save(rbp, r15_off * wordSize); | |
249 const Address r14_save(rbp, r14_off * wordSize); | |
250 const Address r13_save(rbp, r13_off * wordSize); | |
251 const Address r12_save(rbp, r12_off * wordSize); | |
252 const Address rbx_save(rbp, rbx_off * wordSize); | |
253 | |
254 // stub code | |
255 __ enter(); | |
304 | 256 __ subptr(rsp, -rsp_after_call_off * wordSize); |
0 | 257 |
258 // save register parameters | |
259 #ifndef _WIN64 | |
304 | 260 __ movptr(parameters, c_rarg5); // parameters |
261 __ movptr(entry_point, c_rarg4); // entry_point | |
0 | 262 #endif |
263 | |
304 | 264 __ movptr(method, c_rarg3); // method |
265 __ movl(result_type, c_rarg2); // result type | |
266 __ movptr(result, c_rarg1); // result | |
267 __ movptr(call_wrapper, c_rarg0); // call wrapper | |
0 | 268 |
269 // save regs belonging to calling function | |
304 | 270 __ movptr(rbx_save, rbx); |
271 __ movptr(r12_save, r12); | |
272 __ movptr(r13_save, r13); | |
273 __ movptr(r14_save, r14); | |
274 __ movptr(r15_save, r15); | |
0 | 275 #ifdef _WIN64 |
2407
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
276 for (int i = 6; i <= 15; i++) { |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
277 __ movdqu(xmm_save(i), as_XMMRegister(i)); |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
278 } |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
279 |
0 | 280 const Address rdi_save(rbp, rdi_off * wordSize); |
281 const Address rsi_save(rbp, rsi_off * wordSize); | |
282 | |
304 | 283 __ movptr(rsi_save, rsi); |
284 __ movptr(rdi_save, rdi); | |
0 | 285 #else |
286 const Address mxcsr_save(rbp, mxcsr_off * wordSize); | |
287 { | |
288 Label skip_ldmx; | |
289 __ stmxcsr(mxcsr_save); | |
290 __ movl(rax, mxcsr_save); | |
291 __ andl(rax, MXCSR_MASK); // Only check control and mask bits | |
304 | 292 ExternalAddress mxcsr_std(StubRoutines::x86::mxcsr_std()); |
0 | 293 __ cmp32(rax, mxcsr_std); |
294 __ jcc(Assembler::equal, skip_ldmx); | |
295 __ ldmxcsr(mxcsr_std); | |
296 __ bind(skip_ldmx); | |
297 } | |
298 #endif | |
299 | |
300 // Load up thread register | |
304 | 301 __ movptr(r15_thread, thread); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
302 __ reinit_heapbase(); |
0 | 303 |
304 #ifdef ASSERT | |
305 // make sure we have no pending exceptions | |
306 { | |
307 Label L; | |
304 | 308 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
0 | 309 __ jcc(Assembler::equal, L); |
310 __ stop("StubRoutines::call_stub: entered with pending exception"); | |
311 __ bind(L); | |
312 } | |
313 #endif | |
314 | |
315 // pass parameters if any | |
316 BLOCK_COMMENT("pass parameters if any"); | |
317 Label parameters_done; | |
318 __ movl(c_rarg3, parameter_size); | |
319 __ testl(c_rarg3, c_rarg3); | |
320 __ jcc(Assembler::zero, parameters_done); | |
321 | |
322 Label loop; | |
304 | 323 __ movptr(c_rarg2, parameters); // parameter pointer |
324 __ movl(c_rarg1, c_rarg3); // parameter counter is in c_rarg1 | |
0 | 325 __ BIND(loop); |
304 | 326 __ movptr(rax, Address(c_rarg2, 0));// get parameter |
327 __ addptr(c_rarg2, wordSize); // advance to next parameter | |
328 __ decrementl(c_rarg1); // decrement counter | |
329 __ push(rax); // pass parameter | |
0 | 330 __ jcc(Assembler::notZero, loop); |
331 | |
332 // call Java function | |
333 __ BIND(parameters_done); | |
304 | 334 __ movptr(rbx, method); // get methodOop |
335 __ movptr(c_rarg1, entry_point); // get entry_point | |
336 __ mov(r13, rsp); // set sender sp | |
0 | 337 BLOCK_COMMENT("call Java function"); |
338 __ call(c_rarg1); | |
339 | |
340 BLOCK_COMMENT("call_stub_return_address:"); | |
341 return_address = __ pc(); | |
342 | |
343 // store result depending on type (everything that is not | |
344 // T_OBJECT, T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT) | |
304 | 345 __ movptr(c_rarg0, result); |
0 | 346 Label is_long, is_float, is_double, exit; |
347 __ movl(c_rarg1, result_type); | |
348 __ cmpl(c_rarg1, T_OBJECT); | |
349 __ jcc(Assembler::equal, is_long); | |
350 __ cmpl(c_rarg1, T_LONG); | |
351 __ jcc(Assembler::equal, is_long); | |
352 __ cmpl(c_rarg1, T_FLOAT); | |
353 __ jcc(Assembler::equal, is_float); | |
354 __ cmpl(c_rarg1, T_DOUBLE); | |
355 __ jcc(Assembler::equal, is_double); | |
356 | |
357 // handle T_INT case | |
358 __ movl(Address(c_rarg0, 0), rax); | |
359 | |
360 __ BIND(exit); | |
361 | |
362 // pop parameters | |
304 | 363 __ lea(rsp, rsp_after_call); |
0 | 364 |
365 #ifdef ASSERT | |
366 // verify that threads correspond | |
367 { | |
368 Label L, S; | |
304 | 369 __ cmpptr(r15_thread, thread); |
0 | 370 __ jcc(Assembler::notEqual, S); |
371 __ get_thread(rbx); | |
304 | 372 __ cmpptr(r15_thread, rbx); |
0 | 373 __ jcc(Assembler::equal, L); |
374 __ bind(S); | |
375 __ jcc(Assembler::equal, L); | |
376 __ stop("StubRoutines::call_stub: threads must correspond"); | |
377 __ bind(L); | |
378 } | |
379 #endif | |
380 | |
381 // restore regs belonging to calling function | |
2407
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
382 #ifdef _WIN64 |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
383 for (int i = 15; i >= 6; i--) { |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
384 __ movdqu(as_XMMRegister(i), xmm_save(i)); |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
385 } |
b1c22848507b
6741940: Nonvolatile XMM registers not preserved across JNI calls
iveresov
parents:
2324
diff
changeset
|
386 #endif |
304 | 387 __ movptr(r15, r15_save); |
388 __ movptr(r14, r14_save); | |
389 __ movptr(r13, r13_save); | |
390 __ movptr(r12, r12_save); | |
391 __ movptr(rbx, rbx_save); | |
0 | 392 |
393 #ifdef _WIN64 | |
304 | 394 __ movptr(rdi, rdi_save); |
395 __ movptr(rsi, rsi_save); | |
0 | 396 #else |
397 __ ldmxcsr(mxcsr_save); | |
398 #endif | |
399 | |
400 // restore rsp | |
304 | 401 __ addptr(rsp, -rsp_after_call_off * wordSize); |
0 | 402 |
403 // return | |
304 | 404 __ pop(rbp); |
0 | 405 __ ret(0); |
406 | |
407 // handle return types different from T_INT | |
408 __ BIND(is_long); | |
409 __ movq(Address(c_rarg0, 0), rax); | |
410 __ jmp(exit); | |
411 | |
412 __ BIND(is_float); | |
413 __ movflt(Address(c_rarg0, 0), xmm0); | |
414 __ jmp(exit); | |
415 | |
416 __ BIND(is_double); | |
417 __ movdbl(Address(c_rarg0, 0), xmm0); | |
418 __ jmp(exit); | |
419 | |
420 return start; | |
421 } | |
422 | |
423 // Return point for a Java call if there's an exception thrown in | |
424 // Java code. The exception is caught and transformed into a | |
425 // pending exception stored in JavaThread that can be tested from | |
426 // within the VM. | |
427 // | |
428 // Note: Usually the parameters are removed by the callee. In case | |
429 // of an exception crossing an activation frame boundary, that is | |
430 // not the case if the callee is compiled code => need to setup the | |
431 // rsp. | |
432 // | |
433 // rax: exception oop | |
434 | |
435 address generate_catch_exception() { | |
436 StubCodeMark mark(this, "StubRoutines", "catch_exception"); | |
437 address start = __ pc(); | |
438 | |
439 // same as in generate_call_stub(): | |
440 const Address rsp_after_call(rbp, rsp_after_call_off * wordSize); | |
441 const Address thread (rbp, thread_off * wordSize); | |
442 | |
443 #ifdef ASSERT | |
444 // verify that threads correspond | |
445 { | |
446 Label L, S; | |
304 | 447 __ cmpptr(r15_thread, thread); |
0 | 448 __ jcc(Assembler::notEqual, S); |
449 __ get_thread(rbx); | |
304 | 450 __ cmpptr(r15_thread, rbx); |
0 | 451 __ jcc(Assembler::equal, L); |
452 __ bind(S); | |
453 __ stop("StubRoutines::catch_exception: threads must correspond"); | |
454 __ bind(L); | |
455 } | |
456 #endif | |
457 | |
458 // set pending exception | |
459 __ verify_oop(rax); | |
460 | |
304 | 461 __ movptr(Address(r15_thread, Thread::pending_exception_offset()), rax); |
0 | 462 __ lea(rscratch1, ExternalAddress((address)__FILE__)); |
304 | 463 __ movptr(Address(r15_thread, Thread::exception_file_offset()), rscratch1); |
0 | 464 __ movl(Address(r15_thread, Thread::exception_line_offset()), (int) __LINE__); |
465 | |
466 // complete return to VM | |
467 assert(StubRoutines::_call_stub_return_address != NULL, | |
468 "_call_stub_return_address must have been generated before"); | |
469 __ jump(RuntimeAddress(StubRoutines::_call_stub_return_address)); | |
470 | |
471 return start; | |
472 } | |
473 | |
474 // Continuation point for runtime calls returning with a pending | |
475 // exception. The pending exception check happened in the runtime | |
476 // or native call stub. The pending exception in Thread is | |
477 // converted into a Java-level exception. | |
478 // | |
479 // Contract with Java-level exception handlers: | |
480 // rax: exception | |
481 // rdx: throwing pc | |
482 // | |
483 // NOTE: At entry of this stub, exception-pc must be on stack !! | |
484 | |
485 address generate_forward_exception() { | |
486 StubCodeMark mark(this, "StubRoutines", "forward exception"); | |
487 address start = __ pc(); | |
488 | |
489 // Upon entry, the sp points to the return address returning into | |
490 // Java (interpreted or compiled) code; i.e., the return address | |
491 // becomes the throwing pc. | |
492 // | |
493 // Arguments pushed before the runtime call are still on the stack | |
494 // but the exception handler will reset the stack pointer -> | |
495 // ignore them. A potential result in registers can be ignored as | |
496 // well. | |
497 | |
498 #ifdef ASSERT | |
499 // make sure this code is only executed if there is a pending exception | |
500 { | |
501 Label L; | |
304 | 502 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL); |
0 | 503 __ jcc(Assembler::notEqual, L); |
504 __ stop("StubRoutines::forward exception: no pending exception (1)"); | |
505 __ bind(L); | |
506 } | |
507 #endif | |
508 | |
509 // compute exception handler into rbx | |
304 | 510 __ movptr(c_rarg0, Address(rsp, 0)); |
0 | 511 BLOCK_COMMENT("call exception_handler_for_return_address"); |
512 __ call_VM_leaf(CAST_FROM_FN_PTR(address, | |
513 SharedRuntime::exception_handler_for_return_address), | |
1295 | 514 r15_thread, c_rarg0); |
304 | 515 __ mov(rbx, rax); |
0 | 516 |
517 // setup rax & rdx, remove return address & clear pending exception | |
304 | 518 __ pop(rdx); |
519 __ movptr(rax, Address(r15_thread, Thread::pending_exception_offset())); | |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
520 __ movptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD); |
0 | 521 |
522 #ifdef ASSERT | |
523 // make sure exception is set | |
524 { | |
525 Label L; | |
304 | 526 __ testptr(rax, rax); |
0 | 527 __ jcc(Assembler::notEqual, L); |
528 __ stop("StubRoutines::forward exception: no pending exception (2)"); | |
529 __ bind(L); | |
530 } | |
531 #endif | |
532 | |
533 // continue at exception handler (return address removed) | |
534 // rax: exception | |
535 // rbx: exception handler | |
536 // rdx: throwing pc | |
537 __ verify_oop(rax); | |
538 __ jmp(rbx); | |
539 | |
540 return start; | |
541 } | |
542 | |
543 // Support for jint atomic::xchg(jint exchange_value, volatile jint* dest) | |
544 // | |
545 // Arguments : | |
546 // c_rarg0: exchange_value | |
547 // c_rarg0: dest | |
548 // | |
549 // Result: | |
550 // *dest <- ex, return (orig *dest) | |
551 address generate_atomic_xchg() { | |
552 StubCodeMark mark(this, "StubRoutines", "atomic_xchg"); | |
553 address start = __ pc(); | |
554 | |
555 __ movl(rax, c_rarg0); // Copy to eax we need a return value anyhow | |
556 __ xchgl(rax, Address(c_rarg1, 0)); // automatic LOCK | |
557 __ ret(0); | |
558 | |
559 return start; | |
560 } | |
561 | |
562 // Support for intptr_t atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) | |
563 // | |
564 // Arguments : | |
565 // c_rarg0: exchange_value | |
566 // c_rarg1: dest | |
567 // | |
568 // Result: | |
569 // *dest <- ex, return (orig *dest) | |
570 address generate_atomic_xchg_ptr() { | |
571 StubCodeMark mark(this, "StubRoutines", "atomic_xchg_ptr"); | |
572 address start = __ pc(); | |
573 | |
304 | 574 __ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow |
575 __ xchgptr(rax, Address(c_rarg1, 0)); // automatic LOCK | |
0 | 576 __ ret(0); |
577 | |
578 return start; | |
579 } | |
580 | |
581 // Support for jint atomic::atomic_cmpxchg(jint exchange_value, volatile jint* dest, | |
582 // jint compare_value) | |
583 // | |
584 // Arguments : | |
585 // c_rarg0: exchange_value | |
586 // c_rarg1: dest | |
587 // c_rarg2: compare_value | |
588 // | |
589 // Result: | |
590 // if ( compare_value == *dest ) { | |
591 // *dest = exchange_value | |
592 // return compare_value; | |
593 // else | |
594 // return *dest; | |
595 address generate_atomic_cmpxchg() { | |
596 StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg"); | |
597 address start = __ pc(); | |
598 | |
599 __ movl(rax, c_rarg2); | |
600 if ( os::is_MP() ) __ lock(); | |
601 __ cmpxchgl(c_rarg0, Address(c_rarg1, 0)); | |
602 __ ret(0); | |
603 | |
604 return start; | |
605 } | |
606 | |
607 // Support for jint atomic::atomic_cmpxchg_long(jlong exchange_value, | |
608 // volatile jlong* dest, | |
609 // jlong compare_value) | |
610 // Arguments : | |
611 // c_rarg0: exchange_value | |
612 // c_rarg1: dest | |
613 // c_rarg2: compare_value | |
614 // | |
615 // Result: | |
616 // if ( compare_value == *dest ) { | |
617 // *dest = exchange_value | |
618 // return compare_value; | |
619 // else | |
620 // return *dest; | |
621 address generate_atomic_cmpxchg_long() { | |
622 StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_long"); | |
623 address start = __ pc(); | |
624 | |
625 __ movq(rax, c_rarg2); | |
626 if ( os::is_MP() ) __ lock(); | |
627 __ cmpxchgq(c_rarg0, Address(c_rarg1, 0)); | |
628 __ ret(0); | |
629 | |
630 return start; | |
631 } | |
632 | |
633 // Support for jint atomic::add(jint add_value, volatile jint* dest) | |
634 // | |
635 // Arguments : | |
636 // c_rarg0: add_value | |
637 // c_rarg1: dest | |
638 // | |
639 // Result: | |
640 // *dest += add_value | |
641 // return *dest; | |
642 address generate_atomic_add() { | |
643 StubCodeMark mark(this, "StubRoutines", "atomic_add"); | |
644 address start = __ pc(); | |
645 | |
646 __ movl(rax, c_rarg0); | |
647 if ( os::is_MP() ) __ lock(); | |
648 __ xaddl(Address(c_rarg1, 0), c_rarg0); | |
649 __ addl(rax, c_rarg0); | |
650 __ ret(0); | |
651 | |
652 return start; | |
653 } | |
654 | |
655 // Support for intptr_t atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) | |
656 // | |
657 // Arguments : | |
658 // c_rarg0: add_value | |
659 // c_rarg1: dest | |
660 // | |
661 // Result: | |
662 // *dest += add_value | |
663 // return *dest; | |
664 address generate_atomic_add_ptr() { | |
665 StubCodeMark mark(this, "StubRoutines", "atomic_add_ptr"); | |
666 address start = __ pc(); | |
667 | |
304 | 668 __ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow |
0 | 669 if ( os::is_MP() ) __ lock(); |
304 | 670 __ xaddptr(Address(c_rarg1, 0), c_rarg0); |
671 __ addptr(rax, c_rarg0); | |
0 | 672 __ ret(0); |
673 | |
674 return start; | |
675 } | |
676 | |
677 // Support for intptr_t OrderAccess::fence() | |
678 // | |
679 // Arguments : | |
680 // | |
681 // Result: | |
682 address generate_orderaccess_fence() { | |
683 StubCodeMark mark(this, "StubRoutines", "orderaccess_fence"); | |
684 address start = __ pc(); | |
671
d0994e5bebce
6822204: volatile fences should prefer lock:addl to actual mfence instructions
never
parents:
647
diff
changeset
|
685 __ membar(Assembler::StoreLoad); |
0 | 686 __ ret(0); |
687 | |
688 return start; | |
689 } | |
690 | |
691 // Support for intptr_t get_previous_fp() | |
692 // | |
693 // This routine is used to find the previous frame pointer for the | |
694 // caller (current_frame_guess). This is used as part of debugging | |
695 // ps() is seemingly lost trying to find frames. | |
696 // This code assumes that caller current_frame_guess) has a frame. | |
697 address generate_get_previous_fp() { | |
698 StubCodeMark mark(this, "StubRoutines", "get_previous_fp"); | |
699 const Address old_fp(rbp, 0); | |
700 const Address older_fp(rax, 0); | |
701 address start = __ pc(); | |
702 | |
703 __ enter(); | |
304 | 704 __ movptr(rax, old_fp); // callers fp |
705 __ movptr(rax, older_fp); // the frame for ps() | |
706 __ pop(rbp); | |
0 | 707 __ ret(0); |
708 | |
709 return start; | |
710 } | |
711 | |
712 //---------------------------------------------------------------------------------------------------- | |
713 // Support for void verify_mxcsr() | |
714 // | |
715 // This routine is used with -Xcheck:jni to verify that native | |
716 // JNI code does not return to Java code without restoring the | |
717 // MXCSR register to our expected state. | |
718 | |
719 address generate_verify_mxcsr() { | |
720 StubCodeMark mark(this, "StubRoutines", "verify_mxcsr"); | |
721 address start = __ pc(); | |
722 | |
723 const Address mxcsr_save(rsp, 0); | |
724 | |
725 if (CheckJNICalls) { | |
726 Label ok_ret; | |
304 | 727 __ push(rax); |
728 __ subptr(rsp, wordSize); // allocate a temp location | |
0 | 729 __ stmxcsr(mxcsr_save); |
730 __ movl(rax, mxcsr_save); | |
731 __ andl(rax, MXCSR_MASK); // Only check control and mask bits | |
304 | 732 __ cmpl(rax, *(int *)(StubRoutines::x86::mxcsr_std())); |
0 | 733 __ jcc(Assembler::equal, ok_ret); |
734 | |
735 __ warn("MXCSR changed by native JNI code, use -XX:+RestoreMXCSROnJNICall"); | |
736 | |
304 | 737 __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); |
0 | 738 |
739 __ bind(ok_ret); | |
304 | 740 __ addptr(rsp, wordSize); |
741 __ pop(rax); | |
0 | 742 } |
743 | |
744 __ ret(0); | |
745 | |
746 return start; | |
747 } | |
748 | |
749 address generate_f2i_fixup() { | |
750 StubCodeMark mark(this, "StubRoutines", "f2i_fixup"); | |
751 Address inout(rsp, 5 * wordSize); // return address + 4 saves | |
752 | |
753 address start = __ pc(); | |
754 | |
755 Label L; | |
756 | |
304 | 757 __ push(rax); |
758 __ push(c_rarg3); | |
759 __ push(c_rarg2); | |
760 __ push(c_rarg1); | |
0 | 761 |
762 __ movl(rax, 0x7f800000); | |
763 __ xorl(c_rarg3, c_rarg3); | |
764 __ movl(c_rarg2, inout); | |
765 __ movl(c_rarg1, c_rarg2); | |
766 __ andl(c_rarg1, 0x7fffffff); | |
767 __ cmpl(rax, c_rarg1); // NaN? -> 0 | |
768 __ jcc(Assembler::negative, L); | |
769 __ testl(c_rarg2, c_rarg2); // signed ? min_jint : max_jint | |
770 __ movl(c_rarg3, 0x80000000); | |
771 __ movl(rax, 0x7fffffff); | |
772 __ cmovl(Assembler::positive, c_rarg3, rax); | |
773 | |
774 __ bind(L); | |
304 | 775 __ movptr(inout, c_rarg3); |
776 | |
777 __ pop(c_rarg1); | |
778 __ pop(c_rarg2); | |
779 __ pop(c_rarg3); | |
780 __ pop(rax); | |
0 | 781 |
782 __ ret(0); | |
783 | |
784 return start; | |
785 } | |
786 | |
787 address generate_f2l_fixup() { | |
788 StubCodeMark mark(this, "StubRoutines", "f2l_fixup"); | |
789 Address inout(rsp, 5 * wordSize); // return address + 4 saves | |
790 address start = __ pc(); | |
791 | |
792 Label L; | |
793 | |
304 | 794 __ push(rax); |
795 __ push(c_rarg3); | |
796 __ push(c_rarg2); | |
797 __ push(c_rarg1); | |
0 | 798 |
799 __ movl(rax, 0x7f800000); | |
800 __ xorl(c_rarg3, c_rarg3); | |
801 __ movl(c_rarg2, inout); | |
802 __ movl(c_rarg1, c_rarg2); | |
803 __ andl(c_rarg1, 0x7fffffff); | |
804 __ cmpl(rax, c_rarg1); // NaN? -> 0 | |
805 __ jcc(Assembler::negative, L); | |
806 __ testl(c_rarg2, c_rarg2); // signed ? min_jlong : max_jlong | |
807 __ mov64(c_rarg3, 0x8000000000000000); | |
808 __ mov64(rax, 0x7fffffffffffffff); | |
304 | 809 __ cmov(Assembler::positive, c_rarg3, rax); |
0 | 810 |
811 __ bind(L); | |
304 | 812 __ movptr(inout, c_rarg3); |
813 | |
814 __ pop(c_rarg1); | |
815 __ pop(c_rarg2); | |
816 __ pop(c_rarg3); | |
817 __ pop(rax); | |
0 | 818 |
819 __ ret(0); | |
820 | |
821 return start; | |
822 } | |
823 | |
824 address generate_d2i_fixup() { | |
825 StubCodeMark mark(this, "StubRoutines", "d2i_fixup"); | |
826 Address inout(rsp, 6 * wordSize); // return address + 5 saves | |
827 | |
828 address start = __ pc(); | |
829 | |
830 Label L; | |
831 | |
304 | 832 __ push(rax); |
833 __ push(c_rarg3); | |
834 __ push(c_rarg2); | |
835 __ push(c_rarg1); | |
836 __ push(c_rarg0); | |
0 | 837 |
838 __ movl(rax, 0x7ff00000); | |
839 __ movq(c_rarg2, inout); | |
840 __ movl(c_rarg3, c_rarg2); | |
304 | 841 __ mov(c_rarg1, c_rarg2); |
842 __ mov(c_rarg0, c_rarg2); | |
0 | 843 __ negl(c_rarg3); |
304 | 844 __ shrptr(c_rarg1, 0x20); |
0 | 845 __ orl(c_rarg3, c_rarg2); |
846 __ andl(c_rarg1, 0x7fffffff); | |
847 __ xorl(c_rarg2, c_rarg2); | |
848 __ shrl(c_rarg3, 0x1f); | |
849 __ orl(c_rarg1, c_rarg3); | |
850 __ cmpl(rax, c_rarg1); | |
851 __ jcc(Assembler::negative, L); // NaN -> 0 | |
304 | 852 __ testptr(c_rarg0, c_rarg0); // signed ? min_jint : max_jint |
0 | 853 __ movl(c_rarg2, 0x80000000); |
854 __ movl(rax, 0x7fffffff); | |
304 | 855 __ cmov(Assembler::positive, c_rarg2, rax); |
0 | 856 |
857 __ bind(L); | |
304 | 858 __ movptr(inout, c_rarg2); |
859 | |
860 __ pop(c_rarg0); | |
861 __ pop(c_rarg1); | |
862 __ pop(c_rarg2); | |
863 __ pop(c_rarg3); | |
864 __ pop(rax); | |
0 | 865 |
866 __ ret(0); | |
867 | |
868 return start; | |
869 } | |
870 | |
871 address generate_d2l_fixup() { | |
872 StubCodeMark mark(this, "StubRoutines", "d2l_fixup"); | |
873 Address inout(rsp, 6 * wordSize); // return address + 5 saves | |
874 | |
875 address start = __ pc(); | |
876 | |
877 Label L; | |
878 | |
304 | 879 __ push(rax); |
880 __ push(c_rarg3); | |
881 __ push(c_rarg2); | |
882 __ push(c_rarg1); | |
883 __ push(c_rarg0); | |
0 | 884 |
885 __ movl(rax, 0x7ff00000); | |
886 __ movq(c_rarg2, inout); | |
887 __ movl(c_rarg3, c_rarg2); | |
304 | 888 __ mov(c_rarg1, c_rarg2); |
889 __ mov(c_rarg0, c_rarg2); | |
0 | 890 __ negl(c_rarg3); |
304 | 891 __ shrptr(c_rarg1, 0x20); |
0 | 892 __ orl(c_rarg3, c_rarg2); |
893 __ andl(c_rarg1, 0x7fffffff); | |
894 __ xorl(c_rarg2, c_rarg2); | |
895 __ shrl(c_rarg3, 0x1f); | |
896 __ orl(c_rarg1, c_rarg3); | |
897 __ cmpl(rax, c_rarg1); | |
898 __ jcc(Assembler::negative, L); // NaN -> 0 | |
899 __ testq(c_rarg0, c_rarg0); // signed ? min_jlong : max_jlong | |
900 __ mov64(c_rarg2, 0x8000000000000000); | |
901 __ mov64(rax, 0x7fffffffffffffff); | |
902 __ cmovq(Assembler::positive, c_rarg2, rax); | |
903 | |
904 __ bind(L); | |
905 __ movq(inout, c_rarg2); | |
906 | |
304 | 907 __ pop(c_rarg0); |
908 __ pop(c_rarg1); | |
909 __ pop(c_rarg2); | |
910 __ pop(c_rarg3); | |
911 __ pop(rax); | |
0 | 912 |
913 __ ret(0); | |
914 | |
915 return start; | |
916 } | |
917 | |
918 address generate_fp_mask(const char *stub_name, int64_t mask) { | |
1365 | 919 __ align(CodeEntryAlignment); |
0 | 920 StubCodeMark mark(this, "StubRoutines", stub_name); |
921 address start = __ pc(); | |
922 | |
923 __ emit_data64( mask, relocInfo::none ); | |
924 __ emit_data64( mask, relocInfo::none ); | |
925 | |
926 return start; | |
927 } | |
928 | |
929 // The following routine generates a subroutine to throw an | |
930 // asynchronous UnknownError when an unsafe access gets a fault that | |
931 // could not be reasonably prevented by the programmer. (Example: | |
932 // SIGBUS/OBJERR.) | |
933 address generate_handler_for_unsafe_access() { | |
934 StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); | |
935 address start = __ pc(); | |
936 | |
304 | 937 __ push(0); // hole for return address-to-be |
938 __ pusha(); // push registers | |
0 | 939 Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); |
940 | |
3937 | 941 // FIXME: this probably needs alignment logic |
942 | |
304 | 943 __ subptr(rsp, frame::arg_reg_save_area_bytes); |
0 | 944 BLOCK_COMMENT("call handle_unsafe_access"); |
945 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); | |
304 | 946 __ addptr(rsp, frame::arg_reg_save_area_bytes); |
947 | |
948 __ movptr(next_pc, rax); // stuff next address | |
949 __ popa(); | |
0 | 950 __ ret(0); // jump to next address |
951 | |
952 return start; | |
953 } | |
954 | |
955 // Non-destructive plausibility checks for oops | |
956 // | |
957 // Arguments: | |
958 // all args on stack! | |
959 // | |
960 // Stack after saving c_rarg3: | |
961 // [tos + 0]: saved c_rarg3 | |
962 // [tos + 1]: saved c_rarg2 | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
963 // [tos + 2]: saved r12 (several TemplateTable methods use it) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
964 // [tos + 3]: saved flags |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
965 // [tos + 4]: return address |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
966 // * [tos + 5]: error message (char*) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
967 // * [tos + 6]: object to verify (oop) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
968 // * [tos + 7]: saved rax - saved by caller and bashed |
1583 | 969 // * [tos + 8]: saved r10 (rscratch1) - saved by caller |
0 | 970 // * = popped on exit |
971 address generate_verify_oop() { | |
972 StubCodeMark mark(this, "StubRoutines", "verify_oop"); | |
973 address start = __ pc(); | |
974 | |
975 Label exit, error; | |
976 | |
304 | 977 __ pushf(); |
0 | 978 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); |
979 | |
304 | 980 __ push(r12); |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
981 |
0 | 982 // save c_rarg2 and c_rarg3 |
304 | 983 __ push(c_rarg2); |
984 __ push(c_rarg3); | |
0 | 985 |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
986 enum { |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
987 // After previous pushes. |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
988 oop_to_verify = 6 * wordSize, |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
989 saved_rax = 7 * wordSize, |
1583 | 990 saved_r10 = 8 * wordSize, |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
991 |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
992 // Before the call to MacroAssembler::debug(), see below. |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
993 return_addr = 16 * wordSize, |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
994 error_msg = 17 * wordSize |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
995 }; |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
996 |
0 | 997 // get object |
304 | 998 __ movptr(rax, Address(rsp, oop_to_verify)); |
0 | 999 |
1000 // make sure object is 'reasonable' | |
304 | 1001 __ testptr(rax, rax); |
0 | 1002 __ jcc(Assembler::zero, exit); // if obj is NULL it is OK |
1003 // Check if the oop is in the right area of memory | |
304 | 1004 __ movptr(c_rarg2, rax); |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1005 __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_mask()); |
304 | 1006 __ andptr(c_rarg2, c_rarg3); |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1007 __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_bits()); |
304 | 1008 __ cmpptr(c_rarg2, c_rarg3); |
0 | 1009 __ jcc(Assembler::notZero, error); |
1010 | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1011 // set r12 to heapbase for load_klass() |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1012 __ reinit_heapbase(); |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1013 |
0 | 1014 // make sure klass is 'reasonable' |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1015 __ load_klass(rax, rax); // get klass |
304 | 1016 __ testptr(rax, rax); |
0 | 1017 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
1018 // Check if the klass is in the right area of memory | |
304 | 1019 __ mov(c_rarg2, rax); |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1020 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_mask()); |
304 | 1021 __ andptr(c_rarg2, c_rarg3); |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1022 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_bits()); |
304 | 1023 __ cmpptr(c_rarg2, c_rarg3); |
0 | 1024 __ jcc(Assembler::notZero, error); |
1025 | |
1026 // make sure klass' klass is 'reasonable' | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1027 __ load_klass(rax, rax); |
304 | 1028 __ testptr(rax, rax); |
0 | 1029 __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken |
1030 // Check if the klass' klass is in the right area of memory | |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1031 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_mask()); |
304 | 1032 __ andptr(rax, c_rarg3); |
512
db4caa99ef11
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
405
diff
changeset
|
1033 __ movptr(c_rarg3, (intptr_t) Universe::verify_klass_bits()); |
304 | 1034 __ cmpptr(rax, c_rarg3); |
0 | 1035 __ jcc(Assembler::notZero, error); |
1036 | |
1037 // return if everything seems ok | |
1038 __ bind(exit); | |
304 | 1039 __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back |
1583 | 1040 __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back |
304 | 1041 __ pop(c_rarg3); // restore c_rarg3 |
1042 __ pop(c_rarg2); // restore c_rarg2 | |
1043 __ pop(r12); // restore r12 | |
1044 __ popf(); // restore flags | |
1583 | 1045 __ ret(4 * wordSize); // pop caller saved stuff |
0 | 1046 |
1047 // handle errors | |
1048 __ bind(error); | |
304 | 1049 __ movptr(rax, Address(rsp, saved_rax)); // get saved rax back |
1583 | 1050 __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back |
304 | 1051 __ pop(c_rarg3); // get saved c_rarg3 back |
1052 __ pop(c_rarg2); // get saved c_rarg2 back | |
1053 __ pop(r12); // get saved r12 back | |
1054 __ popf(); // get saved flags off stack -- | |
0 | 1055 // will be ignored |
1056 | |
304 | 1057 __ pusha(); // push registers |
0 | 1058 // (rip is already |
1059 // already pushed) | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1060 // debug(char* msg, int64_t pc, int64_t regs[]) |
0 | 1061 // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and |
1062 // pushed all the registers, so now the stack looks like: | |
1063 // [tos + 0] 16 saved registers | |
1064 // [tos + 16] return address | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1065 // * [tos + 17] error message (char*) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1066 // * [tos + 18] object to verify (oop) |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1067 // * [tos + 19] saved rax - saved by caller and bashed |
1583 | 1068 // * [tos + 20] saved r10 (rscratch1) - saved by caller |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1069 // * = popped on exit |
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1070 |
304 | 1071 __ movptr(c_rarg0, Address(rsp, error_msg)); // pass address of error message |
1072 __ movptr(c_rarg1, Address(rsp, return_addr)); // pass return address | |
1073 __ movq(c_rarg2, rsp); // pass address of regs on stack | |
1074 __ mov(r12, rsp); // remember rsp | |
1075 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows | |
1076 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1077 BLOCK_COMMENT("call MacroAssembler::debug"); |
304 | 1078 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug64))); |
1079 __ mov(rsp, r12); // restore rsp | |
1080 __ popa(); // pop registers (includes r12) | |
1583 | 1081 __ ret(4 * wordSize); // pop caller saved stuff |
0 | 1082 |
1083 return start; | |
1084 } | |
1085 | |
1086 // | |
1087 // Verify that a register contains clean 32-bits positive value | |
1088 // (high 32-bits are 0) so it could be used in 64-bits shifts. | |
1089 // | |
1090 // Input: | |
1091 // Rint - 32-bits value | |
1092 // Rtmp - scratch | |
1093 // | |
1094 void assert_clean_int(Register Rint, Register Rtmp) { | |
1095 #ifdef ASSERT | |
1096 Label L; | |
1097 assert_different_registers(Rtmp, Rint); | |
1098 __ movslq(Rtmp, Rint); | |
1099 __ cmpq(Rtmp, Rint); | |
124
b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
kvn
parents:
113
diff
changeset
|
1100 __ jcc(Assembler::equal, L); |
0 | 1101 __ stop("high 32-bits of int value are not 0"); |
1102 __ bind(L); | |
1103 #endif | |
1104 } | |
1105 | |
1106 // Generate overlap test for array copy stubs | |
1107 // | |
1108 // Input: | |
1109 // c_rarg0 - from | |
1110 // c_rarg1 - to | |
1111 // c_rarg2 - element count | |
1112 // | |
1113 // Output: | |
1114 // rax - &from[element count - 1] | |
1115 // | |
1116 void array_overlap_test(address no_overlap_target, Address::ScaleFactor sf) { | |
1117 assert(no_overlap_target != NULL, "must be generated"); | |
1118 array_overlap_test(no_overlap_target, NULL, sf); | |
1119 } | |
1120 void array_overlap_test(Label& L_no_overlap, Address::ScaleFactor sf) { | |
1121 array_overlap_test(NULL, &L_no_overlap, sf); | |
1122 } | |
1123 void array_overlap_test(address no_overlap_target, Label* NOLp, Address::ScaleFactor sf) { | |
1124 const Register from = c_rarg0; | |
1125 const Register to = c_rarg1; | |
1126 const Register count = c_rarg2; | |
1127 const Register end_from = rax; | |
1128 | |
304 | 1129 __ cmpptr(to, from); |
1130 __ lea(end_from, Address(from, count, sf, 0)); | |
0 | 1131 if (NOLp == NULL) { |
1132 ExternalAddress no_overlap(no_overlap_target); | |
1133 __ jump_cc(Assembler::belowEqual, no_overlap); | |
304 | 1134 __ cmpptr(to, end_from); |
0 | 1135 __ jump_cc(Assembler::aboveEqual, no_overlap); |
1136 } else { | |
1137 __ jcc(Assembler::belowEqual, (*NOLp)); | |
304 | 1138 __ cmpptr(to, end_from); |
0 | 1139 __ jcc(Assembler::aboveEqual, (*NOLp)); |
1140 } | |
1141 } | |
1142 | |
1143 // Shuffle first three arg regs on Windows into Linux/Solaris locations. | |
1144 // | |
1145 // Outputs: | |
1146 // rdi - rcx | |
1147 // rsi - rdx | |
1148 // rdx - r8 | |
1149 // rcx - r9 | |
1150 // | |
1151 // Registers r9 and r10 are used to save rdi and rsi on Windows, which latter | |
1152 // are non-volatile. r9 and r10 should not be used by the caller. | |
1153 // | |
1154 void setup_arg_regs(int nargs = 3) { | |
1155 const Register saved_rdi = r9; | |
1156 const Register saved_rsi = r10; | |
1157 assert(nargs == 3 || nargs == 4, "else fix"); | |
1158 #ifdef _WIN64 | |
1159 assert(c_rarg0 == rcx && c_rarg1 == rdx && c_rarg2 == r8 && c_rarg3 == r9, | |
1160 "unexpected argument registers"); | |
1161 if (nargs >= 4) | |
304 | 1162 __ mov(rax, r9); // r9 is also saved_rdi |
1163 __ movptr(saved_rdi, rdi); | |
1164 __ movptr(saved_rsi, rsi); | |
1165 __ mov(rdi, rcx); // c_rarg0 | |
1166 __ mov(rsi, rdx); // c_rarg1 | |
1167 __ mov(rdx, r8); // c_rarg2 | |
0 | 1168 if (nargs >= 4) |
304 | 1169 __ mov(rcx, rax); // c_rarg3 (via rax) |
0 | 1170 #else |
1171 assert(c_rarg0 == rdi && c_rarg1 == rsi && c_rarg2 == rdx && c_rarg3 == rcx, | |
1172 "unexpected argument registers"); | |
1173 #endif | |
1174 } | |
1175 | |
1176 void restore_arg_regs() { | |
1177 const Register saved_rdi = r9; | |
1178 const Register saved_rsi = r10; | |
1179 #ifdef _WIN64 | |
304 | 1180 __ movptr(rdi, saved_rdi); |
1181 __ movptr(rsi, saved_rsi); | |
0 | 1182 #endif |
1183 } | |
1184 | |
1185 // Generate code for an array write pre barrier | |
1186 // | |
1187 // addr - starting address | |
2324 | 1188 // count - element count |
1189 // tmp - scratch register | |
0 | 1190 // |
1191 // Destroy no registers! | |
1192 // | |
2324 | 1193 void gen_write_ref_array_pre_barrier(Register addr, Register count, bool dest_uninitialized) { |
0 | 1194 BarrierSet* bs = Universe::heap()->barrier_set(); |
1195 switch (bs->kind()) { | |
1196 case BarrierSet::G1SATBCT: | |
1197 case BarrierSet::G1SATBCTLogging: | |
2324 | 1198 // With G1, don't generate the call if we statically know that the target in uninitialized |
1199 if (!dest_uninitialized) { | |
1200 __ pusha(); // push registers | |
1201 if (count == c_rarg0) { | |
1202 if (addr == c_rarg1) { | |
1203 // exactly backwards!! | |
1204 __ xchgptr(c_rarg1, c_rarg0); | |
1205 } else { | |
1206 __ movptr(c_rarg1, count); | |
1207 __ movptr(c_rarg0, addr); | |
1208 } | |
1209 } else { | |
1210 __ movptr(c_rarg0, addr); | |
1211 __ movptr(c_rarg1, count); | |
1212 } | |
1213 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_pre), 2); | |
1214 __ popa(); | |
0 | 1215 } |
2324 | 1216 break; |
0 | 1217 case BarrierSet::CardTableModRef: |
1218 case BarrierSet::CardTableExtension: | |
1219 case BarrierSet::ModRef: | |
1220 break; | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1221 default: |
0 | 1222 ShouldNotReachHere(); |
1223 | |
1224 } | |
1225 } | |
1226 | |
1227 // | |
1228 // Generate code for an array write post barrier | |
1229 // | |
1230 // Input: | |
1231 // start - register containing starting address of destination array | |
1232 // end - register containing ending address of destination array | |
1233 // scratch - scratch register | |
1234 // | |
1235 // The input registers are overwritten. | |
1236 // The ending address is inclusive. | |
1237 void gen_write_ref_array_post_barrier(Register start, Register end, Register scratch) { | |
1238 assert_different_registers(start, end, scratch); | |
1239 BarrierSet* bs = Universe::heap()->barrier_set(); | |
1240 switch (bs->kind()) { | |
1241 case BarrierSet::G1SATBCT: | |
1242 case BarrierSet::G1SATBCTLogging: | |
1243 | |
1244 { | |
304 | 1245 __ pusha(); // push registers (overkill) |
0 | 1246 // must compute element count unless barrier set interface is changed (other platforms supply count) |
1247 assert_different_registers(start, end, scratch); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
1248 __ lea(scratch, Address(end, BytesPerHeapOop)); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
1249 __ subptr(scratch, start); // subtract start to get #bytes |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
1250 __ shrptr(scratch, LogBytesPerHeapOop); // convert to element count |
304 | 1251 __ mov(c_rarg0, start); |
1252 __ mov(c_rarg1, scratch); | |
1192
776fb94f33cc
6918006: G1: spill space must be reserved on the stack for barrier calls on Windows x64
apetrusenko
parents:
1174
diff
changeset
|
1253 __ call_VM_leaf(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post), 2); |
304 | 1254 __ popa(); |
0 | 1255 } |
1256 break; | |
1257 case BarrierSet::CardTableModRef: | |
1258 case BarrierSet::CardTableExtension: | |
1259 { | |
1260 CardTableModRefBS* ct = (CardTableModRefBS*)bs; | |
1261 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); | |
1262 | |
1263 Label L_loop; | |
1264 | |
304 | 1265 __ shrptr(start, CardTableModRefBS::card_shift); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
1266 __ addptr(end, BytesPerHeapOop); |
304 | 1267 __ shrptr(end, CardTableModRefBS::card_shift); |
1268 __ subptr(end, start); // number of bytes to copy | |
0 | 1269 |
249
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1270 intptr_t disp = (intptr_t) ct->byte_map_base; |
4114
6729bbc1fcd6
7003454: order constants in constant table by number of references in code
twisti
parents:
3960
diff
changeset
|
1271 if (Assembler::is_simm32(disp)) { |
249
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1272 Address cardtable(noreg, noreg, Address::no_scale, disp); |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1273 __ lea(scratch, cardtable); |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1274 } else { |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1275 ExternalAddress cardtable((address)disp); |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1276 __ lea(scratch, cardtable); |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1277 } |
910a4cb98e9e
6717457: Internal Error (src/share/vm/code/relocInfo.hpp:1089)
never
parents:
196
diff
changeset
|
1278 |
0 | 1279 const Register count = end; // 'end' register contains bytes count now |
304 | 1280 __ addptr(start, scratch); |
0 | 1281 __ BIND(L_loop); |
1282 __ movb(Address(start, count, Address::times_1), 0); | |
304 | 1283 __ decrement(count); |
0 | 1284 __ jcc(Assembler::greaterEqual, L_loop); |
1285 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1286 break; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1287 default: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1288 ShouldNotReachHere(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1289 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1290 } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
124
diff
changeset
|
1291 } |
0 | 1292 |
405 | 1293 |
0 | 1294 // Copy big chunks forward |
1295 // | |
1296 // Inputs: | |
1297 // end_from - source arrays end address | |
1298 // end_to - destination array end address | |
1299 // qword_count - 64-bits element count, negative | |
1300 // to - scratch | |
1301 // L_copy_32_bytes - entry label | |
1302 // L_copy_8_bytes - exit label | |
1303 // | |
1304 void copy_32_bytes_forward(Register end_from, Register end_to, | |
1305 Register qword_count, Register to, | |
1306 Label& L_copy_32_bytes, Label& L_copy_8_bytes) { | |
1307 DEBUG_ONLY(__ stop("enter at entry label, not here")); | |
1308 Label L_loop; | |
1365 | 1309 __ align(OptoLoopAlignment); |
0 | 1310 __ BIND(L_loop); |
405 | 1311 if(UseUnalignedLoadStores) { |
1312 __ movdqu(xmm0, Address(end_from, qword_count, Address::times_8, -24)); | |
1313 __ movdqu(Address(end_to, qword_count, Address::times_8, -24), xmm0); | |
1314 __ movdqu(xmm1, Address(end_from, qword_count, Address::times_8, - 8)); | |
1315 __ movdqu(Address(end_to, qword_count, Address::times_8, - 8), xmm1); | |
1316 | |
1317 } else { | |
1318 __ movq(to, Address(end_from, qword_count, Address::times_8, -24)); | |
1319 __ movq(Address(end_to, qword_count, Address::times_8, -24), to); | |
1320 __ movq(to, Address(end_from, qword_count, Address::times_8, -16)); | |
1321 __ movq(Address(end_to, qword_count, Address::times_8, -16), to); | |
1322 __ movq(to, Address(end_from, qword_count, Address::times_8, - 8)); | |
1323 __ movq(Address(end_to, qword_count, Address::times_8, - 8), to); | |
1324 __ movq(to, Address(end_from, qword_count, Address::times_8, - 0)); | |
1325 __ movq(Address(end_to, qword_count, Address::times_8, - 0), to); | |
1326 } | |
0 | 1327 __ BIND(L_copy_32_bytes); |
304 | 1328 __ addptr(qword_count, 4); |
0 | 1329 __ jcc(Assembler::lessEqual, L_loop); |
304 | 1330 __ subptr(qword_count, 4); |
0 | 1331 __ jcc(Assembler::less, L_copy_8_bytes); // Copy trailing qwords |
1332 } | |
1333 | |
1334 | |
1335 // Copy big chunks backward | |
1336 // | |
1337 // Inputs: | |
1338 // from - source arrays address | |
1339 // dest - destination array address | |
1340 // qword_count - 64-bits element count | |
1341 // to - scratch | |
1342 // L_copy_32_bytes - entry label | |
1343 // L_copy_8_bytes - exit label | |
1344 // | |
1345 void copy_32_bytes_backward(Register from, Register dest, | |
1346 Register qword_count, Register to, | |
1347 Label& L_copy_32_bytes, Label& L_copy_8_bytes) { | |
1348 DEBUG_ONLY(__ stop("enter at entry label, not here")); | |
1349 Label L_loop; | |
1365 | 1350 __ align(OptoLoopAlignment); |
0 | 1351 __ BIND(L_loop); |
405 | 1352 if(UseUnalignedLoadStores) { |
1353 __ movdqu(xmm0, Address(from, qword_count, Address::times_8, 16)); | |
1354 __ movdqu(Address(dest, qword_count, Address::times_8, 16), xmm0); | |
1355 __ movdqu(xmm1, Address(from, qword_count, Address::times_8, 0)); | |
1356 __ movdqu(Address(dest, qword_count, Address::times_8, 0), xmm1); | |
1357 | |
1358 } else { | |
1359 __ movq(to, Address(from, qword_count, Address::times_8, 24)); | |
1360 __ movq(Address(dest, qword_count, Address::times_8, 24), to); | |
1361 __ movq(to, Address(from, qword_count, Address::times_8, 16)); | |
1362 __ movq(Address(dest, qword_count, Address::times_8, 16), to); | |
1363 __ movq(to, Address(from, qword_count, Address::times_8, 8)); | |
1364 __ movq(Address(dest, qword_count, Address::times_8, 8), to); | |
1365 __ movq(to, Address(from, qword_count, Address::times_8, 0)); | |
1366 __ movq(Address(dest, qword_count, Address::times_8, 0), to); | |
1367 } | |
0 | 1368 __ BIND(L_copy_32_bytes); |
304 | 1369 __ subptr(qword_count, 4); |
0 | 1370 __ jcc(Assembler::greaterEqual, L_loop); |
304 | 1371 __ addptr(qword_count, 4); |
0 | 1372 __ jcc(Assembler::greater, L_copy_8_bytes); // Copy trailing qwords |
1373 } | |
1374 | |
1375 | |
1376 // Arguments: | |
1377 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1378 // ignored | |
1379 // name - stub name string | |
1380 // | |
1381 // Inputs: | |
1382 // c_rarg0 - source array address | |
1383 // c_rarg1 - destination array address | |
1384 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1385 // | |
1386 // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries, | |
1387 // we let the hardware handle it. The one to eight bytes within words, | |
1388 // dwords or qwords that span cache line boundaries will still be loaded | |
1389 // and stored atomically. | |
1390 // | |
1391 // Side Effects: | |
1392 // disjoint_byte_copy_entry is set to the no-overlap entry point | |
1393 // used by generate_conjoint_byte_copy(). | |
1394 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1395 address generate_disjoint_byte_copy(bool aligned, address* entry, const char *name) { |
0 | 1396 __ align(CodeEntryAlignment); |
1397 StubCodeMark mark(this, "StubRoutines", name); | |
1398 address start = __ pc(); | |
1399 | |
1400 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes; | |
1401 Label L_copy_byte, L_exit; | |
1402 const Register from = rdi; // source array address | |
1403 const Register to = rsi; // destination array address | |
1404 const Register count = rdx; // elements count | |
1405 const Register byte_count = rcx; | |
1406 const Register qword_count = count; | |
1407 const Register end_from = from; // source array end address | |
1408 const Register end_to = to; // destination array end address | |
1409 // End pointers are inclusive, and if count is not zero they point | |
1410 // to the last unit copied: end_to[0] := end_from[0] | |
1411 | |
1412 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1413 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1414 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1415 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1416 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1417 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1418 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1419 } |
0 | 1420 |
1421 setup_arg_regs(); // from => rdi, to => rsi, count => rdx | |
1422 // r9 and r10 may be used to save non-volatile registers | |
1423 | |
1424 // 'from', 'to' and 'count' are now valid | |
304 | 1425 __ movptr(byte_count, count); |
1426 __ shrptr(count, 3); // count => qword_count | |
0 | 1427 |
1428 // Copy from low to high addresses. Use 'to' as scratch. | |
304 | 1429 __ lea(end_from, Address(from, qword_count, Address::times_8, -8)); |
1430 __ lea(end_to, Address(to, qword_count, Address::times_8, -8)); | |
1431 __ negptr(qword_count); // make the count negative | |
0 | 1432 __ jmp(L_copy_32_bytes); |
1433 | |
1434 // Copy trailing qwords | |
1435 __ BIND(L_copy_8_bytes); | |
1436 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8)); | |
1437 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax); | |
304 | 1438 __ increment(qword_count); |
0 | 1439 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1440 | |
1441 // Check for and copy trailing dword | |
1442 __ BIND(L_copy_4_bytes); | |
304 | 1443 __ testl(byte_count, 4); |
0 | 1444 __ jccb(Assembler::zero, L_copy_2_bytes); |
1445 __ movl(rax, Address(end_from, 8)); | |
1446 __ movl(Address(end_to, 8), rax); | |
1447 | |
304 | 1448 __ addptr(end_from, 4); |
1449 __ addptr(end_to, 4); | |
0 | 1450 |
1451 // Check for and copy trailing word | |
1452 __ BIND(L_copy_2_bytes); | |
304 | 1453 __ testl(byte_count, 2); |
0 | 1454 __ jccb(Assembler::zero, L_copy_byte); |
1455 __ movw(rax, Address(end_from, 8)); | |
1456 __ movw(Address(end_to, 8), rax); | |
1457 | |
304 | 1458 __ addptr(end_from, 2); |
1459 __ addptr(end_to, 2); | |
0 | 1460 |
1461 // Check for and copy trailing byte | |
1462 __ BIND(L_copy_byte); | |
304 | 1463 __ testl(byte_count, 1); |
0 | 1464 __ jccb(Assembler::zero, L_exit); |
1465 __ movb(rax, Address(end_from, 8)); | |
1466 __ movb(Address(end_to, 8), rax); | |
1467 | |
1468 __ BIND(L_exit); | |
1469 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); | |
1470 restore_arg_regs(); | |
304 | 1471 __ xorptr(rax, rax); // return 0 |
0 | 1472 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1473 __ ret(0); | |
1474 | |
1475 // Copy in 32-bytes chunks | |
1476 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1477 __ jmp(L_copy_4_bytes); | |
1478 | |
1479 return start; | |
1480 } | |
1481 | |
1482 // Arguments: | |
1483 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1484 // ignored | |
1485 // name - stub name string | |
1486 // | |
1487 // Inputs: | |
1488 // c_rarg0 - source array address | |
1489 // c_rarg1 - destination array address | |
1490 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1491 // | |
1492 // If 'from' and/or 'to' are aligned on 4-, 2-, or 1-byte boundaries, | |
1493 // we let the hardware handle it. The one to eight bytes within words, | |
1494 // dwords or qwords that span cache line boundaries will still be loaded | |
1495 // and stored atomically. | |
1496 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1497 address generate_conjoint_byte_copy(bool aligned, address nooverlap_target, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1498 address* entry, const char *name) { |
0 | 1499 __ align(CodeEntryAlignment); |
1500 StubCodeMark mark(this, "StubRoutines", name); | |
1501 address start = __ pc(); | |
1502 | |
1503 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_copy_2_bytes; | |
1504 const Register from = rdi; // source array address | |
1505 const Register to = rsi; // destination array address | |
1506 const Register count = rdx; // elements count | |
1507 const Register byte_count = rcx; | |
1508 const Register qword_count = count; | |
1509 | |
1510 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1511 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1512 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1513 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1514 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1515 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1516 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1517 } |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1518 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1519 array_overlap_test(nooverlap_target, Address::times_1); |
0 | 1520 setup_arg_regs(); // from => rdi, to => rsi, count => rdx |
1521 // r9 and r10 may be used to save non-volatile registers | |
1522 | |
1523 // 'from', 'to' and 'count' are now valid | |
304 | 1524 __ movptr(byte_count, count); |
1525 __ shrptr(count, 3); // count => qword_count | |
0 | 1526 |
1527 // Copy from high to low addresses. | |
1528 | |
1529 // Check for and copy trailing byte | |
304 | 1530 __ testl(byte_count, 1); |
0 | 1531 __ jcc(Assembler::zero, L_copy_2_bytes); |
1532 __ movb(rax, Address(from, byte_count, Address::times_1, -1)); | |
1533 __ movb(Address(to, byte_count, Address::times_1, -1), rax); | |
304 | 1534 __ decrement(byte_count); // Adjust for possible trailing word |
0 | 1535 |
1536 // Check for and copy trailing word | |
1537 __ BIND(L_copy_2_bytes); | |
304 | 1538 __ testl(byte_count, 2); |
0 | 1539 __ jcc(Assembler::zero, L_copy_4_bytes); |
1540 __ movw(rax, Address(from, byte_count, Address::times_1, -2)); | |
1541 __ movw(Address(to, byte_count, Address::times_1, -2), rax); | |
1542 | |
1543 // Check for and copy trailing dword | |
1544 __ BIND(L_copy_4_bytes); | |
304 | 1545 __ testl(byte_count, 4); |
0 | 1546 __ jcc(Assembler::zero, L_copy_32_bytes); |
1547 __ movl(rax, Address(from, qword_count, Address::times_8)); | |
1548 __ movl(Address(to, qword_count, Address::times_8), rax); | |
1549 __ jmp(L_copy_32_bytes); | |
1550 | |
1551 // Copy trailing qwords | |
1552 __ BIND(L_copy_8_bytes); | |
1553 __ movq(rax, Address(from, qword_count, Address::times_8, -8)); | |
1554 __ movq(Address(to, qword_count, Address::times_8, -8), rax); | |
304 | 1555 __ decrement(qword_count); |
0 | 1556 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1557 | |
1558 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); | |
1559 restore_arg_regs(); | |
304 | 1560 __ xorptr(rax, rax); // return 0 |
0 | 1561 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1562 __ ret(0); | |
1563 | |
1564 // Copy in 32-bytes chunks | |
1565 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1566 | |
1567 inc_counter_np(SharedRuntime::_jbyte_array_copy_ctr); | |
1568 restore_arg_regs(); | |
304 | 1569 __ xorptr(rax, rax); // return 0 |
0 | 1570 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1571 __ ret(0); | |
1572 | |
1573 return start; | |
1574 } | |
1575 | |
1576 // Arguments: | |
1577 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1578 // ignored | |
1579 // name - stub name string | |
1580 // | |
1581 // Inputs: | |
1582 // c_rarg0 - source array address | |
1583 // c_rarg1 - destination array address | |
1584 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1585 // | |
1586 // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we | |
1587 // let the hardware handle it. The two or four words within dwords | |
1588 // or qwords that span cache line boundaries will still be loaded | |
1589 // and stored atomically. | |
1590 // | |
1591 // Side Effects: | |
1592 // disjoint_short_copy_entry is set to the no-overlap entry point | |
1593 // used by generate_conjoint_short_copy(). | |
1594 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1595 address generate_disjoint_short_copy(bool aligned, address *entry, const char *name) { |
0 | 1596 __ align(CodeEntryAlignment); |
1597 StubCodeMark mark(this, "StubRoutines", name); | |
1598 address start = __ pc(); | |
1599 | |
1600 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes,L_copy_2_bytes,L_exit; | |
1601 const Register from = rdi; // source array address | |
1602 const Register to = rsi; // destination array address | |
1603 const Register count = rdx; // elements count | |
1604 const Register word_count = rcx; | |
1605 const Register qword_count = count; | |
1606 const Register end_from = from; // source array end address | |
1607 const Register end_to = to; // destination array end address | |
1608 // End pointers are inclusive, and if count is not zero they point | |
1609 // to the last unit copied: end_to[0] := end_from[0] | |
1610 | |
1611 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1612 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1613 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1614 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1615 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1616 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1617 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1618 } |
0 | 1619 |
1620 setup_arg_regs(); // from => rdi, to => rsi, count => rdx | |
1621 // r9 and r10 may be used to save non-volatile registers | |
1622 | |
1623 // 'from', 'to' and 'count' are now valid | |
304 | 1624 __ movptr(word_count, count); |
1625 __ shrptr(count, 2); // count => qword_count | |
0 | 1626 |
1627 // Copy from low to high addresses. Use 'to' as scratch. | |
304 | 1628 __ lea(end_from, Address(from, qword_count, Address::times_8, -8)); |
1629 __ lea(end_to, Address(to, qword_count, Address::times_8, -8)); | |
1630 __ negptr(qword_count); | |
0 | 1631 __ jmp(L_copy_32_bytes); |
1632 | |
1633 // Copy trailing qwords | |
1634 __ BIND(L_copy_8_bytes); | |
1635 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8)); | |
1636 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax); | |
304 | 1637 __ increment(qword_count); |
0 | 1638 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1639 | |
1640 // Original 'dest' is trashed, so we can't use it as a | |
1641 // base register for a possible trailing word copy | |
1642 | |
1643 // Check for and copy trailing dword | |
1644 __ BIND(L_copy_4_bytes); | |
304 | 1645 __ testl(word_count, 2); |
0 | 1646 __ jccb(Assembler::zero, L_copy_2_bytes); |
1647 __ movl(rax, Address(end_from, 8)); | |
1648 __ movl(Address(end_to, 8), rax); | |
1649 | |
304 | 1650 __ addptr(end_from, 4); |
1651 __ addptr(end_to, 4); | |
0 | 1652 |
1653 // Check for and copy trailing word | |
1654 __ BIND(L_copy_2_bytes); | |
304 | 1655 __ testl(word_count, 1); |
0 | 1656 __ jccb(Assembler::zero, L_exit); |
1657 __ movw(rax, Address(end_from, 8)); | |
1658 __ movw(Address(end_to, 8), rax); | |
1659 | |
1660 __ BIND(L_exit); | |
1661 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); | |
1662 restore_arg_regs(); | |
304 | 1663 __ xorptr(rax, rax); // return 0 |
0 | 1664 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1665 __ ret(0); | |
1666 | |
1667 // Copy in 32-bytes chunks | |
1668 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1669 __ jmp(L_copy_4_bytes); | |
1670 | |
1671 return start; | |
1672 } | |
1673 | |
1763 | 1674 address generate_fill(BasicType t, bool aligned, const char *name) { |
1675 __ align(CodeEntryAlignment); | |
1676 StubCodeMark mark(this, "StubRoutines", name); | |
1677 address start = __ pc(); | |
1678 | |
1679 BLOCK_COMMENT("Entry:"); | |
1680 | |
1681 const Register to = c_rarg0; // source array address | |
1682 const Register value = c_rarg1; // value | |
1683 const Register count = c_rarg2; // elements count | |
1684 | |
1685 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1686 | |
1687 __ generate_fill(t, aligned, to, value, count, rax, xmm0); | |
1688 | |
1689 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
1690 __ ret(0); | |
1691 return start; | |
1692 } | |
1693 | |
0 | 1694 // Arguments: |
1695 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1696 // ignored | |
1697 // name - stub name string | |
1698 // | |
1699 // Inputs: | |
1700 // c_rarg0 - source array address | |
1701 // c_rarg1 - destination array address | |
1702 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1703 // | |
1704 // If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we | |
1705 // let the hardware handle it. The two or four words within dwords | |
1706 // or qwords that span cache line boundaries will still be loaded | |
1707 // and stored atomically. | |
1708 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1709 address generate_conjoint_short_copy(bool aligned, address nooverlap_target, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1710 address *entry, const char *name) { |
0 | 1711 __ align(CodeEntryAlignment); |
1712 StubCodeMark mark(this, "StubRoutines", name); | |
1713 address start = __ pc(); | |
1714 | |
1715 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes; | |
1716 const Register from = rdi; // source array address | |
1717 const Register to = rsi; // destination array address | |
1718 const Register count = rdx; // elements count | |
1719 const Register word_count = rcx; | |
1720 const Register qword_count = count; | |
1721 | |
1722 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1723 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1724 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1725 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1726 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1727 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1728 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1729 } |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1730 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1731 array_overlap_test(nooverlap_target, Address::times_2); |
0 | 1732 setup_arg_regs(); // from => rdi, to => rsi, count => rdx |
1733 // r9 and r10 may be used to save non-volatile registers | |
1734 | |
1735 // 'from', 'to' and 'count' are now valid | |
304 | 1736 __ movptr(word_count, count); |
1737 __ shrptr(count, 2); // count => qword_count | |
0 | 1738 |
1739 // Copy from high to low addresses. Use 'to' as scratch. | |
1740 | |
1741 // Check for and copy trailing word | |
304 | 1742 __ testl(word_count, 1); |
0 | 1743 __ jccb(Assembler::zero, L_copy_4_bytes); |
1744 __ movw(rax, Address(from, word_count, Address::times_2, -2)); | |
1745 __ movw(Address(to, word_count, Address::times_2, -2), rax); | |
1746 | |
1747 // Check for and copy trailing dword | |
1748 __ BIND(L_copy_4_bytes); | |
304 | 1749 __ testl(word_count, 2); |
0 | 1750 __ jcc(Assembler::zero, L_copy_32_bytes); |
1751 __ movl(rax, Address(from, qword_count, Address::times_8)); | |
1752 __ movl(Address(to, qword_count, Address::times_8), rax); | |
1753 __ jmp(L_copy_32_bytes); | |
1754 | |
1755 // Copy trailing qwords | |
1756 __ BIND(L_copy_8_bytes); | |
1757 __ movq(rax, Address(from, qword_count, Address::times_8, -8)); | |
1758 __ movq(Address(to, qword_count, Address::times_8, -8), rax); | |
304 | 1759 __ decrement(qword_count); |
0 | 1760 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1761 | |
1762 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); | |
1763 restore_arg_regs(); | |
304 | 1764 __ xorptr(rax, rax); // return 0 |
0 | 1765 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1766 __ ret(0); | |
1767 | |
1768 // Copy in 32-bytes chunks | |
1769 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1770 | |
1771 inc_counter_np(SharedRuntime::_jshort_array_copy_ctr); | |
1772 restore_arg_regs(); | |
304 | 1773 __ xorptr(rax, rax); // return 0 |
0 | 1774 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1775 __ ret(0); | |
1776 | |
1777 return start; | |
1778 } | |
1779 | |
1780 // Arguments: | |
1781 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1782 // ignored | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1783 // is_oop - true => oop array, so generate store check code |
0 | 1784 // name - stub name string |
1785 // | |
1786 // Inputs: | |
1787 // c_rarg0 - source array address | |
1788 // c_rarg1 - destination array address | |
1789 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1790 // | |
1791 // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let | |
1792 // the hardware handle it. The two dwords within qwords that span | |
1793 // cache line boundaries will still be loaded and stored atomicly. | |
1794 // | |
1795 // Side Effects: | |
1796 // disjoint_int_copy_entry is set to the no-overlap entry point | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1797 // used by generate_conjoint_int_oop_copy(). |
0 | 1798 // |
2324 | 1799 address generate_disjoint_int_oop_copy(bool aligned, bool is_oop, address* entry, |
1800 const char *name, bool dest_uninitialized = false) { | |
0 | 1801 __ align(CodeEntryAlignment); |
1802 StubCodeMark mark(this, "StubRoutines", name); | |
1803 address start = __ pc(); | |
1804 | |
1805 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_4_bytes, L_exit; | |
1806 const Register from = rdi; // source array address | |
1807 const Register to = rsi; // destination array address | |
1808 const Register count = rdx; // elements count | |
1809 const Register dword_count = rcx; | |
1810 const Register qword_count = count; | |
1811 const Register end_from = from; // source array end address | |
1812 const Register end_to = to; // destination array end address | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1813 const Register saved_to = r11; // saved destination array address |
0 | 1814 // End pointers are inclusive, and if count is not zero they point |
1815 // to the last unit copied: end_to[0] := end_from[0] | |
1816 | |
1817 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1818 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1819 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1820 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1821 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1822 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1823 BLOCK_COMMENT("Entry:"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1824 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1825 |
0 | 1826 setup_arg_regs(); // from => rdi, to => rsi, count => rdx |
1827 // r9 and r10 may be used to save non-volatile registers | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1828 if (is_oop) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1829 __ movq(saved_to, to); |
2324 | 1830 gen_write_ref_array_pre_barrier(to, count, dest_uninitialized); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1831 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1832 |
0 | 1833 // 'from', 'to' and 'count' are now valid |
304 | 1834 __ movptr(dword_count, count); |
1835 __ shrptr(count, 1); // count => qword_count | |
0 | 1836 |
1837 // Copy from low to high addresses. Use 'to' as scratch. | |
304 | 1838 __ lea(end_from, Address(from, qword_count, Address::times_8, -8)); |
1839 __ lea(end_to, Address(to, qword_count, Address::times_8, -8)); | |
1840 __ negptr(qword_count); | |
0 | 1841 __ jmp(L_copy_32_bytes); |
1842 | |
1843 // Copy trailing qwords | |
1844 __ BIND(L_copy_8_bytes); | |
1845 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8)); | |
1846 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax); | |
304 | 1847 __ increment(qword_count); |
0 | 1848 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1849 | |
1850 // Check for and copy trailing dword | |
1851 __ BIND(L_copy_4_bytes); | |
304 | 1852 __ testl(dword_count, 1); // Only byte test since the value is 0 or 1 |
0 | 1853 __ jccb(Assembler::zero, L_exit); |
1854 __ movl(rax, Address(end_from, 8)); | |
1855 __ movl(Address(end_to, 8), rax); | |
1856 | |
1857 __ BIND(L_exit); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1858 if (is_oop) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1859 __ leaq(end_to, Address(saved_to, dword_count, Address::times_4, -4)); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1860 gen_write_ref_array_post_barrier(saved_to, end_to, rax); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1861 } |
0 | 1862 inc_counter_np(SharedRuntime::_jint_array_copy_ctr); |
1863 restore_arg_regs(); | |
304 | 1864 __ xorptr(rax, rax); // return 0 |
0 | 1865 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1866 __ ret(0); | |
1867 | |
1868 // Copy 32-bytes chunks | |
1869 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1870 __ jmp(L_copy_4_bytes); | |
1871 | |
1872 return start; | |
1873 } | |
1874 | |
1875 // Arguments: | |
1876 // aligned - true => Input and output aligned on a HeapWord == 8-byte boundary | |
1877 // ignored | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1878 // is_oop - true => oop array, so generate store check code |
0 | 1879 // name - stub name string |
1880 // | |
1881 // Inputs: | |
1882 // c_rarg0 - source array address | |
1883 // c_rarg1 - destination array address | |
1884 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1885 // | |
1886 // If 'from' and/or 'to' are aligned on 4-byte boundaries, we let | |
1887 // the hardware handle it. The two dwords within qwords that span | |
1888 // cache line boundaries will still be loaded and stored atomicly. | |
1889 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1890 address generate_conjoint_int_oop_copy(bool aligned, bool is_oop, address nooverlap_target, |
2324 | 1891 address *entry, const char *name, |
1892 bool dest_uninitialized = false) { | |
0 | 1893 __ align(CodeEntryAlignment); |
1894 StubCodeMark mark(this, "StubRoutines", name); | |
1895 address start = __ pc(); | |
1896 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1897 Label L_copy_32_bytes, L_copy_8_bytes, L_copy_2_bytes, L_exit; |
0 | 1898 const Register from = rdi; // source array address |
1899 const Register to = rsi; // destination array address | |
1900 const Register count = rdx; // elements count | |
1901 const Register dword_count = rcx; | |
1902 const Register qword_count = count; | |
1903 | |
1904 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
1905 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
1906 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1907 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1908 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1909 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1910 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1911 } |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1912 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1913 array_overlap_test(nooverlap_target, Address::times_4); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1914 setup_arg_regs(); // from => rdi, to => rsi, count => rdx |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1915 // r9 and r10 may be used to save non-volatile registers |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
1916 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1917 if (is_oop) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1918 // no registers are destroyed by this call |
2324 | 1919 gen_write_ref_array_pre_barrier(to, count, dest_uninitialized); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1920 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1921 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1922 assert_clean_int(count, rax); // Make sure 'count' is clean int. |
0 | 1923 // 'from', 'to' and 'count' are now valid |
304 | 1924 __ movptr(dword_count, count); |
1925 __ shrptr(count, 1); // count => qword_count | |
0 | 1926 |
1927 // Copy from high to low addresses. Use 'to' as scratch. | |
1928 | |
1929 // Check for and copy trailing dword | |
304 | 1930 __ testl(dword_count, 1); |
0 | 1931 __ jcc(Assembler::zero, L_copy_32_bytes); |
1932 __ movl(rax, Address(from, dword_count, Address::times_4, -4)); | |
1933 __ movl(Address(to, dword_count, Address::times_4, -4), rax); | |
1934 __ jmp(L_copy_32_bytes); | |
1935 | |
1936 // Copy trailing qwords | |
1937 __ BIND(L_copy_8_bytes); | |
1938 __ movq(rax, Address(from, qword_count, Address::times_8, -8)); | |
1939 __ movq(Address(to, qword_count, Address::times_8, -8), rax); | |
304 | 1940 __ decrement(qword_count); |
0 | 1941 __ jcc(Assembler::notZero, L_copy_8_bytes); |
1942 | |
1943 inc_counter_np(SharedRuntime::_jint_array_copy_ctr); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1944 if (is_oop) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1945 __ jmp(L_exit); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1946 } |
0 | 1947 restore_arg_regs(); |
304 | 1948 __ xorptr(rax, rax); // return 0 |
0 | 1949 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1950 __ ret(0); | |
1951 | |
1952 // Copy in 32-bytes chunks | |
1953 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
1954 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1955 inc_counter_np(SharedRuntime::_jint_array_copy_ctr); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1956 __ bind(L_exit); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1957 if (is_oop) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1958 Register end_to = rdx; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1959 __ leaq(end_to, Address(to, dword_count, Address::times_4, -4)); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1960 gen_write_ref_array_post_barrier(to, end_to, rax); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1961 } |
0 | 1962 restore_arg_regs(); |
304 | 1963 __ xorptr(rax, rax); // return 0 |
0 | 1964 __ leave(); // required for proper stackwalking of RuntimeStub frame |
1965 __ ret(0); | |
1966 | |
1967 return start; | |
1968 } | |
1969 | |
1970 // Arguments: | |
1971 // aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes | |
1972 // ignored | |
1973 // is_oop - true => oop array, so generate store check code | |
1974 // name - stub name string | |
1975 // | |
1976 // Inputs: | |
1977 // c_rarg0 - source array address | |
1978 // c_rarg1 - destination array address | |
1979 // c_rarg2 - element count, treated as ssize_t, can be zero | |
1980 // | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
1981 // Side Effects: |
0 | 1982 // disjoint_oop_copy_entry or disjoint_long_copy_entry is set to the |
1983 // no-overlap entry point used by generate_conjoint_long_oop_copy(). | |
1984 // | |
2324 | 1985 address generate_disjoint_long_oop_copy(bool aligned, bool is_oop, address *entry, |
1986 const char *name, bool dest_uninitialized = false) { | |
0 | 1987 __ align(CodeEntryAlignment); |
1988 StubCodeMark mark(this, "StubRoutines", name); | |
1989 address start = __ pc(); | |
1990 | |
1991 Label L_copy_32_bytes, L_copy_8_bytes, L_exit; | |
1992 const Register from = rdi; // source array address | |
1993 const Register to = rsi; // destination array address | |
1994 const Register qword_count = rdx; // elements count | |
1995 const Register end_from = from; // source array end address | |
1996 const Register end_to = rcx; // destination array end address | |
1997 const Register saved_to = to; | |
1998 // End pointers are inclusive, and if count is not zero they point | |
1999 // to the last unit copied: end_to[0] := end_from[0] | |
2000 | |
2001 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2002 // Save no-overlap entry point for generate_conjoint_long_oop_copy() | |
2003 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
2004 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2005 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2006 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2007 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2008 BLOCK_COMMENT("Entry:"); |
0 | 2009 } |
2010 | |
2011 setup_arg_regs(); // from => rdi, to => rsi, count => rdx | |
2012 // r9 and r10 may be used to save non-volatile registers | |
2013 // 'from', 'to' and 'qword_count' are now valid | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2014 if (is_oop) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2015 // no registers are destroyed by this call |
2324 | 2016 gen_write_ref_array_pre_barrier(to, qword_count, dest_uninitialized); |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2017 } |
0 | 2018 |
2019 // Copy from low to high addresses. Use 'to' as scratch. | |
304 | 2020 __ lea(end_from, Address(from, qword_count, Address::times_8, -8)); |
2021 __ lea(end_to, Address(to, qword_count, Address::times_8, -8)); | |
2022 __ negptr(qword_count); | |
0 | 2023 __ jmp(L_copy_32_bytes); |
2024 | |
2025 // Copy trailing qwords | |
2026 __ BIND(L_copy_8_bytes); | |
2027 __ movq(rax, Address(end_from, qword_count, Address::times_8, 8)); | |
2028 __ movq(Address(end_to, qword_count, Address::times_8, 8), rax); | |
304 | 2029 __ increment(qword_count); |
0 | 2030 __ jcc(Assembler::notZero, L_copy_8_bytes); |
2031 | |
2032 if (is_oop) { | |
2033 __ jmp(L_exit); | |
2034 } else { | |
2035 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); | |
2036 restore_arg_regs(); | |
304 | 2037 __ xorptr(rax, rax); // return 0 |
0 | 2038 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2039 __ ret(0); | |
2040 } | |
2041 | |
2042 // Copy 64-byte chunks | |
2043 copy_32_bytes_forward(end_from, end_to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
2044 | |
2045 if (is_oop) { | |
2046 __ BIND(L_exit); | |
2047 gen_write_ref_array_post_barrier(saved_to, end_to, rax); | |
2048 inc_counter_np(SharedRuntime::_oop_array_copy_ctr); | |
2049 } else { | |
2050 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); | |
2051 } | |
2052 restore_arg_regs(); | |
304 | 2053 __ xorptr(rax, rax); // return 0 |
0 | 2054 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2055 __ ret(0); | |
2056 | |
2057 return start; | |
2058 } | |
2059 | |
2060 // Arguments: | |
2061 // aligned - true => Input and output aligned on a HeapWord boundary == 8 bytes | |
2062 // ignored | |
2063 // is_oop - true => oop array, so generate store check code | |
2064 // name - stub name string | |
2065 // | |
2066 // Inputs: | |
2067 // c_rarg0 - source array address | |
2068 // c_rarg1 - destination array address | |
2069 // c_rarg2 - element count, treated as ssize_t, can be zero | |
2070 // | |
2324 | 2071 address generate_conjoint_long_oop_copy(bool aligned, bool is_oop, |
2072 address nooverlap_target, address *entry, | |
2073 const char *name, bool dest_uninitialized = false) { | |
0 | 2074 __ align(CodeEntryAlignment); |
2075 StubCodeMark mark(this, "StubRoutines", name); | |
2076 address start = __ pc(); | |
2077 | |
2078 Label L_copy_32_bytes, L_copy_8_bytes, L_exit; | |
2079 const Register from = rdi; // source array address | |
2080 const Register to = rsi; // destination array address | |
2081 const Register qword_count = rdx; // elements count | |
2082 const Register saved_count = rcx; | |
2083 | |
2084 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2085 assert_clean_int(c_rarg2, rax); // Make sure 'count' is clean int. | |
2086 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2087 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2088 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2089 // caller can pass a 64-bit byte count here (from Unsafe.copyMemory) |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2090 BLOCK_COMMENT("Entry:"); |
0 | 2091 } |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2092 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2093 array_overlap_test(nooverlap_target, Address::times_8); |
0 | 2094 setup_arg_regs(); // from => rdi, to => rsi, count => rdx |
2095 // r9 and r10 may be used to save non-volatile registers | |
2096 // 'from', 'to' and 'qword_count' are now valid | |
2097 if (is_oop) { | |
2098 // Save to and count for store barrier | |
304 | 2099 __ movptr(saved_count, qword_count); |
0 | 2100 // No registers are destroyed by this call |
2324 | 2101 gen_write_ref_array_pre_barrier(to, saved_count, dest_uninitialized); |
0 | 2102 } |
2103 | |
2104 __ jmp(L_copy_32_bytes); | |
2105 | |
2106 // Copy trailing qwords | |
2107 __ BIND(L_copy_8_bytes); | |
2108 __ movq(rax, Address(from, qword_count, Address::times_8, -8)); | |
2109 __ movq(Address(to, qword_count, Address::times_8, -8), rax); | |
304 | 2110 __ decrement(qword_count); |
0 | 2111 __ jcc(Assembler::notZero, L_copy_8_bytes); |
2112 | |
2113 if (is_oop) { | |
2114 __ jmp(L_exit); | |
2115 } else { | |
2116 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); | |
2117 restore_arg_regs(); | |
304 | 2118 __ xorptr(rax, rax); // return 0 |
0 | 2119 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2120 __ ret(0); | |
2121 } | |
2122 | |
2123 // Copy in 32-bytes chunks | |
2124 copy_32_bytes_backward(from, to, qword_count, rax, L_copy_32_bytes, L_copy_8_bytes); | |
2125 | |
2126 if (is_oop) { | |
2127 __ BIND(L_exit); | |
304 | 2128 __ lea(rcx, Address(to, saved_count, Address::times_8, -8)); |
0 | 2129 gen_write_ref_array_post_barrier(to, rcx, rax); |
2130 inc_counter_np(SharedRuntime::_oop_array_copy_ctr); | |
2131 } else { | |
2132 inc_counter_np(SharedRuntime::_jlong_array_copy_ctr); | |
2133 } | |
2134 restore_arg_regs(); | |
304 | 2135 __ xorptr(rax, rax); // return 0 |
0 | 2136 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2137 __ ret(0); | |
2138 | |
2139 return start; | |
2140 } | |
2141 | |
2142 | |
2143 // Helper for generating a dynamic type check. | |
2144 // Smashes no registers. | |
2145 void generate_type_check(Register sub_klass, | |
2146 Register super_check_offset, | |
2147 Register super_klass, | |
2148 Label& L_success) { | |
2149 assert_different_registers(sub_klass, super_check_offset, super_klass); | |
2150 | |
2151 BLOCK_COMMENT("type_check:"); | |
2152 | |
2153 Label L_miss; | |
2154 | |
644
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
512
diff
changeset
|
2155 __ check_klass_subtype_fast_path(sub_klass, super_klass, noreg, &L_success, &L_miss, NULL, |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
512
diff
changeset
|
2156 super_check_offset); |
c517646eef23
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
512
diff
changeset
|
2157 __ check_klass_subtype_slow_path(sub_klass, super_klass, noreg, noreg, &L_success, NULL); |
0 | 2158 |
2159 // Fall through on failure! | |
2160 __ BIND(L_miss); | |
2161 } | |
2162 | |
2163 // | |
2164 // Generate checkcasting array copy stub | |
2165 // | |
2166 // Input: | |
2167 // c_rarg0 - source array address | |
2168 // c_rarg1 - destination array address | |
2169 // c_rarg2 - element count, treated as ssize_t, can be zero | |
2170 // c_rarg3 - size_t ckoff (super_check_offset) | |
2171 // not Win64 | |
2172 // c_rarg4 - oop ckval (super_klass) | |
2173 // Win64 | |
2174 // rsp+40 - oop ckval (super_klass) | |
2175 // | |
2176 // Output: | |
2177 // rax == 0 - success | |
2178 // rax == -1^K - failure, where K is partial transfer count | |
2179 // | |
2324 | 2180 address generate_checkcast_copy(const char *name, address *entry, |
2181 bool dest_uninitialized = false) { | |
0 | 2182 |
2183 Label L_load_element, L_store_element, L_do_card_marks, L_done; | |
2184 | |
2185 // Input registers (after setup_arg_regs) | |
2186 const Register from = rdi; // source array address | |
2187 const Register to = rsi; // destination array address | |
2188 const Register length = rdx; // elements count | |
2189 const Register ckoff = rcx; // super_check_offset | |
2190 const Register ckval = r8; // super_klass | |
2191 | |
2192 // Registers used as temps (r13, r14 are save-on-entry) | |
2193 const Register end_from = from; // source array end address | |
2194 const Register end_to = r13; // destination array end address | |
2195 const Register count = rdx; // -(count_remaining) | |
2196 const Register r14_length = r14; // saved copy of length | |
2197 // End pointers are inclusive, and if length is not zero they point | |
2198 // to the last unit copied: end_to[0] := end_from[0] | |
2199 | |
2200 const Register rax_oop = rax; // actual oop copied | |
2201 const Register r11_klass = r11; // oop._klass | |
2202 | |
2203 //--------------------------------------------------------------- | |
2204 // Assembler stub will be used for this call to arraycopy | |
2205 // if the two arrays are subtypes of Object[] but the | |
2206 // destination array type is not equal to or a supertype | |
2207 // of the source type. Each element must be separately | |
2208 // checked. | |
2209 | |
2210 __ align(CodeEntryAlignment); | |
2211 StubCodeMark mark(this, "StubRoutines", name); | |
2212 address start = __ pc(); | |
2213 | |
2214 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2215 | |
2216 #ifdef ASSERT | |
2217 // caller guarantees that the arrays really are different | |
2218 // otherwise, we would have to make conjoint checks | |
2219 { Label L; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2220 array_overlap_test(L, TIMES_OOP); |
0 | 2221 __ stop("checkcast_copy within a single array"); |
2222 __ bind(L); | |
2223 } | |
2224 #endif //ASSERT | |
2225 | |
2226 setup_arg_regs(4); // from => rdi, to => rsi, length => rdx | |
2227 // ckoff => rcx, ckval => r8 | |
2228 // r9 and r10 may be used to save non-volatile registers | |
2229 #ifdef _WIN64 | |
2230 // last argument (#4) is on stack on Win64 | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2231 __ movptr(ckval, Address(rsp, 6 * wordSize)); |
0 | 2232 #endif |
2233 | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2234 // Caller of this entry point must set up the argument registers. |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2235 if (entry != NULL) { |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2236 *entry = __ pc(); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2237 BLOCK_COMMENT("Entry:"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2238 } |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2239 |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2240 // allocate spill slots for r13, r14 |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2241 enum { |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2242 saved_r13_offset, |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2243 saved_r14_offset, |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2244 saved_rbp_offset |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2245 }; |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2246 __ subptr(rsp, saved_rbp_offset * wordSize); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2247 __ movptr(Address(rsp, saved_r13_offset * wordSize), r13); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2248 __ movptr(Address(rsp, saved_r14_offset * wordSize), r14); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2249 |
0 | 2250 // check that int operands are properly extended to size_t |
2251 assert_clean_int(length, rax); | |
2252 assert_clean_int(ckoff, rax); | |
2253 | |
2254 #ifdef ASSERT | |
2255 BLOCK_COMMENT("assert consistent ckoff/ckval"); | |
2256 // The ckoff and ckval must be mutually consistent, | |
2257 // even though caller generates both. | |
2258 { Label L; | |
2259 int sco_offset = (klassOopDesc::header_size() * HeapWordSize + | |
2260 Klass::super_check_offset_offset_in_bytes()); | |
2261 __ cmpl(ckoff, Address(ckval, sco_offset)); | |
2262 __ jcc(Assembler::equal, L); | |
2263 __ stop("super_check_offset inconsistent"); | |
2264 __ bind(L); | |
2265 } | |
2266 #endif //ASSERT | |
2267 | |
2268 // Loop-invariant addresses. They are exclusive end pointers. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2269 Address end_from_addr(from, length, TIMES_OOP, 0); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2270 Address end_to_addr(to, length, TIMES_OOP, 0); |
0 | 2271 // Loop-variant addresses. They assume post-incremented count < 0. |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2272 Address from_element_addr(end_from, count, TIMES_OOP, 0); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2273 Address to_element_addr(end_to, count, TIMES_OOP, 0); |
0 | 2274 |
2324 | 2275 gen_write_ref_array_pre_barrier(to, count, dest_uninitialized); |
0 | 2276 |
2277 // Copy from low to high addresses, indexed from the end of each array. | |
304 | 2278 __ lea(end_from, end_from_addr); |
2279 __ lea(end_to, end_to_addr); | |
2280 __ movptr(r14_length, length); // save a copy of the length | |
2281 assert(length == count, ""); // else fix next line: | |
2282 __ negptr(count); // negate and test the length | |
0 | 2283 __ jcc(Assembler::notZero, L_load_element); |
2284 | |
2285 // Empty array: Nothing to do. | |
304 | 2286 __ xorptr(rax, rax); // return 0 on (trivial) success |
0 | 2287 __ jmp(L_done); |
2288 | |
2289 // ======== begin loop ======== | |
2290 // (Loop is rotated; its entry is L_load_element.) | |
2291 // Loop control: | |
2292 // for (count = -count; count != 0; count++) | |
2293 // Base pointers src, dst are biased by 8*(count-1),to last element. | |
1365 | 2294 __ align(OptoLoopAlignment); |
0 | 2295 |
2296 __ BIND(L_store_element); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2297 __ store_heap_oop(to_element_addr, rax_oop); // store the oop |
304 | 2298 __ increment(count); // increment the count toward zero |
0 | 2299 __ jcc(Assembler::zero, L_do_card_marks); |
2300 | |
2301 // ======== loop entry is here ======== | |
2302 __ BIND(L_load_element); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2303 __ load_heap_oop(rax_oop, from_element_addr); // load the oop |
304 | 2304 __ testptr(rax_oop, rax_oop); |
0 | 2305 __ jcc(Assembler::zero, L_store_element); |
2306 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2307 __ load_klass(r11_klass, rax_oop);// query the object klass |
0 | 2308 generate_type_check(r11_klass, ckoff, ckval, L_store_element); |
2309 // ======== end loop ======== | |
2310 | |
2311 // It was a real error; we must depend on the caller to finish the job. | |
2312 // Register rdx = -1 * number of *remaining* oops, r14 = *total* oops. | |
2313 // Emit GC store barriers for the oops we have copied (r14 + rdx), | |
2314 // and report their number to the caller. | |
2315 assert_different_registers(rax, r14_length, count, to, end_to, rcx); | |
304 | 2316 __ lea(end_to, to_element_addr); |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
2317 __ addptr(end_to, -heapOopSize); // make an inclusive end pointer |
362 | 2318 gen_write_ref_array_post_barrier(to, end_to, rscratch1); |
304 | 2319 __ movptr(rax, r14_length); // original oops |
2320 __ addptr(rax, count); // K = (original - remaining) oops | |
2321 __ notptr(rax); // report (-1^K) to caller | |
0 | 2322 __ jmp(L_done); |
2323 | |
2324 // Come here on success only. | |
2325 __ BIND(L_do_card_marks); | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
671
diff
changeset
|
2326 __ addptr(end_to, -heapOopSize); // make an inclusive end pointer |
362 | 2327 gen_write_ref_array_post_barrier(to, end_to, rscratch1); |
304 | 2328 __ xorptr(rax, rax); // return 0 on success |
0 | 2329 |
2330 // Common exit point (success or failure). | |
2331 __ BIND(L_done); | |
304 | 2332 __ movptr(r13, Address(rsp, saved_r13_offset * wordSize)); |
2333 __ movptr(r14, Address(rsp, saved_r14_offset * wordSize)); | |
0 | 2334 inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr); |
2335 restore_arg_regs(); | |
2336 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
2337 __ ret(0); | |
2338 | |
2339 return start; | |
2340 } | |
2341 | |
2342 // | |
2343 // Generate 'unsafe' array copy stub | |
2344 // Though just as safe as the other stubs, it takes an unscaled | |
2345 // size_t argument instead of an element count. | |
2346 // | |
2347 // Input: | |
2348 // c_rarg0 - source array address | |
2349 // c_rarg1 - destination array address | |
2350 // c_rarg2 - byte count, treated as ssize_t, can be zero | |
2351 // | |
2352 // Examines the alignment of the operands and dispatches | |
2353 // to a long, int, short, or byte copy loop. | |
2354 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2355 address generate_unsafe_copy(const char *name, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2356 address byte_copy_entry, address short_copy_entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2357 address int_copy_entry, address long_copy_entry) { |
0 | 2358 |
2359 Label L_long_aligned, L_int_aligned, L_short_aligned; | |
2360 | |
2361 // Input registers (before setup_arg_regs) | |
2362 const Register from = c_rarg0; // source array address | |
2363 const Register to = c_rarg1; // destination array address | |
2364 const Register size = c_rarg2; // byte count (size_t) | |
2365 | |
2366 // Register used as a temp | |
2367 const Register bits = rax; // test copy of low bits | |
2368 | |
2369 __ align(CodeEntryAlignment); | |
2370 StubCodeMark mark(this, "StubRoutines", name); | |
2371 address start = __ pc(); | |
2372 | |
2373 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2374 | |
2375 // bump this on entry, not on exit: | |
2376 inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr); | |
2377 | |
304 | 2378 __ mov(bits, from); |
2379 __ orptr(bits, to); | |
2380 __ orptr(bits, size); | |
0 | 2381 |
2382 __ testb(bits, BytesPerLong-1); | |
2383 __ jccb(Assembler::zero, L_long_aligned); | |
2384 | |
2385 __ testb(bits, BytesPerInt-1); | |
2386 __ jccb(Assembler::zero, L_int_aligned); | |
2387 | |
2388 __ testb(bits, BytesPerShort-1); | |
2389 __ jump_cc(Assembler::notZero, RuntimeAddress(byte_copy_entry)); | |
2390 | |
2391 __ BIND(L_short_aligned); | |
304 | 2392 __ shrptr(size, LogBytesPerShort); // size => short_count |
0 | 2393 __ jump(RuntimeAddress(short_copy_entry)); |
2394 | |
2395 __ BIND(L_int_aligned); | |
304 | 2396 __ shrptr(size, LogBytesPerInt); // size => int_count |
0 | 2397 __ jump(RuntimeAddress(int_copy_entry)); |
2398 | |
2399 __ BIND(L_long_aligned); | |
304 | 2400 __ shrptr(size, LogBytesPerLong); // size => qword_count |
0 | 2401 __ jump(RuntimeAddress(long_copy_entry)); |
2402 | |
2403 return start; | |
2404 } | |
2405 | |
2406 // Perform range checks on the proposed arraycopy. | |
2407 // Kills temp, but nothing else. | |
2408 // Also, clean the sign bits of src_pos and dst_pos. | |
2409 void arraycopy_range_checks(Register src, // source array oop (c_rarg0) | |
2410 Register src_pos, // source position (c_rarg1) | |
2411 Register dst, // destination array oo (c_rarg2) | |
2412 Register dst_pos, // destination position (c_rarg3) | |
2413 Register length, | |
2414 Register temp, | |
2415 Label& L_failed) { | |
2416 BLOCK_COMMENT("arraycopy_range_checks:"); | |
2417 | |
2418 // if (src_pos + length > arrayOop(src)->length()) FAIL; | |
2419 __ movl(temp, length); | |
2420 __ addl(temp, src_pos); // src_pos + length | |
2421 __ cmpl(temp, Address(src, arrayOopDesc::length_offset_in_bytes())); | |
2422 __ jcc(Assembler::above, L_failed); | |
2423 | |
2424 // if (dst_pos + length > arrayOop(dst)->length()) FAIL; | |
2425 __ movl(temp, length); | |
2426 __ addl(temp, dst_pos); // dst_pos + length | |
2427 __ cmpl(temp, Address(dst, arrayOopDesc::length_offset_in_bytes())); | |
2428 __ jcc(Assembler::above, L_failed); | |
2429 | |
2430 // Have to clean up high 32-bits of 'src_pos' and 'dst_pos'. | |
2431 // Move with sign extension can be used since they are positive. | |
2432 __ movslq(src_pos, src_pos); | |
2433 __ movslq(dst_pos, dst_pos); | |
2434 | |
2435 BLOCK_COMMENT("arraycopy_range_checks done"); | |
2436 } | |
2437 | |
2438 // | |
2439 // Generate generic array copy stubs | |
2440 // | |
2441 // Input: | |
2442 // c_rarg0 - src oop | |
2443 // c_rarg1 - src_pos (32-bits) | |
2444 // c_rarg2 - dst oop | |
2445 // c_rarg3 - dst_pos (32-bits) | |
2446 // not Win64 | |
2447 // c_rarg4 - element count (32-bits) | |
2448 // Win64 | |
2449 // rsp+40 - element count (32-bits) | |
2450 // | |
2451 // Output: | |
2452 // rax == 0 - success | |
2453 // rax == -1^K - failure, where K is partial transfer count | |
2454 // | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2455 address generate_generic_copy(const char *name, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2456 address byte_copy_entry, address short_copy_entry, |
2409
348c0df561a9
7026307: DEBUG MESSAGE: broken null klass on amd64
iveresov
parents:
2407
diff
changeset
|
2457 address int_copy_entry, address oop_copy_entry, |
348c0df561a9
7026307: DEBUG MESSAGE: broken null klass on amd64
iveresov
parents:
2407
diff
changeset
|
2458 address long_copy_entry, address checkcast_copy_entry) { |
0 | 2459 |
2460 Label L_failed, L_failed_0, L_objArray; | |
2461 Label L_copy_bytes, L_copy_shorts, L_copy_ints, L_copy_longs; | |
2462 | |
2463 // Input registers | |
2464 const Register src = c_rarg0; // source array oop | |
2465 const Register src_pos = c_rarg1; // source position | |
2466 const Register dst = c_rarg2; // destination array oop | |
2467 const Register dst_pos = c_rarg3; // destination position | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2468 #ifndef _WIN64 |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2469 const Register length = c_rarg4; |
0 | 2470 #else |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2471 const Address length(rsp, 6 * wordSize); // elements count is on stack on Win64 |
0 | 2472 #endif |
2473 | |
2474 { int modulus = CodeEntryAlignment; | |
2475 int target = modulus - 5; // 5 = sizeof jmp(L_failed) | |
2476 int advance = target - (__ offset() % modulus); | |
2477 if (advance < 0) advance += modulus; | |
2478 if (advance > 0) __ nop(advance); | |
2479 } | |
2480 StubCodeMark mark(this, "StubRoutines", name); | |
2481 | |
2482 // Short-hop target to L_failed. Makes for denser prologue code. | |
2483 __ BIND(L_failed_0); | |
2484 __ jmp(L_failed); | |
2485 assert(__ offset() % CodeEntryAlignment == 0, "no further alignment needed"); | |
2486 | |
2487 __ align(CodeEntryAlignment); | |
2488 address start = __ pc(); | |
2489 | |
2490 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2491 | |
2492 // bump this on entry, not on exit: | |
2493 inc_counter_np(SharedRuntime::_generic_array_copy_ctr); | |
2494 | |
2495 //----------------------------------------------------------------------- | |
2496 // Assembler stub will be used for this call to arraycopy | |
2497 // if the following conditions are met: | |
2498 // | |
2499 // (1) src and dst must not be null. | |
2500 // (2) src_pos must not be negative. | |
2501 // (3) dst_pos must not be negative. | |
2502 // (4) length must not be negative. | |
2503 // (5) src klass and dst klass should be the same and not NULL. | |
2504 // (6) src and dst should be arrays. | |
2505 // (7) src_pos + length must not exceed length of src. | |
2506 // (8) dst_pos + length must not exceed length of dst. | |
2507 // | |
2508 | |
2509 // if (src == NULL) return -1; | |
304 | 2510 __ testptr(src, src); // src oop |
0 | 2511 size_t j1off = __ offset(); |
2512 __ jccb(Assembler::zero, L_failed_0); | |
2513 | |
2514 // if (src_pos < 0) return -1; | |
2515 __ testl(src_pos, src_pos); // src_pos (32-bits) | |
2516 __ jccb(Assembler::negative, L_failed_0); | |
2517 | |
2518 // if (dst == NULL) return -1; | |
304 | 2519 __ testptr(dst, dst); // dst oop |
0 | 2520 __ jccb(Assembler::zero, L_failed_0); |
2521 | |
2522 // if (dst_pos < 0) return -1; | |
2523 __ testl(dst_pos, dst_pos); // dst_pos (32-bits) | |
2524 size_t j4off = __ offset(); | |
2525 __ jccb(Assembler::negative, L_failed_0); | |
2526 | |
2527 // The first four tests are very dense code, | |
2528 // but not quite dense enough to put four | |
2529 // jumps in a 16-byte instruction fetch buffer. | |
2530 // That's good, because some branch predicters | |
2531 // do not like jumps so close together. | |
2532 // Make sure of this. | |
2533 guarantee(((j1off ^ j4off) & ~15) != 0, "I$ line of 1st & 4th jumps"); | |
2534 | |
2535 // registers used as temp | |
2536 const Register r11_length = r11; // elements count to copy | |
2537 const Register r10_src_klass = r10; // array klass | |
2538 | |
2539 // if (length < 0) return -1; | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2540 __ movl(r11_length, length); // length (elements count, 32-bits value) |
0 | 2541 __ testl(r11_length, r11_length); |
2542 __ jccb(Assembler::negative, L_failed_0); | |
2543 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2544 __ load_klass(r10_src_klass, src); |
0 | 2545 #ifdef ASSERT |
2546 // assert(src->klass() != NULL); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2547 { |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2548 BLOCK_COMMENT("assert klasses not null {"); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2549 Label L1, L2; |
304 | 2550 __ testptr(r10_src_klass, r10_src_klass); |
0 | 2551 __ jcc(Assembler::notZero, L2); // it is broken if klass is NULL |
2552 __ bind(L1); | |
2553 __ stop("broken null klass"); | |
2554 __ bind(L2); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2555 __ load_klass(rax, dst); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2556 __ cmpq(rax, 0); |
0 | 2557 __ jcc(Assembler::equal, L1); // this would be broken also |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2558 BLOCK_COMMENT("} assert klasses not null done"); |
0 | 2559 } |
2560 #endif | |
2561 | |
2562 // Load layout helper (32-bits) | |
2563 // | |
2564 // |array_tag| | header_size | element_type | |log2_element_size| | |
2565 // 32 30 24 16 8 2 0 | |
2566 // | |
2567 // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0 | |
2568 // | |
2569 | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2570 const int lh_offset = klassOopDesc::header_size() * HeapWordSize + |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2571 Klass::layout_helper_offset_in_bytes(); |
0 | 2572 |
2573 // Handle objArrays completely differently... | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2574 const jint objArray_lh = Klass::array_layout_helper(T_OBJECT); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2575 __ cmpl(Address(r10_src_klass, lh_offset), objArray_lh); |
0 | 2576 __ jcc(Assembler::equal, L_objArray); |
2577 | |
2578 // if (src->klass() != dst->klass()) return -1; | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2579 __ load_klass(rax, dst); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2580 __ cmpq(r10_src_klass, rax); |
0 | 2581 __ jcc(Assembler::notEqual, L_failed); |
2582 | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2583 const Register rax_lh = rax; // layout helper |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2584 __ movl(rax_lh, Address(r10_src_klass, lh_offset)); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2585 |
0 | 2586 // if (!src->is_Array()) return -1; |
2587 __ cmpl(rax_lh, Klass::_lh_neutral_value); | |
2588 __ jcc(Assembler::greaterEqual, L_failed); | |
2589 | |
2590 // At this point, it is known to be a typeArray (array_tag 0x3). | |
2591 #ifdef ASSERT | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2592 { |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2593 BLOCK_COMMENT("assert primitive array {"); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2594 Label L; |
0 | 2595 __ cmpl(rax_lh, (Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift)); |
2596 __ jcc(Assembler::greaterEqual, L); | |
2597 __ stop("must be a primitive array"); | |
2598 __ bind(L); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2599 BLOCK_COMMENT("} assert primitive array done"); |
0 | 2600 } |
2601 #endif | |
2602 | |
2603 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length, | |
2604 r10, L_failed); | |
2605 | |
2606 // typeArrayKlass | |
2607 // | |
2608 // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize); | |
2609 // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize); | |
2610 // | |
2611 | |
2612 const Register r10_offset = r10; // array offset | |
2613 const Register rax_elsize = rax_lh; // element size | |
2614 | |
2615 __ movl(r10_offset, rax_lh); | |
2616 __ shrl(r10_offset, Klass::_lh_header_size_shift); | |
304 | 2617 __ andptr(r10_offset, Klass::_lh_header_size_mask); // array_offset |
2618 __ addptr(src, r10_offset); // src array offset | |
2619 __ addptr(dst, r10_offset); // dst array offset | |
0 | 2620 BLOCK_COMMENT("choose copy loop based on element size"); |
2621 __ andl(rax_lh, Klass::_lh_log2_element_size_mask); // rax_lh -> rax_elsize | |
2622 | |
2623 // next registers should be set before the jump to corresponding stub | |
2624 const Register from = c_rarg0; // source array address | |
2625 const Register to = c_rarg1; // destination array address | |
2626 const Register count = c_rarg2; // elements count | |
2627 | |
2628 // 'from', 'to', 'count' registers should be set in such order | |
2629 // since they are the same as 'src', 'src_pos', 'dst'. | |
2630 | |
2631 __ BIND(L_copy_bytes); | |
2632 __ cmpl(rax_elsize, 0); | |
2633 __ jccb(Assembler::notEqual, L_copy_shorts); | |
304 | 2634 __ lea(from, Address(src, src_pos, Address::times_1, 0));// src_addr |
2635 __ lea(to, Address(dst, dst_pos, Address::times_1, 0));// dst_addr | |
2636 __ movl2ptr(count, r11_length); // length | |
0 | 2637 __ jump(RuntimeAddress(byte_copy_entry)); |
2638 | |
2639 __ BIND(L_copy_shorts); | |
2640 __ cmpl(rax_elsize, LogBytesPerShort); | |
2641 __ jccb(Assembler::notEqual, L_copy_ints); | |
304 | 2642 __ lea(from, Address(src, src_pos, Address::times_2, 0));// src_addr |
2643 __ lea(to, Address(dst, dst_pos, Address::times_2, 0));// dst_addr | |
2644 __ movl2ptr(count, r11_length); // length | |
0 | 2645 __ jump(RuntimeAddress(short_copy_entry)); |
2646 | |
2647 __ BIND(L_copy_ints); | |
2648 __ cmpl(rax_elsize, LogBytesPerInt); | |
2649 __ jccb(Assembler::notEqual, L_copy_longs); | |
304 | 2650 __ lea(from, Address(src, src_pos, Address::times_4, 0));// src_addr |
2651 __ lea(to, Address(dst, dst_pos, Address::times_4, 0));// dst_addr | |
2652 __ movl2ptr(count, r11_length); // length | |
0 | 2653 __ jump(RuntimeAddress(int_copy_entry)); |
2654 | |
2655 __ BIND(L_copy_longs); | |
2656 #ifdef ASSERT | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2657 { |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2658 BLOCK_COMMENT("assert long copy {"); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2659 Label L; |
0 | 2660 __ cmpl(rax_elsize, LogBytesPerLong); |
2661 __ jcc(Assembler::equal, L); | |
2662 __ stop("must be long copy, but elsize is wrong"); | |
2663 __ bind(L); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2664 BLOCK_COMMENT("} assert long copy done"); |
0 | 2665 } |
2666 #endif | |
304 | 2667 __ lea(from, Address(src, src_pos, Address::times_8, 0));// src_addr |
2668 __ lea(to, Address(dst, dst_pos, Address::times_8, 0));// dst_addr | |
2669 __ movl2ptr(count, r11_length); // length | |
0 | 2670 __ jump(RuntimeAddress(long_copy_entry)); |
2671 | |
2672 // objArrayKlass | |
2673 __ BIND(L_objArray); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2674 // live at this point: r10_src_klass, r11_length, src[_pos], dst[_pos] |
0 | 2675 |
2676 Label L_plain_copy, L_checkcast_copy; | |
2677 // test array classes for subtyping | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2678 __ load_klass(rax, dst); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2679 __ cmpq(r10_src_klass, rax); // usual case is exact equality |
0 | 2680 __ jcc(Assembler::notEqual, L_checkcast_copy); |
2681 | |
2682 // Identically typed arrays can be copied without element-wise checks. | |
2683 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length, | |
2684 r10, L_failed); | |
2685 | |
304 | 2686 __ lea(from, Address(src, src_pos, TIMES_OOP, |
0 | 2687 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // src_addr |
304 | 2688 __ lea(to, Address(dst, dst_pos, TIMES_OOP, |
2689 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); // dst_addr | |
2690 __ movl2ptr(count, r11_length); // length | |
0 | 2691 __ BIND(L_plain_copy); |
2692 __ jump(RuntimeAddress(oop_copy_entry)); | |
2693 | |
2694 __ BIND(L_checkcast_copy); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2695 // live at this point: r10_src_klass, r11_length, rax (dst_klass) |
0 | 2696 { |
2697 // Before looking at dst.length, make sure dst is also an objArray. | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2698 __ cmpl(Address(rax, lh_offset), objArray_lh); |
0 | 2699 __ jcc(Assembler::notEqual, L_failed); |
2700 | |
2701 // It is safe to examine both src.length and dst.length. | |
2702 arraycopy_range_checks(src, src_pos, dst, dst_pos, r11_length, | |
2703 rax, L_failed); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2704 |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2705 const Register r11_dst_klass = r11; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2706 __ load_klass(r11_dst_klass, dst); // reload |
0 | 2707 |
2708 // Marshal the base address arguments now, freeing registers. | |
304 | 2709 __ lea(from, Address(src, src_pos, TIMES_OOP, |
0 | 2710 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
304 | 2711 __ lea(to, Address(dst, dst_pos, TIMES_OOP, |
0 | 2712 arrayOopDesc::base_offset_in_bytes(T_OBJECT))); |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2713 __ movl(count, length); // length (reloaded) |
0 | 2714 Register sco_temp = c_rarg3; // this register is free now |
2715 assert_different_registers(from, to, count, sco_temp, | |
2716 r11_dst_klass, r10_src_klass); | |
2717 assert_clean_int(count, sco_temp); | |
2718 | |
2719 // Generate the type check. | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2720 const int sco_offset = (klassOopDesc::header_size() * HeapWordSize + |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2721 Klass::super_check_offset_offset_in_bytes()); |
0 | 2722 __ movl(sco_temp, Address(r11_dst_klass, sco_offset)); |
2723 assert_clean_int(sco_temp, rax); | |
2724 generate_type_check(r10_src_klass, sco_temp, r11_dst_klass, L_plain_copy); | |
2725 | |
2726 // Fetch destination element klass from the objArrayKlass header. | |
2727 int ek_offset = (klassOopDesc::header_size() * HeapWordSize + | |
2728 objArrayKlass::element_klass_offset_in_bytes()); | |
304 | 2729 __ movptr(r11_dst_klass, Address(r11_dst_klass, ek_offset)); |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2730 __ movl( sco_temp, Address(r11_dst_klass, sco_offset)); |
0 | 2731 assert_clean_int(sco_temp, rax); |
2732 | |
2733 // the checkcast_copy loop needs two extra arguments: | |
2734 assert(c_rarg3 == sco_temp, "#3 already in place"); | |
2006
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2735 // Set up arguments for checkcast_copy_entry. |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2736 setup_arg_regs(4); |
bbefa3ca1543
6998985: faulty generic arraycopy on windows x86_64: 4th arg overwritten with oop
twisti
parents:
1972
diff
changeset
|
2737 __ movptr(r8, r11_dst_klass); // dst.klass.element_klass, r8 is c_rarg4 on Linux/Solaris |
0 | 2738 __ jump(RuntimeAddress(checkcast_copy_entry)); |
2739 } | |
2740 | |
2741 __ BIND(L_failed); | |
304 | 2742 __ xorptr(rax, rax); |
2743 __ notptr(rax); // return -1 | |
0 | 2744 __ leave(); // required for proper stackwalking of RuntimeStub frame |
2745 __ ret(0); | |
2746 | |
2747 return start; | |
2748 } | |
2749 | |
2750 void generate_arraycopy_stubs() { | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2751 address entry; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2752 address entry_jbyte_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2753 address entry_jshort_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2754 address entry_jint_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2755 address entry_oop_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2756 address entry_jlong_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2757 address entry_checkcast_arraycopy; |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2758 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2759 StubRoutines::_jbyte_disjoint_arraycopy = generate_disjoint_byte_copy(false, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2760 "jbyte_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2761 StubRoutines::_jbyte_arraycopy = generate_conjoint_byte_copy(false, entry, &entry_jbyte_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2762 "jbyte_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2763 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2764 StubRoutines::_jshort_disjoint_arraycopy = generate_disjoint_short_copy(false, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2765 "jshort_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2766 StubRoutines::_jshort_arraycopy = generate_conjoint_short_copy(false, entry, &entry_jshort_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2767 "jshort_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2768 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2769 StubRoutines::_jint_disjoint_arraycopy = generate_disjoint_int_oop_copy(false, false, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2770 "jint_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2771 StubRoutines::_jint_arraycopy = generate_conjoint_int_oop_copy(false, false, entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2772 &entry_jint_arraycopy, "jint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2773 |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2774 StubRoutines::_jlong_disjoint_arraycopy = generate_disjoint_long_oop_copy(false, false, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2775 "jlong_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2776 StubRoutines::_jlong_arraycopy = generate_conjoint_long_oop_copy(false, false, entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2777 &entry_jlong_arraycopy, "jlong_arraycopy"); |
0 | 2778 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2779 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2780 if (UseCompressedOops) { |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2781 StubRoutines::_oop_disjoint_arraycopy = generate_disjoint_int_oop_copy(false, true, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2782 "oop_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2783 StubRoutines::_oop_arraycopy = generate_conjoint_int_oop_copy(false, true, entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2784 &entry_oop_arraycopy, "oop_arraycopy"); |
2324 | 2785 StubRoutines::_oop_disjoint_arraycopy_uninit = generate_disjoint_int_oop_copy(false, true, &entry, |
2786 "oop_disjoint_arraycopy_uninit", | |
2787 /*dest_uninitialized*/true); | |
2788 StubRoutines::_oop_arraycopy_uninit = generate_conjoint_int_oop_copy(false, true, entry, | |
2789 NULL, "oop_arraycopy_uninit", | |
2790 /*dest_uninitialized*/true); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2791 } else { |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2792 StubRoutines::_oop_disjoint_arraycopy = generate_disjoint_long_oop_copy(false, true, &entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2793 "oop_disjoint_arraycopy"); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2794 StubRoutines::_oop_arraycopy = generate_conjoint_long_oop_copy(false, true, entry, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2795 &entry_oop_arraycopy, "oop_arraycopy"); |
2324 | 2796 StubRoutines::_oop_disjoint_arraycopy_uninit = generate_disjoint_long_oop_copy(false, true, &entry, |
2797 "oop_disjoint_arraycopy_uninit", | |
2798 /*dest_uninitialized*/true); | |
2799 StubRoutines::_oop_arraycopy_uninit = generate_conjoint_long_oop_copy(false, true, entry, | |
2800 NULL, "oop_arraycopy_uninit", | |
2801 /*dest_uninitialized*/true); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
16
diff
changeset
|
2802 } |
0 | 2803 |
2324 | 2804 StubRoutines::_checkcast_arraycopy = generate_checkcast_copy("checkcast_arraycopy", &entry_checkcast_arraycopy); |
2805 StubRoutines::_checkcast_arraycopy_uninit = generate_checkcast_copy("checkcast_arraycopy_uninit", NULL, | |
2806 /*dest_uninitialized*/true); | |
2807 | |
2313
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2808 StubRoutines::_unsafe_arraycopy = generate_unsafe_copy("unsafe_arraycopy", |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2809 entry_jbyte_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2810 entry_jshort_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2811 entry_jint_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2812 entry_jlong_arraycopy); |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2813 StubRoutines::_generic_arraycopy = generate_generic_copy("generic_arraycopy", |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2814 entry_jbyte_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2815 entry_jshort_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2816 entry_jint_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2817 entry_oop_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2818 entry_jlong_arraycopy, |
d89a22843c62
7020521: arraycopy stubs place prebarriers incorrectly
iveresov
parents:
2006
diff
changeset
|
2819 entry_checkcast_arraycopy); |
0 | 2820 |
1763 | 2821 StubRoutines::_jbyte_fill = generate_fill(T_BYTE, false, "jbyte_fill"); |
2822 StubRoutines::_jshort_fill = generate_fill(T_SHORT, false, "jshort_fill"); | |
2823 StubRoutines::_jint_fill = generate_fill(T_INT, false, "jint_fill"); | |
2824 StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill"); | |
2825 StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill"); | |
2826 StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill"); | |
2827 | |
0 | 2828 // We don't generate specialized code for HeapWord-aligned source |
2829 // arrays, so just use the code we've already generated | |
2830 StubRoutines::_arrayof_jbyte_disjoint_arraycopy = StubRoutines::_jbyte_disjoint_arraycopy; | |
2831 StubRoutines::_arrayof_jbyte_arraycopy = StubRoutines::_jbyte_arraycopy; | |
2832 | |
2833 StubRoutines::_arrayof_jshort_disjoint_arraycopy = StubRoutines::_jshort_disjoint_arraycopy; | |
2834 StubRoutines::_arrayof_jshort_arraycopy = StubRoutines::_jshort_arraycopy; | |
2835 | |
2836 StubRoutines::_arrayof_jint_disjoint_arraycopy = StubRoutines::_jint_disjoint_arraycopy; | |
2837 StubRoutines::_arrayof_jint_arraycopy = StubRoutines::_jint_arraycopy; | |
2838 | |
2839 StubRoutines::_arrayof_jlong_disjoint_arraycopy = StubRoutines::_jlong_disjoint_arraycopy; | |
2840 StubRoutines::_arrayof_jlong_arraycopy = StubRoutines::_jlong_arraycopy; | |
2841 | |
2842 StubRoutines::_arrayof_oop_disjoint_arraycopy = StubRoutines::_oop_disjoint_arraycopy; | |
2843 StubRoutines::_arrayof_oop_arraycopy = StubRoutines::_oop_arraycopy; | |
2324 | 2844 |
2845 StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit = StubRoutines::_oop_disjoint_arraycopy_uninit; | |
2846 StubRoutines::_arrayof_oop_arraycopy_uninit = StubRoutines::_oop_arraycopy_uninit; | |
0 | 2847 } |
2848 | |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2849 void generate_math_stubs() { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2850 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2851 StubCodeMark mark(this, "StubRoutines", "log"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2852 StubRoutines::_intrinsic_log = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2853 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2854 __ subq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2855 __ movdbl(Address(rsp, 0), xmm0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2856 __ fld_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2857 __ flog(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2858 __ fstp_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2859 __ movdbl(xmm0, Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2860 __ addq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2861 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2862 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2863 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2864 StubCodeMark mark(this, "StubRoutines", "log10"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2865 StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2866 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2867 __ subq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2868 __ movdbl(Address(rsp, 0), xmm0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2869 __ fld_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2870 __ flog10(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2871 __ fstp_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2872 __ movdbl(xmm0, Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2873 __ addq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2874 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2875 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2876 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2877 StubCodeMark mark(this, "StubRoutines", "sin"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2878 StubRoutines::_intrinsic_sin = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2879 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2880 __ subq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2881 __ movdbl(Address(rsp, 0), xmm0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2882 __ fld_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2883 __ trigfunc('s'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2884 __ fstp_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2885 __ movdbl(xmm0, Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2886 __ addq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2887 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2888 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2889 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2890 StubCodeMark mark(this, "StubRoutines", "cos"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2891 StubRoutines::_intrinsic_cos = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2892 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2893 __ subq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2894 __ movdbl(Address(rsp, 0), xmm0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2895 __ fld_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2896 __ trigfunc('c'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2897 __ fstp_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2898 __ movdbl(xmm0, Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2899 __ addq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2900 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2901 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2902 { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2903 StubCodeMark mark(this, "StubRoutines", "tan"); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2904 StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc(); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2905 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2906 __ subq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2907 __ movdbl(Address(rsp, 0), xmm0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2908 __ fld_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2909 __ trigfunc('t'); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2910 __ fstp_d(Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2911 __ movdbl(xmm0, Address(rsp, 0)); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2912 __ addq(rsp, 8); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2913 __ ret(0); |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2914 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2915 |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2916 // 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:
1108
diff
changeset
|
2917 // the strict version. |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2918 StubRoutines::_intrinsic_exp = SharedRuntime::dexp; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2919 StubRoutines::_intrinsic_pow = SharedRuntime::dpow; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2920 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
2921 |
0 | 2922 #undef __ |
2923 #define __ masm-> | |
2924 | |
2925 // Continuation point for throwing of implicit exceptions that are | |
2926 // not handled in the current activation. Fabricates an exception | |
2927 // oop and initiates normal exception dispatching in this | |
2928 // frame. Since we need to preserve callee-saved values (currently | |
2929 // only for C2, but done for C1 as well) we need a callee-saved oop | |
2930 // map and therefore have to make these stubs into RuntimeStubs | |
2931 // rather than BufferBlobs. If the compiler needs all registers to | |
2932 // be preserved between the fault point and the exception handler | |
2933 // then it must assume responsibility for that in | |
2934 // AbstractCompiler::continuation_for_implicit_null_exception or | |
2935 // continuation_for_implicit_division_by_zero_exception. All other | |
2936 // implicit exceptions (e.g., NullPointerException or | |
2937 // AbstractMethodError on entry) are either at call sites or | |
2938 // otherwise assume that stack unwinding will be initiated, so | |
2939 // caller saved registers were assumed volatile in the compiler. | |
2940 address generate_throw_exception(const char* name, | |
2941 address runtime_entry, | |
3781
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2942 Register arg1 = noreg, |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2943 Register arg2 = noreg) { |
0 | 2944 // Information about frame layout at time of blocking runtime call. |
2945 // Note that we only have to preserve callee-saved registers since | |
2946 // the compilers are responsible for supplying a continuation point | |
2947 // if they expect all registers to be preserved. | |
2948 enum layout { | |
2949 rbp_off = frame::arg_reg_save_area_bytes/BytesPerInt, | |
2950 rbp_off2, | |
2951 return_off, | |
2952 return_off2, | |
2953 framesize // inclusive of return address | |
2954 }; | |
2955 | |
2956 int insts_size = 512; | |
2957 int locs_size = 64; | |
2958 | |
2959 CodeBuffer code(name, insts_size, locs_size); | |
2960 OopMapSet* oop_maps = new OopMapSet(); | |
2961 MacroAssembler* masm = new MacroAssembler(&code); | |
2962 | |
2963 address start = __ pc(); | |
2964 | |
2965 // This is an inlined and slightly modified version of call_VM | |
2966 // which has the ability to fetch the return PC out of | |
2967 // thread-local storage and also sets up last_Java_sp slightly | |
2968 // differently than the real call_VM | |
2969 | |
2970 __ enter(); // required for proper stackwalking of RuntimeStub frame | |
2971 | |
2972 assert(is_even(framesize/2), "sp not 16-byte aligned"); | |
2973 | |
2974 // return address and rbp are already in place | |
304 | 2975 __ subptr(rsp, (framesize-4) << LogBytesPerInt); // prolog |
0 | 2976 |
2977 int frame_complete = __ pc() - start; | |
2978 | |
2979 // Set up last_Java_sp and last_Java_fp | |
2980 __ set_last_Java_frame(rsp, rbp, NULL); | |
2981 | |
2982 // Call runtime | |
3781
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2983 if (arg1 != noreg) { |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2984 assert(arg2 != c_rarg1, "clobbered"); |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2985 __ movptr(c_rarg1, arg1); |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2986 } |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2987 if (arg2 != noreg) { |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2988 __ movptr(c_rarg2, arg2); |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
2989 } |
304 | 2990 __ movptr(c_rarg0, r15_thread); |
0 | 2991 BLOCK_COMMENT("call runtime_entry"); |
2992 __ call(RuntimeAddress(runtime_entry)); | |
2993 | |
2994 // Generate oop map | |
2995 OopMap* map = new OopMap(framesize, 0); | |
2996 | |
2997 oop_maps->add_gc_map(__ pc() - start, map); | |
2998 | |
2999 __ reset_last_Java_frame(true, false); | |
3000 | |
3001 __ leave(); // required for proper stackwalking of RuntimeStub frame | |
3002 | |
3003 // check for pending exceptions | |
3004 #ifdef ASSERT | |
3005 Label L; | |
304 | 3006 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), |
3007 (int32_t) NULL_WORD); | |
0 | 3008 __ jcc(Assembler::notEqual, L); |
3009 __ should_not_reach_here(); | |
3010 __ bind(L); | |
3011 #endif // ASSERT | |
3012 __ jump(RuntimeAddress(StubRoutines::forward_exception_entry())); | |
3013 | |
3014 | |
3015 // codeBlob framesize is in words (not VMRegImpl::slot_size) | |
3016 RuntimeStub* stub = | |
3017 RuntimeStub::new_runtime_stub(name, | |
3018 &code, | |
3019 frame_complete, | |
3020 (framesize >> (LogBytesPerWord - LogBytesPerInt)), | |
3021 oop_maps, false); | |
3022 return stub->entry_point(); | |
3023 } | |
3024 | |
3025 // Initialization | |
3026 void generate_initial() { | |
3027 // Generates all stubs and initializes the entry points | |
3028 | |
3029 // This platform-specific stub is needed by generate_call_stub() | |
304 | 3030 StubRoutines::x86::_mxcsr_std = generate_fp_mask("mxcsr_std", 0x0000000000001F80); |
0 | 3031 |
3032 // entry points that exist in all platforms Note: This is code | |
3033 // that could be shared among different platforms - however the | |
3034 // benefit seems to be smaller than the disadvantage of having a | |
3035 // much more complicated generator structure. See also comment in | |
3036 // stubRoutines.hpp. | |
3037 | |
3038 StubRoutines::_forward_exception_entry = generate_forward_exception(); | |
3039 | |
3040 StubRoutines::_call_stub_entry = | |
3041 generate_call_stub(StubRoutines::_call_stub_return_address); | |
3042 | |
3043 // is referenced by megamorphic call | |
3044 StubRoutines::_catch_exception_entry = generate_catch_exception(); | |
3045 | |
3046 // atomic calls | |
3047 StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); | |
3048 StubRoutines::_atomic_xchg_ptr_entry = generate_atomic_xchg_ptr(); | |
3049 StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg(); | |
3050 StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long(); | |
3051 StubRoutines::_atomic_add_entry = generate_atomic_add(); | |
3052 StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr(); | |
3053 StubRoutines::_fence_entry = generate_orderaccess_fence(); | |
3054 | |
3055 StubRoutines::_handler_for_unsafe_access_entry = | |
3056 generate_handler_for_unsafe_access(); | |
3057 | |
3058 // platform dependent | |
304 | 3059 StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp(); |
3060 | |
3061 StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr(); | |
3781
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3062 |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3063 // Build this early so it's available for the interpreter. Stub |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3064 // expects the required and actual types as register arguments in |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3065 // j_rarg0 and j_rarg1 respectively. |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3066 StubRoutines::_throw_WrongMethodTypeException_entry = |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3067 generate_throw_exception("WrongMethodTypeException throw_exception", |
d83ac25d0304
7055355: JSR 292: crash while throwing WrongMethodTypeException
never
parents:
2409
diff
changeset
|
3068 CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException), |
3937 | 3069 rax, rcx); |
0 | 3070 } |
3071 | |
3072 void generate_all() { | |
3073 // Generates all stubs and initializes the entry points | |
3074 | |
3075 // These entry points require SharedInfo::stack0 to be set up in | |
3076 // non-core builds and need to be relocatable, so they each | |
3077 // fabricate a RuntimeStub internally. | |
3078 StubRoutines::_throw_AbstractMethodError_entry = | |
3079 generate_throw_exception("AbstractMethodError throw_exception", | |
3080 CAST_FROM_FN_PTR(address, | |
3081 SharedRuntime:: | |
3937 | 3082 throw_AbstractMethodError)); |
0 | 3083 |
16
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
3084 StubRoutines::_throw_IncompatibleClassChangeError_entry = |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
3085 generate_throw_exception("IncompatibleClassChangeError throw_exception", |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
3086 CAST_FROM_FN_PTR(address, |
f8236e79048a
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
0
diff
changeset
|
3087 SharedRuntime:: |
3937 | 3088 throw_IncompatibleClassChangeError)); |
0 | 3089 |
3090 StubRoutines::_throw_NullPointerException_at_call_entry = | |
3091 generate_throw_exception("NullPointerException at call throw_exception", | |
3092 CAST_FROM_FN_PTR(address, | |
3093 SharedRuntime:: | |
3937 | 3094 throw_NullPointerException_at_call)); |
0 | 3095 |
3096 StubRoutines::_throw_StackOverflowError_entry = | |
3097 generate_throw_exception("StackOverflowError throw_exception", | |
3098 CAST_FROM_FN_PTR(address, | |
3099 SharedRuntime:: | |
3937 | 3100 throw_StackOverflowError)); |
0 | 3101 |
3102 // entry points that are platform specific | |
304 | 3103 StubRoutines::x86::_f2i_fixup = generate_f2i_fixup(); |
3104 StubRoutines::x86::_f2l_fixup = generate_f2l_fixup(); | |
3105 StubRoutines::x86::_d2i_fixup = generate_d2i_fixup(); | |
3106 StubRoutines::x86::_d2l_fixup = generate_d2l_fixup(); | |
3107 | |
3108 StubRoutines::x86::_float_sign_mask = generate_fp_mask("float_sign_mask", 0x7FFFFFFF7FFFFFFF); | |
3109 StubRoutines::x86::_float_sign_flip = generate_fp_mask("float_sign_flip", 0x8000000080000000); | |
3110 StubRoutines::x86::_double_sign_mask = generate_fp_mask("double_sign_mask", 0x7FFFFFFFFFFFFFFF); | |
3111 StubRoutines::x86::_double_sign_flip = generate_fp_mask("double_sign_flip", 0x8000000000000000); | |
0 | 3112 |
3113 // support for verify_oop (must happen after universe_init) | |
3114 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); | |
3115 | |
3116 // arraycopy stubs used by compilers | |
3117 generate_arraycopy_stubs(); | |
1108 | 3118 |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1108
diff
changeset
|
3119 generate_math_stubs(); |
0 | 3120 } |
3121 | |
3122 public: | |
3123 StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { | |
3124 if (all) { | |
3125 generate_all(); | |
3126 } else { | |
3127 generate_initial(); | |
3128 } | |
3129 } | |
3130 }; // end class declaration | |
3131 | |
3132 void StubGenerator_generate(CodeBuffer* code, bool all) { | |
3133 StubGenerator g(code, all); | |
3134 } |