V8 Project
v8::internal::ActionNode Class Reference

#include <jsregexp.h>

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

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 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)
 
ActionType action_type ()
 
virtual int GreedyLoopTextLength ()
 
- 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 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 ActionNodeSetRegister (int reg, int val, RegExpNode *on_success)
 
static ActionNodeIncrementRegister (int reg, RegExpNode *on_success)
 
static ActionNodeStorePosition (int reg, bool is_capture, RegExpNode *on_success)
 
static ActionNodeClearCaptures (Interval range, RegExpNode *on_success)
 
static ActionNodeBeginSubmatch (int stack_pointer_reg, int position_reg, RegExpNode *on_success)
 
static ActionNodePositiveSubmatchSuccess (int stack_pointer_reg, int restore_reg, int clear_capture_count, int clear_capture_from, RegExpNode *on_success)
 
static ActionNodeEmptyMatchCheck (int start_register, int repetition_register, int repetition_limit, RegExpNode *on_success)
 

Private Member Functions

 ActionNode (ActionType action_type, RegExpNode *on_success)
 

Private Attributes

union {
   struct {
      int   reg
 
      int   value
 
   }   u_store_register
 
   struct {
      int   reg
 
   }   u_increment_register
 
   struct {
      int   reg
 
      bool   is_capture
 
   }   u_position_register
 
   struct {
      int   stack_pointer_register
 
      int   current_position_register
 
      int   clear_register_count
 
      int   clear_register_from
 
   }   u_submatch
 
   struct {
      int   start_register
 
      int   repetition_register
 
      int   repetition_limit
 
   }   u_empty_match_check
 
   struct {
      int   range_from
 
