V8 Project
v8::internal::RegExpNode Class Referenceabstract

#include <jsregexp.h>

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

Public Member Functions

 RegExpNode (Zone *zone)
 
virtual ~RegExpNode ()
 
virtual void Accept (NodeVisitor *visitor)=0
 
virtual void Emit (RegExpCompiler *compiler, Trace *trace)=0
 
virtual int EatsAtLeast (int still_to_find, int budget, bool not_at_start)=0
 
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 void GetQuickCheckDetails (QuickCheckDetails *details, RegExpCompiler *compiler, int characters_filled_in, bool not_at_start)=0
 
virtual int GreedyLoopTextLength ()
 
virtual RegExpNodeGetSuccessorOfOmnivorousTextNode (RegExpCompiler *compiler)
 
virtual void FillInBMInfo (int offset, int budget, BoyerMooreLookahead *bm, bool not_at_start)
 
virtual RegExpNodeFilterOneByte (int depth, bool ignore_case)
 
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 Attributes

static const int kNodeIsTooComplexForGreedyLoops = -1
 
static const int kRecursionBudget = 200
 
static const int kMaxCopiesCodeGenerated = 10
 

Protected Types

enum  LimitResult { DONE , CONTINUE }
 

Protected Member Functions

LimitResult LimitVersions (RegExpCompiler *compiler, Trace *trace)
 
void set_bm_info (bool not_at_start, BoyerMooreLookahead *bm)
 

Protected Attributes

RegExpNodereplacement_
 

Private Attributes

Label label_
 
NodeInfo info_
 
int trace_count_
 
BoyerMooreLookaheadbm_info_ [2]
 
Zonezone_
 

Static Private Attributes

static const int kFirstCharBudget = 10
 

Detailed Description

Definition at line 571 of file jsregexp.h.

Member Enumeration Documentation

◆ LimitResult

Enumerator
DONE 
CONTINUE 

Definition at line 671 of file jsregexp.h.

Constructor & Destructor Documentation

◆ RegExpNode()

v8::internal::RegExpNode::RegExpNode ( Zone zone)
inlineexplicit

Definition at line 573 of file jsregexp.h.

575  bm_info_[0] = bm_info_[1] = NULL;
576  }
Zone * zone() const
Definition: jsregexp.h:668
BoyerMooreLookahead * bm_info_[2]
Definition: jsregexp.h:690
RegExpNode * replacement_
Definition: jsregexp.h:672
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

References bm_info_, and NULL.

◆ ~RegExpNode()

v8::internal::RegExpNode::~RegExpNode ( )
virtual

Definition at line 2225 of file jsregexp.cc.

2225  {
2226 }

Member Function Documentation

◆ Accept()

virtual void v8::internal::RegExpNode::Accept ( NodeVisitor visitor)
pure virtual

Implemented in v8::internal::LoopChoiceNode, v8::internal::ChoiceNode, v8::internal::EndNode, v8::internal::BackReferenceNode, v8::internal::AssertionNode, v8::internal::TextNode, and v8::internal::ActionNode.

Referenced by v8::internal::Analysis::EnsureAnalyzed().

+ Here is the caller graph for this function:

◆ bm_info()

BoyerMooreLookahead* v8::internal::RegExpNode::bm_info ( bool  not_at_start)
inline

Definition at line 664 of file jsregexp.h.

664  {
665  return bm_info_[not_at_start ? 1 : 0];
666  }

References bm_info_.

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

+ Here is the caller graph for this function:

◆ EatsAtLeast()

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

◆ Emit()

◆ EmitQuickCheck()

bool v8::internal::RegExpNode::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 
)

Definition at line 2445 of file jsregexp.cc.

