Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | List of all members
dart::Trace Class Reference

#include <regexp.h>

Classes

class  DeferredAction
 
class  DeferredCapture
 
class  DeferredClearCaptures
 
class  DeferredIncrementRegister
 
class  DeferredSetRegister
 

Public Types

enum  TriBool { UNKNOWN = -1 , FALSE_VALUE = 0 , TRUE_VALUE = 1 }
 

Public Member Functions

 Trace ()
 
void Flush (RegExpCompiler *compiler, RegExpNode *successor)
 
intptr_t cp_offset ()
 
DeferredActionactions ()
 
bool is_trivial ()
 
TriBool at_start ()
 
void set_at_start (TriBool at_start)
 
BlockLabelbacktrack ()
 
BlockLabelloop_label ()
 
RegExpNodestop_node ()
 
intptr_t characters_preloaded ()
 
intptr_t bound_checked_up_to ()
 
intptr_t flush_budget ()
 
QuickCheckDetailsquick_check_performed ()
 
bool mentions_reg (intptr_t reg)
 
bool GetStoredPosition (intptr_t reg, intptr_t *cp_offset)
 
void add_action (DeferredAction *new_action)
 
void set_backtrack (BlockLabel *backtrack)
 
void set_stop_node (RegExpNode *node)
 
void set_loop_label (BlockLabel *label)
 
void set_characters_preloaded (intptr_t count)
 
void set_bound_checked_up_to (intptr_t to)
 
void set_flush_budget (intptr_t to)
 
void set_quick_check_performed (QuickCheckDetails *d)
 
void InvalidateCurrentCharacter ()
 
void AdvanceCurrentPositionInTrace (intptr_t by, RegExpCompiler *compiler)
 

Detailed Description

Definition at line 1202 of file regexp.h.

Member Enumeration Documentation

◆ TriBool

Enumerator
UNKNOWN 
FALSE_VALUE 
TRUE_VALUE 

Definition at line 1206 of file regexp.h.

1206{ UNKNOWN = -1, FALSE_VALUE = 0, TRUE_VALUE = 1 };
@ FALSE_VALUE
Definition: regexp.h:1206
@ TRUE_VALUE
Definition: regexp.h:1206

Constructor & Destructor Documentation

◆ Trace()

dart::Trace::Trace ( )
inline

Definition at line 1267 of file regexp.h.

1268 : cp_offset_(0),
1269 actions_(nullptr),
1270 backtrack_(nullptr),
1271 stop_node_(nullptr),
1272 loop_label_(nullptr),
1273 characters_preloaded_(0),
1274 bound_checked_up_to_(0),
1275 flush_budget_(100),
1276 at_start_(UNKNOWN) {}

Member Function Documentation

◆ actions()

DeferredAction * dart::Trace::actions ( )
inline

Definition at line 1284 of file regexp.h.

1284{ return actions_; }

◆ add_action()

void dart::Trace::add_action ( DeferredAction new_action)
inline

Definition at line 1316 of file regexp.h.

1316 {
1317 ASSERT(new_action->next_ == nullptr);
1318 new_action->next_ = actions_;
1319 actions_ = new_action;
1320 }
#define ASSERT(E)

◆ AdvanceCurrentPositionInTrace()

void dart::Trace::AdvanceCurrentPositionInTrace ( intptr_t  by,
RegExpCompiler compiler 
)

Definition at line 2562 of file regexp.cc.

