Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::ActionNode Class Reference

#include <regexp.h>

Inheritance diagram for dart::ActionNode:
dart::SeqRegExpNode dart::RegExpNode dart::ZoneAllocated

Public Types

enum  ActionType {
  SET_REGISTER , INCREMENT_REGISTER , STORE_POSITION , BEGIN_SUBMATCH ,
  POSITIVE_SUBMATCH_SUCCESS , EMPTY_MATCH_CHECK , CLEAR_CAPTURES
}
 

Public Member Functions

virtual void Accept (NodeVisitor *visitor)
 
virtual void Emit (RegExpCompiler *compiler, Trace *trace)
 
virtual intptr_t EatsAtLeast (intptr_t still_to_find, intptr_t budget, bool not_at_start)
 
virtual void GetQuickCheckDetails (QuickCheckDetails *details, RegExpCompiler *compiler, intptr_t filled_in, bool not_at_start)
 
virtual void FillInBMInfo (intptr_t offset, intptr_t budget, BoyerMooreLookahead *bm, bool not_at_start)
 
ActionType action_type ()
 
virtual intptr_t GreedyLoopTextLength ()
 
- Public Member Functions inherited from dart::SeqRegExpNode
 SeqRegExpNode (RegExpNode *on_success)
 
RegExpNodeon_success ()
 
void set_on_success (RegExpNode *node)
 
virtual RegExpNodeFilterOneByte (intptr_t depth)
 
virtual void FillInBMInfo (intptr_t offset, intptr_t budget, BoyerMooreLookahead *bm, bool not_at_start)
 
- Public Member Functions inherited from dart::RegExpNode
 RegExpNode (Zone *zone)
 
virtual ~RegExpNode ()
 
virtual void Accept (NodeVisitor *visitor)=0
 
virtual void Emit (RegExpCompiler *compiler, Trace *trace)=0
 
virtual intptr_t EatsAtLeast (intptr_t still_to_find, intptr_t budget, bool not_at_start)=0
 
bool EmitQuickCheck (RegExpCompiler *compiler, Trace *bounds_check_trace, Trace *trace, bool preload_has_checked_bounds, BlockLabel *on_possible_success, QuickCheckDetails *details_return, bool fall_through_on_failure)
 
virtual void GetQuickCheckDetails (QuickCheckDetails *details, RegExpCompiler *compiler, intptr_t characters_filled_in, bool not_at_start)=0
 
virtual intptr_t GreedyLoopTextLength ()
 
virtual RegExpNodeGetSuccessorOfOmnivorousTextNode (RegExpCompiler *compiler)
 
virtual void FillInBMInfo (intptr_t offset, intptr_t budget, BoyerMooreLookahead *bm, bool not_at_start)
 
virtual RegExpNodeFilterOneByte (intptr_t depth)
 
RegExpNodereplacement ()
 
RegExpNodeset_replacement (RegExpNode *replacement)
 
void SaveBMInfo (BoyerMooreLookahead *bm, bool not_at_start, intptr_t offset)
 
BlockLabellabel ()
 
NodeInfoinfo ()
 
BoyerMooreLookaheadbm_info (bool not_at_start)
 
Zonezone () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static ActionNodeSetRegister (intptr_t reg, intptr_t val, RegExpNode *on_success)
 
static ActionNodeIncrementRegister (intptr_t reg, RegExpNode *on_success)
 
static ActionNodeStorePosition (intptr_t reg, bool is_capture, RegExpNode *on_success)
 
static ActionNodeClearCaptures (Interval range, RegExpNode *on_success)
 
static ActionNodeBeginSubmatch (intptr_t stack_pointer_reg, intptr_t position_reg, RegExpNode *on_success)
 
static ActionNodePositiveSubmatchSuccess (intptr_t stack_pointer_reg, intptr_t restore_reg, intptr_t clear_capture_count, intptr_t clear_capture_from, RegExpNode *on_success)
 
static ActionNodeEmptyMatchCheck (intptr_t start_register, intptr_t repetition_register, intptr_t repetition_limit, RegExpNode *on_success)
 

