11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_H_ 61cb0ef41Sopenharmony_ci#define V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/regexp/regexp-flags.h" 91cb0ef41Sopenharmony_ci#include "src/regexp/regexp.h" 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cinamespace v8 { 121cb0ef41Sopenharmony_cinamespace internal { 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciclass ExperimentalRegExp final : public AllStatic { 151cb0ef41Sopenharmony_ci public: 161cb0ef41Sopenharmony_ci // Initialization & Compilation 171cb0ef41Sopenharmony_ci // ------------------------------------------------------------------------- 181cb0ef41Sopenharmony_ci // Check whether a parsed regexp pattern can be compiled and executed by the 191cb0ef41Sopenharmony_ci // EXPERIMENTAL engine. 201cb0ef41Sopenharmony_ci // TODO(mbid, v8:10765): This walks the RegExpTree, but it could also be 211cb0ef41Sopenharmony_ci // checked on the fly in the parser. Not done currently because walking the 221cb0ef41Sopenharmony_ci // AST again is more flexible and less error prone (but less performant). 231cb0ef41Sopenharmony_ci static bool CanBeHandled(RegExpTree* tree, RegExpFlags flags, 241cb0ef41Sopenharmony_ci int capture_count); 251cb0ef41Sopenharmony_ci static void Initialize(Isolate* isolate, Handle<JSRegExp> re, 261cb0ef41Sopenharmony_ci Handle<String> pattern, RegExpFlags flags, 271cb0ef41Sopenharmony_ci int capture_count); 281cb0ef41Sopenharmony_ci static bool IsCompiled(Handle<JSRegExp> re, Isolate* isolate); 291cb0ef41Sopenharmony_ci V8_WARN_UNUSED_RESULT 301cb0ef41Sopenharmony_ci static bool Compile(Isolate* isolate, Handle<JSRegExp> re); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci // Execution: 331cb0ef41Sopenharmony_ci static int32_t MatchForCallFromJs(Address subject, int32_t start_position, 341cb0ef41Sopenharmony_ci Address input_start, Address input_end, 351cb0ef41Sopenharmony_ci int* output_registers, 361cb0ef41Sopenharmony_ci int32_t output_register_count, 371cb0ef41Sopenharmony_ci RegExp::CallOrigin call_origin, 381cb0ef41Sopenharmony_ci Isolate* isolate, Address regexp); 391cb0ef41Sopenharmony_ci static MaybeHandle<Object> Exec( 401cb0ef41Sopenharmony_ci Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject, 411cb0ef41Sopenharmony_ci int index, Handle<RegExpMatchInfo> last_match_info, 421cb0ef41Sopenharmony_ci RegExp::ExecQuirks exec_quirks = RegExp::ExecQuirks::kNone); 431cb0ef41Sopenharmony_ci static int32_t ExecRaw(Isolate* isolate, RegExp::CallOrigin call_origin, 441cb0ef41Sopenharmony_ci JSRegExp regexp, String subject, 451cb0ef41Sopenharmony_ci int32_t* output_registers, 461cb0ef41Sopenharmony_ci int32_t output_register_count, int32_t subject_index); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci // Compile and execute a regexp with the experimental engine, regardless of 491cb0ef41Sopenharmony_ci // its type tag. The regexp itself is not changed (apart from lastIndex). 501cb0ef41Sopenharmony_ci static MaybeHandle<Object> OneshotExec( 511cb0ef41Sopenharmony_ci Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject, 521cb0ef41Sopenharmony_ci int index, Handle<RegExpMatchInfo> last_match_info, 531cb0ef41Sopenharmony_ci RegExp::ExecQuirks exec_quirks = RegExp::ExecQuirks::kNone); 541cb0ef41Sopenharmony_ci static int32_t OneshotExecRaw(Isolate* isolate, Handle<JSRegExp> regexp, 551cb0ef41Sopenharmony_ci Handle<String> subject, 561cb0ef41Sopenharmony_ci int32_t* output_registers, 571cb0ef41Sopenharmony_ci int32_t output_register_count, 581cb0ef41Sopenharmony_ci int32_t subject_index); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci static constexpr bool kSupportsUnicode = false; 611cb0ef41Sopenharmony_ci}; 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci} // namespace internal 641cb0ef41Sopenharmony_ci} // namespace v8 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci#endif // V8_REGEXP_EXPERIMENTAL_EXPERIMENTAL_H_ 67