2563 {
2564 // We don't have an instruction for shifting the current character register
2565 // down or for using a shifted value for anything so lets just forget that
2566 // we preloaded any characters into it.
2567 characters_preloaded_ = 0;
2568 // Adjust the offsets of the quick check performed information. This
2569 // information is used to find out what we already determined about the
2570 // characters by means of mask and compare.
2571 quick_check_performed_.Advance(by, compiler->one_byte());
2572 cp_offset_ += by;
2573 if (cp_offset_ > RegExpMacroAssembler::kMaxCPOffset) {
2574 compiler->SetRegExpTooBig();
2575 cp_offset_ = 0;
2576 }
2577 bound_checked_up_to_ =
2578 Utils::Maximum(static_cast<intptr_t>(0), bound_checked_up_to_ - by);
2579}
void Advance(intptr_t by, bool one_byte)
Definition: regexp.cc:1871
static constexpr intptr_t kMaxCPOffset
static constexpr T Maximum(T x, T y)
Definition: utils.h:41

◆ at_start()

TriBool dart::Trace::at_start ( )
inline

Definition at line 1300 of file regexp.h.

1300{ return at_start_; }

◆ backtrack()

BlockLabel * dart::Trace::backtrack ( )
inline

Definition at line 1302 of file regexp.h.

1302{ return backtrack_; }

◆ bound_checked_up_to()

intptr_t dart::Trace::bound_checked_up_to ( )
inline

Definition at line 1306 of file regexp.h.

1306{ return bound_checked_up_to_; }

◆ characters_preloaded()

intptr_t dart::Trace::characters_preloaded ( )
inline

Definition at line 1305 of file regexp.h.

1305{ return characters_preloaded_; }

◆ cp_offset()

intptr_t dart::Trace::cp_offset ( )
inline

Definition at line 1283 of file regexp.h.

1283{ return cp_offset_; }

◆ Flush()

void dart::Trace::Flush ( RegExpCompiler compiler,
RegExpNode successor 
)

Definition at line 649 of file regexp.cc.

649 {
650 RegExpMacroAssembler* assembler = compiler->macro_assembler();
651
652 ASSERT(!is_trivial());
653
654 if (actions_ == nullptr && backtrack() == nullptr) {
655 // Here we just have some deferred cp advances to fix and we are back to
656 // a normal situation. We may also have to forget some information gained
657 // through a quick check that was already performed.
658 if (cp_offset_ != 0) assembler->AdvanceCurrentPosition(cp_offset_);
659 // Create a new trivial state and generate the node with that.
660 Trace new_state;
661 successor->Emit(compiler, &new_state);
662 return;
663 }
664
665 // Generate deferred actions here along with code to undo them again.
666 OutSet affected_registers;
667
668 if (backtrack() != nullptr) {
669 // Here we have a concrete backtrack location. These are set up by choice
670 // nodes and so they indicate that we have a deferred save of the current
671 // position which we may need to emit here.
672 assembler->PushCurrentPosition();
673 }
674 Zone* zone = successor->zone();
675 intptr_t max_register = FindAffectedRegisters(&affected_registers, zone);
676 OutSet registers_to_pop;
677 OutSet registers_to_clear;
678 PerformDeferredActions(assembler, max_register, affected_registers,
679 &registers_to_pop, &registers_to_clear, zone);
680 if (cp_offset_ != 0) {
681 assembler->AdvanceCurrentPosition(cp_offset_);
682 }
683
684 // Create a new trivial state and generate the node with that.
685 BlockLabel undo;
686 assembler->PushBacktrack(&undo);
687 Trace new_state;
688 successor->Emit(compiler, &new_state);
689
690 // On backtrack we need to restore state.
691 assembler->BindBlock(&undo);
692 RestoreAffectedRegisters(assembler, max_register, registers_to_pop,
693 registers_to_clear);
694 if (backtrack() == nullptr) {
695 assembler->Backtrack();
696 } else {
697 assembler->PopCurrentPosition();
698 assembler->GoTo(backtrack());
699 }
700}
bool is_trivial()
Definition: regexp.h:1295
BlockLabel * backtrack()
Definition: regexp.h:1302

◆ flush_budget()

intptr_t dart::Trace::flush_budget ( )
inline

Definition at line 1307 of file regexp.h.

1307{ return flush_budget_; }

◆ GetStoredPosition()

