Commit 29b59adb authored by yangguo@chromium.org's avatar yangguo@chromium.org

Revert "Remove unnecessary check in RegExpExecStub."

This reverts r22203 and r22205.

TBR=danno@chromium.org

Review URL: https://codereview.chromium.org/369063005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22211 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cfccf793
...@@ -2520,12 +2520,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -2520,12 +2520,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION)); __ cmp(r0, Operand(NativeRegExpMacroAssembler::EXCEPTION));
// If not exception it can only be retry. Handle that in the runtime system. // If not exception it can only be retry. Handle that in the runtime system.
__ b(ne, &runtime); __ b(ne, &runtime);
// Result must now be exception. If there is no pending exception already a
// Result must now be exception. // 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(r1, Operand(isolate()->factory()->the_hole_value()));
__ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, __ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate()))); isolate())));
__ ldr(r0, MemOperand(r2, 0)); __ ldr(r0, MemOperand(r2, 0));
__ cmp(r0, r1);
__ b(eq, &runtime);
__ str(r1, MemOperand(r2, 0)); // Clear pending exception. __ str(r1, MemOperand(r2, 0)); // Clear pending exception.
// Check if the exception is a termination. If so, throw as uncatchable. // Check if the exception is a termination. If so, throw as uncatchable.
......
...@@ -2855,12 +2855,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -2855,12 +2855,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ Bind(&exception); __ Bind(&exception);
Register exception_value = x0; 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(x10, Operand(isolate()->factory()->the_hole_value()));
__ Mov(x11, __ Mov(x11,
Operand(ExternalReference(Isolate::kPendingExceptionAddress, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate()))); isolate())));
__ Ldr(exception_value, MemOperand(x11)); __ Ldr(exception_value, MemOperand(x11));
__ Cmp(x10, exception_value);
__ B(eq, &runtime);
__ Str(x10, MemOperand(x11)); // Clear pending exception. __ Str(x10, MemOperand(x11)); // Clear pending exception.
// Check if the exception is a termination. If so, throw as uncatchable. // Check if the exception is a termination. If so, throw as uncatchable.
......
...@@ -1596,14 +1596,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -1596,14 +1596,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ cmp(eax, NativeRegExpMacroAssembler::EXCEPTION); __ cmp(eax, NativeRegExpMacroAssembler::EXCEPTION);
// If not exception it can only be retry. Handle that in the runtime system. // If not exception it can only be retry. Handle that in the runtime system.
__ j(not_equal, &runtime); __ j(not_equal, &runtime);
// Result must now be exception. If there is no pending exception already a
// Result must now be exception. // 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, ExternalReference pending_exception(Isolate::kPendingExceptionAddress,
isolate()); isolate());
__ mov(edx, Immediate(isolate()->factory()->the_hole_value())); __ mov(edx, Immediate(isolate()->factory()->the_hole_value()));
__ mov(eax, Operand::StaticVariable(pending_exception)); __ 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); __ mov(Operand::StaticVariable(pending_exception), edx);
// Special handling of termination exceptions which are uncatchable // Special handling of termination exceptions which are uncatchable
......
...@@ -2670,12 +2670,16 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -2670,12 +2670,16 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ Branch(&failure, eq, v0, Operand(NativeRegExpMacroAssembler::FAILURE)); __ Branch(&failure, eq, v0, Operand(NativeRegExpMacroAssembler::FAILURE));
// If not exception it can only be retry. Handle that in the runtime system. // If not exception it can only be retry. Handle that in the runtime system.
__ Branch(&runtime, ne, v0, Operand(NativeRegExpMacroAssembler::EXCEPTION)); __ Branch(&runtime, ne, v0, Operand(NativeRegExpMacroAssembler::EXCEPTION));
// Result must now be exception. If there is no pending exception already a
// Result must now be exception. // 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(a1, Operand(isolate()->factory()->the_hole_value()));
__ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate()))); isolate())));
__ lw(v0, MemOperand(a2, 0)); __ lw(v0, MemOperand(a2, 0));
__ Branch(&runtime, eq, v0, Operand(a1));
__ sw(a1, MemOperand(a2, 0)); // Clear pending exception. __ sw(a1, MemOperand(a2, 0)); // Clear pending exception.
// Check if the exception is a termination. If so, throw as uncatchable. // Check if the exception is a termination. If so, throw as uncatchable.
......
...@@ -1574,14 +1574,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -1574,14 +1574,19 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ ret(REG_EXP_EXEC_ARGUMENT_COUNT * kPointerSize); __ ret(REG_EXP_EXEC_ARGUMENT_COUNT * kPointerSize);
__ bind(&exception); __ 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( ExternalReference pending_exception_address(
Isolate::kPendingExceptionAddress, isolate()); Isolate::kPendingExceptionAddress, isolate());
Operand pending_exception_operand = Operand pending_exception_operand =
masm->ExternalOperand(pending_exception_address, rbx); masm->ExternalOperand(pending_exception_address, rbx);
__ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
__ movp(rax, pending_exception_operand); __ 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); __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex);
Label termination_exception; Label termination_exception;
......
// 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());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment