Reviewers: Erik Corry,

Message:
Please take a look.

The performance regression was introduced in r9027 when I committed my tentative implementation for sliced strings. In particular, the bug was introduced in line
4500:
http://code.google.com/p/v8/source/diff?spec=svn9027&r=9027&format=side&path=/branches/bleeding_edge/src/arm/code-stubs-arm.cc


http://codereview.chromium.org/7824033/diff/1/src/arm/code-stubs-arm.cc
File src/arm/code-stubs-arm.cc (left):

http://codereview.chromium.org/7824033/diff/1/src/arm/code-stubs-arm.cc#oldcode4530
src/arm/code-stubs-arm.cc:4530: __ b(ne, &runtime);
even though subject is not the result of the regexp, comparing it with
SUCCESS, FAILURE and EXCEPTION would eventually result in a jump into
runtime, so that the final result is correct, but performance takes a
hit.

http://codereview.chromium.org/7824033/diff/1/src/arm/code-stubs-arm.cc
File src/arm/code-stubs-arm.cc (right):

http://codereview.chromium.org/7824033/diff/1/src/arm/code-stubs-arm.cc#newcode4490
src/arm/code-stubs-arm.cc:4490: __ ldr(subject, MemOperand(fp,
kSubjectOffset + 2 * kPointerSize));
the underlying subject string is no longer needed, and can be replaced
by the original subject string.

http://codereview.chromium.org/7824033/diff/1/src/arm/code-stubs-arm.cc#newcode4523
src/arm/code-stubs-arm.cc:4523: __ cmp(r0,
Operand(NativeRegExpMacroAssembler::SUCCESS));
not subject (r4) but r0 is the return value of the regexp.

Description:
Fixed performance regression in v8 regexp benchmark on ARM.


Please review this at http://codereview.chromium.org/7824033/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/arm/code-stubs-arm.cc


Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index f6b87c38e58f0b4cd403bb15c835e01fe59ea6d0..c8d3edd033c8f9fdbb955575437aa47dc16e6915 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -4487,7 +4487,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// frame. Therefore we have to use fp, which points exactly to two pointer // sizes below the previous sp. (Because creating a new stack frame pushes
   // the previous fp onto the stack and moves up sp by 2 * kPointerSize.)
-  __ ldr(r0, MemOperand(fp, kSubjectOffset + 2 * kPointerSize));
+  __ ldr(subject, MemOperand(fp, kSubjectOffset + 2 * kPointerSize));
// If slice offset is not 0, load the length from the original sliced string.
   // Argument 4, r3: End of string data
   // Argument 3, r2: Start of string data
@@ -4495,7 +4495,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
   __ add(r9, r8, Operand(r9, LSL, r3));
   __ add(r2, r9, Operand(r1, LSL, r3));

-  __ ldr(r8, FieldMemOperand(r0, String::kLengthOffset));
+  __ ldr(r8, FieldMemOperand(subject, String::kLengthOffset));
   __ mov(r8, Operand(r8, ASR, kSmiTagSize));
   __ add(r3, r9, Operand(r8, LSL, r3));

@@ -4503,7 +4503,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
   // Already there

   // Argument 1 (r0): Subject string.
-  // Already there
+  __ mov(r0, subject);

   // Locate the code entry and call it.
   __ add(r7, r7, Operand(Code::kHeaderSize - kHeapObjectTag));
@@ -4520,12 +4520,12 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
   // Check the result.
   Label success;

-  __ cmp(subject, Operand(NativeRegExpMacroAssembler::SUCCESS));
+  __ cmp(r0, Operand(NativeRegExpMacroAssembler::SUCCESS));
   __ b(eq, &success);
   Label failure;
-  __ cmp(subject, Operand(NativeRegExpMacroAssembler::FAILURE));
+  __ cmp(r0, Operand(NativeRegExpMacroAssembler::FAILURE));
   __ b(eq, &failure);
-  __ cmp(subject, Operand(NativeRegExpMacroAssembler::EXCEPTION));
+  __ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION));
// If not exception it can only be retry. Handle that in the runtime system.
   __ b(ne, &runtime);
// Result must now be exception. If there is no pending exception already a @@ -4537,18 +4537,18 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address,
                                        isolate)));
   __ ldr(r0, MemOperand(r2, 0));
-  __ cmp(subject, r1);
+  __ cmp(r0, r1);
   __ b(eq, &runtime);

   __ str(r1, MemOperand(r2, 0));  // Clear pending exception.

   // Check if the exception is a termination. If so, throw as uncatchable.
   __ LoadRoot(ip, Heap::kTerminationExceptionRootIndex);
-  __ cmp(subject, ip);
+  __ cmp(r0, ip);
   Label termination_exception;
   __ b(eq, &termination_exception);

-  __ Throw(subject);  // Expects thrown value in r0.
+  __ Throw(r0);  // Expects thrown value in r0.

   __ bind(&termination_exception);
   __ ThrowUncatchable(TERMINATION, r0);  // Expects thrown value in r0.


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to