< prev index next >

src/hotspot/share/runtime/stubRoutines.cpp

Print this page

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "asm/codeBuffer.hpp"
 27 #include "asm/macroAssembler.inline.hpp"
 28 #include "memory/resourceArea.hpp"
 29 #include "oops/access.inline.hpp"
 30 #include "oops/oop.inline.hpp"
 31 #include "prims/vectorSupport.hpp"

 32 #include "runtime/interfaceSupport.inline.hpp"
 33 #include "runtime/timerTrace.hpp"
 34 #include "runtime/safefetch.inline.hpp"
 35 #include "runtime/sharedRuntime.hpp"
 36 #include "utilities/align.hpp"
 37 #include "utilities/copy.hpp"
 38 #ifdef COMPILER2
 39 #include "opto/runtime.hpp"
 40 #endif
 41 
 42 UnsafeCopyMemory* UnsafeCopyMemory::_table                      = NULL;
 43 int UnsafeCopyMemory::_table_length                             = 0;
 44 int UnsafeCopyMemory::_table_max_length                         = 0;
 45 address UnsafeCopyMemory::_common_exit_stub_pc                  = NULL;
 46 
 47 // Implementation of StubRoutines - for a description
 48 // of how to extend it, see the header file.
 49 
 50 // Class Variables
 51 
 52 BufferBlob* StubRoutines::_code1                                = NULL;
 53 BufferBlob* StubRoutines::_code2                                = NULL;

 54 
 55 address StubRoutines::_call_stub_return_address                 = NULL;
 56 address StubRoutines::_call_stub_entry                          = NULL;
 57 
 58 address StubRoutines::_catch_exception_entry                    = NULL;
 59 address StubRoutines::_forward_exception_entry                  = NULL;
 60 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
 61 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
 62 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
 63 address StubRoutines::_throw_StackOverflowError_entry           = NULL;
 64 address StubRoutines::_throw_delayed_StackOverflowError_entry   = NULL;
 65 jint    StubRoutines::_verify_oop_count                         = 0;
 66 address StubRoutines::_verify_oop_subroutine_entry              = NULL;
 67 address StubRoutines::_atomic_xchg_entry                        = NULL;
 68 address StubRoutines::_atomic_xchg_long_entry                   = NULL;
 69 address StubRoutines::_atomic_store_entry                       = NULL;
 70 address StubRoutines::_atomic_cmpxchg_entry                     = NULL;
 71 address StubRoutines::_atomic_cmpxchg_byte_entry                = NULL;
 72 address StubRoutines::_atomic_cmpxchg_long_entry                = NULL;
 73 address StubRoutines::_atomic_add_entry                         = NULL;
 74 address StubRoutines::_atomic_add_long_entry                    = NULL;
 75 address StubRoutines::_fence_entry                              = NULL;
 76 
 77 // Compiled code entry points default values
 78 // The default functions don't have separate disjoint versions.
 79 address StubRoutines::_jbyte_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
 80 address StubRoutines::_jshort_arraycopy         = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
 81 address StubRoutines::_jint_arraycopy           = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 82 address StubRoutines::_jlong_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
 83 address StubRoutines::_oop_arraycopy            = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
 84 address StubRoutines::_oop_arraycopy_uninit     = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
 85 address StubRoutines::_jbyte_disjoint_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
 86 address StubRoutines::_jshort_disjoint_arraycopy         = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
 87 address StubRoutines::_jint_disjoint_arraycopy           = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 88 address StubRoutines::_jlong_disjoint_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
 89 address StubRoutines::_oop_disjoint_arraycopy            = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
 90 address StubRoutines::_oop_disjoint_arraycopy_uninit     = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
 91 






 92 address StubRoutines::_arrayof_jbyte_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
 93 address StubRoutines::_arrayof_jshort_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
 94 address StubRoutines::_arrayof_jint_arraycopy   = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
 95 address StubRoutines::_arrayof_jlong_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
 96 address StubRoutines::_arrayof_oop_arraycopy    = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
 97 address StubRoutines::_arrayof_oop_arraycopy_uninit      = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
 98 address StubRoutines::_arrayof_jbyte_disjoint_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
 99 address StubRoutines::_arrayof_jshort_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
