Index: runtime/lib/regexp.cc |
diff --git a/runtime/lib/regexp.cc b/runtime/lib/regexp.cc |
index 646261628738d6904f277787168a02655548bfbd..4d10f7a2cd450b80c4186b55d7e2b9aa00b01793 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,25 @@ 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) || \ |
+ defined(TARGET_ARCH_MIPS) |
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,25 +92,16 @@ 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()); |
- RegExpEngine::DotPrint(pattern.ToCString(), |
- compileData.node, |
- regexp.is_ignore_case()); |
- } |
- |
+#if defined(USE_JSCRE) || \ |
+ defined(TARGET_ARCH_MIPS) |
return Jscre::Execute(regexp, str, start_index.Value()); |
+#else |
+ // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. |
srdjan
2014/09/22 22:34:07
We occasionally run with --no-intrinsify. Will it
jgruber1
2014/09/23 10:58:46
Good point, I wasn't aware of that flag. Added bac
|
+ UNREACHABLE(); |
+ USE(&str); |
+ USE(&start_index); |
+ return Array::null(); |
+#endif |
} |
} // namespace dart |