2451  {
2452  if (details->characters() == 0) return false;
2454  details, compiler, 0, trace->at_start() == Trace::FALSE_VALUE);
2455  if (details->cannot_match()) return false;
2456  if (!details->Rationalize(compiler->one_byte())) return false;
2457  DCHECK(details->characters() == 1 ||
2458  compiler->macro_assembler()->CanReadUnaligned());
2459  uint32_t mask = details->mask();
2460  uint32_t value = details->value();
2461 
2462  RegExpMacroAssembler* assembler = compiler->macro_assembler();
2463 
2464  if (trace->characters_preloaded() != details->characters()) {
2465  DCHECK(trace->cp_offset() == bounds_check_trace->cp_offset());
2466  // We are attempting to preload the minimum number of characters
2467  // any choice would eat, so if the bounds check fails, then none of the
2468  // choices can succeed, so we can just immediately backtrack, rather
2469  // than go to the next choice.
2470  assembler->LoadCurrentCharacter(trace->cp_offset(),
2471  bounds_check_trace->backtrack(),
2472  !preload_has_checked_bounds,
2473  details->characters());
2474  }
2475 
2476 
2477  bool need_mask = true;
2478 
2479  if (details->characters() == 1) {
2480  // If number of characters preloaded is 1 then we used a byte or 16 bit
2481  // load so the value is already masked down.
2482  uint32_t char_mask;
2483  if (compiler->one_byte()) {
2484  char_mask = String::kMaxOneByteCharCode;
2485  } else {
2486  char_mask = String::kMaxUtf16CodeUnit;
2487  }
2488  if ((mask & char_mask) == char_mask) need_mask = false;
2489  mask &= char_mask;
2490  } else {
2491  // For 2-character preloads in one-byte mode or 1-character preloads in
2492  // two-byte mode we also use a 16 bit load with zero extend.
2493  if (details->characters() == 2 && compiler->one_byte()) {
2494  if ((mask & 0xffff) == 0xffff) need_mask = false;
2495  } else if (details->characters() == 1 && !compiler->one_byte()) {
2496  if ((mask & 0xffff) == 0xffff) need_mask = false;
2497  } else {
2498  if (mask == 0xffffffff) need_mask = false;
2499  }
2500  }
2501 
2502  if (fall_through_on_failure) {
2503  if (need_mask) {
2504  assembler->CheckCharacterAfterAnd(value, mask, on_possible_success);
2505  } else {
2506  assembler->CheckCharacter(value, on_possible_success);
2507  }
2508  } else {
2509  if (need_mask) {
2510  assembler->CheckNotCharacterAfterAnd(value, mask, trace->backtrack());
2511  } else {
2512  assembler->CheckNotCharacter(value, trace->backtrack());
2513  }
2514  }
2515  return true;
2516 }
virtual void GetQuickCheckDetails(QuickCheckDetails *details, RegExpCompiler *compiler, int characters_filled_in, bool not_at_start)=0
static const int32_t kMaxOneByteCharCode
Definition: objects.h:8811
static const int kMaxUtf16CodeUnit
Definition: objects.h:8813
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::Trace::at_start(), v8::internal::Trace::backtrack(), v8::internal::QuickCheckDetails::cannot_match(), v8::internal::RegExpMacroAssembler::CanReadUnaligned(), v8::internal::QuickCheckDetails::characters(), v8::internal::Trace::characters_preloaded(), v8::internal::RegExpMacroAssembler::CheckCharacter(), v8::internal::RegExpMacroAssembler::CheckCharacterAfterAnd(), v8::internal::RegExpMacroAssembler::CheckNotCharacter(), v8::internal::RegExpMacroAssembler::CheckNotCharacterAfterAnd(), v8::internal::Trace::cp_offset(), DCHECK, v8::internal::Trace::FALSE_VALUE, v8::internal::String::kMaxOneByteCharCode, v8::internal::String::kMaxUtf16CodeUnit, v8::internal::RegExpMacroAssembler::LoadCurrentCharacter(), v8::internal::RegExpCompiler::macro_assembler(), v8::internal::QuickCheckDetails::mask(), v8::internal::RegExpCompiler::one_byte(), v8::internal::QuickCheckDetails::Rationalize(), and v8::internal::QuickCheckDetails::value().

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

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

◆ FillInBMInfo()

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

◆ FilterOneByte()

virtual RegExpNode* v8::internal::RegExpNode::FilterOneByte ( int  depth,
bool  ignore_case 
)
inlinevirtual

Reimplemented in v8::internal::LoopChoiceNode, v8::internal::NegativeLookaheadChoiceNode, v8::internal::ChoiceNode, v8::internal::TextNode, and v8::internal::SeqRegExpNode.