100 address StubRoutines::_arrayof_jint_disjoint_arraycopy   = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
101 address StubRoutines::_arrayof_jlong_disjoint_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
102 address StubRoutines::_arrayof_oop_disjoint_arraycopy    = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
103 address StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
104 
105 address StubRoutines::_data_cache_writeback              = NULL;
106 address StubRoutines::_data_cache_writeback_sync         = NULL;
107 
108 address StubRoutines::_checkcast_arraycopy               = NULL;
109 address StubRoutines::_checkcast_arraycopy_uninit        = NULL;
110 address StubRoutines::_unsafe_arraycopy                  = NULL;
111 address StubRoutines::_generic_arraycopy                 = NULL;

161 address StubRoutines::_dlog = NULL;
162 address StubRoutines::_dlog10 = NULL;
163 address StubRoutines::_dpow = NULL;
164 address StubRoutines::_dsin = NULL;
165 address StubRoutines::_dcos = NULL;
166 address StubRoutines::_dlibm_sin_cos_huge = NULL;
167 address StubRoutines::_dlibm_reduce_pi04l = NULL;
168 address StubRoutines::_dlibm_tan_cot_huge = NULL;
169 address StubRoutines::_dtan = NULL;
170 
171 address StubRoutines::_safefetch32_entry                 = NULL;
172 address StubRoutines::_safefetch32_fault_pc              = NULL;
173 address StubRoutines::_safefetch32_continuation_pc       = NULL;
174 address StubRoutines::_safefetchN_entry                  = NULL;
175 address StubRoutines::_safefetchN_fault_pc               = NULL;
176 address StubRoutines::_safefetchN_continuation_pc        = NULL;
177 
178 address StubRoutines::_vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{NULL}, {NULL}};
179 address StubRoutines::_vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{NULL}, {NULL}};
180 











181 // Initialization
182 //
183 // Note: to break cycle with universe initialization, stubs are generated in two phases.
184 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
185 // The second phase includes all other stubs (which may depend on universe being initialized.)
186 
187 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
188 
189 void UnsafeCopyMemory::create_table(int max_size) {
190   UnsafeCopyMemory::_table = new UnsafeCopyMemory[max_size];
191   UnsafeCopyMemory::_table_max_length = max_size;
192 }
193 
194 bool UnsafeCopyMemory::contains_pc(address pc) {
195   for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) {
196     UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i];
197     if (pc >= entry->start_pc() && pc < entry->end_pc()) {
198       return true;
199     }
200   }
201   return false;
202 }
203 
204 address UnsafeCopyMemory::page_error_continue_pc(address pc) {
205   for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) {
206     UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i];
207     if (pc >= entry->start_pc() && pc < entry->end_pc()) {
208       return entry->error_exit_pc();
209     }
210   }
211   return NULL;
212 }
213 
214 void StubRoutines::initialize1() {
215   if (_code1 == NULL) {
216     ResourceMark rm;
217     TraceTime timer("StubRoutines generation 1", TRACETIME_LOG(Info, startuptime));
218     _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
219     if (_code1 == NULL) {
220       vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
221     }
222     CodeBuffer buffer(_code1);
223     StubGenerator_generate(&buffer, false);
224     // When new stubs added we need to make sure there is some space left
225     // to catch situation when we should increase size again.
226     assert(code_size1 == 0 || buffer.insts_remaining() > 200, "increase code_size1");
227   }
228 }
229 
230 
231 #ifdef ASSERT
232 typedef void (*arraycopy_fn)(address src, address dst, int count);
233 
234 // simple tests of generated arraycopy functions
235 static void test_arraycopy_func(address func, int alignment) {
236   int v = 0xcc;
237   int v2 = 0x11;
238   jlong lbuffer[8];
239   jlong lbuffer2[8];
240   address fbuffer  = (address) lbuffer;
241   address fbuffer2 = (address) lbuffer2;
242   unsigned int i;
243   for (i = 0; i < sizeof(lbuffer); i++) {
244     fbuffer[i] = v; fbuffer2[i] = v2;
245   }
246   // C++ does not guarantee jlong[] array alignment to 8 bytes.
247   // Use middle of array to check that memory before it is not modified.
248   address buffer  = align_up((address)&lbuffer[4], BytesPerLong);
249   address buffer2 = align_up((address)&lbuffer2[4], BytesPerLong);
250   // do an aligned copy
251   ((arraycopy_fn)func)(buffer, buffer2, 0);
252   for (i = 0; i < sizeof(lbuffer); i++) {
253     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
254   }
255   // adjust destination alignment
256   ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
257   for (i = 0; i < sizeof(lbuffer); i++) {
258     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
259   }
260   // adjust source alignment
261   ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
262   for (i = 0; i < sizeof(lbuffer); i++) {
263     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
264   }
265 }
266 #endif // ASSERT
267 
















