Skip to content

Commit 097c2af

Browse files
committed
Allow minimum header of 8 instead of 16
1 parent 7001783 commit 097c2af

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/hotspot/cpu/x86/c2_stubGenerator_x86_64_string.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static void generate_string_indexof_stubs(StubGenerator *stubgen, address *fnptr
401401
// Only done for small haystacks
402402
//
403403
// NOTE: This code assumes that the haystack points to a java array type AND there are
404-
// at least 16 bytes of header preceeding the haystack pointer.
404+
// at least 8 bytes of header preceeding the haystack pointer.
405405
//
406406
// This means that we're copying up to 15 bytes of the header onto the stack along
407407
// with the haystack bytes. After the copy completes, we adjust the haystack pointer
@@ -412,7 +412,20 @@ static void generate_string_indexof_stubs(StubGenerator *stubgen, address *fnptr
412412
const Register index = rax;
413413
const Register haystack = rbx;
414414

415-
// Only a single vector load/store of either 16 or 32 bytes
415+
// Only a single vector load/store of either 8, 16 or 32 bytes
416+
assert(arrayOopDesc::base_offset_in_bytes(T_BYTE) >= 8,
417+
"need at least 8 bytes preceding the haystack");
418+
if (arrayOopDesc::base_offset_in_bytes(T_BYTE) < 16) {
419+
Label L_moreThan8;
420+
__ cmpq(haystack_len, 0x8);
421+
__ ja_b(L_moreThan8);
422+
__ movq(index, COPIED_HAYSTACK_STACK_OFFSET + 0x8);
423+
__ movq(XMM_TMP1, Address(haystack, haystack_len, Address::times_1, -0x8));
424+
__ movq(Address(rsp, COPIED_HAYSTACK_STACK_OFFSET), XMM_TMP1);
425+
__ jmpb(L_adjustHaystack);
426+
__ bind(L_moreThan8);
427+
}
428+
416429
__ cmpq(haystack_len, 0x10);
417430
__ ja_b(L_moreThan16);
418431

0 commit comments

Comments
 (0)