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

Unified Diff: runtime/lib/regexp.cc

Issue 683433003: Integrate the Irregexp Regular Expression Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 2 months 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 | « no previous file | runtime/lib/regexp_patch.dart » ('j') | runtime/lib/regexp_patch.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | runtime/lib/regexp_patch.dart » ('j') | runtime/lib/regexp_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698