V8 Project
v8::internal::AssertionNode Class Reference

#include <jsregexp.h>

+ Inheritance diagram for v8::internal::AssertionNode:
+ Collaboration diagram for v8::internal::AssertionNode:

Public Types

enum  AssertionType {
  AT_END , AT_START , AT_BOUNDARY , AT_NON_BOUNDARY ,
  AFTER_NEWLINE
}
 

Public Member Functions

virtual void Accept (NodeVisitor *visitor)
 
virtual void Emit (RegExpCompiler *compiler, Trace *trace)
 
virtual int EatsAtLeast (int still_to_find, int budget, bool not_at_start)
 
virtual void GetQuickCheckDetails (QuickCheckDetails *details, RegExpCompiler *compiler, int filled_in, bool not_at_start)
 
virtual void FillInBMInfo (int offset, int budget, BoyerMooreLookahead *bm, bool not_at_start)
 
AssertionType assertion_type ()
 
- Public Member Functions inherited from v8::internal::SeqRegExpNode
 SeqRegExpNode (RegExpNode *on_success)
 
RegExpNodeon_success ()
 
void set_on_success (RegExpNode *node)
 
virtual RegExpNodeFilterOneByte (int depth, bool ignore_case)
 
- Public Member Functions inherited from v8::internal::RegExpNode
 RegExpNode (Zone *zone)
 
virtual ~RegExpNode ()
 
bool EmitQuickCheck (RegExpCompiler *compiler, Trace *bounds_check_trace, Trace *trace, bool preload_has_checked_bounds, Label *on_possible_success, QuickCheckDetails *details_return, bool fall_through_on_failure)
 
virtual int GreedyLoopTextLength ()
 
virtual RegExpNodeGetSuccessorOfOmnivorousTextNode (RegExpCompiler *compiler)
 
RegExpNodereplacement ()
 
RegExpNodeset_replacement (RegExpNode *replacement)
 
void SaveBMInfo (BoyerMooreLookahead *bm, bool not_at_start, int offset)
 
Label * label ()
 
NodeInfoinfo ()
 
BoyerMooreLookaheadbm_info (bool not_at_start)
 
Zonezone () const
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Static Public Member Functions

static AssertionNodeAtEnd (RegExpNode *on_success)
 
static AssertionNodeAtStart (RegExpNode *on_success)
 
static AssertionNodeAtBoundary (RegExpNode *on_success)
 
static AssertionNodeAtNonBoundary (RegExpNode *on_success)
 
static AssertionNodeAfterNewline (RegExpNode *on_success)
 

Private Types

enum  IfPrevious { kIsNonWord , kIsWord }
 

Private Member Functions

void EmitBoundaryCheck (RegExpCompiler *compiler, Trace *trace)
 
void BacktrackIfPrevious (RegExpCompiler *compiler, Trace *trace, IfPrevious backtrack_if_previous)
 
 AssertionNode (AssertionType t, RegExpNode *on_success)
 

Private Attributes

AssertionType assertion_type_
 

Additional Inherited Members

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

Detailed Description

Definition at line 883 of file jsregexp.h.

Member Enumeration Documentation

◆ AssertionType

Enumerator
AT_END 
AT_START 
AT_BOUNDARY 
AT_NON_BOUNDARY 
AFTER_NEWLINE 

Definition at line 885 of file jsregexp.h.

◆ IfPrevious

Enumerator
kIsNonWord 
kIsWord 

Definition at line 922 of file jsregexp.h.

Constructor & Destructor Documentation

◆ AssertionNode()

v8::internal::AssertionNode::AssertionNode ( AssertionType  t,
RegExpNode on_success 
)
inlineprivate

Definition at line 926 of file jsregexp.h.

AssertionType assertion_type_
Definition: jsregexp.h:928
RegExpNode * on_success()
Definition: jsregexp.h:727
SeqRegExpNode(RegExpNode *on_success)
Definition: jsregexp.h:725

Referenced by AfterNewline(), AtBoundary(), AtEnd(), AtNonBoundary(), and AtStart().

+ Here is the caller graph for this function:

Member Function Documentation

◆ Accept()

virtual void v8::internal::AssertionNode::Accept ( NodeVisitor visitor)
virtual

◆ AfterNewline()

static AssertionNode* v8::internal::AssertionNode::AfterNewline ( RegExpNode on_success)
inlinestatic

Definition at line 904 of file jsregexp.h.

904  {
906  }
AssertionNode(AssertionType t, RegExpNode *on_success)
Definition: jsregexp.h:926
Zone * zone() const
Definition: jsregexp.h:668

