@@ -648,16 +648,17 @@ Handle<Object> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
648648 __ ldr (r0, MemOperand (frame_pointer (), kInputStart ));
649649 // Find negative length (offset of start relative to end).
650650 __ sub (current_input_offset (), r0, end_of_input_address ());
651- // Set r0 to address of char before start of input
651+ // Set r0 to address of char before start of the input string
652652 // (effectively string position -1).
653+ __ ldr (r1, MemOperand (frame_pointer (), kStartIndex ));
653654 __ sub (r0, current_input_offset (), Operand (char_size ()));
655+ __ sub (r0, r0, Operand (r1, LSL , (mode_ == UC16 ) ? 1 : 0 ));
654656 // Store this value in a local variable, for use when clearing
655657 // position registers.
656658 __ str (r0, MemOperand (frame_pointer (), kInputStartMinusOne ));
657659
658660 // Determine whether the start index is zero, that is at the start of the
659661 // string, and store that value in a local variable.
660- __ ldr (r1, MemOperand (frame_pointer (), kStartIndex ));
661662 __ tst (r1, Operand (r1));
662663 __ mov (r1, Operand (1 ), LeaveCC, eq);
663664 __ mov (r1, Operand (0 ), LeaveCC, ne);
@@ -700,12 +701,15 @@ Handle<Object> RegExpMacroAssemblerARM::GetCode(Handle<String> source) {
700701 // copy captures to output
701702 __ ldr (r1, MemOperand (frame_pointer (), kInputStart ));
702703 __ ldr (r0, MemOperand (frame_pointer (), kRegisterOutput ));
704+ __ ldr (r2, MemOperand (frame_pointer (), kStartIndex ));
703705 __ sub (r1, end_of_input_address (), r1);
704706 // r1 is length of input in bytes.
705707 if (mode_ == UC16 ) {
706708 __ mov (r1, Operand (r1, LSR , 1 ));
707709 }
708710 // r1 is length of input in characters.
711+ __ add (r1, r1, Operand (r2));
712+ // r1 is length of string in characters.
709713
710714 ASSERT_EQ (0 , num_saved_registers_ % 2 );
711715 // Always an even number of capture registers. This allows us to
0 commit comments