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

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

Issue 1815333002: Simpler regex names: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 9 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
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_assembler_bytecode.h » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 "vm/regexp.h" 5 #include "vm/regexp.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/regexp_assembler.h" 8 #include "vm/regexp_assembler.h"
9 #include "vm/regexp_assembler_bytecode.h" 9 #include "vm/regexp_assembler_bytecode.h"
10 #include "vm/regexp_assembler_ir.h" 10 #include "vm/regexp_assembler_ir.h"
(...skipping 5000 matching lines...) Expand 10 before | Expand all | Expand 10 after
5011 RegExpCompileData* data, 5011 RegExpCompileData* data,
5012 const ParsedFunction* parsed_function, 5012 const ParsedFunction* parsed_function,
5013 const ZoneGrowableArray<const ICData*>& ic_data_array) { 5013 const ZoneGrowableArray<const ICData*>& ic_data_array) {
5014 ASSERT(!FLAG_interpret_irregexp); 5014 ASSERT(!FLAG_interpret_irregexp);
5015 Zone* zone = Thread::Current()->zone(); 5015 Zone* zone = Thread::Current()->zone();
5016 5016
5017 const Function& function = parsed_function->function(); 5017 const Function& function = parsed_function->function();
5018 const intptr_t specialization_cid = function.string_specialization_cid(); 5018 const intptr_t specialization_cid = function.string_specialization_cid();
5019 const bool is_one_byte = (specialization_cid == kOneByteStringCid || 5019 const bool is_one_byte = (specialization_cid == kOneByteStringCid ||
5020 specialization_cid == kExternalOneByteStringCid); 5020 specialization_cid == kExternalOneByteStringCid);
5021 JSRegExp& regexp = JSRegExp::Handle(zone, function.regexp()); 5021 RegExp& regexp = RegExp::Handle(zone, function.regexp());
5022 const String& pattern = String::Handle(zone, regexp.pattern()); 5022 const String& pattern = String::Handle(zone, regexp.pattern());
5023 5023
5024 ASSERT(!regexp.IsNull()); 5024 ASSERT(!regexp.IsNull());
5025 ASSERT(!pattern.IsNull()); 5025 ASSERT(!pattern.IsNull());
5026 5026
5027 const bool ignore_case = regexp.is_ignore_case(); 5027 const bool ignore_case = regexp.is_ignore_case();
5028 const bool is_global = regexp.is_global(); 5028 const bool is_global = regexp.is_global();
5029 5029
5030 RegExpCompiler compiler(data->capture_count, ignore_case, is_one_byte); 5030 RegExpCompiler compiler(data->capture_count, ignore_case, is_one_byte);
5031 5031
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
5125 if (FLAG_trace_irregexp) { 5125 if (FLAG_trace_irregexp) {
5126 macro_assembler->PrintBlocks(); 5126 macro_assembler->PrintBlocks();
5127 } 5127 }
5128 5128
5129 return result; 5129 return result;
5130 } 5130 }
5131 5131
5132 5132
5133 RegExpEngine::CompilationResult RegExpEngine::CompileBytecode( 5133 RegExpEngine::CompilationResult RegExpEngine::CompileBytecode(
5134 RegExpCompileData* data, 5134 RegExpCompileData* data,
5135 const JSRegExp& regexp, 5135 const RegExp& regexp,
5136 bool is_one_byte, 5136 bool is_one_byte,
5137 Zone* zone) { 5137 Zone* zone) {
5138 ASSERT(FLAG_interpret_irregexp); 5138 ASSERT(FLAG_interpret_irregexp);
5139 const String& pattern = String::Handle(zone, regexp.pattern()); 5139 const String& pattern = String::Handle(zone, regexp.pattern());
5140 5140
5141 ASSERT(!regexp.IsNull()); 5141 ASSERT(!regexp.IsNull());
5142 ASSERT(!pattern.IsNull()); 5142 ASSERT(!pattern.IsNull());
5143 5143
5144 const bool ignore_case = regexp.is_ignore_case(); 5144 const bool ignore_case = regexp.is_ignore_case();
5145 const bool is_global = regexp.is_global(); 5145 const bool is_global = regexp.is_global();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5238 5238
5239 if (FLAG_trace_irregexp) { 5239 if (FLAG_trace_irregexp) {
5240 macro_assembler->PrintBlocks(); 5240 macro_assembler->PrintBlocks();
5241 } 5241 }
5242 5242
5243 return result; 5243 return result;
5244 } 5244 }
5245 5245
5246 5246
5247 static void CreateSpecializedFunction(Zone* zone, 5247 static void CreateSpecializedFunction(Zone* zone,
5248 const JSRegExp& regexp, 5248 const RegExp& regexp,
5249 intptr_t specialization_cid, 5249 intptr_t specialization_cid,
5250 const Object& owner) { 5250 const Object& owner) {
5251 const intptr_t kParamCount = RegExpMacroAssembler::kParamCount; 5251 const intptr_t kParamCount = RegExpMacroAssembler::kParamCount;
5252 5252
5253 Function& fn = Function::Handle(zone, Function::New( 5253 Function& fn = Function::Handle(zone, Function::New(
5254 // Append the regexp pattern to the function name. 5254 // Append the regexp pattern to the function name.
5255 String::Handle(zone, Symbols::New( 5255 String::Handle(zone, Symbols::New(
5256 String::Handle(zone, String::Concat( 5256 String::Handle(zone, String::Concat(
5257 String::Handle(zone, String::Concat( 5257 String::Handle(zone, String::Concat(
5258 Symbols::Irregexp(), 5258 Symbols::ColonMatcher(),
5259 Symbols::ColonSpace(), Heap::kOld)), 5259 Symbols::ColonSpace(), Heap::kOld)),
5260 String::Handle(regexp.pattern()), Heap::kOld)))), 5260 String::Handle(regexp.pattern()), Heap::kOld)))),
5261 RawFunction::kIrregexpFunction, 5261 RawFunction::kIrregexpFunction,
5262 true, // Static. 5262 true, // Static.
5263 false, // Not const. 5263 false, // Not const.
5264 false, // Not abstract. 5264 false, // Not abstract.
5265 false, // Not external. 5265 false, // Not external.
5266 false, // Not native. 5266 false, // Not native.
5267 owner, 5267 owner,
5268 TokenPosition::kMinSource)); 5268 TokenPosition::kMinSource));
(...skipping 21 matching lines...) Expand all
5290 // Cache the result. 5290 // Cache the result.
5291 regexp.set_function(specialization_cid, fn); 5291 regexp.set_function(specialization_cid, fn);
5292 5292
5293 fn.SetRegExpData(regexp, specialization_cid); 5293 fn.SetRegExpData(regexp, specialization_cid);
5294 fn.set_is_debuggable(false); 5294 fn.set_is_debuggable(false);
5295 5295
5296 // The function is compiled lazily during the first call. 5296 // The function is compiled lazily during the first call.
5297 } 5297 }
5298 5298
5299 5299
5300 RawJSRegExp* RegExpEngine::CreateJSRegExp(Zone* zone, 5300 RawRegExp* RegExpEngine::CreateRegExp(Zone* zone,
5301 const String& pattern, 5301 const String& pattern,
5302 bool multi_line, 5302 bool multi_line,
5303 bool ignore_case) { 5303 bool ignore_case) {
5304 const JSRegExp& regexp = JSRegExp::Handle(JSRegExp::New()); 5304 const RegExp& regexp = RegExp::Handle(RegExp::New());
5305 5305
5306 regexp.set_pattern(pattern); 5306 regexp.set_pattern(pattern);
5307 5307
5308 if (multi_line) { 5308 if (multi_line) {
5309 regexp.set_is_multi_line(); 5309 regexp.set_is_multi_line();
5310 } 5310 }
5311 if (ignore_case) { 5311 if (ignore_case) {
5312 regexp.set_is_ignore_case(); 5312 regexp.set_is_ignore_case();
5313 } 5313 }
5314 5314
(...skipping 11 matching lines...) Expand all
5326 CreateSpecializedFunction(zone, regexp, kTwoByteStringCid, owner); 5326 CreateSpecializedFunction(zone, regexp, kTwoByteStringCid, owner);
5327 CreateSpecializedFunction(zone, regexp, kExternalOneByteStringCid, owner); 5327 CreateSpecializedFunction(zone, regexp, kExternalOneByteStringCid, owner);
5328 CreateSpecializedFunction(zone, regexp, kExternalTwoByteStringCid, owner); 5328 CreateSpecializedFunction(zone, regexp, kExternalTwoByteStringCid, owner);
5329 } 5329 }
5330 5330
5331 return regexp.raw(); 5331 return regexp.raw();
5332 } 5332 }
5333 5333
5334 5334
5335 } // namespace dart 5335 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_assembler_bytecode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698