Reviewers: ,
Message:
Committed patchset #1 manually as r22211 (presubmit successful).
Description:
Revert "Remove unnecessary check in RegExpExecStub."
This reverts r22203 and r22205.
[email protected]
Committed: https://code.google.com/p/v8/source/detail?r=22211
Please review this at https://codereview.chromium.org/369063005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+35, -30 lines):
M src/arm/code-stubs-arm.cc
M src/arm64/code-stubs-arm64.cc
M src/ia32/code-stubs-ia32.cc
M src/mips/code-stubs-mips.cc
M src/x64/code-stubs-x64.cc
D test/mjsunit/regexp-stack-overflow.js
Index: test/mjsunit/regexp-stack-overflow.js
diff --git a/test/mjsunit/regexp-stack-overflow.js
b/test/mjsunit/regexp-stack-overflow.js
deleted file mode 100644
index
637d205642d2032c9415f06e839d0788973a1ab3..0000000000000000000000000000000000000000
--- a/test/mjsunit/regexp-stack-overflow.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Flags: --stack-size=100
-
-var result = null;
-var re = /\w/;
-re.test("a"); // Trigger regexp compile.
-
-function rec() {
- try {
- return rec();
- } catch (e) {
- return re.test("b");
- }
-}
-
-assertTrue(rec());
Index: src/arm/code-stubs-arm.cc
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index
fbde24dafaa44e04492e7c92b62b3da58b07481b..06c1b05815010bc9e72f6130c0c258f27f393ed8
100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -2520,12 +2520,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm)
{
__ 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.
+ // Result must now be exception. If there is no pending exception
already a
+ // stack overflow (on the backtrack stack) was detected in RegExp code
but
+ // haven't created the exception yet. Handle that in the runtime system.
+ // TODO(592): Rerunning the RegExp to get the stack overflow exception.
__ mov(r1, Operand(isolate()->factory()->the_hole_value()));
__ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate())));
__ ldr(r0, MemOperand(r2, 0));
+ __ 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.
Index: src/arm64/code-stubs-arm64.cc
diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc
index
70eae4373aa9c9dff39d4a7fa816a8452749d684..6dc564da4a9d434a7643b1a3102f5d1dd0cfb6cb
100644
--- a/src/arm64/code-stubs-arm64.cc
+++ b/src/arm64/code-stubs-arm64.cc
@@ -2855,12 +2855,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm)
{
__ Bind(&exception);
Register exception_value = x0;
- // Result must now be exception.
+ // A stack overflow (on the backtrack stack) may have occured
+ // in the RegExp code but no exception has been created yet.
+ // If there is no pending exception, handle that in the runtime system.
__ Mov(x10, Operand(isolate()->factory()->the_hole_value()));
__ Mov(x11,
Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate())));
__ Ldr(exception_value, MemOperand(x11));
+ __ Cmp(x10, exception_value);
+ __ B(eq, &runtime);
+
__ Str(x10, MemOperand(x11)); // Clear pending exception.
// Check if the exception is a termination. If so, throw as uncatchable.
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index
0590ad466d23fa02ed4cbb515518ea04fdb0f48a..8a05e007639d432f33701b614d26d8993c197883
100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -1596,14 +1596,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm)
{
__ cmp(eax, NativeRegExpMacroAssembler::EXCEPTION);
// If not exception it can only be retry. Handle that in the runtime
system.
__ j(not_equal, &runtime);
-
- // Result must now be exception.
+ // Result must now be exception. If there is no pending exception
already a
+ // stack overflow (on the backtrack stack) was detected in RegExp code
but
+ // haven't created the exception yet. Handle that in the runtime system.
+ // TODO(592): Rerunning the RegExp to get the stack overflow exception.
ExternalReference pending_exception(Isolate::kPendingExceptionAddress,
isolate());
__ mov(edx, Immediate(isolate()->factory()->the_hole_value()));
__ mov(eax, Operand::StaticVariable(pending_exception));
+ __ cmp(edx, eax);
+ __ j(equal, &runtime);
+ // For exception, throw the exception again.
- // Clear pending exception.
+ // Clear the pending exception variable.
__ mov(Operand::StaticVariable(pending_exception), edx);
// Special handling of termination exceptions which are uncatchable
Index: src/mips/code-stubs-mips.cc
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index
18f3a9a395a182fee85d5fc0b688ddbd6b482c9d..68d81bbfc74cc75d4cd7da8cf2c2df33d9f3878e
100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -2670,12 +2670,16 @@ void RegExpExecStub::Generate(MacroAssembler* masm)
{
__ Branch(&failure, eq, v0,
Operand(NativeRegExpMacroAssembler::FAILURE));
// If not exception it can only be retry. Handle that in the runtime
system.
__ Branch(&runtime, ne, v0,
Operand(NativeRegExpMacroAssembler::EXCEPTION));
-
- // Result must now be exception.
+ // Result must now be exception. If there is no pending exception
already a
+ // stack overflow (on the backtrack stack) was detected in RegExp code
but
+ // haven't created the exception yet. Handle that in the runtime system.
+ // TODO(592): Rerunning the RegExp to get the stack overflow exception.
__ li(a1, Operand(isolate()->factory()->the_hole_value()));
__ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate())));
__ lw(v0, MemOperand(a2, 0));
+ __ Branch(&runtime, eq, v0, Operand(a1));
+
__ sw(a1, MemOperand(a2, 0)); // Clear pending exception.
// Check if the exception is a termination. If so, throw as uncatchable.
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index
62ce31cc744d3f29904d261698061758a88630dc..c08e38b50992bbc1a2fbae027654f08cda603c2c
100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -1574,14 +1574,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm)
{
__ ret(REG_EXP_EXEC_ARGUMENT_COUNT * kPointerSize);
__ bind(&exception);
- // Result must now be exception.
+ // Result must now be exception. If there is no pending exception
already a
+ // stack overflow (on the backtrack stack) was detected in RegExp code
but
+ // haven't created the exception yet. Handle that in the runtime system.
+ // TODO(592): Rerunning the RegExp to get the stack overflow exception.
ExternalReference pending_exception_address(
Isolate::kPendingExceptionAddress, isolate());
Operand pending_exception_operand =
masm->ExternalOperand(pending_exception_address, rbx);
- __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
__ movp(rax, pending_exception_operand);
- __ movp(pending_exception_operand, rdx); // Clear pending exception.
+ __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
+ __ cmpp(rax, rdx);
+ __ j(equal, &runtime);
+ __ movp(pending_exception_operand, rdx);
__ CompareRoot(rax, Heap::kTerminationExceptionRootIndex);
Label termination_exception;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.