Revision: 11281
Author:   [email protected]
Date:     Thu Apr 12 00:45:25 2012
Log: Port regexp microoptimizations to MIPS. Also fix some formatting. This includes http://codereview.chromium.org/9965107/ from Daniel Kalmar
http://code.google.com/p/v8/source/detail?r=11281

Modified:
 /branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.cc

=======================================
--- /branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.cc Mon Apr 2 06:26:05 2012 +++ /branches/bleeding_edge/src/mips/regexp-macro-assembler-mips.cc Thu Apr 12 00:45:25 2012
@@ -158,7 +158,7 @@
 void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) {
   if (by != 0) {
     __ Addu(current_input_offset(),
-           current_input_offset(), Operand(by * char_size()));
+            current_input_offset(), Operand(by * char_size()));
   }
 }

@@ -229,9 +229,9 @@


 void RegExpMacroAssemblerMIPS::CheckCharacters(Vector<const uc16> str,
-                                              int cp_offset,
-                                              Label* on_failure,
-                                              bool check_end_of_string) {
+                                               int cp_offset,
+                                               Label* on_failure,
+                                               bool check_end_of_string) {
   if (on_failure == NULL) {
     // Instead of inlining a backtrack for each test, (re)use the global
     // backtrack target.
@@ -452,24 +452,26 @@


 void RegExpMacroAssemblerMIPS::CheckNotCharacter(uint32_t c,
-                                                Label* on_not_equal) {
+                                                 Label* on_not_equal) {
   BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c));
 }


 void RegExpMacroAssemblerMIPS::CheckCharacterAfterAnd(uint32_t c,
-                                                     uint32_t mask,
-                                                     Label* on_equal) {
+                                                      uint32_t mask,
+                                                      Label* on_equal) {
   __ And(a0, current_character(), Operand(mask));
-  BranchOrBacktrack(on_equal, eq, a0, Operand(c));
+  Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c);
+  BranchOrBacktrack(on_equal, eq, a0, rhs);
 }


 void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterAnd(uint32_t c,
-                                                        uint32_t mask,
- Label* on_not_equal) {
+                                                         uint32_t mask,
+ Label* on_not_equal) {
   __ And(a0, current_character(), Operand(mask));
-  BranchOrBacktrack(on_not_equal, ne, a0, Operand(c));
+  Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c);
+  BranchOrBacktrack(on_not_equal, ne, a0, rhs);
 }


@@ -519,7 +521,7 @@


 bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
- Label* on_no_match) { + Label* on_no_match) {
   // Range checks (c in min..max) are generally implemented by an unsigned
   // (c - min) <= (max - min) check.
   switch (type) {
@@ -884,23 +886,23 @@


 void RegExpMacroAssemblerMIPS::IfRegisterGE(int reg,
-                                           int comparand,
-                                           Label* if_ge) {
+                                            int comparand,
+                                            Label* if_ge) {
   __ lw(a0, register_location(reg));
     BranchOrBacktrack(if_ge, ge, a0, Operand(comparand));
 }


 void RegExpMacroAssemblerMIPS::IfRegisterLT(int reg,
-                                           int comparand,
-                                           Label* if_lt) {
+                                            int comparand,
+                                            Label* if_lt) {
   __ lw(a0, register_location(reg));
   BranchOrBacktrack(if_lt, lt, a0, Operand(comparand));
 }


 void RegExpMacroAssemblerMIPS::IfRegisterEqPos(int reg,
-                                              Label* if_eq) {
+                                               Label* if_eq) {
   __ lw(a0, register_location(reg));
   BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset()));
 }
@@ -913,9 +915,9 @@


 void RegExpMacroAssemblerMIPS::LoadCurrentCharacter(int cp_offset,
-                                                   Label* on_end_of_input,
-                                                   bool check_bounds,
-                                                   int characters) {
+                                                    Label* on_end_of_input,
+                                                    bool check_bounds,
+                                                    int characters) {
   ASSERT(cp_offset >= -1);      // ^ and \b can look behind one character.
   ASSERT(cp_offset < (1<<30));  // Be sane! (And ensure negation works).
   if (check_bounds) {
@@ -966,7 +968,7 @@


 void RegExpMacroAssemblerMIPS::PushRegister(int register_index,
- StackCheckFlag check_stack_limit) { + StackCheckFlag check_stack_limit) {
   __ lw(a0, register_location(register_index));
   Push(a0);
   if (check_stack_limit) CheckStackLimit();
@@ -1013,7 +1015,7 @@


 void RegExpMacroAssemblerMIPS::WriteCurrentPositionToRegister(int reg,
- int cp_offset) { + int cp_offset) {
   if (cp_offset == 0) {
     __ sw(current_input_offset(), register_location(reg));
   } else {
@@ -1170,7 +1172,7 @@


 void RegExpMacroAssemblerMIPS::CheckPosition(int cp_offset,
-                                            Label* on_outside_input) {
+                                             Label* on_outside_input) {
   BranchOrBacktrack(on_outside_input,
                     ge,
                     current_input_offset(),
@@ -1198,8 +1200,10 @@
 }


-void RegExpMacroAssemblerMIPS::SafeCall(Label* to, Condition cond, Register rs,
-                                           const Operand& rt) {
+void RegExpMacroAssemblerMIPS::SafeCall(Label* to,
+                                        Condition cond,
+                                        Register rs,
+                                        const Operand& rt) {
   __ BranchAndLink(to, cond, rs, rt);
 }

@@ -1270,7 +1274,7 @@


 void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
- int characters) { + int characters) {
   Register offset = current_input_offset();
   if (cp_offset != 0) {
     __ Addu(a0, current_input_offset(), Operand(cp_offset * char_size()));

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

Reply via email to