Friends

class DotPrinter
 

Additional Inherited Members

- Static Public Attributes inherited from dart::RegExpNode
static constexpr intptr_t kNodeIsTooComplexForGreedyLoops = -1
 
static constexpr intptr_t kRecursionBudget = 200
 
static constexpr intptr_t kMaxCopiesCodeGenerated = 10
 
- Protected Types inherited from dart::RegExpNode
enum  LimitResult { DONE , CONTINUE }
 
- Protected Member Functions inherited from dart::SeqRegExpNode
RegExpNodeFilterSuccessor (intptr_t depth)
 
- Protected Member Functions inherited from dart::RegExpNode
LimitResult LimitVersions (RegExpCompiler *compiler, Trace *trace)
 
void set_bm_info (bool not_at_start, BoyerMooreLookahead *bm)
 
- Protected Attributes inherited from dart::RegExpNode
RegExpNodereplacement_
 

Detailed Description

Definition at line 562 of file regexp.h.

Member Enumeration Documentation

◆ ActionType

Enumerator
SET_REGISTER 
INCREMENT_REGISTER 
STORE_POSITION 
BEGIN_SUBMATCH 
POSITIVE_SUBMATCH_SUCCESS 
EMPTY_MATCH_CHECK 
CLEAR_CAPTURES 

Definition at line 564 of file regexp.h.

Member Function Documentation

◆ Accept()

virtual void dart::ActionNode::Accept ( NodeVisitor visitor)
virtual

Implements dart::RegExpNode.

◆ action_type()

ActionType dart::ActionNode::action_type ( )
inline

Definition at line 609 of file regexp.h.

609{ return action_type_; }

◆ BeginSubmatch()

ActionNode * dart::ActionNode::BeginSubmatch ( intptr_t  stack_pointer_reg,
intptr_t  position_reg,
RegExpNode on_success 
)
static

Definition at line 792 of file regexp.cc.

794 {
795 ActionNode* result =
796 new (on_success->zone()) ActionNode(BEGIN_SUBMATCH, on_success);
797 result->data_.u_submatch.stack_pointer_register = stack_reg;
798 result->data_.u_submatch.current_position_register = position_reg;
799 return result;
800}
Zone * zone() const
Definition: regexp.h:483
RegExpNode * on_success()
Definition: regexp.h:544
GAsyncResult * result

◆ ClearCaptures()

ActionNode * dart::ActionNode::ClearCaptures ( Interval  range,
RegExpNode on_success 
)
static

Definition at line 784 of file regexp.cc.

784 {
785 ActionNode* result =
786 new (on_success->zone()) ActionNode(CLEAR_CAPTURES, on_success);
787 result->data_.u_clear_captures.range_from = range.from();
788 result->data_.u_clear_captures.range_to = range.to();
789 return result;
790}

◆ EatsAtLeast()

intptr_t dart::ActionNode::EatsAtLeast ( intptr_t  still_to_find,
intptr_t  budget,
bool  not_at_start 
)
virtual

Implements dart::RegExpNode.

Definition at line 1473 of file regexp.cc.