References AFTER_NEWLINE, AssertionNode(), v8::internal::SeqRegExpNode::on_success(), and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ assertion_type()

AssertionType v8::internal::AssertionNode::assertion_type ( )
inline

Definition at line 918 of file jsregexp.h.

918 { return assertion_type_; }

References assertion_type_.

◆ AtBoundary()

static AssertionNode* v8::internal::AssertionNode::AtBoundary ( RegExpNode on_success)
inlinestatic

Definition at line 898 of file jsregexp.h.

898  {
900  }

References AssertionNode(), AT_BOUNDARY, v8::internal::SeqRegExpNode::on_success(), and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ AtEnd()

static AssertionNode* v8::internal::AssertionNode::AtEnd ( RegExpNode on_success)
inlinestatic

Definition at line 892 of file jsregexp.h.

892  {
893  return new(on_success->zone()) AssertionNode(AT_END, on_success);
894  }

References AssertionNode(), AT_END, v8::internal::SeqRegExpNode::on_success(), and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ AtNonBoundary()

static AssertionNode* v8::internal::AssertionNode::AtNonBoundary ( RegExpNode on_success)
inlinestatic

Definition at line 901 of file jsregexp.h.

901  {
903  }

References AssertionNode(), AT_NON_BOUNDARY, v8::internal::SeqRegExpNode::on_success(), and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ AtStart()

static AssertionNode* v8::internal::AssertionNode::AtStart ( RegExpNode on_success)
inlinestatic

Definition at line 895 of file jsregexp.h.

895  {
897  }

References AssertionNode(), AT_START, v8::internal::SeqRegExpNode::on_success(), and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ BacktrackIfPrevious()

void v8::internal::AssertionNode::BacktrackIfPrevious ( RegExpCompiler compiler,
Trace trace,
AssertionNode::IfPrevious  backtrack_if_previous 
)
private

Definition at line 3098 of file jsregexp.cc.

3101  {
3102  RegExpMacroAssembler* assembler = compiler->macro_assembler();
3103  Trace new_trace(*trace);
3104  new_trace.InvalidateCurrentCharacter();
3105 
3106  Label fall_through, dummy;
3107 
3108  Label* non_word = backtrack_if_previous == kIsNonWord ?
3109  new_trace.backtrack() :
3110  &fall_through;
3111  Label* word = backtrack_if_previous == kIsNonWord ?
3112  &fall_through :
3113  new_trace.backtrack();
3114 
3115  if (new_trace.cp_offset() == 0) {
3116  // The start of input counts as a non-word character, so the question is
3117  // decided if we are at the start.
3118  assembler->CheckAtStart(non_word);
3119  }
3120  // We already checked that we are not at the start of input so it must be
3121  // OK to load the previous character.
3122  assembler->LoadCurrentCharacter(new_trace.cp_offset() - 1, &dummy, false);
3123  EmitWordCheck(assembler, word, non_word, backtrack_if_previous == kIsNonWord);
3124 
3125  assembler->Bind(&fall_through);
3126  on_success()->Emit(compiler, &new_trace);
3127 }
virtual void Emit(RegExpCompiler *compiler, Trace *trace)=0
static void Trace(const char *msg,...)
Definition: scheduler.cc:21
static void EmitWordCheck(RegExpMacroAssembler *assembler, Label *word, Label *non_word, bool fall_through_on_word)
Definition: jsregexp.cc:2986

References v8::internal::Trace::backtrack(), v8::internal::RegExpMacroAssembler::Bind(), v8::internal::RegExpMacroAssembler::CheckAtStart(), v8::internal::Trace::cp_offset(), v8::internal::EmitWordCheck(), v8::internal::Trace::InvalidateCurrentCharacter(), v8::internal::RegExpMacroAssembler::LoadCurrentCharacter(), and v8::internal::RegExpCompiler::macro_assembler().

+ Here is the call graph for this function:

◆ EatsAtLeast()

int v8::internal::AssertionNode::EatsAtLeast ( int  still_to_find,
int  budget,
bool  not_at_start 
)
virtual

Implements v8::internal::RegExpNode.

Definition at line 2297 of file jsregexp.cc.

2299  {
2300  if (budget <= 0) return 0;
2301  // If we know we are not at the start and we are asked "how many characters
2302  // will you match if you succeed?" then we can answer anything since false
2303  // implies false. So lets just return the max answer (still_to_find) since
2304  // that won't prevent us from preloading a lot of characters for the other
2305  // branches in the node graph.
2306  if (assertion_type() == AT_START && not_at_start) return still_to_find;
2307  return on_success()->EatsAtLeast(still_to_find,
2308  budget - 1,
2309  not_at_start);
2310 }
AssertionType assertion_type()
Definition: jsregexp.h:918
virtual int EatsAtLeast(int still_to_find, int budget, bool not_at_start)=0

