Commit de169b7d authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Port regexp microoptimizations to MIPS. Also fix some formatting. This...

Port regexp microoptimizations to MIPS.  Also fix some formatting.  This includes http://codereview.chromium.org/9965107/ from Daniel Kalmar

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11281 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent bd58fddb
...@@ -158,7 +158,7 @@ int RegExpMacroAssemblerMIPS::stack_limit_slack() { ...@@ -158,7 +158,7 @@ int RegExpMacroAssemblerMIPS::stack_limit_slack() {
void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) { void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) {
if (by != 0) { if (by != 0) {
__ Addu(current_input_offset(), __ Addu(current_input_offset(),
current_input_offset(), Operand(by * char_size())); current_input_offset(), Operand(by * char_size()));
} }
} }
...@@ -229,9 +229,9 @@ void RegExpMacroAssemblerMIPS::CheckCharacterLT(uc16 limit, Label* on_less) { ...@@ -229,9 +229,9 @@ void RegExpMacroAssemblerMIPS::CheckCharacterLT(uc16 limit, Label* on_less) {
void RegExpMacroAssemblerMIPS::CheckCharacters(Vector<const uc16> str, void RegExpMacroAssemblerMIPS::CheckCharacters(Vector<const uc16> str,
int cp_offset, int cp_offset,
Label* on_failure, Label* on_failure,
bool check_end_of_string) { bool check_end_of_string) {
if (on_failure == NULL) { if (on_failure == NULL) {
// Instead of inlining a backtrack for each test, (re)use the global // Instead of inlining a backtrack for each test, (re)use the global
// backtrack target. // backtrack target.
...@@ -452,24 +452,26 @@ void RegExpMacroAssemblerMIPS::CheckNotRegistersEqual(int reg1, ...@@ -452,24 +452,26 @@ void RegExpMacroAssemblerMIPS::CheckNotRegistersEqual(int reg1,
void RegExpMacroAssemblerMIPS::CheckNotCharacter(uint32_t c, void RegExpMacroAssemblerMIPS::CheckNotCharacter(uint32_t c,
Label* on_not_equal) { Label* on_not_equal) {
BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c)); BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c));
} }
void RegExpMacroAssemblerMIPS::CheckCharacterAfterAnd(uint32_t c, void RegExpMacroAssemblerMIPS::CheckCharacterAfterAnd(uint32_t c,
uint32_t mask, uint32_t mask,
Label* on_equal) { Label* on_equal) {
__ And(a0, current_character(), Operand(mask)); __ 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, void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterAnd(uint32_t c,
uint32_t mask, uint32_t mask,
Label* on_not_equal) { Label* on_not_equal) {
__ And(a0, current_character(), Operand(mask)); __ 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 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable( ...@@ -519,7 +521,7 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable(
bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, 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 // Range checks (c in min..max) are generally implemented by an unsigned
// (c - min) <= (max - min) check. // (c - min) <= (max - min) check.
switch (type) { switch (type) {
...@@ -884,23 +886,23 @@ void RegExpMacroAssemblerMIPS::GoTo(Label* to) { ...@@ -884,23 +886,23 @@ void RegExpMacroAssemblerMIPS::GoTo(Label* to) {
void RegExpMacroAssemblerMIPS::IfRegisterGE(int reg, void RegExpMacroAssemblerMIPS::IfRegisterGE(int reg,
int comparand, int comparand,
Label* if_ge) { Label* if_ge) {
__ lw(a0, register_location(reg)); __ lw(a0, register_location(reg));
BranchOrBacktrack(if_ge, ge, a0, Operand(comparand)); BranchOrBacktrack(if_ge, ge, a0, Operand(comparand));
} }
void RegExpMacroAssemblerMIPS::IfRegisterLT(int reg, void RegExpMacroAssemblerMIPS::IfRegisterLT(int reg,
int comparand, int comparand,
Label* if_lt) { Label* if_lt) {
__ lw(a0, register_location(reg)); __ lw(a0, register_location(reg));
BranchOrBacktrack(if_lt, lt, a0, Operand(comparand)); BranchOrBacktrack(if_lt, lt, a0, Operand(comparand));
} }
void RegExpMacroAssemblerMIPS::IfRegisterEqPos(int reg, void RegExpMacroAssemblerMIPS::IfRegisterEqPos(int reg,
Label* if_eq) { Label* if_eq) {
__ lw(a0, register_location(reg)); __ lw(a0, register_location(reg));
BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset())); BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset()));
} }
...@@ -913,9 +915,9 @@ RegExpMacroAssembler::IrregexpImplementation ...@@ -913,9 +915,9 @@ RegExpMacroAssembler::IrregexpImplementation
void RegExpMacroAssemblerMIPS::LoadCurrentCharacter(int cp_offset, void RegExpMacroAssemblerMIPS::LoadCurrentCharacter(int cp_offset,
Label* on_end_of_input, Label* on_end_of_input,
bool check_bounds, bool check_bounds,
int characters) { int characters) {
ASSERT(cp_offset >= -1); // ^ and \b can look behind one character. ASSERT(cp_offset >= -1); // ^ and \b can look behind one character.
ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works). ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works).
if (check_bounds) { if (check_bounds) {
...@@ -966,7 +968,7 @@ void RegExpMacroAssemblerMIPS::PushCurrentPosition() { ...@@ -966,7 +968,7 @@ void RegExpMacroAssemblerMIPS::PushCurrentPosition() {
void RegExpMacroAssemblerMIPS::PushRegister(int register_index, void RegExpMacroAssemblerMIPS::PushRegister(int register_index,
StackCheckFlag check_stack_limit) { StackCheckFlag check_stack_limit) {
__ lw(a0, register_location(register_index)); __ lw(a0, register_location(register_index));
Push(a0); Push(a0);
if (check_stack_limit) CheckStackLimit(); if (check_stack_limit) CheckStackLimit();
...@@ -1013,7 +1015,7 @@ void RegExpMacroAssemblerMIPS::Succeed() { ...@@ -1013,7 +1015,7 @@ void RegExpMacroAssemblerMIPS::Succeed() {
void RegExpMacroAssemblerMIPS::WriteCurrentPositionToRegister(int reg, void RegExpMacroAssemblerMIPS::WriteCurrentPositionToRegister(int reg,
int cp_offset) { int cp_offset) {
if (cp_offset == 0) { if (cp_offset == 0) {
__ sw(current_input_offset(), register_location(reg)); __ sw(current_input_offset(), register_location(reg));
} else { } else {
...@@ -1170,7 +1172,7 @@ MemOperand RegExpMacroAssemblerMIPS::register_location(int register_index) { ...@@ -1170,7 +1172,7 @@ MemOperand RegExpMacroAssemblerMIPS::register_location(int register_index) {
void RegExpMacroAssemblerMIPS::CheckPosition(int cp_offset, void RegExpMacroAssemblerMIPS::CheckPosition(int cp_offset,
Label* on_outside_input) { Label* on_outside_input) {
BranchOrBacktrack(on_outside_input, BranchOrBacktrack(on_outside_input,
ge, ge,
current_input_offset(), current_input_offset(),
...@@ -1198,8 +1200,10 @@ void RegExpMacroAssemblerMIPS::BranchOrBacktrack(Label* to, ...@@ -1198,8 +1200,10 @@ void RegExpMacroAssemblerMIPS::BranchOrBacktrack(Label* to,
} }
void RegExpMacroAssemblerMIPS::SafeCall(Label* to, Condition cond, Register rs, void RegExpMacroAssemblerMIPS::SafeCall(Label* to,
const Operand& rt) { Condition cond,
Register rs,
const Operand& rt) {
__ BranchAndLink(to, cond, rs, rt); __ BranchAndLink(to, cond, rs, rt);
} }
...@@ -1270,7 +1274,7 @@ void RegExpMacroAssemblerMIPS::CallCFunctionUsingStub( ...@@ -1270,7 +1274,7 @@ void RegExpMacroAssemblerMIPS::CallCFunctionUsingStub(
void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) { int characters) {
Register offset = current_input_offset(); Register offset = current_input_offset();
if (cp_offset != 0) { if (cp_offset != 0) {
__ Addu(a0, current_input_offset(), Operand(cp_offset * char_size())); __ Addu(a0, current_input_offset(), Operand(cp_offset * char_size()));
......
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