Definition at line 632 of file jsregexp.h.

632  {
633  return this;
634  }

Referenced by v8::internal::RegExpEngine::Compile(), v8::internal::ChoiceNode::FilterOneByte(), v8::internal::NegativeLookaheadChoiceNode::FilterOneByte(), v8::internal::LoopChoiceNode::FilterOneByte(), and v8::internal::SeqRegExpNode::FilterSuccessor().

+ Here is the caller graph for this function:

◆ GetQuickCheckDetails()

virtual void v8::internal::RegExpNode::GetQuickCheckDetails ( QuickCheckDetails details,
RegExpCompiler compiler,
int  characters_filled_in,
bool  not_at_start 
)
pure virtual

◆ GetSuccessorOfOmnivorousTextNode()

virtual RegExpNode* v8::internal::RegExpNode::GetSuccessorOfOmnivorousTextNode ( RegExpCompiler compiler)
inlinevirtual

Reimplemented in v8::internal::TextNode.

Definition at line 611 of file jsregexp.h.

612  {
613  return NULL;
614  }

References NULL.

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

+ Here is the caller graph for this function:

◆ GreedyLoopTextLength()

virtual int v8::internal::RegExpNode::GreedyLoopTextLength ( )
inlinevirtual

Reimplemented in v8::internal::TextNode, and v8::internal::ActionNode.

Definition at line 608 of file jsregexp.h.

static const int kNodeIsTooComplexForGreedyLoops
Definition: jsregexp.h:607

References kNodeIsTooComplexForGreedyLoops.

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

+ Here is the caller graph for this function:

◆ info()

NodeInfo* v8::internal::RegExpNode::info ( )
inline

Definition at line 662 of file jsregexp.h.

662 { return &info_; }

References info_.

Referenced by v8::internal::Analysis::EnsureAnalyzed(), replacement(), set_replacement(), and v8::internal::Analysis::VisitLoopChoice().

+ Here is the caller graph for this function:

◆ label()

Label* v8::internal::RegExpNode::label ( )
inline

Definition at line 654 of file jsregexp.h.

654 { return &label_; }

References label_.

◆ LimitVersions()

RegExpNode::LimitResult v8::internal::RegExpNode::LimitVersions ( RegExpCompiler compiler,
Trace trace 
)
protected

Definition at line 2229 of file jsregexp.cc.

2230  {
2231  // If we are generating a greedy loop then don't stop and don't reuse code.
2232  if (trace->stop_node() != NULL) {
2233  return CONTINUE;
2234  }
2235 
2236  RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
2237  if (trace->is_trivial()) {
2238  if (label_.is_bound()) {
2239  // We are being asked to generate a generic version, but that's already
2240  // been done so just go to it.
2241  macro_assembler->GoTo(&label_);
2242  return DONE;
2243  }
2244  if (compiler->recursion_depth() >= RegExpCompiler::kMaxRecursion) {
2245  // To avoid too deep recursion we push the node to the work queue and just
2246  // generate a goto here.
2247  compiler->AddWork(this);
2248  macro_assembler->GoTo(&label_);
2249  return DONE;
2250  }
2251  // Generate generic version of the node and bind the label for later use.
2252  macro_assembler->Bind(&label_);
2253  return CONTINUE;
2254  }
2255 
2256  // We are being asked to make a non-generic version. Keep track of how many
2257  // non-generic versions we generate so as not to overdo it.
2258  trace_count_++;
2259  if (FLAG_regexp_optimization &&
2261  compiler->recursion_depth() <= RegExpCompiler::kMaxRecursion) {
2262  return CONTINUE;
2263  }
2264 
2265  // If we get here code has been generated for this node too many times or
2266  // recursion is too deep. Time to switch to a generic version. The code for
2267  // generic versions above can handle deep recursion properly.
2268  trace->Flush(compiler, this);
2269  return DONE;
2270 }
static const int kMaxRecursion
Definition: jsregexp.cc:1020
static const int kMaxCopiesCodeGenerated
Definition: jsregexp.h:660

