Author: [email protected]
Date: Wed Jan 14 03:32:23 2009
New Revision: 1070

Added:
    branches/bleeding_edge/test/mjsunit/bugs/bug-187.js
    branches/bleeding_edge/test/mjsunit/regexp-loop-capture.js
    branches/bleeding_edge/test/mjsunit/regress/regress-176.js
       - copied, changed from r1069,  
/branches/bleeding_edge/test/mjsunit/bugs/bug-176.js
Removed:
    branches/bleeding_edge/test/mjsunit/bugs/bug-176.js
Modified:
    branches/bleeding_edge/src/ast.cc
    branches/bleeding_edge/src/ast.h
    branches/bleeding_edge/src/jsregexp.cc
    branches/bleeding_edge/src/jsregexp.h
    branches/bleeding_edge/src/regexp-macro-assembler-ia32.cc
    branches/bleeding_edge/src/regexp-macro-assembler-ia32.h
    branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc
    branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h
    branches/bleeding_edge/src/regexp-macro-assembler-tracer.cc
    branches/bleeding_edge/src/regexp-macro-assembler-tracer.h
    branches/bleeding_edge/src/regexp-macro-assembler.h
    branches/bleeding_edge/test/cctest/test-regexp.cc
    branches/bleeding_edge/test/mjsunit/mjsunit.js
    branches/bleeding_edge/test/mjsunit/mjsunit.status

Log:
Added clearing of captures before entering the body of a loop.  This
also revealed a bug or two that had to be fixed.


Modified: branches/bleeding_edge/src/ast.cc
==============================================================================
--- branches/bleeding_edge/src/ast.cc   (original)
+++ branches/bleeding_edge/src/ast.cc   Wed Jan 14 03:32:23 2009
@@ -210,6 +210,40 @@
  RegExpEmpty RegExpEmpty::kInstance;


+static Interval ListCaptureRegisters(ZoneList<RegExpTree*>* children) {
+  Interval result = Interval::Empty();
+  for (int i = 0; i < children->length(); i++)
+    result = result.Union(children->at(i)->CaptureRegisters());
+  return result;
+}
+
+
+Interval RegExpAlternative::CaptureRegisters() {
+  return ListCaptureRegisters(nodes());
+}
+
+
+Interval RegExpDisjunction::CaptureRegisters() {
+  return ListCaptureRegisters(alternatives());
+}
+
+
+Interval RegExpLookahead::CaptureRegisters() {
+  return body()->CaptureRegisters();
+}
+
+
+Interval RegExpCapture::CaptureRegisters() {
+  Interval self(StartRegister(index()), EndRegister(index()));
+  return self.Union(body()->CaptureRegisters());
+}
+
+
+Interval RegExpQuantifier::CaptureRegisters() {
+  return body()->CaptureRegisters();
+}
+
+
  // Convert regular expression trees to a simple sexp representation.
  // This representation should be different from the input grammar
  // in as many cases as possible, to make it more difficult for incorrect

Modified: branches/bleeding_edge/src/ast.h
==============================================================================
--- branches/bleeding_edge/src/ast.h    (original)
+++ branches/bleeding_edge/src/ast.h    Wed Jan 14 03:32:23 2009
@@ -1214,6 +1214,16 @@
  // Regular expressions


