tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

regexp-interpreter.h (3196B)


      1 // Copyright 2011 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_INTERPRETER_H_
      6 #define V8_REGEXP_REGEXP_INTERPRETER_H_
      7 
      8 // A simple interpreter for the Irregexp byte code.
      9 
     10 #include "irregexp/imported/regexp.h"
     11 
     12 namespace v8 {
     13 namespace internal {
     14 
     15 class TrustedByteArray;
     16 
     17 class V8_EXPORT_PRIVATE IrregexpInterpreter : public AllStatic {
     18 public:
     19  enum Result {
     20    FAILURE = RegExp::kInternalRegExpFailure,
     21    SUCCESS = RegExp::kInternalRegExpSuccess,
     22    EXCEPTION = RegExp::kInternalRegExpException,
     23    RETRY = RegExp::kInternalRegExpRetry,
     24    FALLBACK_TO_EXPERIMENTAL = RegExp::kInternalRegExpFallbackToExperimental,
     25  };
     26 
     27  // In case a StackOverflow occurs, a StackOverflowException is created and
     28  // EXCEPTION is returned.
     29  static int MatchForCallFromRuntime(Isolate* isolate,
     30                                     DirectHandle<IrRegExpData> regexp_data,
     31                                     DirectHandle<String> subject_string,
     32                                     int* output_registers,
     33                                     int output_register_count,
     34                                     int start_position);
     35 
     36  // In case a StackOverflow occurs, EXCEPTION is returned. The caller is
     37  // responsible for creating the exception.
     38  //
     39  // RETRY is returned if a retry through the runtime is needed (e.g. when
     40  // interrupts have been scheduled or the regexp is marked for tier-up).
     41  //
     42  // Arguments input_start and input_end are unused. They are only passed to
     43  // match the signature of the native irregex code.
     44  //
     45  // Arguments output_registers and output_register_count describe the results
     46  // array, which will contain register values of all captures if one or more
     47  // matches were found. In this case, the return value is the number of
     48  // matches. For all other return codes, the results array remains unmodified.
     49  static int MatchForCallFromJs(Address subject, int32_t start_position,
     50                                Address input_start, Address input_end,
     51                                int* output_registers,
     52                                int32_t output_register_count,
     53                                RegExp::CallOrigin call_origin,
     54                                Isolate* isolate, Address regexp_data);
     55 
     56  static Result MatchInternal(Isolate* isolate,
     57                              Tagged<TrustedByteArray>* code_array,
     58                              Tagged<String>* subject_string,
     59                              int* output_registers, int output_register_count,
     60                              int total_register_count, int start_position,
     61                              RegExp::CallOrigin call_origin,
     62                              uint32_t backtrack_limit);
     63 
     64 private:
     65  static int Match(Isolate* isolate, Tagged<IrRegExpData> regexp_data,
     66                   Tagged<String> subject_string, int* output_registers,
     67                   int output_register_count, int start_position,
     68                   RegExp::CallOrigin call_origin);
     69 };
     70 
     71 }  // namespace internal
     72 }  // namespace v8
     73 
     74 #endif  // V8_REGEXP_REGEXP_INTERPRETER_H_