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