+class RegExpVisitor BASE_EMBEDDED {
+ public:
+  virtual ~RegExpVisitor() { }
+#define MAKE_CASE(Name)                                              \
+  virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
+  FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
+#undef MAKE_CASE
+};
+
+
  class RegExpTree: public ZoneObject {
   public:
    static const int kInfinity = kMaxInt;
@@ -1224,6 +1234,9 @@
    virtual bool IsTextElement() { return false; }
    virtual int min_match() = 0;
    virtual int max_match() = 0;
+  // Returns the interval of registers used for captures within this
+  // expression.
+  virtual Interval CaptureRegisters() { return Interval::Empty(); }
    virtual void AppendToText(RegExpText* text);
    SmartPointer<const char> ToString();
  #define MAKE_ASTYPE(Name)                                                   
\
@@ -1241,6 +1254,7 @@
    virtual RegExpNode* ToNode(RegExpCompiler* compiler,
                               RegExpNode* on_success);
    virtual RegExpDisjunction* AsDisjunction();
+  virtual Interval CaptureRegisters();
    virtual bool IsDisjunction();
    virtual int min_match() { return min_match_; }
    virtual int max_match() { return max_match_; }
@@ -1259,6 +1273,7 @@
    virtual RegExpNode* ToNode(RegExpCompiler* compiler,
                               RegExpNode* on_success);
    virtual RegExpAlternative* AsAlternative();
+  virtual Interval CaptureRegisters();
    virtual bool IsAlternative();
    virtual int min_match() { return min_match_; }
    virtual int max_match() { return max_match_; }
@@ -1423,6 +1438,7 @@
                              RegExpCompiler* compiler,
                              RegExpNode* on_success);
    virtual RegExpQuantifier* AsQuantifier();
+  virtual Interval CaptureRegisters();
    virtual bool IsQuantifier();
    virtual int min_match() { return min_match_; }
    virtual int max_match() { return max_match_; }
@@ -1458,6 +1474,7 @@
                              RegExpCompiler* compiler,
                              RegExpNode* on_success);
    virtual RegExpCapture* AsCapture();
+  virtual Interval CaptureRegisters();
    virtual bool IsCapture();
    virtual int min_match() { return body_->min_match(); }
    virtual int max_match() { return body_->max_match(); }
@@ -1485,6 +1502,7 @@
    virtual RegExpNode* ToNode(RegExpCompiler* compiler,
                               RegExpNode* on_success);
    virtual RegExpLookahead* AsLookahead();
+  virtual Interval CaptureRegisters();
    virtual bool IsLookahead();
    virtual int min_match() { return 0; }
    virtual int max_match() { return 0; }
@@ -1505,7 +1523,7 @@
                               RegExpNode* on_success);
    virtual RegExpBackReference* AsBackReference();
    virtual bool IsBackReference();
-  virtual int min_match() { return capture_->min_match(); }
+  virtual int min_match() { return 0; }
    virtual int max_match() { return capture_->max_match(); }
    int index() { return capture_->index(); }
    RegExpCapture* capture() { return capture_; }
@@ -1527,16 +1545,6 @@
    static RegExpEmpty* GetInstance() { return &kInstance; }
   private:
    static RegExpEmpty kInstance;
-};
-
-
-class RegExpVisitor BASE_EMBEDDED {
- public:
-  virtual ~RegExpVisitor() { }
-#define MAKE_CASE(Name)                                              \
-  virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
-  FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
-#undef MAKE_CASE
  };



Modified: branches/bleeding_edge/src/jsregexp.cc
==============================================================================
--- branches/bleeding_edge/src/jsregexp.cc      (original)
+++ branches/bleeding_edge/src/jsregexp.cc      Wed Jan 14 03:32:23 2009
@@ -1304,12 +1304,22 @@
    return array;
  }

+bool GenerationVariant::DeferredAction::Mentions(int that) {
+  if (type() == ActionNode::CLEAR_CAPTURES) {
+    Interval range = static_cast<DeferredClearCaptures*>(this)->range();
+    return range.Contains(that);
+  } else {
+    return reg() == that;
+  }
+}
+

  bool GenerationVariant::mentions_reg(int reg) {
    for (DeferredAction* action = actions_;
         action != NULL;
         action = action->next()) {
-    if (reg == action->reg()) return true;
+    if (action->Mentions(reg))
+      return true;
    }
    return false;
  }
