Chromium Code Reviews| Index: runtime/lib/regexp.cc |
| diff --git a/runtime/lib/regexp.cc b/runtime/lib/regexp.cc |
| index 964a48850fd09cfc35171ccd0ea0f6ffb49a3207..e6286b28606985a250b635249ea4ac7a93f39319 100644 |
| --- a/runtime/lib/regexp.cc |
| +++ b/runtime/lib/regexp.cc |
| @@ -4,6 +4,7 @@ |
| #include "platform/assert.h" |
| #include "vm/bootstrap_natives.h" |
| +#include "vm/compiler.h" |
| #include "vm/exceptions.h" |
| #include "vm/native_entry.h" |
| #include "vm/object.h" |
| @@ -13,6 +14,9 @@ |
| 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)); |
| @@ -22,7 +26,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) |
| 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. |
| + JSRegExp& regexp = JSRegExp::Handle( |
| + isolate, RegExpEngine::New(isolate, pattern, multi_line, ignore_case)); |
| + |
| + return regexp.raw(); |
| +#endif |
| } |
| @@ -70,27 +91,26 @@ DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { |
| GET_NON_NULL_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); |
| - // The irregexp parser runs alongside the jscre parser while the port is |
| - // still in progress. When done, it will replace jscre completely. |
| - const String& pattern = String::Handle(regexp.pattern()); |
| - RegExpCompileData compileData; |
| - if (RegExpParser::ParseRegExp(pattern, regexp.is_multi_line(), |
| - &compileData)) { |
| - RegExpEngine::Compile(&compileData, |
| - regexp.is_ignore_case(), |
| - regexp.is_global(), // A Dart regexp is always global |
| - regexp.is_multi_line(), |
| - pattern, |
| - str, |
| - str.IsOneByteString()); |
| +#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. |
| + Function& fn = Function::Handle(regexp.function(cid)); |
|
Florian Schneider
2014/10/01 17:04:15
const Function&
jgruber1
2014/10/03 18:59:53
Done.
|
| + ASSERT(!fn.IsNull()); |
| + |
| + if (fn.CurrentCode() == StubCode::LazyCompile_entry()->code()) { |
|
Florian Schneider
2014/10/01 17:04:14
In the instrinc assembly code you check
(sample_s
jgruber1
2014/10/03 18:59:53
Done.
|
| + // Set the sample subject now that we have it. |
| + regexp.set_sample_subject(cid, str); |
| #ifdef DEBUG |
|
Vyacheslav Egorov (Google)
2014/10/01 20:13:21
Empty #ifdef ?
jgruber1
2014/10/03 18:59:53
Done.
|
| - RegExpEngine::DotPrint(pattern.ToCString(), |
| - compileData.node, |
| - regexp.is_ignore_case()); |
| #endif |
| } |
| - return Jscre::Execute(regexp, str, start_index.Value()); |
| + // And finally call the generated code. |
| + return IRRegExpMacroAssembler::Execute(fn, str, start_index, isolate); |
| +#endif |
| } |
| } // namespace dart |