      int   range_to
 
   }   u_clear_captures
 
data_
 
ActionType action_type_
 

Friends

class DotPrinter
 

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 746 of file jsregexp.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 748 of file jsregexp.h.

Constructor & Destructor Documentation

◆ ActionNode()

v8::internal::ActionNode::ActionNode ( ActionType  action_type,
RegExpNode on_success 
)
inlineprivate

Definition at line 822 of file jsregexp.h.

ActionType action_type_
Definition: jsregexp.h:825
ActionType action_type()
Definition: jsregexp.h:789
RegExpNode * on_success()
Definition: jsregexp.h:727
SeqRegExpNode(RegExpNode *on_success)
Definition: jsregexp.h:725

Member Function Documentation

◆ Accept()

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

◆ action_type()

ActionType v8::internal::ActionNode::action_type ( )
inline

Definition at line 789 of file jsregexp.h.

789 { return action_type_; }

References action_type_.

◆ BeginSubmatch()

ActionNode * v8::internal::ActionNode::BeginSubmatch ( int  stack_pointer_reg,
int  position_reg,
RegExpNode on_success 
)
static

Definition at line 1512 of file jsregexp.cc.

1514  {
1515  ActionNode* result =
1517  result->data_.u_submatch.stack_pointer_register = stack_reg;
1518  result->data_.u_submatch.current_position_register = position_reg;
1519  return result;
1520 }
ActionNode(ActionType action_type, RegExpNode *on_success)
Definition: jsregexp.h:822
Zone * zone() const
Definition: jsregexp.h:668

References data_, u_submatch, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ ClearCaptures()

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

Definition at line 1502 of file jsregexp.cc.

1503  {
1504  ActionNode* result =
1506  result->data_.u_clear_captures.range_from = range.from();
1507  result->data_.u_clear_captures.range_to = range.to();
1508  return result;
1509 }

References data_, v8::internal::Interval::from(), v8::internal::Interval::to(), u_clear_captures, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ EatsAtLeast()

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

Implements v8::internal::RegExpNode.

Definition at line 2273 of file jsregexp.cc.

2275  {
2276  if (budget <= 0) return 0;
2277  if (action_type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input!
2278  return on_success()->EatsAtLeast(still_to_find,
2279  budget - 1,
2280  not_at_start);
2281 }
virtual int EatsAtLeast(int still_to_find, int budget, bool not_at_start)=0

◆ Emit()

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

Implements v8::internal::RegExpNode.

Definition at line 4234 of file jsregexp.cc.

4234  {
4235  RegExpMacroAssembler* assembler = compiler->macro_assembler();
4236  LimitResult limit_result = LimitVersions(compiler, trace);
4237  if (limit_result == DONE) return;
4238  DCHECK(limit_result == CONTINUE);
4239 
4240  RecursionCheck rc(compiler);
4241 
4242  switch (action_type_) {
4243  case STORE_POSITION: {
4244  Trace::DeferredCapture
4245  new_capture(data_.u_position_register.reg,
4246  data_.u_position_register.is_capture,
4247  trace);
4248  Trace new_trace = *trace;
4249  new_trace.add_action(&new_capture);
4250  on_success()->Emit(compiler, &new_trace);
4251  break;
4252  }
4253  case INCREMENT_REGISTER: {
4254  Trace::DeferredIncrementRegister
4255  new_increment(data_.u_increment_register.reg);
4256  Trace new_trace = *trace;
4257  new_trace.add_action(&new_increment);
4258  on_success()->Emit(compiler, &new_trace);
4259  break;
4260  }
4261  case SET_REGISTER: {
4262  Trace::DeferredSetRegister
4263  new_set(data_.u_store_register.reg, data_.u_store_register.value);
4264  Trace new_trace = *trace;
4265  new_trace.add_action(&new_set);
4266  on_success()->Emit(compiler, &new_trace);
4267  break;
4268  }
4269  case CLEAR_CAPTURES: {
4270  Trace::DeferredClearCaptures
4271  new_capture(Interval(data_.u_clear_captures.range_from,
4272  data_.u_clear_captures.range_to));
4273  Trace new_trace = *trace;
4274  new_trace.add_action(&new_capture);
4275  on_success()->Emit(compiler, &new_trace);
4276  break;
4277  }
4278  case BEGIN_SUBMATCH:
4279  if (!trace->is_trivial()) {
4280  trace->Flush(compiler, this);
4281  } else {
4282  assembler->WriteCurrentPositionToRegister(
4283  data_.u_submatch.current_position_register, 0);
4284  assembler->WriteStackPointerToRegister(
4285  data_.u_submatch.stack_pointer_register);
4286  on_success()->Emit(compiler, trace);
4287  }
4288  break;
4289  case EMPTY_MATCH_CHECK: {
4290  int start_pos_reg = data_.u_empty_match_check.start_register;
4291  int stored_pos = 0;
4292  int rep_reg = data_.u_empty_match_check.repetition_register;
4293  bool has_minimum = (rep_reg != RegExpCompiler::kNoRegister);
4294  bool know_dist = trace->GetStoredPosition(start_pos_reg, &stored_pos);
4295  if (know_dist && !has_minimum && stored_pos == trace->cp_offset()) {
4296  // If we know we haven't advanced and there is no minimum we
4297  // can just backtrack immediately.
4298  assembler->GoTo(trace->backtrack());
4299  } else if (know_dist && stored_pos < trace->cp_offset()) {
4300  // If we know we've advanced we can generate the continuation
4301  // immediately.
4302  on_success()->Emit(compiler, trace);
4303  } else if (!trace->is_trivial()) {
4304  trace->Flush(compiler, this);
4305  } else {
4306  Label skip_empty_check;
4307  // If we have a minimum number of repetitions we check the current
4308  // number first and skip the empty check if it's not enough.
4309  if (has_minimum) {
4310  int limit = data_.u_empty_match_check.repetition_limit;
4311  assembler->IfRegisterLT(rep_reg, limit, &skip_empty_check);
4312  }
4313  // If the match is empty we bail out, otherwise we fall through
4314  // to the on-success continuation.
4315  assembler->IfRegisterEqPos(data_.u_empty_match_check.start_register,
4316  trace->backtrack());
4317  assembler->Bind(&skip_empty_check);
4318  on_success()->Emit(compiler, trace);
4319  }
4320  break;
4321  }
4323  if (!trace->is_trivial()) {
4324  trace->Flush(compiler, this);
4325  return;
4326  }
4327  assembler->ReadCurrentPositionFromRegister(
4328  data_.u_submatch.current_position_register);
4329  assembler->ReadStackPointerFromRegister(
4330  data_.u_submatch.stack_pointer_register);
4331  int clear_register_count = data_.u_submatch.clear_register_count;
4332  if (clear_register_count == 0) {
4333  on_success()->Emit(compiler, trace);
4334  return;
4335  }
4336  int clear_registers_from = data_.u_submatch.clear_register_from;
4337  Label clear_registers_backtrack;
4338  Trace new_trace = *trace;
4339  new_trace.set_backtrack(&clear_registers_backtrack);
4340  on_success()->Emit(compiler, &new_trace);
4341 
4342  assembler->Bind(&clear_registers_backtrack);
4343  int clear_registers_to = clear_registers_from + clear_register_count - 1;
4344  assembler->ClearRegisters(clear_registers_from, clear_registers_to);
4345 
4346  DCHECK(trace->backtrack() == NULL);
4347  assembler->Backtrack();
4348  return;
4349  }
4350  default:
4351  UNREACHABLE();
4352  }
4353 }
union v8::internal::ActionNode::@22 data_
static const int kNoRegister
Definition: jsregexp.cc:1038
LimitResult LimitVersions(RegExpCompiler *compiler, Trace *trace)
Definition: jsregexp.cc:2229
virtual void Emit(RegExpCompiler *compiler, Trace *trace)=0
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 UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205
static void Trace(const char *msg,...)
Definition: scheduler.cc:21

References action_type_, v8::internal::Trace::add_action(), v8::internal::Trace::backtrack(), v8::internal::RegExpMacroAssembler::Backtrack(), BEGIN_SUBMATCH, v8::internal::RegExpMacroAssembler::Bind(), CLEAR_CAPTURES, clear_register_count, v8::internal::RegExpMacroAssembler::ClearRegisters(), v8::internal::RegExpNode::CONTINUE, v8::internal::Trace::cp_offset(), data_, DCHECK, v8::internal::RegExpNode::DONE, v8::internal::RegExpNode::Emit(), EMPTY_MATCH_CHECK, v8::internal::Trace::Flush(), v8::internal::Trace::GetStoredPosition(), v8::internal::RegExpMacroAssembler::GoTo(), v8::internal::RegExpMacroAssembler::IfRegisterEqPos(), v8::internal::RegExpMacroAssembler::IfRegisterLT(), INCREMENT_REGISTER, v8::internal::Trace::is_trivial(), v8::internal::RegExpCompiler::kNoRegister, v8::internal::RegExpNode::LimitVersions(), v8::internal::RegExpCompiler::macro_assembler(), NULL, v8::internal::SeqRegExpNode::on_success(), POSITIVE_SUBMATCH_SUCCESS, v8::internal::RegExpMacroAssembler::ReadCurrentPositionFromRegister(), v8::internal::RegExpMacroAssembler::ReadStackPointerFromRegister(), v8::internal::Trace::set_backtrack(), SET_REGISTER, STORE_POSITION, UNREACHABLE, v8::internal::RegExpMacroAssembler::WriteCurrentPositionToRegister(), and v8::internal::RegExpMacroAssembler::WriteStackPointerToRegister().

+ Here is the call graph for this function:

◆ EmptyMatchCheck()

ActionNode * v8::internal::ActionNode::EmptyMatchCheck ( int  start_register,
int  repetition_register,
int  repetition_limit,
RegExpNode on_success 
)
static

Definition at line 1538 of file jsregexp.cc.

1541  {
1542  ActionNode* result =
1544  result->data_.u_empty_match_check.start_register = start_register;
1545  result->data_.u_empty_match_check.repetition_register = repetition_register;
1546  result->data_.u_empty_match_check.repetition_limit = repetition_limit;
1547  return result;
1548 }

References data_, u_empty_match_check, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ FillInBMInfo()

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

Reimplemented from v8::internal::SeqRegExpNode.

Definition at line 2284 of file jsregexp.cc.

2287  {
2288  if (action_type_ == BEGIN_SUBMATCH) {
2289  bm->SetRest(offset);
2290  } else if (action_type_ != POSITIVE_SUBMATCH_SUCCESS) {
2291  on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start);
2292  }
2293  SaveBMInfo(bm, not_at_start, offset);
2294 }
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