268 void StubRoutines::initialize2() {
269   if (_code2 == NULL) {
270     ResourceMark rm;
271     TraceTime timer("StubRoutines generation 2", TRACETIME_LOG(Info, startuptime));
272     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
273     if (_code2 == NULL) {
274       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
275     }
276     CodeBuffer buffer(_code2);
277     StubGenerator_generate(&buffer, true);
278     // When new stubs added we need to make sure there is some space left
279     // to catch situation when we should increase size again.
280     assert(code_size2 == 0 || buffer.insts_remaining() > 200, "increase code_size2");
281   }
282 
283 #ifdef ASSERT
284 
285   MACOS_AARCH64_ONLY(os::current_thread_enable_wx(WXExec));
286 
287 #define TEST_ARRAYCOPY(type)                                                    \
288   test_arraycopy_func(          type##_arraycopy(),          sizeof(type));     \
289   test_arraycopy_func(          type##_disjoint_arraycopy(), sizeof(type));     \
290   test_arraycopy_func(arrayof_##type##_arraycopy(),          sizeof(HeapWord)); \
291   test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
292 
293   // Make sure all the arraycopy stubs properly handle zero count
294   TEST_ARRAYCOPY(jbyte);
295   TEST_ARRAYCOPY(jshort);
296   TEST_ARRAYCOPY(jint);
297   TEST_ARRAYCOPY(jlong);

348   TEST_COPYRTN(jint);
349   TEST_COPYRTN(jlong);
350 
351 #undef TEST_COPYRTN
352 
353   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_words), sizeof(HeapWord));
354   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words), sizeof(HeapWord));
355   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words_atomic), sizeof(HeapWord));
356   // Aligned to BytesPerLong
357   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_conjoint_words), sizeof(jlong));
358   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_disjoint_words), sizeof(jlong));
359 
360   MACOS_AARCH64_ONLY(os::current_thread_enable_wx(WXWrite));
361 
362 #endif
363 }
364 
365 
366 void stubRoutines_init1() { StubRoutines::initialize1(); }
367 void stubRoutines_init2() { StubRoutines::initialize2(); }