1475 {
1476 if (budget <= 0) return 0;
1477 if (action_type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input!
1478 return on_success()->EatsAtLeast(still_to_find, budget - 1, not_at_start);
1479}
virtual intptr_t EatsAtLeast(intptr_t still_to_find, intptr_t budget, bool not_at_start)=0

◆ Emit()

void dart::ActionNode::Emit ( RegExpCompiler compiler,
Trace trace 
)
virtual

Implements dart::RegExpNode.

Definition at line 3407 of file regexp.cc.

3407 {
3408 RegExpMacroAssembler* assembler = compiler->macro_assembler();
3409 LimitResult limit_result = LimitVersions(compiler, trace);
3410 if (limit_result == DONE) return;
3411 ASSERT(limit_result == CONTINUE);
3412
3413 RecursionCheck rc(compiler);
3414
3415 switch (action_type_) {
3416 case STORE_POSITION: {
3417 Trace::DeferredCapture new_capture(data_.u_position_register.reg,
3418 data_.u_position_register.is_capture,
3419 trace);
3420 Trace new_trace = *trace;
3421 new_trace.add_action(&new_capture);
3422 on_success()->Emit(compiler, &new_trace);
3423 break;
3424 }
3425 case INCREMENT_REGISTER: {
3426 Trace::DeferredIncrementRegister new_increment(
3427 data_.u_increment_register.reg);
3428 Trace new_trace = *trace;
3429 new_trace.add_action(&new_increment);
3430 on_success()->Emit(compiler, &new_trace);
3431 break;
3432 }
3433 case SET_REGISTER: {
3434 Trace::DeferredSetRegister new_set(data_.u_store_register.reg,
3435 data_.u_store_register.value);
3436 Trace new_trace = *trace;
3437 new_trace.add_action(&new_set);
3438 on_success()->Emit(compiler, &new_trace);
3439 break;
3440 }
3441 case CLEAR_CAPTURES: {
3442 Trace::DeferredClearCaptures new_capture(Interval(
3443 data_.u_clear_captures.range_from, data_.u_clear_captures.range_to));
3444 Trace new_trace = *trace;
3445 new_trace.add_action(&new_capture);
3446 on_success()->Emit(compiler, &new_trace);
3447 break;
3448 }
3449 case BEGIN_SUBMATCH:
3450 if (!trace->is_trivial()) {
3451 trace->Flush(compiler, this);
3452 } else {
3453 assembler->WriteCurrentPositionToRegister(
3454 data_.u_submatch.current_position_register, 0);
3455 assembler->WriteStackPointerToRegister(
3456 data_.u_submatch.stack_pointer_register);
3457 on_success()->Emit(compiler, trace);
3458 }
3459 break;
3460 case EMPTY_MATCH_CHECK: {
3461 intptr_t start_pos_reg = data_.u_empty_match_check.start_register;
3462 intptr_t stored_pos = 0;
3463 intptr_t rep_reg = data_.u_empty_match_check.repetition_register;
3464 bool has_minimum = (rep_reg != RegExpCompiler::kNoRegister);
3465 bool know_dist = trace->GetStoredPosition(start_pos_reg, &stored_pos);
3466 if (know_dist && !has_minimum && stored_pos == trace->cp_offset()) {
3467 // If we know we haven't advanced and there is no minimum we
3468 // can just backtrack immediately.
3469 assembler->GoTo(trace->backtrack());
3470 } else if (know_dist && stored_pos < trace->cp_offset()) {
3471 // If we know we've advanced we can generate the continuation
3472 // immediately.
3473 on_success()->Emit(compiler, trace);
3474 } else if (!trace->is_trivial()) {
3475 trace->Flush(compiler, this);
3476 } else {
3477 BlockLabel skip_empty_check;
3478 // If we have a minimum number of repetitions we check the current
3479 // number first and skip the empty check if it's not enough.
3480 if (has_minimum) {
3481 intptr_t limit = data_.u_empty_match_check.repetition_limit;
3482 assembler->IfRegisterLT(rep_reg, limit, &skip_empty_check);
3483 }
3484 // If the match is empty we bail out, otherwise we fall through
3485 // to the on-success continuation.
3486 assembler->IfRegisterEqPos(data_.u_empty_match_check.start_register,
3487 trace->backtrack());
3488 assembler->BindBlock(&skip_empty_check);
3489 on_success()->Emit(compiler, trace);
3490 }
3491 break;
3492 }
3494 if (!trace->is_trivial()) {
3495 trace->Flush(compiler, this);
3496 return;
3497 }
3498 assembler->ReadCurrentPositionFromRegister(
3499 data_.u_submatch.current_position_register);
3500 assembler->ReadStackPointerFromRegister(
3501 data_.u_submatch.stack_pointer_register);
3502 intptr_t clear_register_count = data_.u_submatch.clear_register_count;
3503 if (clear_register_count == 0) {
3504 on_success()->Emit(compiler, trace);
3505 return;
3506 }
3507 intptr_t clear_registers_from = data_.u_submatch.clear_register_from;
3508 BlockLabel clear_registers_backtrack;
3509 Trace new_trace = *trace;
3510 new_trace.set_backtrack(&clear_registers_backtrack);
3511 on_success()->Emit(compiler, &new_trace);
3512
3513 assembler->BindBlock(&clear_registers_backtrack);
3514 intptr_t clear_registers_to =
3515 clear_registers_from + clear_register_count - 1;
3516 assembler->ClearRegisters(clear_registers_from, clear_registers_to);
3517
3518 ASSERT(trace->backtrack() == nullptr);
3519 assembler->Backtrack();
3520 return;
3521 }
3522 default:
3523 UNREACHABLE();
3524 }
3525}
#define UNREACHABLE()
Definition: assert.h:248
intptr_t clear_register_count
Definition: regexp.h:631
static constexpr intptr_t kNoRegister
Definition: regexp.cc:355
virtual void Emit(RegExpCompiler *compiler, Trace *trace)=0
LimitResult LimitVersions(RegExpCompiler *compiler, Trace *trace)
Definition: regexp.cc:1431
#define ASSERT(E)