@@ -1320,7 +1330,7 @@
    for (DeferredAction* action = actions_;
         action != NULL;
         action = action->next()) {
-    if (reg == action->reg()) {
+    if (action->Mentions(reg)) {
        if (action->type() == ActionNode::STORE_POSITION) {
          *cp_offset = static_cast<DeferredCapture*>(action)->cp_offset();
          return true;
@@ -1338,8 +1348,15 @@
    for (DeferredAction* action = actions_;
         action != NULL;
         action = action->next()) {
-    affected_registers->Set(action->reg());
-    if (action->reg() > max_register) max_register = action->reg();
+    if (action->type() == ActionNode::CLEAR_CAPTURES) {
+      Interval range =  
static_cast<DeferredClearCaptures*>(action)->range();
+      for (int i = range.from(); i <= range.to(); i++)
+        affected_registers->Set(i);
+      if (range.to() > max_register) max_register = range.to();
+    } else {
+      affected_registers->Set(action->reg());
+      if (action->reg() > max_register) max_register = action->reg();
+    }
    }
    return max_register;
  }
@@ -1383,13 +1400,14 @@
      }
      int value = 0;
      bool absolute = false;
+    bool clear = false;
      int store_position = -1;
      // This is a little tricky because we are scanning the actions in  
reverse
      // historical order (newest first).
      for (DeferredAction* action = actions_;
           action != NULL;
           action = action->next()) {
-      if (action->reg() == reg) {
+      if (action->Mentions(reg)) {
          switch (action->type()) {
            case ActionNode::SET_REGISTER: {
              GenerationVariant::DeferredSetRegister* psr =
@@ -1397,6 +1415,7 @@
              value += psr->value();
              absolute = true;
              ASSERT_EQ(store_position, -1);
+            ASSERT(!clear);
              break;
            }
            case ActionNode::INCREMENT_REGISTER:
@@ -1404,17 +1423,28 @@
                value++;
              }
              ASSERT_EQ(store_position, -1);
+            ASSERT(!clear);
              break;
            case ActionNode::STORE_POSITION: {
              GenerationVariant::DeferredCapture* pc =
                  static_cast<GenerationVariant::DeferredCapture*>(action);
-            if (store_position == -1) {
+            if (!clear && store_position == -1) {
                store_position = pc->cp_offset();
              }
              ASSERT(!absolute);
              ASSERT_EQ(value, 0);
              break;
            }
+          case ActionNode::CLEAR_CAPTURES: {
+            // Since we're scanning in reverse order, if we've already
+            // set the position we have to ignore historically earlier
+            // clearing operations.
+            if (store_position == -1)
+              clear = true;
+            ASSERT(!absolute);
+            ASSERT_EQ(value, 0);
+            break;
+          }
            default:
              UNREACHABLE();
              break;
@@ -1423,14 +1453,12 @@
      }
      if (store_position != -1) {
        assembler->WriteCurrentPositionToRegister(reg, store_position);
-    } else {
-      if (absolute) {
-        assembler->SetRegister(reg, value);
-      } else {
-        if (value != 0) {
-          assembler->AdvanceRegister(reg, value);
-        }
-      }
+    } else if (clear) {
+      assembler->ClearRegister(reg);
+    } else if (absolute) {
+      assembler->SetRegister(reg, value);
+    } else if (value != 0) {
+      assembler->AdvanceRegister(reg, value);
      }
    }
  }
@@ -1586,6 +1614,15 @@
  }


+ActionNode* ActionNode::ClearCaptures(Interval range,
+                                      RegExpNode* on_success) {
+  ActionNode* result = new ActionNode(CLEAR_CAPTURES, on_success);
+  result->data_.u_clear_captures.range_from = range.from();
+  result->data_.u_clear_captures.range_to = range.to();
+  return result;
+}
+
+
  ActionNode* ActionNode::BeginSubmatch(int stack_reg,
                                        int position_reg,
                                        RegExpNode* on_success) {
@@ -2267,10 +2304,25 @@
  }


+class VisitMarker {
+ public:
+  explicit VisitMarker(NodeInfo* info) : info_(info) {
+    ASSERT(!info->visited);
+    info->visited = true;
+  }
+  ~VisitMarker() {
+    info_->visited = false;
+  }
+ private:
+  NodeInfo* info_;
+};
+
+
  void LoopChoiceNode::GetQuickCheckDetails(QuickCheckDetails* details,
                                            RegExpCompiler* compiler,
                                            int characters_filled_in) {
-  if (body_can_be_zero_length_) return;
+  if (body_can_be_zero_length_ || info()->visited) return;
+  VisitMarker marker(info());
    return ChoiceNode::GetQuickCheckDetails(details,
                                            compiler,
                                            characters_filled_in);
@@ -2843,7 +2895,7 @@
    // is to use the Dispatch table to try only the relevant ones.
    for (int i = first_normal_choice; i < choice_count; i++) {
      GuardedAlternative alternative = alternatives_->at(i);
-    AlternativeGeneration* alt_gen(alt_gens.at(i));
+    AlternativeGeneration* alt_gen = alt_gens.at(i);
      alt_gen->quick_check_details.set_characters(preload_characters);
      ZoneList<Guard*>* guards = alternative.guards();
      int guard_count = (guards == NULL) ? 0 : guards->length();
@@ -3002,6 +3054,14 @@
        new_variant.add_action(&new_set);
        return on_success()->Emit(compiler, &new_variant);
      }
+    case CLEAR_CAPTURES: {
+      GenerationVariant::DeferredClearCaptures
+        new_capture(Interval(data_.u_clear_captures.range_from,
+                             data_.u_clear_captures.range_to));
+      GenerationVariant new_variant = *variant;
+      new_variant.add_action(&new_capture);
+      return on_success()->Emit(compiler, &new_variant);
+    }
      case BEGIN_SUBMATCH:
        if (!variant->is_trivial()) return variant->Flush(compiler, this);
        assembler->WriteCurrentPositionToRegister(
@@ -3365,6 +3425,12 @@
                      that->data_.u_empty_match_check.repetition_register,
                      that->data_.u_empty_match_check.repetition_limit);
        break;
+    case ActionNode::CLEAR_CAPTURES: {
+      stream()->Add("label=\"clear $%i to $%i\", shape=septagon",
+                    that->data_.u_clear_captures.range_from,
+                    that->data_.u_clear_captures.range_to);
+      break;
+    }
    }
    stream()->Add("];\n");
    PrintAttributes(that);
@@ -3592,9 +3658,13 @@
    if (max == 0) return on_success;  // This can happen due to recursion.
    bool body_can_be_empty = (body->min_match() == 0);
    int body_start_reg = RegExpCompiler::kNoRegister;
+  Interval capture_registers = body->CaptureRegisters();
+  bool needs_capture_clearing = !capture_registers.is_empty();
    if (body_can_be_empty) {
      body_start_reg = compiler->AllocateRegister();
-  } else {
+  } else if (!needs_capture_clearing) {
+    // Only unroll if there are no captures and the body can't be
+    // empty.
      if (min > 0 && min <= kMaxUnrolledMinMatches) {
        int new_max = (max == kInfinity) ? max : max - min;
        // Recurse once to get the loop or optional matches after the fixed  
ones.
@@ -3651,6 +3721,10 @@
      // If the body can be empty we need to store the start position
      // so we can bail out if it was empty.
      body_node = ActionNode::StorePosition(body_start_reg, body_node);
+  }
+  if (needs_capture_clearing) {
+    // Before entering the body of this loop we need to clear captures.
+    body_node = ActionNode::ClearCaptures(capture_registers, body_node);
    }
    GuardedAlternative body_alt(body_node);
    if (has_max) {

Modified: branches/bleeding_edge/src/jsregexp.h
==============================================================================
--- branches/bleeding_edge/src/jsregexp.h       (original)
+++ branches/bleeding_edge/src/jsregexp.h       Wed Jan 14 03:32:23 2009
@@ -664,6 +664,33 @@
  };


+// A simple closed interval.
+class Interval {
+ public:
+  Interval() : from_(kNone), to_(kNone) { }
+  Interval(int from, int to) : from_(from), to_(to) { }
+  Interval Union(Interval that) {
+    if (that.from_ == kNone)
+      return *this;
+    else if (from_ == kNone)
+      return that;
+    else
+      return Interval(Min(from_, that.from_), Max(to_, that.to_));
+  }
+  bool Contains(int value) {
+    return (from_ <= value) && (value <= to_);
+  }
+  bool is_empty() { return from_ == kNone; }
+  int from() { return from_; }
+  int to() { return to_; }
+  static Interval Empty() { return Interval(); }
+  static const int kNone = -1;
+ private:
+  int from_;
+  int to_;
+};
+
+
  class SeqRegExpNode: public RegExpNode {
   public:
    explicit SeqRegExpNode(RegExpNode* on_success)
@@ -683,24 +710,23 @@
      STORE_POSITION,
      BEGIN_SUBMATCH,
      POSITIVE_SUBMATCH_SUCCESS,
-    EMPTY_MATCH_CHECK
+    EMPTY_MATCH_CHECK,
+    CLEAR_CAPTURES
    };
    static ActionNode* SetRegister(int reg, int val, RegExpNode* on_success);
    static ActionNode* IncrementRegister(int reg, RegExpNode* on_success);
    static ActionNode* StorePosition(int reg, RegExpNode* on_success);
-  static ActionNode* BeginSubmatch(
-      int stack_pointer_reg,
-      int position_reg,
-      RegExpNode* on_success);
-  static ActionNode* PositiveSubmatchSuccess(
-      int stack_pointer_reg,
-      int restore_reg,
-      RegExpNode* on_success);
-  static ActionNode* EmptyMatchCheck(
-      int start_register,
-      int repetition_register,
-      int repetition_limit,
-      RegExpNode* on_success);
+  static ActionNode* ClearCaptures(Interval range, RegExpNode* on_success);
+  static ActionNode* BeginSubmatch(int stack_pointer_reg,
+                                   int position_reg,
+                                   RegExpNode* on_success);
+  static ActionNode* PositiveSubmatchSuccess(int stack_pointer_reg,
+                                             int restore_reg,
+                                             RegExpNode* on_success);
+  static ActionNode* EmptyMatchCheck(int start_register,
+                                     int repetition_register,
+                                     int repetition_limit,
+                                     RegExpNode* on_success);
    virtual void Accept(NodeVisitor* visitor);
    virtual bool Emit(RegExpCompiler* compiler, GenerationVariant* variant);
    virtual int EatsAtLeast(int recursion_depth);
@@ -736,6 +762,10 @@
        int repetition_register;
        int repetition_limit;
      } u_empty_match_check;
+    struct {
+      int range_from;
+      int range_to;
+    } u_clear_captures;
    } data_;
    ActionNode(Type type, RegExpNode* on_success)
        : SeqRegExpNode(on_success),
@@ -980,6 +1010,7 @@
      DeferredAction(ActionNode::Type type, int reg)
          : type_(type), reg_(reg), next_(NULL) { }
      DeferredAction* next() { return next_; }
+    bool Mentions(int reg);
      int reg() { return reg_; }
      ActionNode::Type type() { return type_; }
     private:
@@ -1008,6 +1039,16 @@
      int value() { return value_; }
     private:
      int value_;
+  };
+
+  class DeferredClearCaptures : public DeferredAction {
+   public:
+    explicit DeferredClearCaptures(Interval range)
+        : DeferredAction(ActionNode::CLEAR_CAPTURES, -1),
+          range_(range) { }
+    Interval range() { return range_; }
+   private:
+    Interval range_;
    };

    class DeferredIncrementRegister: public DeferredAction {

Modified: branches/bleeding_edge/src/regexp-macro-assembler-ia32.cc
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-ia32.cc   (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-ia32.cc   Wed Jan 14  
03:32:23 2009
@@ -608,6 +608,7 @@
    __ push(esi);
    __ push(edi);
    __ push(ebx);  // Callee-save on MacOS.
+  __ push(Immediate(0));  // Make room for input start minus one

    // Check if we have space on the stack for registers.
    Label retry_stack_check;
@@ -669,6 +670,9 @@
      // Set eax to address of char before start of input
      // (effectively string position -1).
      __ lea(eax, Operand(edi, -char_size()));
+    // Store this value in a local variable, for use when clearing
+    // position registers.
+    __ mov(Operand(ebp, kInputStartMinusOne), eax);
      Label init_loop;
      __ bind(&init_loop);
      __ mov(Operand(ebp, ecx, times_1, +0), eax);
@@ -925,6 +929,12 @@
      __ lea(eax, Operand(edi, cp_offset * char_size()));
      __ mov(register_location(reg), eax);
    }
+}
+
+
+void RegExpMacroAssemblerIA32::ClearRegister(int reg) {
+  __ mov(eax, Operand(ebp, kInputStartMinusOne));
+  __ mov(register_location(reg), eax);
  }



