From d7290b6b6e21ab2341d26fba3ec6f00cb32ebab9 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Fri, 19 Dec 2008 12:08:29 +0000 Subject: [PATCH] Instead of jumping over a conditional backtrack, jump to a single instance somewhere else. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1007 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/regexp-macro-assembler-ia32.cc | 13 +++++++++---- src/regexp-macro-assembler-ia32.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/regexp-macro-assembler-ia32.cc b/src/regexp-macro-assembler-ia32.cc index 2fa23bcf16..29d9d31f7b 100644 --- a/src/regexp-macro-assembler-ia32.cc +++ b/src/regexp-macro-assembler-ia32.cc @@ -93,6 +93,7 @@ RegExpMacroAssemblerIA32::RegExpMacroAssemblerIA32( entry_label_(), start_label_(), success_label_(), + backtrack_label_(), exit_label_(), self_(Heap::undefined_value()) { __ jmp(&entry_label_); // We'll write the entry code later. @@ -106,6 +107,7 @@ RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() { entry_label_.Unuse(); start_label_.Unuse(); success_label_.Unuse(); + backtrack_label_.Unuse(); exit_label_.Unuse(); check_preempt_label_.Unuse(); } @@ -564,6 +566,12 @@ Handle RegExpMacroAssemblerIA32::GetCode(Handle source) { __ pop(esi); __ ret(0); + // Backtrack code (branch target for conditional backtracks). + if (backtrack_label_.is_linked()) { + __ bind(&backtrack_label_); + Backtrack(); + } + // Preempt-code if (check_preempt_label_.is_linked()) { __ bind(&check_preempt_label_); @@ -818,10 +826,7 @@ void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, return; } if (to == NULL) { - Label skip; - __ j(NegateCondition(condition), &skip); - Backtrack(); - __ bind(&skip); + __ j(condition, &backtrack_label_); return; } __ j(condition, to); diff --git a/src/regexp-macro-assembler-ia32.h b/src/regexp-macro-assembler-ia32.h index d639a2eef4..95ff01a109 100644 --- a/src/regexp-macro-assembler-ia32.h +++ b/src/regexp-macro-assembler-ia32.h @@ -201,6 +201,7 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler { Label entry_label_; Label start_label_; Label success_label_; + Label backtrack_label_; Label exit_label_; Label check_preempt_label_; // Handle used to represent the generated code object itself.