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

Side by Side Diff: runtime/lib/regexp.cc

Issue 1071713003: - Remove JSCRE from the runtime. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "vm/thread.h"
12 12
13 #include "lib/regexp_jsc.h"
14
15 namespace dart { 13 namespace dart {
16 14
17 DECLARE_FLAG(bool, trace_irregexp); 15 DECLARE_FLAG(bool, trace_irregexp);
18 DEFINE_FLAG(bool, use_jscre, false, "Use the JSCRE regular expression engine");
19 16
20 17
21 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) { 18 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_factory, 4) {
22 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); 19 ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull());
23 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1)); 20 GET_NON_NULL_NATIVE_ARGUMENT(String, pattern, arguments->NativeArgAt(1));
24 GET_NON_NULL_NATIVE_ARGUMENT( 21 GET_NON_NULL_NATIVE_ARGUMENT(
25 Instance, handle_multi_line, arguments->NativeArgAt(2)); 22 Instance, handle_multi_line, arguments->NativeArgAt(2));
26 GET_NON_NULL_NATIVE_ARGUMENT( 23 GET_NON_NULL_NATIVE_ARGUMENT(
27 Instance, handle_case_sensitive, arguments->NativeArgAt(3)); 24 Instance, handle_case_sensitive, arguments->NativeArgAt(3));
28 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw(); 25 bool ignore_case = handle_case_sensitive.raw() != Bool::True().raw();
29 bool multi_line = handle_multi_line.raw() == Bool::True().raw(); 26 bool multi_line = handle_multi_line.raw() == Bool::True().raw();
30 27
31 if (FLAG_use_jscre) {
32 return Jscre::Compile(pattern, multi_line, ignore_case);
33 }
34 // Parse the pattern once in order to throw any format exceptions within 28 // Parse the pattern once in order to throw any format exceptions within
35 // the factory constructor. It is parsed again upon compilation. 29 // the factory constructor. It is parsed again upon compilation.
36 RegExpCompileData compileData; 30 RegExpCompileData compileData;
37 if (!RegExpParser::ParseRegExp(pattern, multi_line, &compileData)) { 31 if (!RegExpParser::ParseRegExp(pattern, multi_line, &compileData)) {
38 // Parsing failures throw an exception. 32 // Parsing failures throw an exception.
39 UNREACHABLE(); 33 UNREACHABLE();
40 } 34 }
41 35
42 // Create a JSRegExp object containing only the initial parameters. 36 // Create a JSRegExp object containing only the initial parameters.
43 return RegExpEngine::CreateJSRegExp(zone, 37 return RegExpEngine::CreateJSRegExp(zone,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return Object::null(); 78 return Object::null();
85 } 79 }
86 80
87 81
88 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) { 82 DEFINE_NATIVE_ENTRY(JSSyntaxRegExp_ExecuteMatch, 3) {
89 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0)); 83 const JSRegExp& regexp = JSRegExp::CheckedHandle(arguments->NativeArgAt(0));
90 ASSERT(!regexp.IsNull()); 84 ASSERT(!regexp.IsNull());
91 GET_NON_NULL_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1)); 85 GET_NON_NULL_NATIVE_ARGUMENT(String, str, arguments->NativeArgAt(1));
92 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2)); 86 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2));
93 87
94 if (FLAG_use_jscre) {
95 return Jscre::Execute(regexp, str, start_index.Value());
96 }
97
98 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch. 88 // This function is intrinsified. See Intrinsifier::JSRegExp_ExecuteMatch.
99 const intptr_t cid = str.GetClassId(); 89 const intptr_t cid = str.GetClassId();
100 90
101 // Retrieve the cached function. 91 // Retrieve the cached function.
102 const Function& fn = Function::Handle(regexp.function(cid)); 92 const Function& fn = Function::Handle(regexp.function(cid));
103 ASSERT(!fn.IsNull()); 93 ASSERT(!fn.IsNull());
104 94
105 // And finally call the generated code. 95 // And finally call the generated code.
106 return IRRegExpMacroAssembler::Execute(fn, str, start_index, zone); 96 return IRRegExpMacroAssembler::Execute(fn, str, start_index, zone);
107 } 97 }
108 98
109 } // namespace dart 99 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/core_sources.gypi ('k') | runtime/lib/regexp_jsc.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698