References v8::internal::BoyerMooreLookahead::SetRest().

+ Here is the call graph for this function:

◆ GetQuickCheckDetails()

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

Implements v8::internal::RegExpNode.

Definition at line 778 of file jsregexp.h.

781  {
783  details, compiler, filled_in, not_at_start);
784  }
virtual void GetQuickCheckDetails(QuickCheckDetails *details, RegExpCompiler *compiler, int characters_filled_in, bool not_at_start)=0

References v8::internal::RegExpNode::GetQuickCheckDetails(), and v8::internal::SeqRegExpNode::on_success().

+ Here is the call graph for this function:

◆ GreedyLoopTextLength()

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

Reimplemented from v8::internal::RegExpNode.

Definition at line 791 of file jsregexp.h.

static const int kNodeIsTooComplexForGreedyLoops
Definition: jsregexp.h:607

References v8::internal::RegExpNode::kNodeIsTooComplexForGreedyLoops.

◆ IncrementRegister()

ActionNode * v8::internal::ActionNode::IncrementRegister ( int  reg,
RegExpNode on_success 
)
static

Definition at line 1483 of file jsregexp.cc.

1483  {
1484  ActionNode* result =
1486  result->data_.u_increment_register.reg = reg;
1487  return result;
1488 }

References data_, u_increment_register, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ PositiveSubmatchSuccess()