◆ EmptyMatchCheck()

ActionNode * dart::ActionNode::EmptyMatchCheck ( intptr_t  start_register,
intptr_t  repetition_register,
intptr_t  repetition_limit,
RegExpNode on_success 
)
static

Definition at line 816 of file regexp.cc.

819 {
820 ActionNode* result =
821 new (on_success->zone()) ActionNode(EMPTY_MATCH_CHECK, on_success);
822 result->data_.u_empty_match_check.start_register = start_register;
823 result->data_.u_empty_match_check.repetition_register = repetition_register;
824 result->data_.u_empty_match_check.repetition_limit = repetition_limit;
825 return result;
826}
intptr_t start_register
Definition: regexp.h:635
intptr_t repetition_register
Definition: regexp.h:636
intptr_t repetition_limit
Definition: regexp.h:637

◆ FillInBMInfo()

void dart::ActionNode::FillInBMInfo ( intptr_t  offset,
intptr_t  budget,
BoyerMooreLookahead bm,
bool  not_at_start 
)
virtual

Reimplemented from dart::SeqRegExpNode.

Definition at line 1481 of file regexp.cc.

1484 {
1485 if (action_type_ == BEGIN_SUBMATCH) {
1486 bm->SetRest(offset);
1487 } else if (action_type_ != POSITIVE_SUBMATCH_SUCCESS) {
1488 on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start);
1489 }
1490 SaveBMInfo(bm, not_at_start, offset);
1491}
void SaveBMInfo(BoyerMooreLookahead *bm, bool not_at_start, intptr_t offset)
Definition: regexp.h:465
virtual void FillInBMInfo(intptr_t offset, intptr_t budget, BoyerMooreLookahead *bm, bool not_at_start)
Definition: regexp.h:439
SeparatedVector2 offset

◆ GetQuickCheckDetails()

virtual void dart::ActionNode::GetQuickCheckDetails ( QuickCheckDetails details,
RegExpCompiler compiler,
intptr_t  filled_in,
bool  not_at_start 
)
inlinevirtual

Implements dart::RegExpNode.

Definition at line 598 of file regexp.h.

601 {
602 return on_success()->GetQuickCheckDetails(details, compiler, filled_in,
603 not_at_start);
604 }
virtual void GetQuickCheckDetails(QuickCheckDetails *details, RegExpCompiler *compiler, intptr_t characters_filled_in, bool not_at_start)=0

◆ GreedyLoopTextLength()

virtual intptr_t dart::ActionNode::GreedyLoopTextLength ( )
inlinevirtual

Reimplemented from dart::RegExpNode.

Definition at line 611 of file regexp.h.

611 {
613 }
static constexpr intptr_t kNodeIsTooComplexForGreedyLoops
Definition: regexp.h:422

◆ IncrementRegister()

ActionNode * dart::ActionNode::IncrementRegister ( intptr_t  reg,
RegExpNode on_success 
)
static

