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

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

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)
Patch Set: Done Created 4 years, 1 month 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
« no previous file with comments | « no previous file | runtime/lib/regexp_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const String& errmsg = String::Handle( 71 const String& errmsg = String::Handle(
72 String::New("Regular expression is not initialized yet. ")); 72 String::New("Regular expression is not initialized yet. "));
73 const String& message = String::Handle(String::Concat(errmsg, pattern)); 73 const String& message = String::Handle(String::Concat(errmsg, pattern));
74 const Array& args = Array::Handle(Array::New(1)); 74 const Array& args = Array::Handle(Array::New(1));
75 args.SetAt(0, message); 75 args.SetAt(0, message);
76 Exceptions::ThrowByType(Exceptions::kFormat, args); 76 Exceptions::ThrowByType(Exceptions::kFormat, args);
77 return Object::null(); 77 return Object::null();
78 } 78 }
79 79
80 80
81 static RawObject* ExecuteMatch(Zone* zone,
82 NativeArguments* arguments,
83 bool sticky) {
84 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0));
85 ASSERT(!regexp.IsNull());
86 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1));
87 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2));
88
89 if (FLAG_interpret_irregexp) {
90 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index,
91 /*sticky=*/sticky, zone);
92 }
93
94 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index,
95 /*sticky=*/sticky, zone);
96 }
97
98
81 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) { 99 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatch, 3) {
82 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. 100 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch.
83 const RegExp& regexp = RegExp::CheckedHandle(arguments->NativeArgAt(0)); 101 return ExecuteMatch(zone, arguments, /*sticky=*/false);
84 ASSERT(!regexp.IsNull());
85 GET_NON_NULL_NATIVE_ARGUMENT(String, subject, arguments->NativeArgAt(1));
86 GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_index, arguments->NativeArgAt(2));
87
88 if (FLAG_interpret_irregexp || FLAG_precompiled_runtime) {
89 return BytecodeRegExpMacroAssembler::Interpret(regexp, subject, start_index,
90 zone);
91 }
92
93 return IRRegExpMacroAssembler::Execute(regexp, subject, start_index, zone);
94 } 102 }
95 103
104
105 DEFINE_NATIVE_ENTRY(RegExp_ExecuteMatchSticky, 3) {
106 // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatchSticky.
107 return ExecuteMatch(zone, arguments, /*sticky=*/true);
108 }
109
110
96 } // namespace dart 111 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/regexp_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698