The optimizations performed by Irregexp could possible hide bugs or
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 2 Feb 2009 16:27:31 +0000 (16:27 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 2 Feb 2009 16:27:31 +0000 (16:27 +0000)
could themselves be a source of bugs.  Add a flag to switch off
optimizations (--noirregexp-optimization) to aid testing.
Review URL: http://codereview.chromium.org/19538

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1210 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/flag-definitions.h
src/jsregexp.cc

index a99cc76..9894bc8 100644 (file)
@@ -203,6 +203,7 @@ DEFINE_bool(preemption, false,
 DEFINE_bool(irregexp, true, "new regular expression code")
 DEFINE_bool(trace_regexps, false, "trace Irregexp execution")
 DEFINE_bool(irregexp_native, true, "use native code Irregexp implementation (IA32 only)")
+DEFINE_bool(irregexp_optimization, true, "generate optimized regexp code")
 
 // Testing flags test/cctest/test-{flags,api,serialization}.cc
 DEFINE_bool(testing_bool_flag, true, "testing_bool_flag")
index 590dd7d..d15a3b6 100644 (file)
@@ -2013,7 +2013,8 @@ RegExpNode::LimitResult RegExpNode::LimitVersions(RegExpCompiler* compiler,
   // We are being asked to make a non-generic version.  Keep track of how many
   // non-generic versions we generate so as not to overdo it.
   trace_count_++;
-  if (trace_count_ < kMaxCopiesCodeGenerated &&
+  if (FLAG_irregexp_optimization &&
+      trace_count_ < kMaxCopiesCodeGenerated &&
       compiler->recursion_depth() <= RegExpCompiler::kMaxRecursion) {
     return CONTINUE;
   }
@@ -3117,7 +3118,8 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
     new_trace.quick_check_performed()->Clear();
     alt_gen->expects_preload = preload_is_current;
     bool generate_full_check_inline = false;
-    if (try_to_emit_quick_check_for_alternative(i) &&
+    if (FLAG_irregexp_optimization &&
+        try_to_emit_quick_check_for_alternative(i) &&
         alternative.node()->EmitQuickCheck(compiler,
                                            &new_trace,
                                            preload_has_checked_bounds,
@@ -3899,7 +3901,7 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
   bool needs_capture_clearing = !capture_registers.is_empty();
   if (body_can_be_empty) {
     body_start_reg = compiler->AllocateRegister();
-  } else if (!needs_capture_clearing) {
+  } else if (FLAG_irregexp_optimization && !needs_capture_clearing) {
     // Only unroll if there are no captures and the body can't be
     // empty.
     if (min > 0 && min <= kMaxUnrolledMinMatches) {