Commit 5178af89 authored by lrn@chromium.org's avatar lrn@chromium.org

Irregexp is specialized on subject character type.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@937 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c023ec3a
This diff is collapsed.
......@@ -48,6 +48,9 @@ class RegExpImpl {
// This function calls the garbage collector if necessary.
static Handle<String> ToString(Handle<Object> value);
// Parses the RegExp pattern and prepares the JSRegExp object with
// generic data and choice of implementation - as well as what
// the implementation wants to store in the data field.
static Handle<Object> Compile(Handle<JSRegExp> re,
Handle<String> pattern,
Handle<String> flags);
......@@ -71,12 +74,10 @@ class RegExpImpl {
Handle<String> pattern,
JSRegExp::Flags flags);
// Stores a compiled RegExp pattern in the JSRegExp object.
// The pattern is compiled by Irregexp.
// Prepares a JSRegExp object with Irregexp-specific data.
static Handle<Object> IrregexpPrepare(Handle<JSRegExp> re,
Handle<String> pattern,
JSRegExp::Flags flags,
Handle<FixedArray> irregexp_data);
JSRegExp::Flags flags);
// Compile the pattern using JSCRE and store the result in the
......@@ -140,9 +141,10 @@ class RegExpImpl {
static int JscreNumberOfCaptures(Handle<JSRegExp> re);
static ByteArray* JscreInternal(Handle<JSRegExp> re);
static int IrregexpNumberOfCaptures(Handle<JSRegExp> re);
static int IrregexpNumberOfRegisters(Handle<JSRegExp> re);
static Handle<ByteArray> IrregexpCode(Handle<JSRegExp> re);
static int IrregexpNumberOfCaptures(Handle<FixedArray> re);
static int IrregexpNumberOfRegisters(Handle<FixedArray> re);
static Handle<ByteArray> IrregexpByteCode(Handle<FixedArray> re);
static Handle<Code> IrregexpNativeCode(Handle<FixedArray> re);
// Call jsRegExpExecute once
static Handle<Object> JscreExecOnce(Handle<JSRegExp> regexp,
......@@ -153,7 +155,7 @@ class RegExpImpl {
int* ovector,
int ovector_length);
static Handle<Object> IrregexpExecOnce(Handle<JSRegExp> regexp,
static Handle<Object> IrregexpExecOnce(Handle<FixedArray> regexp,
int num_captures,
Handle<String> subject16,
int previous_index,
......@@ -1082,7 +1084,9 @@ class RegExpEngine: public AllStatic {
RegExpNode** node_return,
bool ignore_case,
bool multiline,
Handle<String> pattern);
Handle<String> pattern,
bool is_ascii);
static void DotPrint(const char* label, RegExpNode* node, bool ignore_case);
};
......
......@@ -2924,7 +2924,7 @@ class JSRegExp: public JSObject {
// ATOM: A simple string to match against using an indexOf operation.
// IRREGEXP: Compiled with Irregexp.
// IRREGEXP_NATIVE: Compiled to native code with Irregexp.
enum Type { NOT_COMPILED, JSCRE, ATOM, IRREGEXP, IRREGEXP_NATIVE };
enum Type { NOT_COMPILED, JSCRE, ATOM, IRREGEXP };
enum Flag { NONE = 0, GLOBAL = 1, IGNORE_CASE = 2, MULTILINE = 4 };
class Flags {
......
......@@ -111,9 +111,10 @@ RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() {
void RegExpMacroAssemblerIA32::AdvanceCurrentPosition(int by) {
ASSERT(by > 0);
Label inside_string;
__ add(Operand(edi), Immediate(by * char_size()));
if (by != 0) {
Label inside_string;
__ add(Operand(edi), Immediate(by * char_size()));
}
}
......@@ -138,7 +139,7 @@ void RegExpMacroAssemblerIA32::Bind(Label* label) {
void RegExpMacroAssemblerIA32::CheckBitmap(uc16 start,
Label* bitmap,
Label* on_zero) {
UNREACHABLE();
UNIMPLEMENTED();
__ mov(eax, current_character());
__ sub(Operand(eax), Immediate(start));
__ cmp(eax, 64); // FIXME: 64 = length_of_bitmap_in_bits.
......@@ -683,6 +684,8 @@ int RegExpMacroAssemblerIA32::CaseInsensitiveCompareUC16(uc16** buffer,
int byte_offset1,
int byte_offset2,
size_t byte_length) {
// This function MUST NOT cause a garbage collection. A GC might move
// the calling generated code and invalidate the stacked return address.
ASSERT(byte_length % 2 == 0);
Address buffer_address = reinterpret_cast<Address>(*buffer);
uc16* substring1 = reinterpret_cast<uc16*>(buffer_address + byte_offset1);
......
......@@ -355,7 +355,7 @@ TEST(CharacterClassEscapes) {
}
static RegExpNode* Compile(const char* input, bool multiline) {
static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) {
V8::Initialize(NULL);
FlatStringReader reader(CStrVector(input));
RegExpParseResult result;
......@@ -363,17 +363,18 @@ static RegExpNode* Compile(const char* input, bool multiline) {
return NULL;
RegExpNode* node = NULL;
Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input));
RegExpEngine::Compile(&result, &node, false, multiline, pattern);
RegExpEngine::Compile(&result, &node, false, multiline, pattern, is_ascii);
return node;
}
static void Execute(const char* input,
bool multiline,
bool is_ascii,
bool dot_output = false) {
v8::HandleScope scope;
ZoneScope zone_scope(DELETE_ON_EXIT);
RegExpNode* node = Compile(input, multiline);
RegExpNode* node = Compile(input, multiline, is_ascii);
USE(node);
#ifdef DEBUG
if (dot_output) {
......@@ -1130,7 +1131,7 @@ TEST(LatinCanonicalize) {
TEST(SimplePropagation) {
v8::HandleScope scope;
ZoneScope zone_scope(DELETE_ON_EXIT);
RegExpNode* node = Compile("(a|^b|c)", false);
RegExpNode* node = Compile("(a|^b|c)", false, true);
CHECK(node->info()->follows_start_interest);
}
......@@ -1300,5 +1301,5 @@ TEST(CharClassDifference) {
TEST(Graph) {
V8::Initialize(NULL);
Execute("(?=[d#.])", false, true);
Execute("(?=[d#.])", false, true, true);
}
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