Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Unified Diff: src/interpreter-irregexp.cc

Issue 13247: * Have an ASCII and a UC16 interpreter for Irregexp bytecodes -... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter-irregexp.h ('k') | src/jsregexp.cc » ('j') | src/jsregexp.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter-irregexp.cc
===================================================================
--- src/interpreter-irregexp.cc (revision 939)
+++ src/interpreter-irregexp.cc (working copy)
@@ -60,6 +60,22 @@
}
+static bool BackRefMatchesNoCase(int from,
+ int current,
+ int len,
+ Vector<const char> subject) {
+ for (int i = 0; i < len; i++) {
+ unsigned int old_char = subject[from++];
+ unsigned int new_char = subject[current++];
+ if (old_char == new_char) continue;
+ if (old_char - 'A' <= 'Z' - 'A') old_char |= 0x20;
+ if (new_char - 'A' <= 'Z' - 'A') new_char |= 0x20;
+ if (old_char != new_char) return false;
+ }
+ return true;
+}
+
+
#ifdef DEBUG
static void TraceInterpreter(const byte* code_base,
const byte* pc,
@@ -96,8 +112,9 @@
+template <typename Char>
static bool RawMatch(const byte* code_base,
- Vector<const uc16> subject,
+ Vector<const Char> subject,
int* registers,
int current,
int current_char) {
@@ -405,23 +422,32 @@
bool IrregexpInterpreter::Match(Handle<ByteArray> code_array,
- Handle<String> subject16,
+ Handle<String> subject,
int* registers,
int start_position) {
- ASSERT(StringShape(*subject16).IsTwoByteRepresentation());
- ASSERT(subject16->IsFlat(StringShape(*subject16)));
+ ASSERT(subject->IsFlat(StringShape(*subject)));
AssertNoAllocation a;
const byte* code_base = code_array->GetDataStartAddress();
+ StringShape subject_shape(*subject);
uc16 previous_char = '\n';
- Vector<const uc16> subject_vector =
- Vector<const uc16>(subject16->GetTwoByteData(), subject16->length());
- if (start_position != 0) previous_char = subject_vector[start_position - 1];
- return RawMatch(code_base,
- subject_vector,
- registers,
- start_position,
- previous_char);
+ if (subject_shape.IsAsciiRepresentation()) {
+ Vector<const char> subject_vector = subject->ToAsciiVector();
+ if (start_position != 0) previous_char = subject_vector[start_position - 1];
+ return RawMatch(code_base,
+ subject_vector,
+ registers,
+ start_position,
+ previous_char);
+ } else {
+ Vector<const uc16> subject_vector = subject->ToUC16Vector();
+ if (start_position != 0) previous_char = subject_vector[start_position - 1];
+ return RawMatch(code_base,
+ subject_vector,
+ registers,
+ start_position,
+ previous_char);
+ }
}
} } // namespace v8::internal
« no previous file with comments | « src/interpreter-irregexp.h ('k') | src/jsregexp.cc » ('j') | src/jsregexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698