annotate src/share/vm/runtime/stubRoutines.cpp @ 4731:1f114331df92

8023730: new hotspot build - hs24-b57 Reviewed-by: jcoomes
author amurillo
date Mon, 26 Aug 2013 12:06:09 -0700
parents 1d7922586cf6
children
rev   line source
duke@0 1 /*
iveresov@2142 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1489 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1489 20 * or visit www.oracle.com if you need additional information or have any
trims@1489 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1869 25 #include "precompiled.hpp"
stefank@1869 26 #include "asm/codeBuffer.hpp"
stefank@1869 27 #include "memory/resourceArea.hpp"
stefank@1869 28 #include "oops/oop.inline.hpp"
stefank@1869 29 #include "runtime/interfaceSupport.hpp"
stefank@1869 30 #include "runtime/sharedRuntime.hpp"
stefank@1869 31 #include "runtime/stubRoutines.hpp"
stefank@1869 32 #include "runtime/timer.hpp"
stefank@1869 33 #include "utilities/copy.hpp"
stefank@1869 34 #ifdef COMPILER2
stefank@1869 35 #include "opto/runtime.hpp"
stefank@1869 36 #endif
duke@0 37
duke@0 38
duke@0 39 // Implementation of StubRoutines - for a description
duke@0 40 // of how to extend it, see the header file.
duke@0 41
duke@0 42 // Class Variables
duke@0 43
duke@0 44 BufferBlob* StubRoutines::_code1 = NULL;
duke@0 45 BufferBlob* StubRoutines::_code2 = NULL;
duke@0 46
duke@0 47 address StubRoutines::_call_stub_return_address = NULL;
duke@0 48 address StubRoutines::_call_stub_entry = NULL;
duke@0 49
duke@0 50 address StubRoutines::_catch_exception_entry = NULL;
duke@0 51 address StubRoutines::_forward_exception_entry = NULL;
duke@0 52 address StubRoutines::_throw_AbstractMethodError_entry = NULL;
dcubed@3 53 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
duke@0 54 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
duke@0 55 address StubRoutines::_throw_StackOverflowError_entry = NULL;
duke@0 56 address StubRoutines::_handler_for_unsafe_access_entry = NULL;
duke@0 57 jint StubRoutines::_verify_oop_count = 0;
duke@0 58 address StubRoutines::_verify_oop_subroutine_entry = NULL;
duke@0 59 address StubRoutines::_atomic_xchg_entry = NULL;
duke@0 60 address StubRoutines::_atomic_xchg_ptr_entry = NULL;
duke@0 61 address StubRoutines::_atomic_store_entry = NULL;
duke@0 62 address StubRoutines::_atomic_store_ptr_entry = NULL;
duke@0 63 address StubRoutines::_atomic_cmpxchg_entry = NULL;
duke@0 64 address StubRoutines::_atomic_cmpxchg_ptr_entry = NULL;
duke@0 65 address StubRoutines::_atomic_cmpxchg_long_entry = NULL;
duke@0 66 address StubRoutines::_atomic_add_entry = NULL;
duke@0 67 address StubRoutines::_atomic_add_ptr_entry = NULL;
duke@0 68 address StubRoutines::_fence_entry = NULL;
duke@0 69 address StubRoutines::_d2i_wrapper = NULL;
duke@0 70 address StubRoutines::_d2l_wrapper = NULL;
duke@0 71
duke@0 72 jint StubRoutines::_fpu_cntrl_wrd_std = 0;
duke@0 73 jint StubRoutines::_fpu_cntrl_wrd_24 = 0;
duke@0 74 jint StubRoutines::_fpu_cntrl_wrd_64 = 0;
duke@0 75 jint StubRoutines::_fpu_cntrl_wrd_trunc = 0;
duke@0 76 jint StubRoutines::_mxcsr_std = 0;
duke@0 77 jint StubRoutines::_fpu_subnormal_bias1[3] = { 0, 0, 0 };
duke@0 78 jint StubRoutines::_fpu_subnormal_bias2[3] = { 0, 0, 0 };
duke@0 79
duke@0 80 // Compiled code entry points default values
iveresov@2142 81 // The default functions don't have separate disjoint versions.
duke@0 82 address StubRoutines::_jbyte_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
duke@0 83 address StubRoutines::_jshort_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
duke@0 84 address StubRoutines::_jint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
duke@0 85 address StubRoutines::_jlong_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
duke@0 86 address StubRoutines::_oop_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
iveresov@2142 87 address StubRoutines::_oop_arraycopy_uninit = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
duke@0 88 address StubRoutines::_jbyte_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
duke@0 89 address StubRoutines::_jshort_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
duke@0 90 address StubRoutines::_jint_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
duke@0 91 address StubRoutines::_jlong_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
duke@0 92 address StubRoutines::_oop_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
iveresov@2142 93 address StubRoutines::_oop_disjoint_arraycopy_uninit = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
duke@0 94
duke@0 95 address StubRoutines::_arrayof_jbyte_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
duke@0 96 address StubRoutines::_arrayof_jshort_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
duke@0 97 address StubRoutines::_arrayof_jint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
duke@0 98 address StubRoutines::_arrayof_jlong_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
duke@0 99 address StubRoutines::_arrayof_oop_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
iveresov@2142 100 address StubRoutines::_arrayof_oop_arraycopy_uninit = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
duke@0 101 address StubRoutines::_arrayof_jbyte_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
duke@0 102 address StubRoutines::_arrayof_jshort_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
duke@0 103 address StubRoutines::_arrayof_jint_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
duke@0 104 address StubRoutines::_arrayof_jlong_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
iveresov@2142 105 address StubRoutines::_arrayof_oop_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
iveresov@2142 106 address StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
iveresov@2142 107
kvn@2653 108 address StubRoutines::_zero_aligned_words = CAST_FROM_FN_PTR(address, Copy::zero_to_words);
duke@0 109
duke@0 110 address StubRoutines::_checkcast_arraycopy = NULL;
iveresov@2142 111 address StubRoutines::_checkcast_arraycopy_uninit = NULL;
duke@0 112 address StubRoutines::_unsafe_arraycopy = NULL;
duke@0 113 address StubRoutines::_generic_arraycopy = NULL;
duke@0 114
never@1664 115
never@1664 116 address StubRoutines::_jbyte_fill;
never@1664 117 address StubRoutines::_jshort_fill;
never@1664 118 address StubRoutines::_jint_fill;
never@1664 119 address StubRoutines::_arrayof_jbyte_fill;
never@1664 120 address StubRoutines::_arrayof_jshort_fill;
never@1664 121 address StubRoutines::_arrayof_jint_fill;
never@1664 122
kvn@4054 123 address StubRoutines::_aescrypt_encryptBlock = NULL;
kvn@4054 124 address StubRoutines::_aescrypt_decryptBlock = NULL;
kvn@4054 125 address StubRoutines::_cipherBlockChaining_encryptAESCrypt = NULL;
kvn@4054 126 address StubRoutines::_cipherBlockChaining_decryptAESCrypt = NULL;
never@1664 127
never@1157 128 double (* StubRoutines::_intrinsic_log )(double) = NULL;
never@1157 129 double (* StubRoutines::_intrinsic_log10 )(double) = NULL;
never@1157 130 double (* StubRoutines::_intrinsic_exp )(double) = NULL;
never@1157 131 double (* StubRoutines::_intrinsic_pow )(double, double) = NULL;
never@1157 132 double (* StubRoutines::_intrinsic_sin )(double) = NULL;
never@1157 133 double (* StubRoutines::_intrinsic_cos )(double) = NULL;
never@1157 134 double (* StubRoutines::_intrinsic_tan )(double) = NULL;
never@1157 135
duke@0 136 // Initialization
duke@0 137 //
duke@0 138 // Note: to break cycle with universe initialization, stubs are generated in two phases.
duke@0 139 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
duke@0 140 // The second phase includes all other stubs (which may depend on universe being initialized.)
duke@0 141
duke@0 142 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
duke@0 143
duke@0 144 void StubRoutines::initialize1() {
duke@0 145 if (_code1 == NULL) {
duke@0 146 ResourceMark rm;
duke@0 147 TraceTime timer("StubRoutines generation 1", TraceStartupTime);
duke@0 148 _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
jcoomes@1410 149 if (_code1 == NULL) {
twisti@1613 150 vm_exit_out_of_memory(code_size1, "CodeCache: no room for StubRoutines (1)");
jcoomes@1410 151 }
twisti@1613 152 CodeBuffer buffer(_code1);
duke@0 153 StubGenerator_generate(&buffer, false);
duke@0 154 }
duke@0 155 }
duke@0 156
duke@0 157
duke@0 158 #ifdef ASSERT
duke@0 159 typedef void (*arraycopy_fn)(address src, address dst, int count);
duke@0 160
duke@0 161 // simple tests of generated arraycopy functions
duke@0 162 static void test_arraycopy_func(address func, int alignment) {
duke@0 163 int v = 0xcc;
duke@0 164 int v2 = 0x11;
kvn@1498 165 jlong lbuffer[8];
kvn@1498 166 jlong lbuffer2[8];
kvn@1498 167 address fbuffer = (address) lbuffer;
kvn@1498 168 address fbuffer2 = (address) lbuffer2;
duke@0 169 unsigned int i;
duke@0 170 for (i = 0; i < sizeof(lbuffer); i++) {
kvn@1498 171 fbuffer[i] = v; fbuffer2[i] = v2;
duke@0 172 }
kvn@1498 173 // C++ does not guarantee jlong[] array alignment to 8 bytes.
kvn@1498 174 // Use middle of array to check that memory before it is not modified.
kvn@1498 175 address buffer = (address) round_to((intptr_t)&lbuffer[4], BytesPerLong);
kvn@1498 176 address buffer2 = (address) round_to((intptr_t)&lbuffer2[4], BytesPerLong);
duke@0 177 // do an aligned copy
duke@0 178 ((arraycopy_fn)func)(buffer, buffer2, 0);
duke@0 179 for (i = 0; i < sizeof(lbuffer); i++) {
kvn@1498 180 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
duke@0 181 }
duke@0 182 // adjust destination alignment
duke@0 183 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
duke@0 184 for (i = 0; i < sizeof(lbuffer); i++) {
kvn@1498 185 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
duke@0 186 }
duke@0 187 // adjust source alignment
duke@0 188 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
duke@0 189 for (i = 0; i < sizeof(lbuffer); i++) {
kvn@1498 190 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
duke@0 191 }
duke@0 192 }
duke@0 193 #endif
duke@0 194
duke@0 195
duke@0 196 void StubRoutines::initialize2() {
duke@0 197 if (_code2 == NULL) {
duke@0 198 ResourceMark rm;
duke@0 199 TraceTime timer("StubRoutines generation 2", TraceStartupTime);
duke@0 200 _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
jcoomes@1410 201 if (_code2 == NULL) {
twisti@1613 202 vm_exit_out_of_memory(code_size2, "CodeCache: no room for StubRoutines (2)");
jcoomes@1410 203 }
twisti@1613 204 CodeBuffer buffer(_code2);
duke@0 205 StubGenerator_generate(&buffer, true);
duke@0 206 }
duke@0 207
duke@0 208 #ifdef ASSERT
duke@0 209
duke@0 210 #define TEST_ARRAYCOPY(type) \
duke@0 211 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
duke@0 212 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
duke@0 213 test_arraycopy_func(arrayof_##type##_arraycopy(), sizeof(HeapWord)); \
duke@0 214 test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
duke@0 215
kvn@1498 216 // Make sure all the arraycopy stubs properly handle zero count
duke@0 217 TEST_ARRAYCOPY(jbyte);
duke@0 218 TEST_ARRAYCOPY(jshort);
duke@0 219 TEST_ARRAYCOPY(jint);
duke@0 220 TEST_ARRAYCOPY(jlong);
duke@0 221
duke@0 222 #undef TEST_ARRAYCOPY
duke@0 223
never@1664 224 #define TEST_FILL(type) \
never@1664 225 if (_##type##_fill != NULL) { \
never@1664 226 union { \
never@1664 227 double d; \
never@1664 228 type body[96]; \
never@1664 229 } s; \
never@1664 230 \
never@1664 231 int v = 32; \
never@1664 232 for (int offset = -2; offset <= 2; offset++) { \
never@1664 233 for (int i = 0; i < 96; i++) { \
never@1664 234 s.body[i] = 1; \
never@1664 235 } \
never@1664 236 type* start = s.body + 8 + offset; \
never@1664 237 for (int aligned = 0; aligned < 2; aligned++) { \
never@1664 238 if (aligned) { \
never@1664 239 if (((intptr_t)start) % HeapWordSize == 0) { \
never@1664 240 ((void (*)(type*, int, int))StubRoutines::_arrayof_##type##_fill)(start, v, 80); \
never@1664 241 } else { \
never@1664 242 continue; \
never@1664 243 } \
never@1664 244 } else { \
never@1664 245 ((void (*)(type*, int, int))StubRoutines::_##type##_fill)(start, v, 80); \
never@1664 246 } \
never@1664 247 for (int i = 0; i < 96; i++) { \
never@1664 248 if (i < (8 + offset) || i >= (88 + offset)) { \
never@1664 249 assert(s.body[i] == 1, "what?"); \
never@1664 250 } else { \
never@1664 251 assert(s.body[i] == 32, "what?"); \
never@1664 252 } \
never@1664 253 } \
never@1664 254 } \
never@1664 255 } \
never@1664 256 } \
never@1664 257
never@1664 258 TEST_FILL(jbyte);
never@1664 259 TEST_FILL(jshort);
never@1664 260 TEST_FILL(jint);
never@1664 261
never@1664 262 #undef TEST_FILL
never@1664 263
kvn@1498 264 #define TEST_COPYRTN(type) \
kvn@1498 265 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_##type##s_atomic), sizeof(type)); \
kvn@1498 266 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::arrayof_conjoint_##type##s), (int)MAX2(sizeof(HeapWord), sizeof(type)))
kvn@1498 267
kvn@1498 268 // Make sure all the copy runtime routines properly handle zero count
kvn@1498 269 TEST_COPYRTN(jbyte);
kvn@1498 270 TEST_COPYRTN(jshort);
kvn@1498 271 TEST_COPYRTN(jint);
kvn@1498 272 TEST_COPYRTN(jlong);
kvn@1498 273
kvn@1498 274 #undef TEST_COPYRTN
kvn@1498 275
kvn@1498 276 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_words), sizeof(HeapWord));
kvn@1498 277 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words), sizeof(HeapWord));
kvn@1498 278 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words_atomic), sizeof(HeapWord));
kvn@1498 279 // Aligned to BytesPerLong
kvn@1498 280 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_conjoint_words), sizeof(jlong));
kvn@1498 281 test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_disjoint_words), sizeof(jlong));
kvn@1498 282
duke@0 283 #endif
duke@0 284 }
duke@0 285
duke@0 286
duke@0 287 void stubRoutines_init1() { StubRoutines::initialize1(); }
duke@0 288 void stubRoutines_init2() { StubRoutines::initialize2(); }
duke@0 289
duke@0 290 //
duke@0 291 // Default versions of arraycopy functions
duke@0 292 //
duke@0 293
iveresov@2142 294 static void gen_arraycopy_barrier_pre(oop* dest, size_t count, bool dest_uninitialized) {
ysr@1226 295 assert(count != 0, "count should be non-zero");
ysr@1226 296 assert(count <= (size_t)max_intx, "count too large");
ysr@1226 297 BarrierSet* bs = Universe::heap()->barrier_set();
ysr@1226 298 assert(bs->has_write_ref_array_pre_opt(), "Must have pre-barrier opt");
iveresov@2142 299 bs->write_ref_array_pre(dest, (int)count, dest_uninitialized);
ysr@1226 300 }
ysr@1226 301
duke@0 302 static void gen_arraycopy_barrier(oop* dest, size_t count) {
duke@0 303 assert(count != 0, "count should be non-zero");
duke@0 304 BarrierSet* bs = Universe::heap()->barrier_set();
duke@0 305 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
ysr@1226 306 bs->write_ref_array((HeapWord*)dest, count);
duke@0 307 }
duke@0 308
duke@0 309 JRT_LEAF(void, StubRoutines::jbyte_copy(jbyte* src, jbyte* dest, size_t count))
duke@0 310 #ifndef PRODUCT
duke@0 311 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy
duke@0 312 #endif // !PRODUCT
kvn@1498 313 Copy::conjoint_jbytes_atomic(src, dest, count);
duke@0 314 JRT_END
duke@0 315
duke@0 316 JRT_LEAF(void, StubRoutines::jshort_copy(jshort* src, jshort* dest, size_t count))
duke@0 317 #ifndef PRODUCT
duke@0 318 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy
duke@0 319 #endif // !PRODUCT
duke@0 320 Copy::conjoint_jshorts_atomic(src, dest, count);
duke@0 321 JRT_END
duke@0 322
duke@0 323 JRT_LEAF(void, StubRoutines::jint_copy(jint* src, jint* dest, size_t count))
duke@0 324 #ifndef PRODUCT
duke@0 325 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy
duke@0 326 #endif // !PRODUCT
duke@0 327 Copy::conjoint_jints_atomic(src, dest, count);
duke@0 328 JRT_END
duke@0 329
duke@0 330 JRT_LEAF(void, StubRoutines::jlong_copy(jlong* src, jlong* dest, size_t count))
duke@0 331 #ifndef PRODUCT
duke@0 332 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path long/double array copy
duke@0 333 #endif // !PRODUCT
duke@0 334 Copy::conjoint_jlongs_atomic(src, dest, count);
duke@0 335 JRT_END
duke@0 336
duke@0 337 JRT_LEAF(void, StubRoutines::oop_copy(oop* src, oop* dest, size_t count))
duke@0 338 #ifndef PRODUCT
duke@0 339 SharedRuntime::_oop_array_copy_ctr++; // Slow-path oop array copy
duke@0 340 #endif // !PRODUCT
duke@0 341 assert(count != 0, "count should be non-zero");
iveresov@2142 342 gen_arraycopy_barrier_pre(dest, count, /*dest_uninitialized*/false);
iveresov@2142 343 Copy::conjoint_oops_atomic(src, dest, count);
iveresov@2142 344 gen_arraycopy_barrier(dest, count);
iveresov@2142 345 JRT_END
iveresov@2142 346
iveresov@2142 347 JRT_LEAF(void, StubRoutines::oop_copy_uninit(oop* src, oop* dest, size_t count))
iveresov@2142 348 #ifndef PRODUCT
iveresov@2142 349 SharedRuntime::_oop_array_copy_ctr++; // Slow-path oop array copy
iveresov@2142 350 #endif // !PRODUCT
iveresov@2142 351 assert(count != 0, "count should be non-zero");
iveresov@2142 352 gen_arraycopy_barrier_pre(dest, count, /*dest_uninitialized*/true);
duke@0 353 Copy::conjoint_oops_atomic(src, dest, count);
duke@0 354 gen_arraycopy_barrier(dest, count);
duke@0 355 JRT_END
duke@0 356
duke@0 357 JRT_LEAF(void, StubRoutines::arrayof_jbyte_copy(HeapWord* src, HeapWord* dest, size_t count))
duke@0 358 #ifndef PRODUCT
duke@0 359 SharedRuntime::_jbyte_array_copy_ctr++; // Slow-path byte array copy
duke@0 360 #endif // !PRODUCT
kvn@1498 361 Copy::arrayof_conjoint_jbytes(src, dest, count);
duke@0 362 JRT_END
duke@0 363
duke@0 364 JRT_LEAF(void, StubRoutines::arrayof_jshort_copy(HeapWord* src, HeapWord* dest, size_t count))
duke@0 365 #ifndef PRODUCT
duke@0 366 SharedRuntime::_jshort_array_copy_ctr++; // Slow-path short/char array copy
duke@0 367 #endif // !PRODUCT
duke@0 368 Copy::arrayof_conjoint_jshorts(src, dest, count);
duke@0 369 JRT_END
duke@0 370
duke@0 371 JRT_LEAF(void, StubRoutines::arrayof_jint_copy(HeapWord* src, HeapWord* dest, size_t count))
duke@0 372 #ifndef PRODUCT
duke@0 373 SharedRuntime::_jint_array_copy_ctr++; // Slow-path int/float array copy
duke@0 374 #endif // !PRODUCT
duke@0 375 Copy::arrayof_conjoint_jints(src, dest, count);
duke@0 376 JRT_END
duke@0 377
duke@0 378 JRT_LEAF(void, StubRoutines::arrayof_jlong_copy(HeapWord* src, HeapWord* dest, size_t count))
duke@0 379 #ifndef PRODUCT
duke@0 380 SharedRuntime::_jlong_array_copy_ctr++; // Slow-path int/float array copy
duke@0 381 #endif // !PRODUCT
duke@0 382 Copy::arrayof_conjoint_jlongs(src, dest, count);
duke@0 383 JRT_END
duke@0 384
duke@0 385 JRT_LEAF(void, StubRoutines::arrayof_oop_copy(HeapWord* src, HeapWord* dest, size_t count))
duke@0 386 #ifndef PRODUCT
duke@0 387 SharedRuntime::_oop_array_copy_ctr++; // Slow-path oop array copy
duke@0 388 #endif // !PRODUCT
duke@0 389 assert(count != 0, "count should be non-zero");
iveresov@2142 390 gen_arraycopy_barrier_pre((oop *) dest, count, /*dest_uninitialized*/false);
duke@0 391 Copy::arrayof_conjoint_oops(src, dest, count);
duke@0 392 gen_arraycopy_barrier((oop *) dest, count);
duke@0 393 JRT_END
never@1664 394
iveresov@2142 395 JRT_LEAF(void, StubRoutines::arrayof_oop_copy_uninit(HeapWord* src, HeapWord* dest, size_t count))
iveresov@2142 396 #ifndef PRODUCT
iveresov@2142 397 SharedRuntime::_oop_array_copy_ctr++; // Slow-path oop array copy
iveresov@2142 398 #endif // !PRODUCT
iveresov@2142 399 assert(count != 0, "count should be non-zero");
iveresov@2142 400 gen_arraycopy_barrier_pre((oop *) dest, count, /*dest_uninitialized*/true);
iveresov@2142 401 Copy::arrayof_conjoint_oops(src, dest, count);
iveresov@2142 402 gen_arraycopy_barrier((oop *) dest, count);
iveresov@2142 403 JRT_END
never@1664 404
never@1664 405 address StubRoutines::select_fill_function(BasicType t, bool aligned, const char* &name) {
never@1664 406 #define RETURN_STUB(xxx_fill) { \
never@1664 407 name = #xxx_fill; \
never@1664 408 return StubRoutines::xxx_fill(); }
never@1664 409
never@1664 410 switch (t) {
never@1664 411 case T_BYTE:
never@1664 412 case T_BOOLEAN:
never@1664 413 if (!aligned) RETURN_STUB(jbyte_fill);
never@1664 414 RETURN_STUB(arrayof_jbyte_fill);
never@1664 415 case T_CHAR:
never@1664 416 case T_SHORT:
never@1664 417 if (!aligned) RETURN_STUB(jshort_fill);
never@1664 418 RETURN_STUB(arrayof_jshort_fill);
never@1664 419 case T_INT:
never@1664 420 case T_FLOAT:
never@1664 421 if (!aligned) RETURN_STUB(jint_fill);
never@1664 422 RETURN_STUB(arrayof_jint_fill);
never@1664 423 case T_DOUBLE:
never@1664 424 case T_LONG:
never@1664 425 case T_ARRAY:
never@1664 426 case T_OBJECT:
never@1664 427 case T_NARROWOOP:
never@1664 428 case T_ADDRESS:
never@1664 429 // Currently unsupported
never@1664 430 return NULL;
never@1664 431
never@1664 432 default:
never@1664 433 ShouldNotReachHere();
never@1664 434 return NULL;
never@1664 435 }
never@1664 436
never@1664 437 #undef RETURN_STUB
never@1664 438 }
roland@2264 439
roland@2264 440 // constants for computing the copy function
roland@2264 441 enum {
roland@2264 442 COPYFUNC_UNALIGNED = 0,
roland@2264 443 COPYFUNC_ALIGNED = 1, // src, dest aligned to HeapWordSize
roland@2264 444 COPYFUNC_CONJOINT = 0,
roland@2264 445 COPYFUNC_DISJOINT = 2 // src != dest, or transfer can descend
roland@2264 446 };
roland@2264 447
roland@2264 448 // Note: The condition "disjoint" applies also for overlapping copies
roland@2264 449 // where an descending copy is permitted (i.e., dest_offset <= src_offset).
roland@2264 450 address
roland@2264 451 StubRoutines::select_arraycopy_function(BasicType t, bool aligned, bool disjoint, const char* &name, bool dest_uninitialized) {
roland@2264 452 int selector =
roland@2264 453 (aligned ? COPYFUNC_ALIGNED : COPYFUNC_UNALIGNED) +
roland@2264 454 (disjoint ? COPYFUNC_DISJOINT : COPYFUNC_CONJOINT);
roland@2264 455
roland@2264 456 #define RETURN_STUB(xxx_arraycopy) { \
roland@2264 457 name = #xxx_arraycopy; \
roland@2264 458 return StubRoutines::xxx_arraycopy(); }
roland@2264 459
roland@2264 460 #define RETURN_STUB_PARM(xxx_arraycopy, parm) { \
roland@2264 461 name = #xxx_arraycopy; \
roland@2264 462 return StubRoutines::xxx_arraycopy(parm); }
roland@2264 463
roland@2264 464 switch (t) {
roland@2264 465 case T_BYTE:
roland@2264 466 case T_BOOLEAN:
roland@2264 467 switch (selector) {
roland@2264 468 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jbyte_arraycopy);
roland@2264 469 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jbyte_arraycopy);
roland@2264 470 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jbyte_disjoint_arraycopy);
roland@2264 471 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jbyte_disjoint_arraycopy);
roland@2264 472 }
roland@2264 473 case T_CHAR:
roland@2264 474 case T_SHORT:
roland@2264 475 switch (selector) {
roland@2264 476 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jshort_arraycopy);
roland@2264 477 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jshort_arraycopy);
roland@2264 478 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jshort_disjoint_arraycopy);
roland@2264 479 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jshort_disjoint_arraycopy);
roland@2264 480 }
roland@2264 481 case T_INT:
roland@2264 482 case T_FLOAT:
roland@2264 483 switch (selector) {
roland@2264 484 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jint_arraycopy);
roland@2264 485 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jint_arraycopy);
roland@2264 486 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jint_disjoint_arraycopy);
roland@2264 487 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jint_disjoint_arraycopy);
roland@2264 488 }
roland@2264 489 case T_DOUBLE:
roland@2264 490 case T_LONG:
roland@2264 491 switch (selector) {
roland@2264 492 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jlong_arraycopy);
roland@2264 493 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jlong_arraycopy);
roland@2264 494 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB(jlong_disjoint_arraycopy);
roland@2264 495 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB(arrayof_jlong_disjoint_arraycopy);
roland@2264 496 }
roland@2264 497 case T_ARRAY:
roland@2264 498 case T_OBJECT:
roland@2264 499 switch (selector) {
roland@2264 500 case COPYFUNC_CONJOINT | COPYFUNC_UNALIGNED: RETURN_STUB_PARM(oop_arraycopy, dest_uninitialized);
roland@2264 501 case COPYFUNC_CONJOINT | COPYFUNC_ALIGNED: RETURN_STUB_PARM(arrayof_oop_arraycopy, dest_uninitialized);
roland@2264 502 case COPYFUNC_DISJOINT | COPYFUNC_UNALIGNED: RETURN_STUB_PARM(oop_disjoint_arraycopy, dest_uninitialized);
roland@2264 503 case COPYFUNC_DISJOINT | COPYFUNC_ALIGNED: RETURN_STUB_PARM(arrayof_oop_disjoint_arraycopy, dest_uninitialized);
roland@2264 504 }
roland@2264 505 default:
roland@2264 506 ShouldNotReachHere();
roland@2264 507 return NULL;
roland@2264 508 }
roland@2264 509
roland@2264 510 #undef RETURN_STUB
roland@2264 511 #undef RETURN_STUB_PARM
roland@2264 512 }