Chromium Code Reviews| Index: runtime/lib/regexp.cc |
| diff --git a/runtime/lib/regexp.cc b/runtime/lib/regexp.cc |
| index 4152923f5419aaf7af939e01c04d2a5b97810fdf..b1b0d64be242ed1b0051870c613796298e29c2fc 100644 |
| --- a/runtime/lib/regexp.cc |
| +++ b/runtime/lib/regexp.cc |
| @@ -7,11 +7,15 @@ |
| #include "vm/exceptions.h" |
| #include "vm/native_entry.h" |
| #include "vm/object.h" |
| +#include "vm/regexp_parser.h" |
| #include "lib/regexp_jsc.h" |
| namespace dart { |
| +DECLARE_FLAG(bool, trace_irregexp); |
| + |
| + |
| DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { |
| ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
| GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); |
| @@ -21,7 +25,24 @@ DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { |
| Instance, handle_case_sensitive, arguments->NativeArgAt(3)); |
| bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); |
| bool multi_line = handle_multi_line.raw() == Bool::True().raw(); |
| + |
| +#if defined(USE_JSCRE) |
|
Ivan Posva
2014/10/31 07:32:37
Let's figure out whether this is even needed.
zerny-google
2014/10/31 11:54:26
Would it be of more value to replace this with a V
|
| return Jscre::Compile(pattern, multi_line, ignore_case); |
| +#else |
| + // Parse the pattern once in order to throw any format exceptions within |
| + // the factory constructor. It is parsed again upon compilation. |
| + RegExpCompileData compileData; |
| + if (!RegExpParser::ParseRegExp(pattern, multi_line, &compileData)) { |
| + // Parsing failures throw an exception. |
| + UNREACHABLE(); |
| + } |
| + |
| + // Create a JSRegExp object containing only the initial parameters. |
| + return RegExpEngine::CreateJSRegExp(isolate, |
| + pattern, |
| + multi_line, |
| + ignore_case); |
| +#endif |
| } |
| @@ -68,7 +89,20 @@ DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { |
| ASSERT(!regexp.IsNull()); |
| GET_NON_NULL_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
| + |
| +#if defined(USE_JSCRE) |
| return Jscre::Execute(regexp, str, start_index.Value()); |
| +#else |
| + // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. |
| + const intptr_t cid = str.GetClassId(); |
| + |
| + // Retrieve the cached function. |
| + const Function& fn = Function::Handle(regexp.function(cid)); |
| + ASSERT(!fn.IsNull()); |
| + |
| + // And finally call the generated code. |
| + return IRRegExpMacroAssembler::Execute(fn, str, start_index, isolate); |
| +#endif |
| } |
| } // namespace dart |