Modified: branches/bleeding_edge/src/regexp-macro-assembler-ia32.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-ia32.h    (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-ia32.h    Wed Jan 14  
03:32:23 2009
@@ -106,6 +106,7 @@
    virtual void SetRegister(int register_index, int to);
    virtual void Succeed();
    virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
+  virtual void ClearRegister(int reg);
    virtual void WriteStackPointerToRegister(int reg);

    static Result Execute(Code* code,
@@ -127,11 +128,14 @@
    static const int kAtStart = kRegisterOutput + kPointerSize;
    static const int kStackHighEnd = kAtStart + kPointerSize;
    // Below the frame pointer - local stack variables.
+  // When adding local variables remember to push space for them in
+  // the frame in GetCode.
    static const int kBackup_esi = kFramePointer - kPointerSize;
    static const int kBackup_edi = kBackup_esi - kPointerSize;
    static const int kBackup_ebx = kBackup_edi - kPointerSize;
+  static const int kInputStartMinusOne = kBackup_ebx - kPointerSize;
    // First register address. Following registers are below it on the stack.
-  static const int kRegisterZero = kBackup_ebx - kPointerSize;
+  static const int kRegisterZero = kInputStartMinusOne - kPointerSize;

    // Initial size of code buffer.
    static const size_t kRegExpCodeSize = 1024;

Modified: branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc       
(original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-irregexp.cc       Wed Jan 
 
14 03:32:23 2009
@@ -107,6 +107,11 @@
  }


+void RegExpMacroAssemblerIrregexp::ClearRegister(int reg) {
+  SetRegister(reg, -1);
+}
+
+
  void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
      int register_index) {
    ASSERT(register_index >= 0);

Modified: branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h        
(original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-irregexp.h        Wed Jan 
14  
03:32:23 2009
@@ -66,6 +66,7 @@
    virtual void AdvanceRegister(int reg, int by);  // r[reg] += by.
    virtual void SetRegister(int register_index, int to);
    virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
+  virtual void ClearRegister(int reg);
    virtual void ReadCurrentPositionFromRegister(int reg);
    virtual void WriteStackPointerToRegister(int reg);
    virtual void ReadStackPointerFromRegister(int reg);

Modified: branches/bleeding_edge/src/regexp-macro-assembler-tracer.cc
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-tracer.cc (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-tracer.cc Wed Jan 14  
03:32:23 2009
@@ -150,6 +150,12 @@
  }


+void RegExpMacroAssemblerTracer::ClearRegister(int reg) {
+  PrintF(" ClearRegister(register=%d);\n", reg);
+  assembler_->ClearRegister(reg);
+}
+
+
  void RegExpMacroAssemblerTracer::ReadCurrentPositionFromRegister(int reg) {
    PrintF(" ReadCurrentPositionFromRegister(register=%d);\n", reg);
    assembler_->ReadCurrentPositionFromRegister(reg);

Modified: branches/bleeding_edge/src/regexp-macro-assembler-tracer.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler-tracer.h  (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler-tracer.h  Wed Jan 14  
03:32:23 2009
@@ -106,6 +106,7 @@
    virtual void SetRegister(int register_index, int to);
    virtual void Succeed();
    virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
+  virtual void ClearRegister(int reg);
    virtual void WriteStackPointerToRegister(int reg);
   private:
    RegExpMacroAssembler* assembler_;

Modified: branches/bleeding_edge/src/regexp-macro-assembler.h
==============================================================================
--- branches/bleeding_edge/src/regexp-macro-assembler.h (original)
+++ branches/bleeding_edge/src/regexp-macro-assembler.h Wed Jan 14 03:32:23  
2009
@@ -167,6 +167,7 @@
    virtual void SetRegister(int register_index, int to) = 0;
    virtual void Succeed() = 0;
    virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0;
+  virtual void ClearRegister(int reg) = 0;
    virtual void WriteStackPointerToRegister(int reg) = 0;

   private:

Modified: branches/bleeding_edge/test/cctest/test-regexp.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-regexp.cc   (original)
+++ branches/bleeding_edge/test/cctest/test-regexp.cc   Wed Jan 14 03:32:23  
2009
@@ -1548,5 +1548,5 @@

  TEST(Graph) {
    V8::Initialize(NULL);
-  Execute("(?:a|)*", false, true, true);
+  Execute("(?:(?:x(.))?\1)+$", false, true, true);
  }

Added: branches/bleeding_edge/test/mjsunit/bugs/bug-187.js
==============================================================================
--- (empty file)
+++ branches/bleeding_edge/test/mjsunit/bugs/bug-187.js Wed Jan 14 03:32:23  
2009
@@ -0,0 +1,30 @@
+// Copyright 2008 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// See http://code.google.com/p/v8/issues/detail?id=187
+
+assertEquals("f,", "foo".match(/(?:(?=(f)o)fx|)./));

Modified: branches/bleeding_edge/test/mjsunit/mjsunit.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/mjsunit.js      (original)
+++ branches/bleeding_edge/test/mjsunit/mjsunit.js      Wed Jan 14 03:32:23 2009
@@ -51,8 +51,32 @@
  }


+function deepEquals(a, b) {
+  if (a == b) return true;
+  if ((typeof a) !== 'object' || (typeof b) !== 'object' ||
+      (a === null) || (b === null))
+    return false;
+  if (a.constructor === Array) {
+    if (b.constructor !== Array)
+      return false;
+    if (a.length != b.length)
+      return false;
+    for (var i = 0; i < a.length; i++) {
+      if (i in a) {
+        if (!(i in b) || !(deepEquals(a[i], b[i])))
+          return false;
+      } else if (i in b) {
+        return false;
+      }
+    }
+    return true;
+  }
+  return false;
+}
+
+
  function assertEquals(expected, found, name_opt) {
-  if (expected != found) {
+  if (!deepEquals(found, expected)) {
      fail(expected, found, name_opt);
    }
  }

Modified: branches/bleeding_edge/test/mjsunit/mjsunit.status
==============================================================================
--- branches/bleeding_edge/test/mjsunit/mjsunit.status  (original)
+++ branches/bleeding_edge/test/mjsunit/mjsunit.status  Wed Jan 14 03:32:23  
2009
@@ -38,6 +38,10 @@
  # no longer using JSCRE.
  regexp-UC16: PASS || FAIL

+# These tests pass with irregexp but fail with jscre
+regress/regress-176: PASS || FAIL
+regexp-loop-capture: PASS || FAIL
+
  [ $arch == arm ]

  # Slow tests which times out in debug mode.

Added: branches/bleeding_edge/test/mjsunit/regexp-loop-capture.js
==============================================================================
--- (empty file)
+++ branches/bleeding_edge/test/mjsunit/regexp-loop-capture.js  Wed Jan 14  
03:32:23 2009
@@ -0,0 +1,29 @@
+// Copyright 2009 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+assertEquals(["abc",undefined,undefined,"c"], /(?:(a)|(b)| 
(c))+/.exec("abc"));
+assertEquals(["ab",undefined], /(?:(a)|b)*/.exec("ab"));

Copied: branches/bleeding_edge/test/mjsunit/regress/regress-176.js (from  
r1069, /branches/bleeding_edge/test/mjsunit/bugs/bug-176.js)
==============================================================================

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

Reply via email to