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

          Line data    Source code
       1             : // Copyright 2017 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_BUILTINS_BUILTINS_REGEXP_GEN_H_
       6             : #define V8_BUILTINS_BUILTINS_REGEXP_GEN_H_
       7             : 
       8             : #include "src/base/optional.h"
       9             : #include "src/code-stub-assembler.h"
      10             : #include "src/message-template.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15        2072 : class RegExpBuiltinsAssembler : public CodeStubAssembler {
      16             :  public:
      17        2072 :   explicit RegExpBuiltinsAssembler(compiler::CodeAssemblerState* state)
      18        2072 :       : CodeStubAssembler(state) {}
      19             : 
      20             :   void BranchIfFastRegExp(
      21             :       Node* const context, Node* const object, Node* const map,
      22             :       base::Optional<DescriptorIndexAndName> additional_property_to_check,
      23             :       Label* const if_isunmodified, Label* const if_ismodified);
      24             : 
      25             :   // Create and initialize a RegExp object.
      26             :   TNode<Object> RegExpCreate(TNode<Context> context,
      27             :                              TNode<Context> native_context,
      28             :                              TNode<Object> regexp_string, TNode<String> flags);
      29             : 
      30             :   TNode<Object> RegExpCreate(TNode<Context> context, TNode<Map> initial_map,
      31             :                              TNode<Object> regexp_string, TNode<String> flags);
      32             : 
      33             :   TNode<BoolT> IsRegExp(TNode<Context> context, TNode<Object> maybe_receiver);
      34             : 
      35             :  protected:
      36             :   TNode<Smi> SmiZero();
      37             :   TNode<IntPtrT> IntPtrZero();
      38             : 
      39             :   // Allocate a RegExpResult with the given length (the number of captures,
      40             :   // including the match itself), index (the index where the match starts),
      41             :   // and input string.
      42             :   TNode<JSRegExpResult> AllocateRegExpResult(TNode<Context> context,
      43             :                                              TNode<Smi> length,
      44             :                                              TNode<Smi> index,
      45             :                                              TNode<String> input);
      46             : 
      47             :   TNode<Object> FastLoadLastIndex(TNode<JSRegExp> regexp);
      48             :   TNode<Object> SlowLoadLastIndex(TNode<Context> context, TNode<Object> regexp);
      49             :   TNode<Object> LoadLastIndex(TNode<Context> context, TNode<Object> regexp,
      50             :                               bool is_fastpath);
      51             : 
      52             :   void FastStoreLastIndex(Node* regexp, Node* value);
      53             :   void SlowStoreLastIndex(Node* context, Node* regexp, Node* value);
      54             :   void StoreLastIndex(Node* context, Node* regexp, Node* value,
      55             :                       bool is_fastpath);
      56             : 
      57             :   // Loads {var_string_start} and {var_string_end} with the corresponding
      58             :   // offsets into the given {string_data}.
      59             :   void GetStringPointers(Node* const string_data, Node* const offset,
      60             :                          Node* const last_index, Node* const string_length,
      61             :                          String::Encoding encoding, Variable* var_string_start,
      62             :                          Variable* var_string_end);
      63             : 
      64             :   // Low level logic around the actual call into pattern matching code.
      65             :   TNode<HeapObject> RegExpExecInternal(TNode<Context> context,
      66             :                                        TNode<JSRegExp> regexp,
      67             :                                        TNode<String> string,
      68             :                                        TNode<Number> last_index,
      69             :                                        TNode<RegExpMatchInfo> match_info);
      70             : 
      71             :   TNode<JSRegExpResult> ConstructNewResultFromMatchInfo(
      72             :       TNode<Context> context, TNode<JSReceiver> maybe_regexp,
      73             :       TNode<RegExpMatchInfo> match_info, TNode<String> string);
      74             : 
      75             :   TNode<RegExpMatchInfo> RegExpPrototypeExecBodyWithoutResult(
      76             :       TNode<Context> context, TNode<JSReceiver> maybe_regexp,
      77             :       TNode<String> string, Label* if_didnotmatch, const bool is_fastpath);
      78             :   TNode<HeapObject> RegExpPrototypeExecBody(TNode<Context> context,
      79             :                                             TNode<JSReceiver> maybe_regexp,
      80             :                                             TNode<String> string,
      81             :                                             const bool is_fastpath);
      82             : 
      83             :   Node* ThrowIfNotJSReceiver(Node* context, Node* maybe_receiver,
      84             :                              MessageTemplate msg_template,
      85             :                              char const* method_name);
      86             : 
      87             :   // Analogous to BranchIfFastRegExp, for use in asserts.
      88             :   TNode<BoolT> IsFastRegExp(SloppyTNode<Context> context,
      89             :                             SloppyTNode<Object> object);
      90             : 
      91             :   void BranchIfFastRegExp(Node* const context, Node* const object,
      92             :                           Label* const if_isunmodified,
      93             :                           Label* const if_ismodified);
      94             : 
      95             :   // Performs fast path checks on the given object itself, but omits prototype
      96             :   // checks.
      97             :   Node* IsFastRegExpNoPrototype(Node* const context, Node* const object);
      98             :   TNode<BoolT> IsFastRegExpWithOriginalExec(TNode<Context> context,
      99             :                                             TNode<JSRegExp> object);
     100             :   Node* IsFastRegExpNoPrototype(Node* const context, Node* const object,
     101             :                                 Node* const map);
     102             : 
     103             :   void BranchIfFastRegExpResult(Node* const context, Node* const object,
     104             :                                 Label* if_isunmodified, Label* if_ismodified);
     105             : 
     106             :   Node* FlagsGetter(Node* const context, Node* const regexp, bool is_fastpath);
     107             : 
     108             :   TNode<Int32T> FastFlagGetter(TNode<JSRegExp> regexp, JSRegExp::Flag flag);
     109             :   TNode<Int32T> SlowFlagGetter(TNode<Context> context, TNode<Object> regexp,
     110             :                                JSRegExp::Flag flag);
     111             :   TNode<Int32T> FlagGetter(TNode<Context> context, TNode<Object> regexp,
     112             :                            JSRegExp::Flag flag, bool is_fastpath);
     113             : 
     114             :   void FlagGetter(Node* context, Node* receiver, JSRegExp::Flag flag,
     115             :                   int counter, const char* method_name);
     116             : 
     117             :   Node* RegExpInitialize(Node* const context, Node* const regexp,
     118             :                          Node* const maybe_pattern, Node* const maybe_flags);
     119             : 
     120             :   Node* RegExpExec(Node* context, Node* regexp, Node* string);
     121             : 
     122             :   Node* AdvanceStringIndex(Node* const string, Node* const index,
     123             :                            Node* const is_unicode, bool is_fastpath);
     124             : 
     125             :   void RegExpPrototypeMatchBody(Node* const context, Node* const regexp,
     126             :                                 TNode<String> const string,
     127             :                                 const bool is_fastpath);
     128             : 
     129             :   void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp,
     130             :                                      Node* const string);
     131             :   void RegExpPrototypeSearchBodySlow(Node* const context, Node* const regexp,
     132             :                                      Node* const string);
     133             : 
     134             :   void RegExpPrototypeSplitBody(Node* const context, Node* const regexp,
     135             :                                 TNode<String> const string,
     136             :                                 TNode<Smi> const limit);
     137             : 
     138             :   Node* ReplaceGlobalCallableFastPath(Node* context, Node* regexp, Node* string,
     139             :                                       Node* replace_callable);
     140             :   Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp,
     141             :                                     TNode<String> string,
     142             :                                     TNode<String> replace_string);
     143             : };
     144             : 
     145         168 : class RegExpMatchAllAssembler : public RegExpBuiltinsAssembler {
     146             :  public:
     147         168 :   explicit RegExpMatchAllAssembler(compiler::CodeAssemblerState* state)
     148         168 :       : RegExpBuiltinsAssembler(state) {}
     149             : 
     150             :   TNode<Object> CreateRegExpStringIterator(TNode<Context> native_context,
     151             :                                            TNode<Object> regexp,
     152             :                                            TNode<String> string,
     153             :                                            TNode<Int32T> global,
     154             :                                            TNode<Int32T> full_unicode);
     155             :   void Generate(TNode<Context> context, TNode<Context> native_context,
     156             :                 TNode<Object> receiver, TNode<Object> maybe_string);
     157             : };
     158             : 
     159             : }  // namespace internal
     160             : }  // namespace v8
     161             : 
     162             : #endif  // V8_BUILTINS_BUILTINS_REGEXP_GEN_H_

Generated by: LCOV version 1.10