| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/regexp_parser.h" | 10 #include "vm/regexp_parser.h" |
| 11 #include "vm/thread.h" |
| 11 | 12 |
| 12 #include "lib/regexp_jsc.h" | 13 #include "lib/regexp_jsc.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 DECLARE_FLAG(bool, trace_irregexp); | 17 DECLARE_FLAG(bool, trace_irregexp); |
| 17 DEFINE_FLAG(bool, use_jscre, false, "Use the JSCRE regular expression engine"); | 18 DEFINE_FLAG(bool, use_jscre, false, "Use the JSCRE regular expression engine"); |
| 18 | 19 |
| 19 | 20 |
| 20 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { | 21 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 } | 33 } |
| 33 // Parse the pattern once in order to throw any format exceptions within | 34 // Parse the pattern once in order to throw any format exceptions within |
| 34 // the factory constructor. It is parsed again upon compilation. | 35 // the factory constructor. It is parsed again upon compilation. |
| 35 RegExpCompileData compileData; | 36 RegExpCompileData compileData; |
| 36 if (!RegExpParser::ParseRegExp(pattern, multi_line, &compileData)) { | 37 if (!RegExpParser::ParseRegExp(pattern, multi_line, &compileData)) { |
| 37 // Parsing failures throw an exception. | 38 // Parsing failures throw an exception. |
| 38 UNREACHABLE(); | 39 UNREACHABLE(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Create a JSRegExp object containing only the initial parameters. | 42 // Create a JSRegExp object containing only the initial parameters. |
| 42 return RegExpEngine::CreateJSRegExp(isolate, | 43 return RegExpEngine::CreateJSRegExp(zone, |
| 43 pattern, | 44 pattern, |
| 44 multi_line, | 45 multi_line, |
| 45 ignore_case); | 46 ignore_case); |
| 46 } | 47 } |
| 47 | 48 |
| 48 | 49 |
| 49 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getPattern, 1) { | 50 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_getPattern, 1) { |
| 50 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); | 51 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); |
| 51 ASSERT(!regexp.IsNull()); | 52 ASSERT(!regexp.IsNull()); |
| 52 return regexp.pattern(); | 53 return regexp.pattern(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 96 } |
| 96 | 97 |
| 97 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. | 98 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. |
| 98 const intptr_t cid = str.GetClassId(); | 99 const intptr_t cid = str.GetClassId(); |
| 99 | 100 |
| 100 // Retrieve the cached function. | 101 // Retrieve the cached function. |
| 101 const Function& fn = Function::Handle(regexp.function(cid)); | 102 const Function& fn = Function::Handle(regexp.function(cid)); |
| 102 ASSERT(!fn.IsNull()); | 103 ASSERT(!fn.IsNull()); |
| 103 | 104 |
| 104 // And finally call the generated code. | 105 // And finally call the generated code. |
| 105 return IRRegExpMacroAssembler::Execute(fn, str, start_index, isolate); | 106 return IRRegExpMacroAssembler::Execute(fn, str, start_index, zone); |
| 106 } | 107 } |
| 107 | 108 |
| 108 } // namespace dart | 109 } // namespace dart |
| OLD | NEW |