368 
369 //
370 // Default versions of arraycopy functions
371 //
372 
373 JRT_LEAF(void, StubRoutines::jbyte_copy(jbyte* src, jbyte* dest, size_t count))
374 #ifndef PRODUCT
375   SharedRuntime::_jbyte_array_copy_ctr++;      // Slow-path byte array copy
376 #endif // !PRODUCT
377   Copy::conjoint_jbytes_atomic(src, dest, count);
378 JRT_END
379 
380 JRT_LEAF(void, StubRoutines::jshort_copy(jshort* src, jshort* dest, size_t count))
381 #ifndef PRODUCT
382   SharedRuntime::_jshort_array_copy_ctr++;     // Slow-path short/char array copy
383 #endif // !PRODUCT
384   Copy::conjoint_jshorts_atomic(src, dest, count);
385 JRT_END
386 
387 JRT_LEAF(void, StubRoutines::jint_copy(jint* src, jint* dest, size_t count))

 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "asm/codeBuffer.hpp"
 27 #include "asm/macroAssembler.inline.hpp"
 28 #include "memory/resourceArea.hpp"
 29 #include "oops/access.inline.hpp"
 30 #include "oops/oop.inline.hpp"
 31 #include "prims/vectorSupport.hpp"
 32 #include "runtime/continuation.hpp"
 33 #include "runtime/interfaceSupport.inline.hpp"
 34 #include "runtime/timerTrace.hpp"
 35 #include "runtime/safefetch.inline.hpp"
 36 #include "runtime/sharedRuntime.hpp"
 37 #include "utilities/align.hpp"
 38 #include "utilities/copy.hpp"
 39 #ifdef COMPILER2
 40 #include "opto/runtime.hpp"
 41 #endif
 42 
 43 UnsafeCopyMemory* UnsafeCopyMemory::_table                      = NULL;
 44 int UnsafeCopyMemory::_table_length                             = 0;
 45 int UnsafeCopyMemory::_table_max_length                         = 0;
 46 address UnsafeCopyMemory::_common_exit_stub_pc                  = NULL;
 47 
 48 // Implementation of StubRoutines - for a description
 49 // of how to extend it, see the header file.
 50 
 51 // Class Variables
 52 
 53 BufferBlob* StubRoutines::_code1                                = NULL;
 54 BufferBlob* StubRoutines::_code2                                = NULL;
 55 BufferBlob* StubRoutines::_code3                                = NULL;
 56 
 57 address StubRoutines::_call_stub_return_address                 = NULL;
 58 address StubRoutines::_call_stub_entry                          = NULL;
 59 
 60 address StubRoutines::_catch_exception_entry                    = NULL;
 61 address StubRoutines::_forward_exception_entry                  = NULL;
 62 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
 63 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
 64 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
 65 address StubRoutines::_throw_StackOverflowError_entry           = NULL;
 66 address StubRoutines::_throw_delayed_StackOverflowError_entry   = NULL;
 67 jint    StubRoutines::_verify_oop_count                         = 0;
 68 address StubRoutines::_verify_oop_subroutine_entry              = NULL;
 69 address StubRoutines::_atomic_xchg_entry                        = NULL;
 70 address StubRoutines::_atomic_xchg_long_entry                   = NULL;
 71 address StubRoutines::_atomic_store_entry                       = NULL;
 72 address StubRoutines::_atomic_cmpxchg_entry                     = NULL;
 73 address StubRoutines::_atomic_cmpxchg_byte_entry                = NULL;
 74 address StubRoutines::_atomic_cmpxchg_long_entry                = NULL;
 75 address StubRoutines::_atomic_add_entry                         = NULL;
 76 address StubRoutines::_atomic_add_long_entry                    = NULL;
 77 address StubRoutines::_fence_entry                              = NULL;
 78 
 79 // Compiled code entry points default values
 80 // The default functions don't have separate disjoint versions.
 81 address StubRoutines::_jbyte_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
 82 address StubRoutines::_jshort_arraycopy         = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
 83 address StubRoutines::_jint_arraycopy           = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 84 address StubRoutines::_jlong_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
 85 address StubRoutines::_oop_arraycopy            = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
 86 address StubRoutines::_oop_arraycopy_uninit     = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
 87 address StubRoutines::_jbyte_disjoint_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jbyte_copy);
 88 address StubRoutines::_jshort_disjoint_arraycopy         = CAST_FROM_FN_PTR(address, StubRoutines::jshort_copy);
 89 address StubRoutines::_jint_disjoint_arraycopy           = CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 90 address StubRoutines::_jlong_disjoint_arraycopy          = CAST_FROM_FN_PTR(address, StubRoutines::jlong_copy);
 91 address StubRoutines::_oop_disjoint_arraycopy            = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy);
 92 address StubRoutines::_oop_disjoint_arraycopy_uninit     = CAST_FROM_FN_PTR(address, StubRoutines::oop_copy_uninit);
 93 
 94 bool    StubRoutines::_has_word_memcpy             = false;
 95 address StubRoutines::_word_memcpy_up              = NULL; // CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 96 address StubRoutines::_word_memcpy_down            = NULL; // CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 97 address StubRoutines::_word_memcpy_up_nt           = NULL; // CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 98 address StubRoutines::_word_memcpy_down_nt         = NULL; // CAST_FROM_FN_PTR(address, StubRoutines::jint_copy);
 99 
100 address StubRoutines::_arrayof_jbyte_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
101 address StubRoutines::_arrayof_jshort_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
102 address StubRoutines::_arrayof_jint_arraycopy   = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
103 address StubRoutines::_arrayof_jlong_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
104 address StubRoutines::_arrayof_oop_arraycopy    = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
105 address StubRoutines::_arrayof_oop_arraycopy_uninit      = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
106 address StubRoutines::_arrayof_jbyte_disjoint_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jbyte_copy);
107 address StubRoutines::_arrayof_jshort_disjoint_arraycopy = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jshort_copy);
108 address StubRoutines::_arrayof_jint_disjoint_arraycopy   = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jint_copy);
109 address StubRoutines::_arrayof_jlong_disjoint_arraycopy  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_jlong_copy);
110 address StubRoutines::_arrayof_oop_disjoint_arraycopy    = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
111 address StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
112 
113 address StubRoutines::_data_cache_writeback              = NULL;
114 address StubRoutines::_data_cache_writeback_sync         = NULL;
115 
116 address StubRoutines::_checkcast_arraycopy               = NULL;
117 address StubRoutines::_checkcast_arraycopy_uninit        = NULL;
118 address StubRoutines::_unsafe_arraycopy                  = NULL;
119 address StubRoutines::_generic_arraycopy                 = NULL;