References v8::internal::RegExpCompiler::AddWork(), v8::internal::RegExpMacroAssembler::Bind(), v8::internal::DONE, v8::internal::Trace::Flush(), v8::internal::RegExpMacroAssembler::GoTo(), v8::internal::Trace::is_trivial(), v8::internal::RegExpCompiler::kMaxRecursion, v8::internal::RegExpCompiler::macro_assembler(), NULL, v8::internal::RegExpCompiler::recursion_depth(), and v8::internal::Trace::stop_node().

Referenced by v8::internal::ActionNode::Emit(), v8::internal::BackReferenceNode::Emit(), and v8::internal::ChoiceNode::Emit().

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

◆ replacement()

RegExpNode* v8::internal::RegExpNode::replacement ( )
inline

Definition at line 636 of file jsregexp.h.

636  {
637  DCHECK(info()->replacement_calculated);
638  return replacement_;
639  }

References DCHECK, info(), and replacement_.

Referenced by set_replacement().

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

◆ SaveBMInfo()

void v8::internal::RegExpNode::SaveBMInfo ( BoyerMooreLookahead bm,
bool  not_at_start,
int  offset 
)
inline

Definition at line 650 of file jsregexp.h.

650  {
651  if (offset == 0) set_bm_info(not_at_start, bm);
652  }
void set_bm_info(bool not_at_start, BoyerMooreLookahead *bm)
Definition: jsregexp.h:676

References set_bm_info().

Referenced by v8::internal::BackReferenceNode::FillInBMInfo(), and v8::internal::ChoiceNode::FillInBMInfo().

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

◆ set_bm_info()

void v8::internal::RegExpNode::set_bm_info ( bool  not_at_start,
BoyerMooreLookahead bm 
)
inlineprotected

Definition at line 676 of file jsregexp.h.

676  {
677  bm_info_[not_at_start ? 1 : 0] = bm;
678  }

References bm_info_.

Referenced by v8::internal::SeqRegExpNode::FillInBMInfo(), v8::internal::TextNode::FillInBMInfo(), v8::internal::NegativeLookaheadChoiceNode::FillInBMInfo(), and SaveBMInfo().

+ Here is the caller graph for this function:

◆ set_replacement()

RegExpNode* v8::internal::RegExpNode::set_replacement ( RegExpNode replacement)
inline

Definition at line 640 of file jsregexp.h.

640  {
641  info()->replacement_calculated = true;
643  return replacement; // For convenience.
644  }
RegExpNode * replacement()
Definition: jsregexp.h:636

References info(), replacement(), replacement_, and v8::internal::NodeInfo::replacement_calculated.

+ Here is the call graph for this function:

◆ zone()

Member Data Documentation

◆ bm_info_

BoyerMooreLookahead* v8::internal::RegExpNode::bm_info_[2]
private

Definition at line 690 of file jsregexp.h.

Referenced by bm_info(), RegExpNode(), and set_bm_info().

◆ info_

NodeInfo v8::internal::RegExpNode::info_
private

Definition at line 683 of file jsregexp.h.

Referenced by info().

◆ kFirstCharBudget

const int v8::internal::RegExpNode::kFirstCharBudget = 10
staticprivate

Definition at line 681 of file jsregexp.h.

◆ kMaxCopiesCodeGenerated

const int v8::internal::RegExpNode::kMaxCopiesCodeGenerated = 10
static

Definition at line 660 of file jsregexp.h.

◆ kNodeIsTooComplexForGreedyLoops

const int v8::internal::RegExpNode::kNodeIsTooComplexForGreedyLoops = -1
static

◆ kRecursionBudget

const int v8::internal::RegExpNode::kRecursionBudget = 200
static

◆ label_

Label v8::internal::RegExpNode::label_
private

Definition at line 682 of file jsregexp.h.

Referenced by label().

◆ replacement_

RegExpNode* v8::internal::RegExpNode::replacement_
protected

Definition at line 672 of file jsregexp.h.

Referenced by replacement(), and set_replacement().

◆ trace_count_

int v8::internal::RegExpNode::trace_count_
private

Definition at line 689 of file jsregexp.h.

◆ zone_

Zone* v8::internal::RegExpNode::zone_
private

Definition at line 692 of file jsregexp.h.

Referenced by zone().


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