mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
6664815
: Eliminate redundant memcpy operation in jni_GetStringUTFRegion
Added support for target buffer in as_utf8_string(), minor refactoring of as_utf8 and added some internal VM testing Reviewed-by: coleenp, dsimms, sla, dholmes
This commit is contained in:
parent
7ee6324490
commit
9efb17f38f
4 changed files with 48 additions and 16 deletions
|
@ -3150,11 +3150,9 @@ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start,
|
|||
} else {
|
||||
//%note jni_7
|
||||
if (len > 0) {
|
||||
ResourceMark rm(THREAD);
|
||||
char *utf_region = java_lang_String::as_utf8_string(s, start, len);
|
||||
int utf_len = (int)strlen(utf_region);
|
||||
memcpy(buf, utf_region, utf_len);
|
||||
buf[utf_len] = 0;
|
||||
// Assume the buffer is large enough as the JNI spec. does not require user error checking
|
||||
java_lang_String::as_utf8_string(s, start, len, buf, INT_MAX);
|
||||
// as_utf8_string null-terminates the result string
|
||||
} else {
|
||||
// JDK null-terminates the buffer even in len is zero
|
||||
if (buf != NULL) {
|
||||
|
@ -3880,6 +3878,7 @@ void TestNewSize_test();
|
|||
void TestOldSize_test();
|
||||
void TestKlass_test();
|
||||
void TestBitMap_test();
|
||||
void TestAsUtf8();
|
||||
#if INCLUDE_ALL_GCS
|
||||
void TestOldFreeSpaceCalculation_test();
|
||||
void TestG1BiasedArray_test();
|
||||
|
@ -3907,6 +3906,7 @@ void execute_internal_vm_tests() {
|
|||
run_unit_test(TestOldSize_test());
|
||||
run_unit_test(TestKlass_test());
|
||||
run_unit_test(TestBitMap_test());
|
||||
run_unit_test(TestAsUtf8());
|
||||
#if INCLUDE_VM_STRUCTS
|
||||
run_unit_test(VMStructs::test());
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue