V8 Project
v8::internal::QuickCheckDetails Class Reference

#include <jsregexp.h>

+ Collaboration diagram for v8::internal::QuickCheckDetails:

Classes

struct  Position
 

Public Member Functions

 QuickCheckDetails ()
 
 QuickCheckDetails (int characters)
 
bool Rationalize (bool one_byte)
 
void Merge (QuickCheckDetails *other, int from_index)
 
void Advance (int by, bool one_byte)
 
void Clear ()
 
bool cannot_match ()
 
void set_cannot_match ()
 
int characters ()
 
void set_characters (int characters)
 
Positionpositions (int index)
 
uint32_t mask ()
 
uint32_t value ()
 

Private Attributes

int characters_
 
Position positions_ [4]
 
uint32_t mask_
 
uint32_t value_
 
bool cannot_match_
 

Detailed Description

Definition at line 518 of file jsregexp.h.

Constructor & Destructor Documentation

◆ QuickCheckDetails() [1/2]

v8::internal::QuickCheckDetails::QuickCheckDetails ( )
inline

Definition at line 520 of file jsregexp.h.

◆ QuickCheckDetails() [2/2]

v8::internal::QuickCheckDetails::QuickCheckDetails ( int  characters)
inlineexplicit

Definition at line 525 of file jsregexp.h.

527  mask_(0),
528  value_(0),
529  cannot_match_(false) { }

Member Function Documentation

◆ Advance()

void v8::internal::QuickCheckDetails::Advance ( int  by,
bool  one_byte 
)

Definition at line 2691 of file jsregexp.cc.

2691  {
2692  DCHECK(by >= 0);
2693  if (by >= characters_) {
2694  Clear();
2695  return;
2696  }
2697  for (int i = 0; i < characters_ - by; i++) {
2698  positions_[i] = positions_[by + i];
2699  }
2700  for (int i = characters_ - by; i < characters_; i++) {
2701  positions_[i].mask = 0;
2702  positions_[i].value = 0;
2704  }
2705  characters_ -= by;
2706  // We could change mask_ and value_ here but we would never advance unless
2707  // they had already been used in a check and they won't be used again because
2708  // it would gain us nothing. So there's no point.
2709 }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK.

Referenced by v8::internal::Trace::AdvanceCurrentPositionInTrace().

+ Here is the caller graph for this function:

◆ cannot_match()

bool v8::internal::QuickCheckDetails::cannot_match ( )
inline

Definition at line 536 of file jsregexp.h.

536 { return cannot_match_; }

References cannot_match_.

Referenced by v8::internal::ChoiceNode::EmitChoices(), v8::internal::RegExpNode::EmitQuickCheck(), and v8::internal::TextNode::GetQuickCheckDetails().

+ Here is the caller graph for this function:

◆ characters()

int v8::internal::QuickCheckDetails::characters ( )
inline

Definition at line 544 of file jsregexp.h.

544 { return characters_; }

References characters_.

Referenced by v8::internal::DeterminedAlready(), v8::internal::RegExpNode::EmitQuickCheck(), v8::internal::TextNode::GetQuickCheckDetails(), v8::internal::ChoiceNode::GetQuickCheckDetails(), v8::internal::Trace::is_trivial(), and set_characters().

+ Here is the caller graph for this function:

◆ Clear()

void v8::internal::QuickCheckDetails::Clear ( )

Definition at line 2681 of file jsregexp.cc.

2681  {
2682  for (int i = 0; i < characters_; i++) {
2683  positions_[i].mask = 0;
2684  positions_[i].value = 0;
2686  }
2687  characters_ = 0;
2688 }

Referenced by v8::internal::ChoiceNode::EmitChoices().

+ Here is the caller graph for this function:

◆ mask()

uint32_t v8::internal::QuickCheckDetails::mask ( )
inline

Definition at line 551 of file jsregexp.h.

551 { return mask_; }

References mask_.

Referenced by v8::internal::RegExpNode::EmitQuickCheck().

+ Here is the caller graph for this function:

◆ Merge()

void v8::internal::QuickCheckDetails::Merge ( QuickCheckDetails other,
int  from_index 
)

Definition at line 2712 of file jsregexp.cc.

2712  {
2713  DCHECK(characters_ == other->characters_);
2714  if (other->cannot_match_) {
2715  return;
2716  }
2717  if (cannot_match_) {
2718  *this = *other;
2719  return;
2720  }
2721  for (int i = from_index; i < characters_; i++) {
2722  QuickCheckDetails::Position* pos = positions(i);
2723  QuickCheckDetails::Position* other_pos = other->positions(i);
2724  if (pos->mask != other_pos->mask ||
2725  pos->value != other_pos->value ||
2726  !other_pos->determines_perfectly) {
2727  // Our mask-compare operation will be approximate unless we have the
2728  // exact same operation on both sides of the alternation.
2729  pos->determines_perfectly = false;
2730  }
2731  pos->mask &= other_pos->mask;
2732  pos->value &= pos->mask;
2733  other_pos->value &= pos->mask;
2734  uc16 differing_bits = (pos->value ^ other_pos->value);
2735  pos->mask &= ~differing_bits;
2736  pos->value &= pos->mask;
2737  }
2738 }
Position * positions(int index)
Definition: jsregexp.h:546
uint16_t uc16
Definition: globals.h:184

References cannot_match_, characters_, DCHECK, v8::internal::QuickCheckDetails::Position::determines_perfectly, v8::internal::QuickCheckDetails::Position::mask, positions(), and v8::internal::QuickCheckDetails::Position::value.

Referenced by v8::internal::ChoiceNode::GetQuickCheckDetails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ positions()

Position* v8::internal::QuickCheckDetails::positions ( int  index)
inline

Definition at line 546 of file jsregexp.h.

546  {
547  DCHECK(index >= 0);
548  DCHECK(index < characters_);
549  return positions_ + index;
550  }

References characters_, DCHECK, and positions_.

Referenced by v8::internal::DeterminedAlready(), v8::internal::TextNode::GetQuickCheckDetails(), and Merge().

+ Here is the caller graph for this function:

◆ Rationalize()

bool v8::internal::QuickCheckDetails::Rationalize ( bool  one_byte)

Definition at line 2421 of file jsregexp.cc.

2421  {
2422  bool found_useful_op = false;
2423  uint32_t char_mask;
2424  if (asc) {
2425  char_mask = String::kMaxOneByteCharCode;
2426  } else {
2427  char_mask = String::kMaxUtf16CodeUnit;
2428  }
2429  mask_ = 0;
2430  value_ = 0;
2431  int char_shift = 0;
2432  for (int i = 0; i < characters_; i++) {
2433  Position* pos = &positions_[i];
2434  if ((pos->mask & String::kMaxOneByteCharCode) != 0) {
2435  found_useful_op = true;
2436  }
2437  mask_ |= (pos->mask & char_mask) << char_shift;
2438  value_ |= (pos->value & char_mask) << char_shift;
2439  char_shift += asc ? 8 : 16;
2440  }
2441  return found_useful_op;
2442 }
static const int32_t kMaxOneByteCharCode
Definition: objects.h:8811
static const int kMaxUtf16CodeUnit
Definition: objects.h:8813

References v8::internal::String::kMaxOneByteCharCode, v8::internal::String::kMaxUtf16CodeUnit, v8::internal::QuickCheckDetails::Position::mask, and v8::internal::QuickCheckDetails::Position::value.

Referenced by v8::internal::RegExpNode::EmitQuickCheck().

+ Here is the caller graph for this function:

◆ set_cannot_match()

void v8::internal::QuickCheckDetails::set_cannot_match ( )
inline

Definition at line 537 of file jsregexp.h.

537 { cannot_match_ = true; }

References cannot_match_.

Referenced by v8::internal::TextNode::GetQuickCheckDetails(), and v8::internal::AssertionNode::GetQuickCheckDetails().

+ Here is the caller graph for this function:

◆ set_characters()

void v8::internal::QuickCheckDetails::set_characters ( int  characters)
inline

Definition at line 545 of file jsregexp.h.

545 { characters_ = characters; }

References characters(), and characters_.

Referenced by v8::internal::ChoiceNode::EmitChoices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value()

uint32_t v8::internal::QuickCheckDetails::value ( )
inline

Definition at line 552 of file jsregexp.h.

552 { return value_; }

References value_.

Referenced by v8::internal::RegExpNode::EmitQuickCheck().

+ Here is the caller graph for this function:

Member Data Documentation

◆ cannot_match_

bool v8::internal::QuickCheckDetails::cannot_match_
private

Definition at line 564 of file jsregexp.h.

Referenced by cannot_match(), Merge(), and set_cannot_match().

◆ characters_

int v8::internal::QuickCheckDetails::characters_
private

Definition at line 557 of file jsregexp.h.

Referenced by characters(), Merge(), positions(), and set_characters().

◆ mask_

uint32_t v8::internal::QuickCheckDetails::mask_
private

Definition at line 560 of file jsregexp.h.

Referenced by mask().

◆ positions_

Position v8::internal::QuickCheckDetails::positions_[4]
private

Definition at line 558 of file jsregexp.h.

Referenced by positions().

◆ value_

uint32_t v8::internal::QuickCheckDetails::value_
private

Definition at line 561 of file jsregexp.h.

Referenced by value().


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