◆ Emit()

void v8::internal::AssertionNode::Emit ( RegExpCompiler compiler,
Trace trace 
)
virtual

Implements v8::internal::RegExpNode.

Definition at line 3145 of file jsregexp.cc.

3145  {
3146  RegExpMacroAssembler* assembler = compiler->macro_assembler();
3147  switch (assertion_type_) {
3148  case AT_END: {
3149  Label ok;
3150  assembler->CheckPosition(trace->cp_offset(), &ok);
3151  assembler->GoTo(trace->backtrack());
3152  assembler->Bind(&ok);
3153  break;
3154  }
3155  case AT_START: {
3156  if (trace->at_start() == Trace::FALSE_VALUE) {
3157  assembler->GoTo(trace->backtrack());
3158  return;
3159  }
3160  if (trace->at_start() == Trace::UNKNOWN) {
3161  assembler->CheckNotAtStart(trace->backtrack());
3162  Trace at_start_trace = *trace;
3163  at_start_trace.set_at_start(true);
3164  on_success()->Emit(compiler, &at_start_trace);
3165  return;
3166  }
3167  }
3168  break;
3169  case AFTER_NEWLINE:
3170  EmitHat(compiler, on_success(), trace);
3171  return;
3172  case AT_BOUNDARY:
3173  case AT_NON_BOUNDARY: {
3174  EmitBoundaryCheck(compiler, trace);
3175  return;
3176  }
3177  }
3178  on_success()->Emit(compiler, trace);
3179 }
void EmitBoundaryCheck(RegExpCompiler *compiler, Trace *trace)
Definition: jsregexp.cc:3047
static void EmitHat(RegExpCompiler *compiler, RegExpNode *on_success, Trace *trace)
Definition: jsregexp.cc:3012

References v8::internal::Trace::at_start(), v8::internal::Trace::backtrack(), v8::internal::RegExpMacroAssembler::Bind(), v8::internal::RegExpMacroAssembler::CheckNotAtStart(), v8::internal::RegExpMacroAssembler::CheckPosition(), v8::internal::Trace::cp_offset(), v8::internal::EmitHat(), v8::internal::Trace::FALSE_VALUE, v8::internal::RegExpMacroAssembler::GoTo(), v8::internal::RegExpCompiler::macro_assembler(), v8::internal::Trace::set_at_start(), and v8::internal::Trace::UNKNOWN.

+ Here is the call graph for this function:

◆ EmitBoundaryCheck()

void v8::internal::AssertionNode::EmitBoundaryCheck ( RegExpCompiler compiler,
Trace trace 
)
private

Definition at line 3047 of file jsregexp.cc.

