LCOV - code coverage report
Current view: top level - src/regexp - regexp-macro-assembler-irregexp.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2019-03-21 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2012 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_
       6             : #define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_
       7             : 
       8             : #include "src/regexp/regexp-macro-assembler.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : 
      13             : // A light-weight assembler for the Irregexp byte code.
      14             : class RegExpMacroAssemblerIrregexp: public RegExpMacroAssembler {
      15             :  public:
      16             :   // Create an assembler. Instructions and relocation information are emitted
      17             :   // into a buffer, with the instructions starting from the beginning and the
      18             :   // relocation information starting from the end of the buffer. See CodeDesc
      19             :   // for a detailed comment on the layout (globals.h).
      20             :   //
      21             :   // The assembler allocates and grows its own buffer, and buffer_size
      22             :   // determines the initial buffer size. The buffer is owned by the assembler
      23             :   // and deallocated upon destruction of the assembler.
      24             :   RegExpMacroAssemblerIrregexp(Isolate* isolate, Zone* zone);
      25             :   virtual ~RegExpMacroAssemblerIrregexp();
      26             :   // The byte-code interpreter checks on each push anyway.
      27       68406 :   virtual int stack_limit_slack() { return 1; }
      28       28327 :   virtual bool CanReadUnaligned() { return false; }
      29             :   virtual void Bind(Label* label);
      30             :   virtual void AdvanceCurrentPosition(int by);  // Signed cp change.
      31             :   virtual void PopCurrentPosition();
      32             :   virtual void PushCurrentPosition();
      33             :   virtual void Backtrack();
      34             :   virtual void GoTo(Label* label);
      35             :   virtual void PushBacktrack(Label* label);
      36             :   virtual bool Succeed();
      37             :   virtual void Fail();
      38             :   virtual void PopRegister(int register_index);
      39             :   virtual void PushRegister(int register_index,
      40             :                             StackCheckFlag check_stack_limit);
      41             :   virtual void AdvanceRegister(int reg, int by);  // r[reg] += by.
      42             :   virtual void SetCurrentPositionFromEnd(int by);
      43             :   virtual void SetRegister(int register_index, int to);
      44             :   virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
      45             :   virtual void ClearRegisters(int reg_from, int reg_to);
      46             :   virtual void ReadCurrentPositionFromRegister(int reg);
      47             :   virtual void WriteStackPointerToRegister(int reg);
      48             :   virtual void ReadStackPointerFromRegister(int reg);
      49             :   virtual void LoadCurrentCharacter(int cp_offset,
      50             :                                     Label* on_end_of_input,
      51             :                                     bool check_bounds = true,
      52             :                                     int characters = 1);
      53             :   virtual void CheckCharacter(unsigned c, Label* on_equal);
      54             :   virtual void CheckCharacterAfterAnd(unsigned c,
      55             :                                       unsigned mask,
      56             :                                       Label* on_equal);
      57             :   virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
      58             :   virtual void CheckCharacterLT(uc16 limit, Label* on_less);
      59             :   virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
      60             :   virtual void CheckAtStart(Label* on_at_start);
      61             :   virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start);
      62             :   virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
      63             :   virtual void CheckNotCharacterAfterAnd(unsigned c,
      64             :                                          unsigned mask,
      65             :                                          Label* on_not_equal);
      66             :   virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
      67             :                                               uc16 minus,
      68             :                                               uc16 mask,
      69             :                                               Label* on_not_equal);
      70             :   virtual void CheckCharacterInRange(uc16 from,
      71             :                                      uc16 to,
      72             :                                      Label* on_in_range);
      73             :   virtual void CheckCharacterNotInRange(uc16 from,
      74             :                                         uc16 to,
      75             :                                         Label* on_not_in_range);
      76             :   virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
      77             :   virtual void CheckNotBackReference(int start_reg, bool read_backward,
      78             :                                      Label* on_no_match);
      79             :   virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
      80             :                                                bool read_backward, bool unicode,
      81             :                                                Label* on_no_match);
      82             :   virtual void IfRegisterLT(int register_index, int comparand, Label* if_lt);
      83             :   virtual void IfRegisterGE(int register_index, int comparand, Label* if_ge);
      84             :   virtual void IfRegisterEqPos(int register_index, Label* if_eq);
      85             : 
      86             :   virtual IrregexpImplementation Implementation();
      87             :   virtual Handle<HeapObject> GetCode(Handle<String> source);
      88             : 
      89             :  private:
      90             :   void Expand();
      91             :   // Code and bitmap emission.
      92             :   inline void EmitOrLink(Label* label);
      93             :   inline void Emit32(uint32_t x);
      94             :   inline void Emit16(uint32_t x);
      95             :   inline void Emit8(uint32_t x);
      96             :   inline void Emit(uint32_t bc, uint32_t arg);
      97             :   // Bytecode buffer.
      98             :   int length();
      99             :   void Copy(byte* a);
     100             : 
     101             :   // The buffer into which code and relocation info are generated.
     102             :   Vector<byte> buffer_;
     103             :   // The program counter.
     104             :   int pc_;
     105             :   // True if the assembler owns the buffer, false if buffer is external.
     106             :   bool own_buffer_;
     107             :   Label backtrack_;
     108             : 
     109             :   int advance_current_start_;
     110             :   int advance_current_offset_;
     111             :   int advance_current_end_;
     112             : 
     113             :   Isolate* isolate_;
     114             : 
     115             :   static const int kInvalidPC = -1;
     116             : 
     117             :   DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMacroAssemblerIrregexp);
     118             : };
     119             : 
     120             : }  // namespace internal
     121             : }  // namespace v8
     122             : 
     123             : #endif  // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_

Generated by: LCOV version 1.10