annotate src/cpu/x86/vm/stubGenerator_x86_64.cpp @ 1972:f95d63e2154a

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