3047  {
3048  RegExpMacroAssembler* assembler = compiler->macro_assembler();
3049  Trace::TriBool next_is_word_character = Trace::UNKNOWN;
3050  bool not_at_start = (trace->at_start() == Trace::FALSE_VALUE);
3051  BoyerMooreLookahead* lookahead = bm_info(not_at_start);
3052  if (lookahead == NULL) {
3053  int eats_at_least =
3056  not_at_start));
3057  if (eats_at_least >= 1) {
3058  BoyerMooreLookahead* bm =
3059  new(zone()) BoyerMooreLookahead(eats_at_least, compiler, zone());
3060  FillInBMInfo(0, kRecursionBudget, bm, not_at_start);
3061  if (bm->at(0)->is_non_word())
3062  next_is_word_character = Trace::FALSE_VALUE;
3063  if (bm->at(0)->is_word()) next_is_word_character = Trace::TRUE_VALUE;
3064  }
3065  } else {
3066  if (lookahead->at(0)->is_non_word())
3067  next_is_word_character = Trace::FALSE_VALUE;
3068  if (lookahead->at(0)->is_word())
3069  next_is_word_character = Trace::TRUE_VALUE;
3070  }
3071  bool at_boundary = (assertion_type_ == AssertionNode::AT_BOUNDARY);
3072  if (next_is_word_character == Trace::UNKNOWN) {
3073  Label before_non_word;
3074  Label before_word;
3075  if (trace->characters_preloaded() != 1) {
3076  assembler->LoadCurrentCharacter(trace->cp_offset(), &before_non_word);
3077  }
3078  // Fall through on non-word.
3079  EmitWordCheck(assembler, &before_word, &before_non_word, false);
3080  // Next character is not a word character.
3081  assembler->Bind(&before_non_word);
3082  Label ok;
3083  BacktrackIfPrevious(compiler, trace, at_boundary ? kIsNonWord : kIsWord);
3084  assembler->GoTo(&ok);
3085 
3086  assembler->Bind(&before_word);
3087  BacktrackIfPrevious(compiler, trace, at_boundary ? kIsWord : kIsNonWord);
3088  assembler->Bind(&ok);
3089  } else if (next_is_word_character == Trace::TRUE_VALUE) {
3090  BacktrackIfPrevious(compiler, trace, at_boundary ? kIsWord : kIsNonWord);
3091  } else {
3092  DCHECK(next_is_word_character == Trace::FALSE_VALUE);
3093  BacktrackIfPrevious(compiler, trace, at_boundary ? kIsNonWord : kIsWord);
3094  }
3095 }
virtual void FillInBMInfo(int offset, int budget, BoyerMooreLookahead *bm, bool not_at_start)
Definition: jsregexp.cc:2313
virtual int EatsAtLeast(int still_to_find, int budget, bool not_at_start)
Definition: jsregexp.cc:2297
void BacktrackIfPrevious(RegExpCompiler *compiler, Trace *trace, IfPrevious backtrack_if_previous)
Definition: jsregexp.cc:3098
BoyerMooreLookahead * bm_info(bool not_at_start)
Definition: jsregexp.h:664
static const int kRecursionBudget
Definition: jsregexp.h:621
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
const int kMaxLookaheadForBoyerMoore
Definition: jsregexp.cc:124

References v8::internal::BoyerMooreLookahead::at(), AT_BOUNDARY, v8::internal::Trace::at_start(), v8::internal::RegExpMacroAssembler::Bind(), v8::internal::Trace::characters_preloaded(), v8::internal::Trace::cp_offset(), DCHECK, v8::internal::EmitWordCheck(), v8::internal::Trace::FALSE_VALUE, v8::internal::RegExpMacroAssembler::GoTo(), v8::internal::BoyerMoorePositionInfo::is_non_word(), v8::internal::BoyerMoorePositionInfo::is_word(), v8::internal::kMaxLookaheadForBoyerMoore, v8::internal::RegExpMacroAssembler::LoadCurrentCharacter(), v8::internal::RegExpCompiler::macro_assembler(), v8::internal::Min(), NULL, v8::internal::Trace::TRUE_VALUE, and v8::internal::Trace::UNKNOWN.

+ Here is the call graph for this function:

◆ FillInBMInfo()

void v8::internal::AssertionNode::FillInBMInfo ( int  offset,
int  budget,
BoyerMooreLookahead bm,
bool  not_at_start 
)
virtual

Reimplemented from v8::internal::SeqRegExpNode.

Definition at line 2313 of file jsregexp.cc.

2316  {
2317  // Match the behaviour of EatsAtLeast on this node.
2318  if (assertion_type() == AT_START && not_at_start) return;
2319  on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start);
2320  SaveBMInfo(bm, not_at_start, offset);
2321 }
void SaveBMInfo(BoyerMooreLookahead *bm, bool not_at_start, int offset)
Definition: jsregexp.h:650
virtual void FillInBMInfo(int offset, int budget, BoyerMooreLookahead *bm, bool not_at_start)
Definition: jsregexp.h:622

◆ GetQuickCheckDetails()

void v8::internal::AssertionNode::GetQuickCheckDetails ( QuickCheckDetails details,
RegExpCompiler compiler,
int  filled_in,
bool  not_at_start 
)
virtual

Implements v8::internal::RegExpNode.

Definition at line 3130 of file jsregexp.cc.

3133  {
3134  if (assertion_type_ == AT_START && not_at_start) {
3135  details->set_cannot_match();
3136  return;
3137  }
3138  return on_success()->GetQuickCheckDetails(details,
3139  compiler,
3140  filled_in,
3141  not_at_start);
3142 }
virtual void GetQuickCheckDetails(QuickCheckDetails *details, RegExpCompiler *compiler, int characters_filled_in, bool not_at_start)=0

References v8::internal::QuickCheckDetails::set_cannot_match().

+ Here is the call graph for this function:

Member Data Documentation

◆ assertion_type_

AssertionType v8::internal::AssertionNode::assertion_type_
private

Definition at line 928 of file jsregexp.h.

Referenced by assertion_type().


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