annotate src/cpu/x86/vm/stubGenerator_x86_32.cpp @ 1192:776fb94f33cc

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