bool dart::Trace::GetStoredPosition ( intptr_t  reg,
intptr_t *  cp_offset 
)

Definition at line 478 of file regexp.cc.

478 {
479 ASSERT(*cp_offset == 0);
480 for (DeferredAction* action = actions_; action != nullptr;
481 action = action->next()) {
482 if (action->Mentions(reg)) {
483 if (action->action_type() == ActionNode::STORE_POSITION) {
484 *cp_offset = static_cast<DeferredCapture*>(action)->cp_offset();
485 return true;
486 } else {
487 return false;
488 }
489 }
490 }
491 return false;
492}
intptr_t cp_offset()
Definition: regexp.h:1283

◆ InvalidateCurrentCharacter()

void dart::Trace::InvalidateCurrentCharacter ( )

Definition at line 2558 of file regexp.cc.

2558 {
2559 characters_preloaded_ = 0;
2560}

◆ is_trivial()

bool dart::Trace::is_trivial ( )
inline

Definition at line 1295 of file regexp.h.

1295 {
1296 return backtrack_ == nullptr && actions_ == nullptr && cp_offset_ == 0 &&
1297 characters_preloaded_ == 0 && bound_checked_up_to_ == 0 &&
1298 quick_check_performed_.characters() == 0 && at_start_ == UNKNOWN;
1299 }
intptr_t characters()
Definition: regexp.h:359

◆ loop_label()

BlockLabel * dart::Trace::loop_label ( )
inline

Definition at line 1303 of file regexp.h.

1303{ return loop_label_; }

◆ mentions_reg()

bool dart::Trace::mentions_reg ( intptr_t  reg)

Definition at line 470 of file regexp.cc.

470 {
471 for (DeferredAction* action = actions_; action != nullptr;
472 action = action->next()) {
473 if (action->Mentions(reg)) return true;
474 }
475 return false;
476}

◆ quick_check_performed()

QuickCheckDetails * dart::Trace::quick_check_performed ( )
inline

Definition at line 1308 of file regexp.h.

1308{ return &quick_check_performed_; }

◆ set_at_start()

void dart::Trace::set_at_start ( TriBool  at_start)
inline

Definition at line 1301 of file regexp.h.

1301{ at_start_ = at_start; }
TriBool at_start()
Definition: regexp.h:1300

◆ set_backtrack()

void dart::Trace::set_backtrack ( BlockLabel backtrack)
inline

Definition at line 1321 of file regexp.h.

1321{ backtrack_ = backtrack; }

◆ set_bound_checked_up_to()

void dart::Trace::set_bound_checked_up_to ( intptr_t  to)
inline

Definition at line 1327 of file regexp.h.

1327{ bound_checked_up_to_ = to; }

◆ set_characters_preloaded()

void dart::Trace::set_characters_preloaded ( intptr_t  count)
inline

Definition at line 1324 of file regexp.h.

1324 {
1325 characters_preloaded_ = count;
1326 }
int count
Definition: FontMgrTest.cpp:50

◆ set_flush_budget()

void dart::Trace::set_flush_budget ( intptr_t  to)
inline

Definition at line 1328 of file regexp.h.

1328{ flush_budget_ = to; }

◆ set_loop_label()

void dart::Trace::set_loop_label ( BlockLabel label)
inline

Definition at line 1323 of file regexp.h.

1323{ loop_label_ = label; }

◆ set_quick_check_performed()

void dart::Trace::set_quick_check_performed ( QuickCheckDetails d)
inline

Definition at line 1329 of file regexp.h.

1329 {
1330 quick_check_performed_ = *d;
1331 }
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19

◆ set_stop_node()

void dart::Trace::set_stop_node ( RegExpNode node)
inline

Definition at line 1322 of file regexp.h.

1322{ stop_node_ = node; }

◆ stop_node()

RegExpNode * dart::Trace::stop_node ( )
inline

Definition at line 1304 of file regexp.h.

1304{ return stop_node_; }

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