169 address StubRoutines::_dlog = NULL;
170 address StubRoutines::_dlog10 = NULL;
171 address StubRoutines::_dpow = NULL;
172 address StubRoutines::_dsin = NULL;
173 address StubRoutines::_dcos = NULL;
174 address StubRoutines::_dlibm_sin_cos_huge = NULL;
175 address StubRoutines::_dlibm_reduce_pi04l = NULL;
176 address StubRoutines::_dlibm_tan_cot_huge = NULL;
177 address StubRoutines::_dtan = NULL;
178 
179 address StubRoutines::_safefetch32_entry                 = NULL;
180 address StubRoutines::_safefetch32_fault_pc              = NULL;
181 address StubRoutines::_safefetch32_continuation_pc       = NULL;
182 address StubRoutines::_safefetchN_entry                  = NULL;
183 address StubRoutines::_safefetchN_fault_pc               = NULL;
184 address StubRoutines::_safefetchN_continuation_pc        = NULL;
185 
186 address StubRoutines::_vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{NULL}, {NULL}};
187 address StubRoutines::_vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{NULL}, {NULL}};
188 
189 RuntimeStub* StubRoutines::_cont_doYield_stub = NULL;
190 address StubRoutines::_cont_doYield       = NULL;
191 address StubRoutines::_cont_jump_from_sp  = NULL;
192 address StubRoutines::_cont_thaw          = NULL;
193 address StubRoutines::_cont_returnBarrier = NULL;
194 address StubRoutines::_cont_returnBarrierExc = NULL;
195 address StubRoutines::_cont_interpreter_forced_preempt_return = NULL;
196 
197 JFR_ONLY(address StubRoutines::_jfr_write_checkpoint = NULL;)
198 JFR_ONLY(address StubRoutines::_jfr_get_event_writer = NULL;)
199 
200 // Initialization
201 //
202 // Note: to break cycle with universe initialization, stubs are generated in two phases.
203 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
204 // The second phase includes all other stubs (which may depend on universe being initialized.)
205 
206 extern void StubGenerator_generate(CodeBuffer* code, int phase); // only interface to generators
207 
208 void UnsafeCopyMemory::create_table(int max_size) {
209   UnsafeCopyMemory::_table = new UnsafeCopyMemory[max_size];
210   UnsafeCopyMemory::_table_max_length = max_size;
211 }
212 
213 bool UnsafeCopyMemory::contains_pc(address pc) {
214   for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) {
215     UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i];
216     if (pc >= entry->start_pc() && pc < entry->end_pc()) {
217       return true;
218     }
219   }
220   return false;
221 }
222 
223 address UnsafeCopyMemory::page_error_continue_pc(address pc) {
224   for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) {
225     UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i];
226     if (pc >= entry->start_pc() && pc < entry->end_pc()) {
227       return entry->error_exit_pc();
228     }
229   }
230   return NULL;
231 }
232 
233 void StubRoutines::initialize1() {
234   if (_code1 == NULL) {
235     ResourceMark rm;
236     TraceTime timer("StubRoutines generation 1", TRACETIME_LOG(Info, startuptime));
237     _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
238     if (_code1 == NULL) {
239       vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
240     }
241     CodeBuffer buffer(_code1);
242     StubGenerator_generate(&buffer, 0);
243     // When new stubs added we need to make sure there is some space left
244     // to catch situation when we should increase size again.
245     assert(code_size1 == 0 || buffer.insts_remaining() > 200, "increase code_size1");
246   }
247 }
248 

