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