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

Side by Side Diff: runtime/vm/regexp_assembler_ir.h

Issue 2951053003: VM(RegExp): Allow OSR optimization of RegExp :matcher functions. (Closed)
Patch Set: Fix bugs with stack growing and block pruning Created 3 years, 6 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
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 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_ 5 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_
6 #define RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_ 6 #define RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 14 matching lines...) Expand all
25 // throw the exception. 25 // throw the exception.
26 // FAILURE: Matching failed. 26 // FAILURE: Matching failed.
27 // SUCCESS: Matching succeeded, and the output array has been filled with 27 // SUCCESS: Matching succeeded, and the output array has been filled with
28 // capture positions. 28 // capture positions.
29 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; 29 enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 };
30 30
31 IRRegExpMacroAssembler(intptr_t specialization_cid, 31 IRRegExpMacroAssembler(intptr_t specialization_cid,
32 intptr_t capture_count, 32 intptr_t capture_count,
33 const ParsedFunction* parsed_function, 33 const ParsedFunction* parsed_function,
34 const ZoneGrowableArray<const ICData*>& ic_data_array, 34 const ZoneGrowableArray<const ICData*>& ic_data_array,
35 intptr_t osr_id,
35 Zone* zone); 36 Zone* zone);
36 virtual ~IRRegExpMacroAssembler(); 37 virtual ~IRRegExpMacroAssembler();
37 38
38 virtual bool CanReadUnaligned(); 39 virtual bool CanReadUnaligned();
39 40
40 static RawArray* Execute(const RegExp& regexp, 41 static RawArray* Execute(const RegExp& regexp,
41 const String& input, 42 const String& input,
42 const Smi& start_offset, 43 const Smi& start_offset,
43 bool sticky, 44 bool sticky,
44 Zone* zone); 45 Zone* zone);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // current position, into the current-character register. 278 // current position, into the current-character register.
278 void LoadCurrentCharacterUnchecked(intptr_t cp_offset, 279 void LoadCurrentCharacterUnchecked(intptr_t cp_offset,
279 intptr_t character_count); 280 intptr_t character_count);
280 281
281 // Returns the character within the passed string at the specified index. 282 // Returns the character within the passed string at the specified index.
282 Value* CharacterAt(LocalVariable* index); 283 Value* CharacterAt(LocalVariable* index);
283 284
284 // Load a number of characters starting from index in the pattern string. 285 // Load a number of characters starting from index in the pattern string.
285 Value* LoadCodeUnitsAt(LocalVariable* index, intptr_t character_count); 286 Value* LoadCodeUnitsAt(LocalVariable* index, intptr_t character_count);
286 287
287 // Check whether preemption has been requested. 288 // Check whether preemption has been requested. Also serves as an OSR entry.
288 void CheckPreemption(); 289 void CheckPreemption(bool is_backtrack);
289 290
290 // Byte size of chars in the string to match (decided by the Mode argument) 291 // Byte size of chars in the string to match (decided by the Mode argument)
291 inline intptr_t char_size() { return static_cast<int>(mode_); } 292 inline intptr_t char_size() { return static_cast<int>(mode_); }
292 293
293 // Equivalent to a conditional branch to the label, unless the label 294 // Equivalent to a conditional branch to the label, unless the label
294 // is NULL, in which case it is a conditional Backtrack. 295 // is NULL, in which case it is a conditional Backtrack.
295 void BranchOrBacktrack(ComparisonInstr* comparison, 296 void BranchOrBacktrack(ComparisonInstr* comparison,
296 BlockLabel* true_successor); 297 BlockLabel* true_successor);
297 298
298 // Set up all local variables and parameters. 299 // Set up all local variables and parameters.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 Definition* PeekStack(); 337 Definition* PeekStack();
337 void CheckStackLimit(); 338 void CheckStackLimit();
338 void GrowStack(); 339 void GrowStack();
339 340
340 // Prints the specified argument. Used for debugging. 341 // Prints the specified argument. Used for debugging.
341 void Print(PushArgumentInstr* argument); 342 void Print(PushArgumentInstr* argument);
342 343
343 // A utility class tracking ids of various objects such as blocks, temps, etc. 344 // A utility class tracking ids of various objects such as blocks, temps, etc.
344 class IdAllocator : public ValueObject { 345 class IdAllocator : public ValueObject {
345 public: 346 public:
346 IdAllocator() : next_id(0) {} 347 explicit IdAllocator(intptr_t first_id = 0) : next_id(first_id) {}
347 348
348 intptr_t Count() const { return next_id; } 349 intptr_t Count() const { return next_id; }
349 intptr_t Alloc(intptr_t count = 1) { 350 intptr_t Alloc(intptr_t count = 1) {
350 ASSERT(count >= 0); 351 ASSERT(count >= 0);
351 intptr_t current_id = next_id; 352 intptr_t current_id = next_id;
352 next_id += count; 353 next_id += count;
353 return current_id; 354 return current_id;
354 } 355 }
355 void Dealloc(intptr_t count = 1) { 356 void Dealloc(intptr_t count = 1) {
356 ASSERT(count <= next_id); 357 ASSERT(count <= next_id);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 IdAllocator temp_id_; 436 IdAllocator temp_id_;
436 IdAllocator arg_id_; 437 IdAllocator arg_id_;
437 IdAllocator local_id_; 438 IdAllocator local_id_;
438 IdAllocator indirect_id_; 439 IdAllocator indirect_id_;
439 }; 440 };
440 441
441 442
442 } // namespace dart 443 } // namespace dart
443 444
444 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_ 445 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_IR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698