249 #ifdef ASSERT
250 typedef void (*arraycopy_fn)(address src, address dst, int count);
251 
252 // simple tests of generated arraycopy functions
253 static void test_arraycopy_func(address func, int alignment) {
254   int v = 0xcc;
255   int v2 = 0x11;
256   jlong lbuffer[8];
257   jlong lbuffer2[8];
258   address fbuffer  = (address) lbuffer;
259   address fbuffer2 = (address) lbuffer2;
260   unsigned int i;
261   for (i = 0; i < sizeof(lbuffer); i++) {
262     fbuffer[i] = v; fbuffer2[i] = v2;
263   }
264   // C++ does not guarantee jlong[] array alignment to 8 bytes.
265   // Use middle of array to check that memory before it is not modified.
266   address buffer  = align_up((address)&lbuffer[4], BytesPerLong);
267   address buffer2 = align_up((address)&lbuffer2[4], BytesPerLong);
268   // do an aligned copy
269   ((arraycopy_fn)func)(buffer, buffer2, 0);
270   for (i = 0; i < sizeof(lbuffer); i++) {
271     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
272   }
273   // adjust destination alignment
274   ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
275   for (i = 0; i < sizeof(lbuffer); i++) {
276     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
277   }
278   // adjust source alignment
279   ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
280   for (i = 0; i < sizeof(lbuffer); i++) {
281     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
282   }
283 }
284 #endif // ASSERT
285 
286 void StubRoutines::initializeContinuationStubs() {
287   if (_code3 == NULL) {
288     ResourceMark rm;
289     TraceTime timer("StubRoutines generation 3", TRACETIME_LOG(Info, startuptime));
290     _code3 = BufferBlob::create("StubRoutines (3)", code_size2);
291     if (_code3 == NULL) {
292       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (3)");
293     }
294     CodeBuffer buffer(_code3);
295     StubGenerator_generate(&buffer, 1);
296     // When new stubs added we need to make sure there is some space left
297     // to catch situation when we should increase size again.
298     assert(code_size2 == 0 || buffer.insts_remaining() > 200, "increase code_size3");
299   }
300 }
301 
302 void StubRoutines::initialize2() {
303   if (_code2 == NULL) {
304     ResourceMark rm;
305     TraceTime timer("StubRoutines generation 2", TRACETIME_LOG(Info, startuptime));
306     _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
307     if (_code2 == NULL) {
308       vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
309     }
310     CodeBuffer buffer(_code2);
311     StubGenerator_generate(&buffer, 2);
312     // When new stubs added we need to make sure there is some space left
313     // to catch situation when we should increase size again.
314     assert(code_size2 == 0 || buffer.insts_remaining() > 200, "increase code_size2");
315   }
316 
317 #ifdef ASSERT
318 
319   MACOS_AARCH64_ONLY(os::current_thread_enable_wx(WXExec));
320 
321 #define TEST_ARRAYCOPY(type)                                                    \
322   test_arraycopy_func(          type##_arraycopy(),          sizeof(type));     \
323   test_arraycopy_func(          type##_disjoint_arraycopy(), sizeof(type));     \
324   test_arraycopy_func(arrayof_##type##_arraycopy(),          sizeof(HeapWord)); \
325   test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
326 
327   // Make sure all the arraycopy stubs properly handle zero count
328   TEST_ARRAYCOPY(jbyte);
329   TEST_ARRAYCOPY(jshort);
330   TEST_ARRAYCOPY(jint);
331   TEST_ARRAYCOPY(jlong);

382   TEST_COPYRTN(jint);
383   TEST_COPYRTN(jlong);
384 
385 #undef TEST_COPYRTN
386 
387   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::conjoint_words), sizeof(HeapWord));
388   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words), sizeof(HeapWord));
389   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::disjoint_words_atomic), sizeof(HeapWord));
390   // Aligned to BytesPerLong
391   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_conjoint_words), sizeof(jlong));
392   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_disjoint_words), sizeof(jlong));
393 
394   MACOS_AARCH64_ONLY(os::current_thread_enable_wx(WXWrite));
395 
396 #endif
397 }
398 
399 
400 void stubRoutines_init1() { StubRoutines::initialize1(); }
401 void stubRoutines_init2() { StubRoutines::initialize2(); }
402 void stubRoutines_initContinuationStubs() { StubRoutines::initializeContinuationStubs(); }
403 
404 //
405 // Default versions of arraycopy functions
406 //
407 
408 JRT_LEAF(void, StubRoutines::jbyte_copy(jbyte* src, jbyte* dest, size_t count))
409 #ifndef PRODUCT
410   SharedRuntime::_jbyte_array_copy_ctr++;      // Slow-path byte array copy
411 #endif // !PRODUCT
412   Copy::conjoint_jbytes_atomic(src, dest, count);
413 JRT_END
414 
415 JRT_LEAF(void, StubRoutines::jshort_copy(jshort* src, jshort* dest, size_t count))
416 #ifndef PRODUCT
417   SharedRuntime::_jshort_array_copy_ctr++;     // Slow-path short/char array copy
418 #endif // !PRODUCT
419   Copy::conjoint_jshorts_atomic(src, dest, count);
420 JRT_END
421 
422 JRT_LEAF(void, StubRoutines::jint_copy(jint* src, jint* dest, size_t count))
< prev index next >