Mercurial > hg > graal-compiler
comparison src/share/vm/prims/jni.cpp @ 12355:cefad50507d8
Merge with hs25-b53
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Fri, 11 Oct 2013 10:38:03 +0200 |
parents | 6b0fd0964b87 03f493ce3a71 |
children | 359f7e70ae7f |
comparison
equal
deleted
inserted
replaced
12058:ccb4f2af2319 | 12355:cefad50507d8 |
---|---|
1337 // non-interface call -- for that little speed boost, don't handlize | 1337 // non-interface call -- for that little speed boost, don't handlize |
1338 debug_only(No_Safepoint_Verifier nosafepoint;) | 1338 debug_only(No_Safepoint_Verifier nosafepoint;) |
1339 if (call_type == JNI_VIRTUAL) { | 1339 if (call_type == JNI_VIRTUAL) { |
1340 // jni_GetMethodID makes sure class is linked and initialized | 1340 // jni_GetMethodID makes sure class is linked and initialized |
1341 // so m should have a valid vtable index. | 1341 // so m should have a valid vtable index. |
1342 assert(!m->has_itable_index(), ""); | |
1342 int vtbl_index = m->vtable_index(); | 1343 int vtbl_index = m->vtable_index(); |
1343 if (vtbl_index != Method::nonvirtual_vtable_index) { | 1344 if (vtbl_index != Method::nonvirtual_vtable_index) { |
1344 Klass* k = h_recv->klass(); | 1345 Klass* k = h_recv->klass(); |
1345 // k might be an arrayKlassOop but all vtables start at | 1346 // k might be an arrayKlassOop but all vtables start at |
1346 // the same place. The cast is to avoid virtual call and assertion. | 1347 // the same place. The cast is to avoid virtual call and assertion. |
1356 } | 1357 } |
1357 } else { | 1358 } else { |
1358 // interface call | 1359 // interface call |
1359 KlassHandle h_holder(THREAD, holder); | 1360 KlassHandle h_holder(THREAD, holder); |
1360 | 1361 |
1361 int itbl_index = m->cached_itable_index(); | 1362 int itbl_index = m->itable_index(); |
1362 if (itbl_index == -1) { | |
1363 itbl_index = klassItable::compute_itable_index(m); | |
1364 m->set_cached_itable_index(itbl_index); | |
1365 // the above may have grabbed a lock, 'm' and anything non-handlized can't be used again | |
1366 } | |
1367 Klass* k = h_recv->klass(); | 1363 Klass* k = h_recv->klass(); |
1368 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); | 1364 selected_method = InstanceKlass::cast(k)->method_at_itable(h_holder(), itbl_index, CHECK); |
1369 } | 1365 } |
1370 } | 1366 } |
1371 | 1367 |
3235 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); | 3231 DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); |
3236 #else /* USDT2 */ | 3232 #else /* USDT2 */ |
3237 HOTSPOT_JNI_GETSTRINGCHARS_ENTRY( | 3233 HOTSPOT_JNI_GETSTRINGCHARS_ENTRY( |
3238 env, string, (uintptr_t *) isCopy); | 3234 env, string, (uintptr_t *) isCopy); |
3239 #endif /* USDT2 */ | 3235 #endif /* USDT2 */ |
3240 //%note jni_5 | |
3241 if (isCopy != NULL) { | |
3242 *isCopy = JNI_TRUE; | |
3243 } | |
3244 oop s = JNIHandles::resolve_non_null(string); | 3236 oop s = JNIHandles::resolve_non_null(string); |
3245 int s_len = java_lang_String::length(s); | 3237 int s_len = java_lang_String::length(s); |
3246 typeArrayOop s_value = java_lang_String::value(s); | 3238 typeArrayOop s_value = java_lang_String::value(s); |
3247 int s_offset = java_lang_String::offset(s); | 3239 int s_offset = java_lang_String::offset(s); |
3248 jchar* buf = NEW_C_HEAP_ARRAY(jchar, s_len + 1, mtInternal); // add one for zero termination | 3240 jchar* buf = NEW_C_HEAP_ARRAY_RETURN_NULL(jchar, s_len + 1, mtInternal); // add one for zero termination |
3249 if (s_len > 0) { | 3241 /* JNI Specification states return NULL on OOM */ |
3250 memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len); | 3242 if (buf != NULL) { |
3251 } | 3243 if (s_len > 0) { |
3252 buf[s_len] = 0; | 3244 memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len); |
3245 } | |
3246 buf[s_len] = 0; | |
3247 //%note jni_5 | |
3248 if (isCopy != NULL) { | |
3249 *isCopy = JNI_TRUE; | |
3250 } | |
3251 } | |
3253 #ifndef USDT2 | 3252 #ifndef USDT2 |
3254 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); | 3253 DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); |
3255 #else /* USDT2 */ | 3254 #else /* USDT2 */ |
3256 HOTSPOT_JNI_GETSTRINGCHARS_RETURN( | 3255 HOTSPOT_JNI_GETSTRINGCHARS_RETURN( |
3257 buf); | 3256 buf); |
3336 HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY( | 3335 HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY( |
3337 env, string, (uintptr_t *) isCopy); | 3336 env, string, (uintptr_t *) isCopy); |
3338 #endif /* USDT2 */ | 3337 #endif /* USDT2 */ |
3339 oop java_string = JNIHandles::resolve_non_null(string); | 3338 oop java_string = JNIHandles::resolve_non_null(string); |
3340 size_t length = java_lang_String::utf8_length(java_string); | 3339 size_t length = java_lang_String::utf8_length(java_string); |
3341 char* result = AllocateHeap(length + 1, mtInternal); | 3340 /* JNI Specification states return NULL on OOM */ |
3342 java_lang_String::as_utf8_string(java_string, result, (int) length + 1); | 3341 char* result = AllocateHeap(length + 1, mtInternal, 0, AllocFailStrategy::RETURN_NULL); |
3343 if (isCopy != NULL) *isCopy = JNI_TRUE; | 3342 if (result != NULL) { |
3343 java_lang_String::as_utf8_string(java_string, result, (int) length + 1); | |
3344 if (isCopy != NULL) { | |
3345 *isCopy = JNI_TRUE; | |
3346 } | |
3347 } | |
3344 #ifndef USDT2 | 3348 #ifndef USDT2 |
3345 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); | 3349 DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); |
3346 #else /* USDT2 */ | 3350 #else /* USDT2 */ |
3347 HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN( | 3351 HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN( |
3348 result); | 3352 result); |
3592 /* Empty array: legal but useless, can't return NULL. \ | 3596 /* Empty array: legal but useless, can't return NULL. \ |
3593 * Return a pointer to something useless. \ | 3597 * Return a pointer to something useless. \ |
3594 * Avoid asserts in typeArrayOop. */ \ | 3598 * Avoid asserts in typeArrayOop. */ \ |
3595 result = (ElementType*)get_bad_address(); \ | 3599 result = (ElementType*)get_bad_address(); \ |
3596 } else { \ | 3600 } else { \ |
3597 result = NEW_C_HEAP_ARRAY(ElementType, len, mtInternal); \ | 3601 /* JNI Specification states return NULL on OOM */ \ |
3598 /* copy the array to the c chunk */ \ | 3602 result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ |
3599 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ | 3603 if (result != NULL) { \ |
3604 /* copy the array to the c chunk */ \ | |
3605 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ | |
3606 if (isCopy) { \ | |
3607 *isCopy = JNI_TRUE; \ | |
3608 } \ | |
3609 } \ | |
3600 } \ | 3610 } \ |
3601 if (isCopy) *isCopy = JNI_TRUE; \ | |
3602 DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ | 3611 DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ |
3603 return result; \ | 3612 return result; \ |
3604 JNI_END | 3613 JNI_END |
3605 | 3614 |
3606 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) | 3615 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) |
3629 /* Empty array: legal but useless, can't return NULL. \ | 3638 /* Empty array: legal but useless, can't return NULL. \ |
3630 * Return a pointer to something useless. \ | 3639 * Return a pointer to something useless. \ |
3631 * Avoid asserts in typeArrayOop. */ \ | 3640 * Avoid asserts in typeArrayOop. */ \ |
3632 result = (ElementType*)get_bad_address(); \ | 3641 result = (ElementType*)get_bad_address(); \ |
3633 } else { \ | 3642 } else { \ |
3634 result = NEW_C_HEAP_ARRAY(ElementType, len, mtInternal); \ | 3643 /* JNI Specification states return NULL on OOM */ \ |
3635 /* copy the array to the c chunk */ \ | 3644 result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ |
3636 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ | 3645 if (result != NULL) { \ |
3646 /* copy the array to the c chunk */ \ | |
3647 memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ | |
3648 if (isCopy) { \ | |
3649 *isCopy = JNI_TRUE; \ | |
3650 } \ | |
3651 } \ | |
3637 } \ | 3652 } \ |
3638 if (isCopy) *isCopy = JNI_TRUE; \ | |
3639 ReturnProbe; \ | 3653 ReturnProbe; \ |
3640 return result; \ | 3654 return result; \ |
3641 JNI_END | 3655 JNI_END |
3642 | 3656 |
3643 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool | 3657 DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool |
5020 #include "gc_interface/collectedHeap.hpp" | 5034 #include "gc_interface/collectedHeap.hpp" |
5021 #if INCLUDE_ALL_GCS | 5035 #if INCLUDE_ALL_GCS |
5022 #include "gc_implementation/g1/heapRegionRemSet.hpp" | 5036 #include "gc_implementation/g1/heapRegionRemSet.hpp" |
5023 #endif | 5037 #endif |
5024 #include "utilities/quickSort.hpp" | 5038 #include "utilities/quickSort.hpp" |
5039 #include "utilities/ostream.hpp" | |
5025 #if INCLUDE_VM_STRUCTS | 5040 #if INCLUDE_VM_STRUCTS |
5026 #include "runtime/vmStructs.hpp" | 5041 #include "runtime/vmStructs.hpp" |
5027 #endif | 5042 #endif |
5028 | 5043 |
5029 #define run_unit_test(unit_test_function_call) \ | 5044 #define run_unit_test(unit_test_function_call) \ |
5030 tty->print_cr("Running test: " #unit_test_function_call); \ | 5045 tty->print_cr("Running test: " #unit_test_function_call); \ |
5031 unit_test_function_call | 5046 unit_test_function_call |
5032 | 5047 |
5048 // Forward declaration | |
5049 void TestReservedSpace_test(); | |
5050 void TestReserveMemorySpecial_test(); | |
5051 void TestVirtualSpace_test(); | |
5052 void TestMetaspaceAux_test(); | |
5053 #if INCLUDE_ALL_GCS | |
5054 void TestG1BiasedArray_test(); | |
5055 #endif | |
5056 | |
5033 void execute_internal_vm_tests() { | 5057 void execute_internal_vm_tests() { |
5034 if (ExecuteInternalVMTests) { | 5058 if (ExecuteInternalVMTests) { |
5035 tty->print_cr("Running internal VM tests"); | 5059 tty->print_cr("Running internal VM tests"); |
5060 run_unit_test(TestReservedSpace_test()); | |
5061 run_unit_test(TestReserveMemorySpecial_test()); | |
5062 run_unit_test(TestVirtualSpace_test()); | |
5063 run_unit_test(TestMetaspaceAux_test()); | |
5036 run_unit_test(GlobalDefinitions::test_globals()); | 5064 run_unit_test(GlobalDefinitions::test_globals()); |
5037 run_unit_test(GCTimerAllTest::all()); | 5065 run_unit_test(GCTimerAllTest::all()); |
5038 run_unit_test(arrayOopDesc::test_max_array_length()); | 5066 run_unit_test(arrayOopDesc::test_max_array_length()); |
5039 run_unit_test(CollectedHeap::test_is_in()); | 5067 run_unit_test(CollectedHeap::test_is_in()); |
5040 run_unit_test(QuickSort::test_quick_sort()); | 5068 run_unit_test(QuickSort::test_quick_sort()); |
5041 run_unit_test(AltHashing::test_alt_hash()); | 5069 run_unit_test(AltHashing::test_alt_hash()); |
5070 run_unit_test(test_loggc_filename()); | |
5042 #if INCLUDE_VM_STRUCTS | 5071 #if INCLUDE_VM_STRUCTS |
5043 run_unit_test(VMStructs::test()); | 5072 run_unit_test(VMStructs::test()); |
5044 #endif | 5073 #endif |
5045 #if INCLUDE_ALL_GCS | 5074 #if INCLUDE_ALL_GCS |
5075 run_unit_test(TestG1BiasedArray_test()); | |
5046 run_unit_test(HeapRegionRemSet::test_prt()); | 5076 run_unit_test(HeapRegionRemSet::test_prt()); |
5047 #endif | 5077 #endif |
5048 tty->print_cr("All internal VM tests passed"); | 5078 tty->print_cr("All internal VM tests passed"); |
5049 } | 5079 } |
5050 } | 5080 } |