ActionNode * v8::internal::ActionNode::PositiveSubmatchSuccess ( int  stack_pointer_reg,
int  restore_reg,
int  clear_capture_count,
int  clear_capture_from,
RegExpNode on_success 
)
static

Definition at line 1523 of file jsregexp.cc.

1527  {
1528  ActionNode* result =
1530  result->data_.u_submatch.stack_pointer_register = stack_reg;
1531  result->data_.u_submatch.current_position_register = position_reg;
1532  result->data_.u_submatch.clear_register_count = clear_register_count;
1533  result->data_.u_submatch.clear_register_from = clear_register_from;
1534  return result;
1535 }

References data_, u_submatch, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ SetRegister()

ActionNode * v8::internal::ActionNode::SetRegister ( int  reg,
int  val,
RegExpNode on_success 
)
static

Definition at line 1472 of file jsregexp.cc.

1474  {
1475  ActionNode* result =
1477  result->data_.u_store_register.reg = reg;
1478  result->data_.u_store_register.value = val;
1479  return result;
1480 }

References data_, u_store_register, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

◆ StorePosition()

ActionNode * v8::internal::ActionNode::StorePosition ( int  reg,
bool  is_capture,
RegExpNode on_success 
)
static

Definition at line 1491 of file jsregexp.cc.

1493  {
1494  ActionNode* result =
1496  result->data_.u_position_register.reg = reg;
1497  result->data_.u_position_register.is_capture = is_capture;
1498  return result;
1499 }

References data_, u_position_register, and v8::internal::RegExpNode::zone().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ DotPrinter

friend class DotPrinter
friend

Definition at line 826 of file jsregexp.h.

Member Data Documentation

◆ action_type_

ActionType v8::internal::ActionNode::action_type_
private

Definition at line 825 of file jsregexp.h.

Referenced by action_type(), and Emit().

◆ clear_register_count

int v8::internal::ActionNode::clear_register_count

Definition at line 809 of file jsregexp.h.

Referenced by Emit().

◆ clear_register_from

int v8::internal::ActionNode::clear_register_from

Definition at line 810 of file jsregexp.h.

◆ current_position_register

int v8::internal::ActionNode::current_position_register

Definition at line 808 of file jsregexp.h.

◆ 

◆ is_capture

bool v8::internal::ActionNode::is_capture

Definition at line 804 of file jsregexp.h.

◆ range_from

int v8::internal::ActionNode::range_from

Definition at line 818 of file jsregexp.h.

◆ range_to

int v8::internal::ActionNode::range_to

Definition at line 819 of file jsregexp.h.

◆ reg

int v8::internal::ActionNode::reg

Definition at line 796 of file jsregexp.h.

◆ repetition_limit

int v8::internal::ActionNode::repetition_limit

Definition at line 815 of file jsregexp.h.

◆ repetition_register

int v8::internal::ActionNode::repetition_register

Definition at line 814 of file jsregexp.h.

◆ stack_pointer_register

int v8::internal::ActionNode::stack_pointer_register

Definition at line 807 of file jsregexp.h.

◆ start_register

int v8::internal::ActionNode::start_register

Definition at line 813 of file jsregexp.h.

◆ 

struct { ... } v8::internal::ActionNode::u_clear_captures

Referenced by ClearCaptures().

◆ 

struct { ... } v8::internal::ActionNode::u_empty_match_check

Referenced by EmptyMatchCheck().

◆ 

struct { ... } v8::internal::ActionNode::u_increment_register

Referenced by IncrementRegister().

◆ 

struct { ... } v8::internal::ActionNode::u_position_register

Referenced by StorePosition().

◆ 

struct { ... } v8::internal::ActionNode::u_store_register

Referenced by SetRegister().

◆ 

struct { ... } v8::internal::ActionNode::u_submatch

◆ value

int v8::internal::ActionNode::value

Definition at line 797 of file jsregexp.h.


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