Definition at line 766 of file regexp.cc.

767 {
768 ActionNode* result =
769 new (on_success->zone()) ActionNode(INCREMENT_REGISTER, on_success);
770 result->data_.u_increment_register.reg = reg;
771 return result;
772}
intptr_t reg
Definition: regexp.h:618

◆ PositiveSubmatchSuccess()

ActionNode * dart::ActionNode::PositiveSubmatchSuccess ( intptr_t  stack_pointer_reg,
intptr_t  restore_reg,
intptr_t  clear_capture_count,
intptr_t  clear_capture_from,
RegExpNode on_success 
)
static

Definition at line 802 of file regexp.cc.

806 {
807 ActionNode* result = new (on_success->zone())
809 result->data_.u_submatch.stack_pointer_register = stack_reg;
810 result->data_.u_submatch.current_position_register = position_reg;
811 result->data_.u_submatch.clear_register_count = clear_register_count;
812 result->data_.u_submatch.clear_register_from = clear_register_from;
813 return result;
814}
intptr_t clear_register_from
Definition: regexp.h:632

◆ SetRegister()

ActionNode * dart::ActionNode::SetRegister ( intptr_t  reg,
intptr_t  val,
RegExpNode on_success 
)
static

Definition at line 756 of file regexp.cc.

758 {
759 ActionNode* result =
760 new (on_success->zone()) ActionNode(SET_REGISTER, on_success);
761 result->data_.u_store_register.reg = reg;
762 result->data_.u_store_register.value = val;
763 return result;
764}

◆ StorePosition()

ActionNode * dart::ActionNode::StorePosition ( intptr_t  reg,
bool  is_capture,
RegExpNode on_success 
)
static

Definition at line 774 of file regexp.cc.

776 {
777 ActionNode* result =
778 new (on_success->zone()) ActionNode(STORE_POSITION, on_success);
779 result->data_.u_position_register.reg = reg;
780 result->data_.u_position_register.is_capture = is_capture;
781 return result;
782}
bool is_capture
Definition: regexp.h:626

Friends And Related Function Documentation

◆ DotPrinter

friend class DotPrinter
friend

Definition at line 647 of file regexp.h.

Member Data Documentation

◆ clear_register_count

intptr_t dart::ActionNode::clear_register_count

Definition at line 631 of file regexp.h.

◆ clear_register_from

intptr_t dart::ActionNode::clear_register_from

Definition at line 632 of file regexp.h.

◆ current_position_register

intptr_t dart::ActionNode::current_position_register

Definition at line 630 of file regexp.h.

◆ is_capture

bool dart::ActionNode::is_capture

Definition at line 626 of file regexp.h.

◆ range_from

intptr_t dart::ActionNode::range_from

Definition at line 640 of file regexp.h.

◆ range_to

intptr_t dart::ActionNode::range_to

Definition at line 641 of file regexp.h.

◆ reg

intptr_t dart::ActionNode::reg

Definition at line 618 of file regexp.h.

◆ repetition_limit

intptr_t dart::ActionNode::repetition_limit

Definition at line 637 of file regexp.h.

◆ repetition_register

intptr_t dart::ActionNode::repetition_register

Definition at line 636 of file regexp.h.

◆ stack_pointer_register

intptr_t dart::ActionNode::stack_pointer_register

Definition at line 629 of file regexp.h.

◆ start_register

intptr_t dart::ActionNode::start_register

Definition at line 635 of file regexp.h.

◆ 

struct { ... } dart::ActionNode::u_clear_captures

◆ 

struct { ... } dart::ActionNode::u_empty_match_check

◆ 

struct { ... } dart::ActionNode::u_increment_register

◆ 

struct { ... } dart::ActionNode::u_position_register

◆ 

struct { ... } dart::ActionNode::u_store_register

◆ 

struct { ... } dart::ActionNode::u_submatch

◆ value

intptr_t dart::ActionNode::value

Definition at line 619 of file regexp.h.


The documentation for this class was generated from the following files: