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

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

Issue 1870343002: - Refactor Symbol allocation to expect a thread parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review feedback. Created 4 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
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_test.cc » ('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 5226 matching lines...) Expand 10 before | Expand all | Expand 10 after
5237 pattern); 5237 pattern);
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(Thread* thread, Zone* zone,
5248 const RegExp& 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(thread,
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::ColonMatcher(), 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.
(...skipping 24 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 RawRegExp* RegExpEngine::CreateRegExp(Zone* zone, 5300 RawRegExp* RegExpEngine::CreateRegExp(Thread* thread,
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 Zone* zone = thread->zone();
5304 const RegExp& regexp = RegExp::Handle(RegExp::New()); 5305 const RegExp& regexp = RegExp::Handle(RegExp::New());
5305 5306
5306 regexp.set_pattern(pattern); 5307 regexp.set_pattern(pattern);
5307 5308
5308 if (multi_line) { 5309 if (multi_line) {
5309 regexp.set_is_multi_line(); 5310 regexp.set_is_multi_line();
5310 } 5311 }
5311 if (ignore_case) { 5312 if (ignore_case) {
5312 regexp.set_is_ignore_case(); 5313 regexp.set_is_ignore_case();
5313 } 5314 }
5314 5315
5315 // TODO(zerny): We might want to use normal string searching algorithms 5316 // TODO(zerny): We might want to use normal string searching algorithms
5316 // for simple patterns. 5317 // for simple patterns.
5317 regexp.set_is_complex(); 5318 regexp.set_is_complex();
5318 regexp.set_is_global(); // All dart regexps are global. 5319 regexp.set_is_global(); // All dart regexps are global.
5319 5320
5320 if (!FLAG_interpret_irregexp) { 5321 if (!FLAG_interpret_irregexp) {
5321 const Library& lib = Library::Handle(zone, Library::CoreLibrary()); 5322 const Library& lib = Library::Handle(zone, Library::CoreLibrary());
5322 const Class& owner = Class::Handle( 5323 const Class& owner = Class::Handle(zone,
5323 zone, lib.LookupClass(Symbols::RegExp())); 5324 lib.LookupClass(Symbols::RegExp()));
5324 5325
5325 CreateSpecializedFunction(zone, regexp, kOneByteStringCid, owner); 5326 CreateSpecializedFunction(thread, zone, regexp, kOneByteStringCid, owner);
5326 CreateSpecializedFunction(zone, regexp, kTwoByteStringCid, owner); 5327 CreateSpecializedFunction(thread, zone, regexp, kTwoByteStringCid, owner);
5327 CreateSpecializedFunction(zone, regexp, kExternalOneByteStringCid, owner); 5328 CreateSpecializedFunction(thread, zone,
5328 CreateSpecializedFunction(zone, regexp, kExternalTwoByteStringCid, owner); 5329 regexp, kExternalOneByteStringCid, owner);
5330 CreateSpecializedFunction(thread, zone,
5331 regexp, kExternalTwoByteStringCid, owner);
5329 } 5332 }
5330 5333
5331 return regexp.raw(); 5334 return regexp.raw();
5332 } 5335 }
5333 5336
5334 5337
5335 } // namespace dart 5338 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/regexp.h ('k') | runtime/vm/regexp_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698