[regexp] Hide the generic JSRegExp::DataAt/SetDataAt accessors
.. and refactor js-regexp.h. - Hide the generic DataAt/SetDataAt accessors and replace them by dedicated accessors. Use the common lower_case naming scheme for these. - Shuffle around definitions in js-regexp.h s.t. they are in a meaningful order. - Dedupe the source/flags accessors - these fields are stored both on the instance and on the data array. We keep only accessors for the instance. Previously, these were disambiguated through naming oddities (e.g. Pattern() returned data->source). Change-Id: I3d53c8b095f0d59621ff779608438f7fa5e8c92a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3193534 Auto-Submit: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Patrick Thier <pthier@chromium.org> Cr-Commit-Position: refs/heads/main@{#77138}
This commit is contained in:
parent
75df72d3a4
commit
77906a700c
@ -7171,7 +7171,7 @@ REGEXP_FLAG_ASSERT_EQ(kLinear);
|
||||
|
||||
v8::RegExp::Flags v8::RegExp::GetFlags() const {
|
||||
i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
|
||||
return RegExp::Flags(static_cast<int>(obj->GetFlags()));
|
||||
return RegExp::Flags(static_cast<int>(obj->flags()));
|
||||
}
|
||||
|
||||
MaybeLocal<v8::Object> v8::RegExp::Exec(Local<Context> context,
|
||||
|
@ -1348,7 +1348,7 @@ void SwissNameDictionary::SwissNameDictionaryVerify(Isolate* isolate,
|
||||
|
||||
void JSRegExp::JSRegExpVerify(Isolate* isolate) {
|
||||
TorqueGeneratedClassVerifiers::JSRegExpVerify(*this, isolate);
|
||||
switch (TypeTag()) {
|
||||
switch (type_tag()) {
|
||||
case JSRegExp::ATOM: {
|
||||
FixedArray arr = FixedArray::cast(data());
|
||||
CHECK(arr.get(JSRegExp::kAtomPatternIndex).IsString());
|
||||
@ -1426,7 +1426,7 @@ void JSRegExp::JSRegExpVerify(Isolate* isolate) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
CHECK_EQ(JSRegExp::NOT_COMPILED, TypeTag());
|
||||
CHECK_EQ(JSRegExp::NOT_COMPILED, type_tag());
|
||||
CHECK(data().IsUndefined(isolate));
|
||||
break;
|
||||
}
|
||||
|
@ -27,15 +27,15 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(JSRegExpResultWithIndices)
|
||||
|
||||
ACCESSORS(JSRegExp, last_index, Object, kLastIndexOffset)
|
||||
|
||||
JSRegExp::Type JSRegExp::TypeTag() const {
|
||||
JSRegExp::Type JSRegExp::type_tag() const {
|
||||
Object data = this->data();
|
||||
if (data.IsUndefined()) return JSRegExp::NOT_COMPILED;
|
||||
Smi smi = Smi::cast(FixedArray::cast(data).get(kTagIndex));
|
||||
return static_cast<JSRegExp::Type>(smi.value());
|
||||
}
|
||||
|
||||
int JSRegExp::CaptureCount() const {
|
||||
switch (TypeTag()) {
|
||||
int JSRegExp::capture_count() const {
|
||||
switch (type_tag()) {
|
||||
case ATOM:
|
||||
return 0;
|
||||
case EXPERIMENTAL:
|
||||
@ -46,52 +46,38 @@ int JSRegExp::CaptureCount() const {
|
||||
}
|
||||
}
|
||||
|
||||
int JSRegExp::MaxRegisterCount() const {
|
||||
CHECK_EQ(TypeTag(), IRREGEXP);
|
||||
int JSRegExp::max_register_count() const {
|
||||
CHECK_EQ(type_tag(), IRREGEXP);
|
||||
return Smi::ToInt(DataAt(kIrregexpMaxRegisterCountIndex));
|
||||
}
|
||||
|
||||
JSRegExp::Flags JSRegExp::GetFlags() const {
|
||||
DCHECK(this->data().IsFixedArray());
|
||||
Object data = this->data();
|
||||
Smi smi = Smi::cast(FixedArray::cast(data).get(kFlagsIndex));
|
||||
return Flags(smi.value());
|
||||
String JSRegExp::atom_pattern() const {
|
||||
DCHECK_EQ(type_tag(), ATOM);
|
||||
return String::cast(DataAt(JSRegExp::kAtomPatternIndex));
|
||||
}
|
||||
|
||||
String JSRegExp::Pattern() {
|
||||
DCHECK(this->data().IsFixedArray());
|
||||
Object data = this->data();
|
||||
String pattern = String::cast(FixedArray::cast(data).get(kSourceIndex));
|
||||
return pattern;
|
||||
String JSRegExp::source() const {
|
||||
return String::cast(TorqueGeneratedClass::source());
|
||||
}
|
||||
|
||||
JSRegExp::Flags JSRegExp::flags() const {
|
||||
Smi smi = Smi::cast(TorqueGeneratedClass::flags());
|
||||
return Flags(smi.value());
|
||||
}
|
||||
|
||||
String JSRegExp::EscapedPattern() {
|
||||
DCHECK(this->source().IsString());
|
||||
String pattern = String::cast(source());
|
||||
return pattern;
|
||||
return String::cast(source());
|
||||
}
|
||||
|
||||
Object JSRegExp::CaptureNameMap() {
|
||||
DCHECK(this->data().IsFixedArray());
|
||||
DCHECK(TypeSupportsCaptures(TypeTag()));
|
||||
Object JSRegExp::capture_name_map() {
|
||||
DCHECK(TypeSupportsCaptures(type_tag()));
|
||||
Object value = DataAt(kIrregexpCaptureNameMapIndex);
|
||||
DCHECK_NE(value, Smi::FromInt(JSRegExp::kUninitializedValue));
|
||||
return value;
|
||||
}
|
||||
|
||||
Object JSRegExp::DataAt(int index) const {
|
||||
DCHECK(TypeTag() != NOT_COMPILED);
|
||||
return FixedArray::cast(data()).get(index);
|
||||
}
|
||||
|
||||
void JSRegExp::SetDataAt(int index, Object value) {
|
||||
DCHECK(TypeTag() != NOT_COMPILED);
|
||||
// Only implementation data can be set this way.
|
||||
DCHECK_GE(index, kFirstTypeSpecificIndex);
|
||||
FixedArray::cast(data()).set(index, value);
|
||||
}
|
||||
|
||||
void JSRegExp::SetCaptureNameMap(Handle<FixedArray> capture_name_map) {
|
||||
void JSRegExp::set_capture_name_map(Handle<FixedArray> capture_name_map) {
|
||||
if (capture_name_map.is_null()) {
|
||||
SetDataAt(JSRegExp::kIrregexpCaptureNameMapIndex, Smi::zero());
|
||||
} else {
|
||||
@ -99,8 +85,20 @@ void JSRegExp::SetCaptureNameMap(Handle<FixedArray> capture_name_map) {
|
||||
}
|
||||
}
|
||||
|
||||
Object JSRegExp::DataAt(int index) const {
|
||||
DCHECK(type_tag() != NOT_COMPILED);
|
||||
return FixedArray::cast(data()).get(index);
|
||||
}
|
||||
|
||||
void JSRegExp::SetDataAt(int index, Object value) {
|
||||
DCHECK(type_tag() != NOT_COMPILED);
|
||||
// Only implementation data can be set this way.
|
||||
DCHECK_GE(index, kFirstTypeSpecificIndex);
|
||||
FixedArray::cast(data()).set(index, value);
|
||||
}
|
||||
|
||||
bool JSRegExp::HasCompiledCode() const {
|
||||
if (TypeTag() != IRREGEXP) return false;
|
||||
if (type_tag() != IRREGEXP) return false;
|
||||
Smi uninitialized = Smi::FromInt(kUninitializedValue);
|
||||
#ifdef DEBUG
|
||||
DCHECK(DataAt(kIrregexpLatin1CodeIndex).IsCodeT() ||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/base/strings.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/objects/code.h"
|
||||
#include "src/objects/js-array-inl.h"
|
||||
#include "src/objects/js-regexp-inl.h"
|
||||
#include "src/regexp/regexp.h"
|
||||
@ -105,8 +106,8 @@ Handle<JSRegExpResultIndices> JSRegExpResultIndices::BuildIndices(
|
||||
return indices;
|
||||
}
|
||||
|
||||
uint32_t JSRegExp::BacktrackLimit() const {
|
||||
CHECK_EQ(TypeTag(), IRREGEXP);
|
||||
uint32_t JSRegExp::backtrack_limit() const {
|
||||
CHECK_EQ(type_tag(), IRREGEXP);
|
||||
return static_cast<uint32_t>(Smi::ToInt(DataAt(kIrregexpBacktrackLimit)));
|
||||
}
|
||||
|
||||
@ -156,18 +157,33 @@ MaybeHandle<JSRegExp> JSRegExp::New(Isolate* isolate, Handle<String> pattern,
|
||||
return JSRegExp::Initialize(regexp, pattern, flags, backtrack_limit);
|
||||
}
|
||||
|
||||
Object JSRegExp::Code(bool is_latin1) const {
|
||||
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
|
||||
Object JSRegExp::code(bool is_latin1) const {
|
||||
DCHECK_EQ(type_tag(), JSRegExp::IRREGEXP);
|
||||
Object value = DataAt(code_index(is_latin1));
|
||||
DCHECK_IMPLIES(V8_EXTERNAL_CODE_SPACE_BOOL, value.IsSmi() || value.IsCodeT());
|
||||
return value;
|
||||
}
|
||||
|
||||
Object JSRegExp::Bytecode(bool is_latin1) const {
|
||||
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
|
||||
void JSRegExp::set_code(bool is_latin1, Handle<Code> code) {
|
||||
SetDataAt(code_index(is_latin1), ToCodeT(*code));
|
||||
}
|
||||
|
||||
Object JSRegExp::bytecode(bool is_latin1) const {
|
||||
DCHECK(type_tag() == JSRegExp::IRREGEXP ||
|
||||
type_tag() == JSRegExp::EXPERIMENTAL);
|
||||
return DataAt(bytecode_index(is_latin1));
|
||||
}
|
||||
|
||||
void JSRegExp::set_bytecode_and_trampoline(Isolate* isolate,
|
||||
Handle<ByteArray> bytecode) {
|
||||
SetDataAt(kIrregexpLatin1BytecodeIndex, *bytecode);
|
||||
SetDataAt(kIrregexpUC16BytecodeIndex, *bytecode);
|
||||
|
||||
Handle<Code> trampoline = BUILTIN_CODE(isolate, RegExpExperimentalTrampoline);
|
||||
SetDataAt(JSRegExp::kIrregexpLatin1CodeIndex, ToCodeT(*trampoline));
|
||||
SetDataAt(JSRegExp::kIrregexpUC16CodeIndex, ToCodeT(*trampoline));
|
||||
}
|
||||
|
||||
bool JSRegExp::ShouldProduceBytecode() {
|
||||
return FLAG_regexp_interpret_all ||
|
||||
(FLAG_regexp_tier_up && !MarkedForTierUp());
|
||||
@ -175,7 +191,7 @@ bool JSRegExp::ShouldProduceBytecode() {
|
||||
|
||||
// Only irregexps are subject to tier-up.
|
||||
bool JSRegExp::CanTierUp() {
|
||||
return FLAG_regexp_tier_up && TypeTag() == JSRegExp::IRREGEXP;
|
||||
return FLAG_regexp_tier_up && type_tag() == JSRegExp::IRREGEXP;
|
||||
}
|
||||
|
||||
// An irregexp is considered to be marked for tier up if the tier-up ticks
|
||||
@ -192,7 +208,7 @@ bool JSRegExp::MarkedForTierUp() {
|
||||
|
||||
void JSRegExp::ResetLastTierUpTick() {
|
||||
DCHECK(FLAG_regexp_tier_up);
|
||||
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
|
||||
DCHECK_EQ(type_tag(), JSRegExp::IRREGEXP);
|
||||
int tier_up_ticks = Smi::ToInt(DataAt(kIrregexpTicksUntilTierUpIndex)) + 1;
|
||||
FixedArray::cast(data()).set(JSRegExp::kIrregexpTicksUntilTierUpIndex,
|
||||
Smi::FromInt(tier_up_ticks));
|
||||
@ -200,7 +216,7 @@ void JSRegExp::ResetLastTierUpTick() {
|
||||
|
||||
void JSRegExp::TierUpTick() {
|
||||
DCHECK(FLAG_regexp_tier_up);
|
||||
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
|
||||
DCHECK_EQ(type_tag(), JSRegExp::IRREGEXP);
|
||||
int tier_up_ticks = Smi::ToInt(DataAt(kIrregexpTicksUntilTierUpIndex));
|
||||
if (tier_up_ticks == 0) {
|
||||
return;
|
||||
@ -211,7 +227,7 @@ void JSRegExp::TierUpTick() {
|
||||
|
||||
void JSRegExp::MarkTierUpForNextExec() {
|
||||
DCHECK(FLAG_regexp_tier_up);
|
||||
DCHECK_EQ(TypeTag(), JSRegExp::IRREGEXP);
|
||||
DCHECK_EQ(type_tag(), JSRegExp::IRREGEXP);
|
||||
FixedArray::cast(data()).set(JSRegExp::kIrregexpTicksUntilTierUpIndex,
|
||||
Smi::zero());
|
||||
}
|
||||
|
@ -37,14 +37,51 @@ namespace internal {
|
||||
// - number of capture registers (output values) of the regexp.
|
||||
class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
|
||||
public:
|
||||
// Meaning of Type:
|
||||
// NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet.
|
||||
// ATOM: A simple string to match against using an indexOf operation.
|
||||
// IRREGEXP: Compiled with Irregexp.
|
||||
// EXPERIMENTAL: Compiled to use the new linear time engine.
|
||||
enum Type { NOT_COMPILED, ATOM, IRREGEXP, EXPERIMENTAL };
|
||||
enum Type {
|
||||
NOT_COMPILED, // Initial value. No data array has been set yet.
|
||||
ATOM, // A simple string match.
|
||||
IRREGEXP, // Compiled with Irregexp (code or bytecode).
|
||||
EXPERIMENTAL, // Compiled to use the experimental linear time engine.
|
||||
};
|
||||
DEFINE_TORQUE_GENERATED_JS_REG_EXP_FLAGS()
|
||||
|
||||
V8_EXPORT_PRIVATE static MaybeHandle<JSRegExp> New(
|
||||
Isolate* isolate, Handle<String> source, Flags flags,
|
||||
uint32_t backtrack_limit = kNoBacktrackLimit);
|
||||
|
||||
static MaybeHandle<JSRegExp> Initialize(
|
||||
Handle<JSRegExp> regexp, Handle<String> source, Flags flags,
|
||||
uint32_t backtrack_limit = kNoBacktrackLimit);
|
||||
static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
|
||||
Handle<String> source,
|
||||
Handle<String> flags_string);
|
||||
|
||||
DECL_ACCESSORS(last_index, Object)
|
||||
|
||||
// Instance fields accessors.
|
||||
inline String source() const;
|
||||
inline Flags flags() const;
|
||||
|
||||
// Data array field accessors.
|
||||
|
||||
inline Type type_tag() const;
|
||||
inline String atom_pattern() const;
|
||||
// This could be a Smi kUninitializedValue or Code.
|
||||
V8_EXPORT_PRIVATE Object code(bool is_latin1) const;
|
||||
V8_EXPORT_PRIVATE void set_code(bool is_unicode, Handle<Code> code);
|
||||
// This could be a Smi kUninitializedValue or ByteArray.
|
||||
V8_EXPORT_PRIVATE Object bytecode(bool is_latin1) const;
|
||||
// Sets the bytecode as well as initializing trampoline slots to the
|
||||
// RegExpInterpreterTrampoline.
|
||||
void set_bytecode_and_trampoline(Isolate* isolate,
|
||||
Handle<ByteArray> bytecode);
|
||||
inline int max_register_count() const;
|
||||
// Number of captures (without the match itself).
|
||||
inline int capture_count() const;
|
||||
inline Object capture_name_map();
|
||||
inline void set_capture_name_map(Handle<FixedArray> capture_name_map);
|
||||
uint32_t backtrack_limit() const;
|
||||
|
||||
static constexpr Flag AsJSRegExpFlag(RegExpFlag f) {
|
||||
return static_cast<Flag>(f);
|
||||
}
|
||||
@ -75,59 +112,33 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
|
||||
STATIC_ASSERT(kFlagCount == v8::RegExp::kFlagCount);
|
||||
STATIC_ASSERT(kFlagCount == kRegExpFlagCount);
|
||||
|
||||
DECL_ACCESSORS(last_index, Object)
|
||||
|
||||
// If the backtrack limit is set to this marker value, no limit is applied.
|
||||
static constexpr uint32_t kNoBacktrackLimit = 0;
|
||||
|
||||
V8_EXPORT_PRIVATE static MaybeHandle<JSRegExp> New(
|
||||
Isolate* isolate, Handle<String> source, Flags flags,
|
||||
uint32_t backtrack_limit = kNoBacktrackLimit);
|
||||
|
||||
static MaybeHandle<JSRegExp> Initialize(
|
||||
Handle<JSRegExp> regexp, Handle<String> source, Flags flags,
|
||||
uint32_t backtrack_limit = kNoBacktrackLimit);
|
||||
static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp,
|
||||
Handle<String> source,
|
||||
Handle<String> flags_string);
|
||||
|
||||
static base::Optional<Flags> FlagsFromString(Isolate* isolate,
|
||||
Handle<String> flags);
|
||||
|
||||
V8_EXPORT_PRIVATE static Handle<String> StringFromFlags(Isolate* isolate,
|
||||
Flags flags);
|
||||
|
||||
inline String EscapedPattern();
|
||||
|
||||
bool CanTierUp();
|
||||
bool MarkedForTierUp();
|
||||
void ResetLastTierUpTick();
|
||||
void TierUpTick();
|
||||
void MarkTierUpForNextExec();
|
||||
|
||||
inline Type TypeTag() const;
|
||||
bool ShouldProduceBytecode();
|
||||
inline bool HasCompiledCode() const;
|
||||
inline void DiscardCompiledCodeForSerialization();
|
||||
|
||||
static constexpr bool TypeSupportsCaptures(Type t) {
|
||||
return t == IRREGEXP || t == EXPERIMENTAL;
|
||||
}
|
||||
|
||||
// Maximum number of captures allowed.
|
||||
static constexpr int kMaxCaptures = 1 << 16;
|
||||
|
||||
// Number of captures (without the match itself).
|
||||
inline int CaptureCount() const;
|
||||
// Each capture (including the match itself) needs two registers.
|
||||
static constexpr int RegistersForCaptureCount(int count) {
|
||||
return (count + 1) * 2;
|
||||
}
|
||||
|
||||
inline int MaxRegisterCount() const;
|
||||
inline Flags GetFlags() const;
|
||||
inline String Pattern();
|
||||
inline String EscapedPattern();
|
||||
inline Object CaptureNameMap();
|
||||
inline Object DataAt(int index) const;
|
||||
// Set implementation data after the object has been prepared.
|
||||
inline void SetDataAt(int index, Object value);
|
||||
inline void SetCaptureNameMap(Handle<FixedArray> capture_name_map);
|
||||
|
||||
static constexpr int code_index(bool is_latin1) {
|
||||
return is_latin1 ? kIrregexpLatin1CodeIndex : kIrregexpUC16CodeIndex;
|
||||
}
|
||||
@ -137,17 +148,6 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
|
||||
: kIrregexpUC16BytecodeIndex;
|
||||
}
|
||||
|
||||
// This could be a Smi kUninitializedValue or Code.
|
||||
V8_EXPORT_PRIVATE Object Code(bool is_latin1) const;
|
||||
// This could be a Smi kUninitializedValue or ByteArray.
|
||||
V8_EXPORT_PRIVATE Object Bytecode(bool is_latin1) const;
|
||||
|
||||
bool ShouldProduceBytecode();
|
||||
inline bool HasCompiledCode() const;
|
||||
inline void DiscardCompiledCodeForSerialization();
|
||||
|
||||
uint32_t BacktrackLimit() const;
|
||||
|
||||
// Dispatched behavior.
|
||||
DECL_PRINTER(JSRegExp)
|
||||
DECL_VERIFIER(JSRegExp)
|
||||
@ -233,10 +233,20 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
|
||||
// The uninitialized value for a regexp code object.
|
||||
static constexpr int kUninitializedValue = -1;
|
||||
|
||||
// If the backtrack limit is set to this marker value, no limit is applied.
|
||||
static constexpr uint32_t kNoBacktrackLimit = 0;
|
||||
|
||||
// The heuristic value for the length of the subject string for which we
|
||||
// tier-up to the compiler immediately, instead of using the interpreter.
|
||||
static constexpr int kTierUpForSubjectLengthValue = 1000;
|
||||
|
||||
// Maximum number of captures allowed.
|
||||
static constexpr int kMaxCaptures = 1 << 16;
|
||||
|
||||
private:
|
||||
inline Object DataAt(int index) const;
|
||||
inline void SetDataAt(int index, Object value);
|
||||
|
||||
TQ_OBJECT_CONSTRUCTORS(JSRegExp)
|
||||
};
|
||||
|
||||
|
@ -806,8 +806,8 @@ Maybe<bool> ValueSerializer::WriteJSPrimitiveWrapper(
|
||||
|
||||
void ValueSerializer::WriteJSRegExp(Handle<JSRegExp> regexp) {
|
||||
WriteTag(SerializationTag::kRegExp);
|
||||
WriteString(handle(regexp->Pattern(), isolate_));
|
||||
WriteVarint(static_cast<uint32_t>(regexp->GetFlags()));
|
||||
WriteString(handle(regexp->source(), isolate_));
|
||||
WriteVarint(static_cast<uint32_t>(regexp->flags()));
|
||||
}
|
||||
|
||||
Maybe<bool> ValueSerializer::WriteJSMap(Handle<JSMap> map) {
|
||||
|
@ -604,7 +604,7 @@ HeapEntry* V8HeapExplorer::AddEntry(HeapObject object) {
|
||||
return AddEntry(object, HeapEntry::kClosure, "native_bind");
|
||||
} else if (object.IsJSRegExp()) {
|
||||
JSRegExp re = JSRegExp::cast(object);
|
||||
return AddEntry(object, HeapEntry::kRegExp, names_->GetName(re.Pattern()));
|
||||
return AddEntry(object, HeapEntry::kRegExp, names_->GetName(re.source()));
|
||||
} else if (object.IsJSObject()) {
|
||||
const char* name = names_->GetName(
|
||||
GetConstructorName(JSObject::cast(object)));
|
||||
|
@ -36,13 +36,13 @@ void ExperimentalRegExp::Initialize(Isolate* isolate, Handle<JSRegExp> re,
|
||||
|
||||
bool ExperimentalRegExp::IsCompiled(Handle<JSRegExp> re, Isolate* isolate) {
|
||||
DCHECK(FLAG_enable_experimental_regexp_engine);
|
||||
DCHECK_EQ(re->TypeTag(), JSRegExp::EXPERIMENTAL);
|
||||
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
|
||||
#ifdef VERIFY_HEAP
|
||||
re->JSRegExpVerify(isolate);
|
||||
#endif
|
||||
|
||||
return re->DataAt(JSRegExp::kIrregexpLatin1BytecodeIndex) !=
|
||||
Smi::FromInt(JSRegExp::kUninitializedValue);
|
||||
static constexpr bool kIsLatin1 = true;
|
||||
return re->bytecode(kIsLatin1) != Smi::FromInt(JSRegExp::kUninitializedValue);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -68,14 +68,14 @@ base::Optional<CompilationResult> CompileImpl(Isolate* isolate,
|
||||
Handle<JSRegExp> regexp) {
|
||||
Zone zone(isolate->allocator(), ZONE_NAME);
|
||||
|
||||
Handle<String> source(regexp->Pattern(), isolate);
|
||||
Handle<String> source(regexp->source(), isolate);
|
||||
|
||||
// Parse and compile the regexp source.
|
||||
RegExpCompileData parse_result;
|
||||
DCHECK(!isolate->has_pending_exception());
|
||||
|
||||
bool parse_success = RegExpParser::ParseRegExpFromHeapString(
|
||||
isolate, &zone, source, JSRegExp::AsRegExpFlags(regexp->GetFlags()),
|
||||
isolate, &zone, source, JSRegExp::AsRegExpFlags(regexp->flags()),
|
||||
&parse_result);
|
||||
if (!parse_success) {
|
||||
// The pattern was already parsed successfully during initialization, so
|
||||
@ -87,7 +87,7 @@ base::Optional<CompilationResult> CompileImpl(Isolate* isolate,
|
||||
}
|
||||
|
||||
ZoneList<RegExpInstruction> bytecode = ExperimentalRegExpCompiler::Compile(
|
||||
parse_result.tree, JSRegExp::AsRegExpFlags(regexp->GetFlags()), &zone);
|
||||
parse_result.tree, JSRegExp::AsRegExpFlags(regexp->flags()), &zone);
|
||||
|
||||
CompilationResult result;
|
||||
result.bytecode = VectorToByteArray(isolate, bytecode.ToVector());
|
||||
@ -100,12 +100,12 @@ base::Optional<CompilationResult> CompileImpl(Isolate* isolate,
|
||||
|
||||
bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) {
|
||||
DCHECK(FLAG_enable_experimental_regexp_engine);
|
||||
DCHECK_EQ(re->TypeTag(), JSRegExp::EXPERIMENTAL);
|
||||
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
|
||||
#ifdef VERIFY_HEAP
|
||||
re->JSRegExpVerify(isolate);
|
||||
#endif
|
||||
|
||||
Handle<String> source(re->Pattern(), isolate);
|
||||
Handle<String> source(re->source(), isolate);
|
||||
if (FLAG_trace_experimental_regexp_engine) {
|
||||
StdoutStream{} << "Compiling experimental regexp " << *source << std::endl;
|
||||
}
|
||||
@ -117,16 +117,8 @@ bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) {
|
||||
return false;
|
||||
}
|
||||
|
||||
re->SetDataAt(JSRegExp::kIrregexpLatin1BytecodeIndex,
|
||||
*compilation_result->bytecode);
|
||||
re->SetDataAt(JSRegExp::kIrregexpUC16BytecodeIndex,
|
||||
*compilation_result->bytecode);
|
||||
|
||||
Handle<Code> trampoline = BUILTIN_CODE(isolate, RegExpExperimentalTrampoline);
|
||||
re->SetDataAt(JSRegExp::kIrregexpLatin1CodeIndex, ToCodeT(*trampoline));
|
||||
re->SetDataAt(JSRegExp::kIrregexpUC16CodeIndex, ToCodeT(*trampoline));
|
||||
|
||||
re->SetCaptureNameMap(compilation_result->capture_name_map);
|
||||
re->set_bytecode_and_trampoline(isolate, compilation_result->bytecode);
|
||||
re->set_capture_name_map(compilation_result->capture_name_map);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -177,15 +169,15 @@ int32_t ExperimentalRegExp::ExecRaw(Isolate* isolate,
|
||||
DisallowGarbageCollection no_gc;
|
||||
|
||||
if (FLAG_trace_experimental_regexp_engine) {
|
||||
String source = String::cast(regexp.DataAt(JSRegExp::kSourceIndex));
|
||||
StdoutStream{} << "Executing experimental regexp " << source << std::endl;
|
||||
StdoutStream{} << "Executing experimental regexp " << regexp.source()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
ByteArray bytecode =
|
||||
ByteArray::cast(regexp.DataAt(JSRegExp::kIrregexpLatin1BytecodeIndex));
|
||||
static constexpr bool kIsLatin1 = true;
|
||||
ByteArray bytecode = ByteArray::cast(regexp.bytecode(kIsLatin1));
|
||||
|
||||
return ExecRawImpl(isolate, call_origin, bytecode, subject,
|
||||
regexp.CaptureCount(), output_registers,
|
||||
regexp.capture_count(), output_registers,
|
||||
output_register_count, subject_index);
|
||||
}
|
||||
|
||||
@ -216,7 +208,7 @@ MaybeHandle<Object> ExperimentalRegExp::Exec(
|
||||
int subject_index, Handle<RegExpMatchInfo> last_match_info,
|
||||
RegExp::ExecQuirks exec_quirks) {
|
||||
DCHECK(FLAG_enable_experimental_regexp_engine);
|
||||
DCHECK_EQ(regexp->TypeTag(), JSRegExp::EXPERIMENTAL);
|
||||
DCHECK_EQ(regexp->type_tag(), JSRegExp::EXPERIMENTAL);
|
||||
#ifdef VERIFY_HEAP
|
||||
regexp->JSRegExpVerify(isolate);
|
||||
#endif
|
||||
@ -230,7 +222,7 @@ MaybeHandle<Object> ExperimentalRegExp::Exec(
|
||||
|
||||
subject = String::Flatten(isolate, subject);
|
||||
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
int output_register_count = JSRegExp::RegistersForCaptureCount(capture_count);
|
||||
|
||||
int32_t* output_registers;
|
||||
@ -274,7 +266,7 @@ int32_t ExperimentalRegExp::OneshotExecRaw(Isolate* isolate,
|
||||
|
||||
if (FLAG_trace_experimental_regexp_engine) {
|
||||
StdoutStream{} << "Experimental execution (oneshot) of regexp "
|
||||
<< regexp->Pattern() << std::endl;
|
||||
<< regexp->source() << std::endl;
|
||||
}
|
||||
|
||||
base::Optional<CompilationResult> compilation_result =
|
||||
@ -284,7 +276,7 @@ int32_t ExperimentalRegExp::OneshotExecRaw(Isolate* isolate,
|
||||
DisallowGarbageCollection no_gc;
|
||||
return ExecRawImpl(isolate, RegExp::kFromRuntime,
|
||||
*compilation_result->bytecode, *subject,
|
||||
regexp->CaptureCount(), output_registers,
|
||||
regexp->capture_count(), output_registers,
|
||||
output_register_count, subject_index);
|
||||
}
|
||||
|
||||
@ -293,9 +285,9 @@ MaybeHandle<Object> ExperimentalRegExp::OneshotExec(
|
||||
int subject_index, Handle<RegExpMatchInfo> last_match_info,
|
||||
RegExp::ExecQuirks exec_quirks) {
|
||||
DCHECK(FLAG_enable_experimental_regexp_engine_on_excessive_backtracks);
|
||||
DCHECK_NE(regexp->TypeTag(), JSRegExp::NOT_COMPILED);
|
||||
DCHECK_NE(regexp->type_tag(), JSRegExp::NOT_COMPILED);
|
||||
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
int output_register_count = JSRegExp::RegistersForCaptureCount(capture_count);
|
||||
|
||||
int32_t* output_registers;
|
||||
|
@ -1060,12 +1060,12 @@ IrregexpInterpreter::Result IrregexpInterpreter::Match(
|
||||
if (FLAG_regexp_tier_up) regexp.TierUpTick();
|
||||
|
||||
bool is_one_byte = String::IsOneByteRepresentationUnderneath(subject_string);
|
||||
ByteArray code_array = ByteArray::cast(regexp.Bytecode(is_one_byte));
|
||||
int total_register_count = regexp.MaxRegisterCount();
|
||||
ByteArray code_array = ByteArray::cast(regexp.bytecode(is_one_byte));
|
||||
int total_register_count = regexp.max_register_count();
|
||||
|
||||
return MatchInternal(isolate, code_array, subject_string, output_registers,
|
||||
output_register_count, total_register_count,
|
||||
start_position, call_origin, regexp.BacktrackLimit());
|
||||
start_position, call_origin, regexp.backtrack_limit());
|
||||
}
|
||||
|
||||
IrregexpInterpreter::Result IrregexpInterpreter::MatchInternal(
|
||||
|
@ -309,7 +309,7 @@ int NativeRegExpMacroAssembler::Execute(
|
||||
RegExpStackScope stack_scope(isolate);
|
||||
|
||||
bool is_one_byte = String::IsOneByteRepresentationUnderneath(input);
|
||||
Code code = FromCodeT(CodeT::cast(regexp.Code(is_one_byte)));
|
||||
Code code = FromCodeT(CodeT::cast(regexp.code(is_one_byte)));
|
||||
RegExp::CallOrigin call_origin = RegExp::CallOrigin::kFromRuntime;
|
||||
|
||||
using RegexpMatcherSig =
|
||||
|
@ -146,7 +146,7 @@ MaybeHandle<Object> RegExp::ThrowRegExpException(Isolate* isolate,
|
||||
|
||||
void RegExp::ThrowRegExpException(Isolate* isolate, Handle<JSRegExp> re,
|
||||
RegExpError error_text) {
|
||||
USE(ThrowRegExpException(isolate, re, Handle<String>(re->Pattern(), isolate),
|
||||
USE(ThrowRegExpException(isolate, re, Handle<String>(re->source(), isolate),
|
||||
error_text));
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ MaybeHandle<Object> RegExp::Compile(Isolate* isolate, Handle<JSRegExp> re,
|
||||
// static
|
||||
bool RegExp::EnsureFullyCompiled(Isolate* isolate, Handle<JSRegExp> re,
|
||||
Handle<String> subject) {
|
||||
switch (re->TypeTag()) {
|
||||
switch (re->type_tag()) {
|
||||
case JSRegExp::NOT_COMPILED:
|
||||
UNREACHABLE();
|
||||
case JSRegExp::ATOM:
|
||||
@ -308,7 +308,7 @@ MaybeHandle<Object> RegExp::Exec(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
Handle<String> subject, int index,
|
||||
Handle<RegExpMatchInfo> last_match_info,
|
||||
ExecQuirks exec_quirks) {
|
||||
switch (regexp->TypeTag()) {
|
||||
switch (regexp->type_tag()) {
|
||||
case JSRegExp::NOT_COMPILED:
|
||||
UNREACHABLE();
|
||||
case JSRegExp::ATOM:
|
||||
@ -352,7 +352,7 @@ int RegExpImpl::AtomExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
subject = String::Flatten(isolate, subject);
|
||||
DisallowGarbageCollection no_gc; // ensure vectors stay valid
|
||||
|
||||
String needle = String::cast(regexp->DataAt(JSRegExp::kAtomPatternIndex));
|
||||
String needle = regexp->atom_pattern();
|
||||
int needle_len = needle.length();
|
||||
DCHECK(needle.IsFlat());
|
||||
DCHECK_LT(0, needle_len);
|
||||
@ -420,8 +420,8 @@ Handle<Object> RegExpImpl::AtomExec(Isolate* isolate, Handle<JSRegExp> re,
|
||||
bool RegExpImpl::EnsureCompiledIrregexp(Isolate* isolate, Handle<JSRegExp> re,
|
||||
Handle<String> sample_subject,
|
||||
bool is_one_byte) {
|
||||
Object compiled_code = re->Code(is_one_byte);
|
||||
Object bytecode = re->Bytecode(is_one_byte);
|
||||
Object compiled_code = re->code(is_one_byte);
|
||||
Object bytecode = re->bytecode(is_one_byte);
|
||||
bool needs_initial_compilation =
|
||||
compiled_code == Smi::FromInt(JSRegExp::kUninitializedValue);
|
||||
// Recompile is needed when we're dealing with the first execution of the
|
||||
@ -450,8 +450,8 @@ namespace {
|
||||
|
||||
#ifdef DEBUG
|
||||
bool RegExpCodeIsValidForPreCompilation(Handle<JSRegExp> re, bool is_one_byte) {
|
||||
Object entry = re->Code(is_one_byte);
|
||||
Object bytecode = re->Bytecode(is_one_byte);
|
||||
Object entry = re->code(is_one_byte);
|
||||
Object bytecode = re->bytecode(is_one_byte);
|
||||
// If we're not using the tier-up strategy, entry can only be a smi
|
||||
// representing an uncompiled regexp here. If we're using the tier-up
|
||||
// strategy, entry can still be a smi representing an uncompiled regexp, when
|
||||
@ -528,9 +528,9 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
|
||||
|
||||
DCHECK(RegExpCodeIsValidForPreCompilation(re, is_one_byte));
|
||||
|
||||
RegExpFlags flags = JSRegExp::AsRegExpFlags(re->GetFlags());
|
||||
RegExpFlags flags = JSRegExp::AsRegExpFlags(re->flags());
|
||||
|
||||
Handle<String> pattern(re->Pattern(), isolate);
|
||||
Handle<String> pattern(re->source(), isolate);
|
||||
pattern = String::Flatten(isolate, pattern);
|
||||
RegExpCompileData compile_data;
|
||||
if (!RegExpParser::ParseRegExpFromHeapString(isolate, &zone, pattern, flags,
|
||||
@ -548,7 +548,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
|
||||
compile_data.compilation_target = re->ShouldProduceBytecode()
|
||||
? RegExpCompilationTarget::kBytecode
|
||||
: RegExpCompilationTarget::kNative;
|
||||
uint32_t backtrack_limit = re->BacktrackLimit();
|
||||
uint32_t backtrack_limit = re->backtrack_limit();
|
||||
const bool compilation_succeeded =
|
||||
Compile(isolate, &zone, &compile_data, flags, pattern, sample_subject,
|
||||
is_one_byte, backtrack_limit);
|
||||
@ -581,7 +581,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
|
||||
}
|
||||
Handle<FixedArray> capture_name_map =
|
||||
RegExp::CreateCaptureNameMap(isolate, compile_data.named_captures);
|
||||
re->SetCaptureNameMap(capture_name_map);
|
||||
re->set_capture_name_map(capture_name_map);
|
||||
int register_max = IrregexpMaxRegisterCount(*data);
|
||||
if (compile_data.register_count > register_max) {
|
||||
SetIrregexpMaxRegisterCount(*data, compile_data.register_count);
|
||||
@ -644,7 +644,7 @@ int RegExpImpl::IrregexpPrepare(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
|
||||
// Only reserve room for output captures. Internal registers are allocated by
|
||||
// the engine.
|
||||
return JSRegExp::RegistersForCaptureCount(regexp->CaptureCount());
|
||||
return JSRegExp::RegistersForCaptureCount(regexp->capture_count());
|
||||
}
|
||||
|
||||
int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
@ -654,7 +654,7 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
DCHECK_LE(index, subject->length());
|
||||
DCHECK(subject->IsFlat());
|
||||
DCHECK_GE(output_size,
|
||||
JSRegExp::RegistersForCaptureCount(regexp->CaptureCount()));
|
||||
JSRegExp::RegistersForCaptureCount(regexp->capture_count()));
|
||||
|
||||
bool is_one_byte = String::IsOneByteRepresentationUnderneath(*subject);
|
||||
|
||||
@ -721,14 +721,13 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
|
||||
Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject,
|
||||
int previous_index, Handle<RegExpMatchInfo> last_match_info,
|
||||
RegExp::ExecQuirks exec_quirks) {
|
||||
DCHECK_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP);
|
||||
DCHECK_EQ(regexp->type_tag(), JSRegExp::IRREGEXP);
|
||||
|
||||
subject = String::Flatten(isolate, subject);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (FLAG_trace_regexp_bytecodes && regexp->ShouldProduceBytecode()) {
|
||||
String pattern = regexp->Pattern();
|
||||
PrintF("\n\nRegexp match: /%s/\n\n", pattern.ToCString().get());
|
||||
PrintF("\n\nRegexp match: /%s/\n\n", regexp->source().ToCString().get());
|
||||
PrintF("\n\nSubject string: '%s'\n\n", subject->ToCString().get());
|
||||
}
|
||||
#endif
|
||||
@ -775,7 +774,7 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
|
||||
return isolate->factory()->null_value();
|
||||
}
|
||||
}
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
return RegExp::SetLastMatchInfo(isolate, last_match_info, subject,
|
||||
capture_count, output_registers);
|
||||
} else if (res == RegExp::RE_FALLBACK_TO_EXPERIMENTAL) {
|
||||
@ -1042,9 +1041,9 @@ RegExpGlobalCache::RegExpGlobalCache(Handle<JSRegExp> regexp,
|
||||
regexp_(regexp),
|
||||
subject_(subject),
|
||||
isolate_(isolate) {
|
||||
DCHECK(IsGlobal(JSRegExp::AsRegExpFlags(regexp->GetFlags())));
|
||||
DCHECK(IsGlobal(JSRegExp::AsRegExpFlags(regexp->flags())));
|
||||
|
||||
switch (regexp_->TypeTag()) {
|
||||
switch (regexp_->type_tag()) {
|
||||
case JSRegExp::NOT_COMPILED:
|
||||
UNREACHABLE();
|
||||
case JSRegExp::ATOM: {
|
||||
@ -1081,7 +1080,7 @@ RegExpGlobalCache::RegExpGlobalCache(Handle<JSRegExp> regexp,
|
||||
return;
|
||||
}
|
||||
registers_per_match_ =
|
||||
JSRegExp::RegistersForCaptureCount(regexp->CaptureCount());
|
||||
JSRegExp::RegistersForCaptureCount(regexp->capture_count());
|
||||
register_array_size_ = std::max(
|
||||
{registers_per_match_, Isolate::kJSRegexpStaticOffsetsVectorSize});
|
||||
break;
|
||||
@ -1117,7 +1116,7 @@ RegExpGlobalCache::~RegExpGlobalCache() {
|
||||
}
|
||||
|
||||
int RegExpGlobalCache::AdvanceZeroLength(int last_index) {
|
||||
if (IsUnicode(JSRegExp::AsRegExpFlags(regexp_->GetFlags())) &&
|
||||
if (IsUnicode(JSRegExp::AsRegExpFlags(regexp_->flags())) &&
|
||||
last_index + 1 < subject_->length() &&
|
||||
unibrow::Utf16::IsLeadSurrogate(subject_->Get(last_index)) &&
|
||||
unibrow::Utf16::IsTrailSurrogate(subject_->Get(last_index + 1))) {
|
||||
@ -1142,7 +1141,7 @@ int32_t* RegExpGlobalCache::FetchNext() {
|
||||
®ister_array_[(current_match_index_ - 1) * registers_per_match_];
|
||||
int last_end_index = last_match[1];
|
||||
|
||||
switch (regexp_->TypeTag()) {
|
||||
switch (regexp_->type_tag()) {
|
||||
case JSRegExp::NOT_COMPILED:
|
||||
UNREACHABLE();
|
||||
case JSRegExp::ATOM:
|
||||
|
@ -678,7 +678,8 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) {
|
||||
Handle<String> source(String::cast(regexp_instance->source()), isolate);
|
||||
Handle<RegExpBoilerplateDescription> boilerplate =
|
||||
isolate->factory()->NewRegExpBoilerplateDescription(
|
||||
data, source, Smi::cast(regexp_instance->flags()));
|
||||
data, source,
|
||||
Smi::FromInt(static_cast<int>(regexp_instance->flags())));
|
||||
|
||||
vector->SynchronizedSet(literal_slot, *boilerplate);
|
||||
DCHECK(HasBoilerplate(
|
||||
|
@ -333,8 +333,8 @@ bool CompiledReplacement::Compile(Isolate* isolate, Handle<JSRegExp> regexp,
|
||||
|
||||
FixedArray capture_name_map;
|
||||
if (capture_count > 0) {
|
||||
DCHECK(JSRegExp::TypeSupportsCaptures(regexp->TypeTag()));
|
||||
Object maybe_capture_name_map = regexp->CaptureNameMap();
|
||||
DCHECK(JSRegExp::TypeSupportsCaptures(regexp->type_tag()));
|
||||
Object maybe_capture_name_map = regexp->capture_name_map();
|
||||
if (maybe_capture_name_map.IsFixedArray()) {
|
||||
capture_name_map = FixedArray::cast(maybe_capture_name_map);
|
||||
}
|
||||
@ -550,9 +550,8 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalAtomRegExpWithString(
|
||||
|
||||
std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
|
||||
|
||||
DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
|
||||
String pattern =
|
||||
String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
|
||||
DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->type_tag());
|
||||
String pattern = pattern_regexp->atom_pattern();
|
||||
int subject_len = subject->length();
|
||||
int pattern_len = pattern.length();
|
||||
int replacement_len = replacement->length();
|
||||
@ -628,7 +627,7 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString(
|
||||
DCHECK(subject->IsFlat());
|
||||
DCHECK(replacement->IsFlat());
|
||||
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
int subject_length = subject->length();
|
||||
|
||||
// Ensure the RegExp is compiled so we can access the capture-name map.
|
||||
@ -641,7 +640,7 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString(
|
||||
isolate, regexp, replacement, capture_count, subject_length);
|
||||
|
||||
// Shortcut for simple non-regexp global replacements
|
||||
if (regexp->TypeTag() == JSRegExp::ATOM && simple_replace) {
|
||||
if (regexp->type_tag() == JSRegExp::ATOM && simple_replace) {
|
||||
if (subject->IsOneByteRepresentation() &&
|
||||
replacement->IsOneByteRepresentation()) {
|
||||
return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
|
||||
@ -706,7 +705,7 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithEmptyString(
|
||||
DCHECK(subject->IsFlat());
|
||||
|
||||
// Shortcut for simple non-regexp global replacements
|
||||
if (regexp->TypeTag() == JSRegExp::ATOM) {
|
||||
if (regexp->type_tag() == JSRegExp::ATOM) {
|
||||
Handle<String> empty_string = isolate->factory()->empty_string();
|
||||
if (subject->IsOneByteRepresentation()) {
|
||||
return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
|
||||
@ -728,7 +727,7 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithEmptyString(
|
||||
|
||||
int start = current_match[0];
|
||||
int end = current_match[1];
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
int subject_length = subject->length();
|
||||
|
||||
int new_length = subject_length - (end - start);
|
||||
@ -967,7 +966,7 @@ RUNTIME_FUNCTION(Runtime_RegExpBuildIndices) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, maybe_names, 2);
|
||||
#ifdef DEBUG
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
|
||||
DCHECK(regexp->GetFlags() & JSRegExp::kHasIndices);
|
||||
DCHECK(regexp->flags() & JSRegExp::kHasIndices);
|
||||
#endif
|
||||
|
||||
return *JSRegExpResultIndices::BuildIndices(isolate, match_info, maybe_names);
|
||||
@ -983,8 +982,8 @@ class MatchInfoBackedMatch : public String::Match {
|
||||
: isolate_(isolate), match_info_(match_info) {
|
||||
subject_ = String::Flatten(isolate, subject);
|
||||
|
||||
if (JSRegExp::TypeSupportsCaptures(regexp->TypeTag())) {
|
||||
Object o = regexp->CaptureNameMap();
|
||||
if (JSRegExp::TypeSupportsCaptures(regexp->type_tag())) {
|
||||
Object o = regexp->capture_name_map();
|
||||
has_named_captures_ = o.IsFixedArray();
|
||||
if (has_named_captures_) {
|
||||
capture_name_map_ = handle(FixedArray::cast(o), isolate);
|
||||
@ -1165,7 +1164,7 @@ static Object SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
|
||||
Handle<RegExpMatchInfo> last_match_array,
|
||||
Handle<JSArray> result_array) {
|
||||
DCHECK(RegExpUtils::IsUnmodifiedRegExp(isolate, regexp));
|
||||
DCHECK_NE(has_capture, regexp->CaptureCount() == 0);
|
||||
DCHECK_NE(has_capture, regexp->capture_count() == 0);
|
||||
DCHECK(subject->IsFlat());
|
||||
|
||||
// Force tier up to native code for global replaces. The global replace is
|
||||
@ -1173,7 +1172,7 @@ static Object SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
|
||||
// native code expects an array to store all the matches, and the bytecode
|
||||
// matches one at a time, so it's easier to tier-up to native code from the
|
||||
// start.
|
||||
if (FLAG_regexp_tier_up && regexp->TypeTag() == JSRegExp::IRREGEXP) {
|
||||
if (FLAG_regexp_tier_up && regexp->type_tag() == JSRegExp::IRREGEXP) {
|
||||
regexp->MarkTierUpForNextExec();
|
||||
if (FLAG_trace_regexp_tier_up) {
|
||||
PrintF("Forcing tier-up of JSRegExp object %p in SearchRegExpMultiple\n",
|
||||
@ -1181,7 +1180,7 @@ static Object SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
|
||||
}
|
||||
}
|
||||
|
||||
int capture_count = regexp->CaptureCount();
|
||||
int capture_count = regexp->capture_count();
|
||||
int subject_length = subject->length();
|
||||
|
||||
static const int kMinLengthToCache = 0x1000;
|
||||
@ -1260,7 +1259,7 @@ static Object SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
|
||||
// subject, i.e., 3 + capture count in total. If the RegExp contains
|
||||
// named captures, they are also passed as the last argument.
|
||||
|
||||
Handle<Object> maybe_capture_map(regexp->CaptureNameMap(), isolate);
|
||||
Handle<Object> maybe_capture_map(regexp->capture_name_map(), isolate);
|
||||
const bool has_named_captures = maybe_capture_map->IsFixedArray();
|
||||
|
||||
const int argc =
|
||||
@ -1350,7 +1349,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace(
|
||||
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
const int flags = regexp->GetFlags();
|
||||
const int flags = regexp->flags();
|
||||
const bool global = (flags & JSRegExp::kGlobal) != 0;
|
||||
const bool sticky = (flags & JSRegExp::kSticky) != 0;
|
||||
|
||||
@ -1422,7 +1421,7 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace(
|
||||
// native code expects an array to store all the matches, and the bytecode
|
||||
// matches one at a time, so it's easier to tier-up to native code from the
|
||||
// start.
|
||||
if (FLAG_regexp_tier_up && regexp->TypeTag() == JSRegExp::IRREGEXP) {
|
||||
if (FLAG_regexp_tier_up && regexp->type_tag() == JSRegExp::IRREGEXP) {
|
||||
regexp->MarkTierUpForNextExec();
|
||||
if (FLAG_trace_regexp_tier_up) {
|
||||
PrintF("Forcing tier-up of JSRegExp object %p in RegExpReplace\n",
|
||||
@ -1472,10 +1471,10 @@ RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) {
|
||||
CHECK(result_array->HasObjectElements());
|
||||
|
||||
subject = String::Flatten(isolate, subject);
|
||||
CHECK(regexp->GetFlags() & JSRegExp::kGlobal);
|
||||
CHECK(regexp->flags() & JSRegExp::kGlobal);
|
||||
|
||||
Object result;
|
||||
if (regexp->CaptureCount() == 0) {
|
||||
if (regexp->capture_count() == 0) {
|
||||
result = SearchRegExpMultiple<false>(isolate, subject, regexp,
|
||||
last_match_info, result_array);
|
||||
} else {
|
||||
@ -1499,7 +1498,7 @@ RUNTIME_FUNCTION(Runtime_StringReplaceNonGlobalRegExpWithFunction) {
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<RegExpMatchInfo> last_match_info = isolate->regexp_last_match_info();
|
||||
|
||||
const int flags = regexp->GetFlags();
|
||||
const int flags = regexp->flags();
|
||||
DCHECK_EQ(flags & JSRegExp::kGlobal, 0);
|
||||
|
||||
// TODO(jgruber): This should be an easy port to CSA with massive payback.
|
||||
@ -1552,9 +1551,9 @@ RUNTIME_FUNCTION(Runtime_StringReplaceNonGlobalRegExpWithFunction) {
|
||||
bool has_named_captures = false;
|
||||
Handle<FixedArray> capture_map;
|
||||
if (m > 1) {
|
||||
DCHECK(JSRegExp::TypeSupportsCaptures(regexp->TypeTag()));
|
||||
DCHECK(JSRegExp::TypeSupportsCaptures(regexp->type_tag()));
|
||||
|
||||
Object maybe_capture_map = regexp->CaptureNameMap();
|
||||
Object maybe_capture_map = regexp->capture_name_map();
|
||||
if (maybe_capture_map.IsFixedArray()) {
|
||||
has_named_captures = true;
|
||||
capture_map = handle(FixedArray::cast(maybe_capture_map), isolate);
|
||||
@ -2015,7 +2014,7 @@ RUNTIME_FUNCTION(Runtime_RegExpStringFromFlags) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
|
||||
Handle<String> flags = JSRegExp::StringFromFlags(isolate, regexp.GetFlags());
|
||||
Handle<String> flags = JSRegExp::StringFromFlags(isolate, regexp.flags());
|
||||
return *flags;
|
||||
}
|
||||
|
||||
|
@ -1135,8 +1135,8 @@ RUNTIME_FUNCTION(Runtime_RegexpHasBytecode) {
|
||||
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
|
||||
CONVERT_BOOLEAN_ARG_CHECKED(is_latin1, 1);
|
||||
bool result;
|
||||
if (regexp.TypeTag() == JSRegExp::IRREGEXP) {
|
||||
result = regexp.Bytecode(is_latin1).IsByteArray();
|
||||
if (regexp.type_tag() == JSRegExp::IRREGEXP) {
|
||||
result = regexp.bytecode(is_latin1).IsByteArray();
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
@ -1149,8 +1149,8 @@ RUNTIME_FUNCTION(Runtime_RegexpHasNativeCode) {
|
||||
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
|
||||
CONVERT_BOOLEAN_ARG_CHECKED(is_latin1, 1);
|
||||
bool result;
|
||||
if (regexp.TypeTag() == JSRegExp::IRREGEXP) {
|
||||
result = regexp.Code(is_latin1).IsCodeT();
|
||||
if (regexp.type_tag() == JSRegExp::IRREGEXP) {
|
||||
result = regexp.code(is_latin1).IsCodeT();
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
@ -1162,7 +1162,7 @@ RUNTIME_FUNCTION(Runtime_RegexpTypeTag) {
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
|
||||
const char* type_str;
|
||||
switch (regexp.TypeTag()) {
|
||||
switch (regexp.type_tag()) {
|
||||
case JSRegExp::NOT_COMPILED:
|
||||
type_str = "NOT_COMPILED";
|
||||
break;
|
||||
|
@ -724,9 +724,9 @@ void WebSnapshotSerializer::WriteValue(Handle<Object> object,
|
||||
return;
|
||||
}
|
||||
uint32_t pattern_id, flags_id;
|
||||
Handle<String> pattern = handle(regexp->Pattern(), isolate_);
|
||||
Handle<String> pattern = handle(regexp->source(), isolate_);
|
||||
Handle<String> flags_string =
|
||||
JSRegExp::StringFromFlags(isolate_, regexp->GetFlags());
|
||||
JSRegExp::StringFromFlags(isolate_, regexp->flags());
|
||||
SerializeString(pattern, pattern_id);
|
||||
SerializeString(flags_string, flags_id);
|
||||
serializer.WriteUint32(ValueType::REGEXP);
|
||||
|
@ -643,9 +643,8 @@ static Handle<JSRegExp> CreateJSRegExp(Handle<String> source, Handle<Code> code,
|
||||
|
||||
factory->SetRegExpIrregexpData(regexp, source, {}, 0,
|
||||
JSRegExp::kNoBacktrackLimit);
|
||||
regexp->SetDataAt(is_unicode ? JSRegExp::kIrregexpUC16CodeIndex
|
||||
: JSRegExp::kIrregexpLatin1CodeIndex,
|
||||
ToCodeT(*code));
|
||||
const bool is_latin1 = !is_unicode;
|
||||
regexp->set_code(is_latin1, code);
|
||||
|
||||
return regexp;
|
||||
}
|
||||
@ -2332,8 +2331,8 @@ TEST(UnicodePropertyEscapeCodeSize) {
|
||||
|
||||
static constexpr int kMaxSize = 200 * KB;
|
||||
static constexpr bool kIsNotLatin1 = false;
|
||||
Object maybe_code = re->Code(kIsNotLatin1);
|
||||
Object maybe_bytecode = re->Bytecode(kIsNotLatin1);
|
||||
Object maybe_code = re->code(kIsNotLatin1);
|
||||
Object maybe_bytecode = re->bytecode(kIsNotLatin1);
|
||||
if (maybe_bytecode.IsByteArray()) {
|
||||
// On x64, excessive inlining produced >250KB.
|
||||
CHECK_LT(ByteArray::cast(maybe_bytecode).Size(), kMaxSize);
|
||||
|
@ -806,7 +806,7 @@ void TestCustomSnapshotDataBlobWithIrregexpCode(
|
||||
// Check that ATOM regexp remains valid.
|
||||
i::Handle<i::JSRegExp> re =
|
||||
Utils::OpenHandle(*CompileRun("re2").As<v8::RegExp>());
|
||||
CHECK_EQ(re->TypeTag(), JSRegExp::ATOM);
|
||||
CHECK_EQ(re->type_tag(), JSRegExp::ATOM);
|
||||
CHECK(!re->HasCompiledCode());
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ TEST_F(TestWithNativeContext, ConvertRegExpFlagsToString) {
|
||||
Handle<JSRegExp> regexp = RunJS<JSRegExp>("regexp");
|
||||
Handle<String> flags = RunJS<String>("regexp.flags");
|
||||
Handle<String> converted_flags =
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->GetFlags());
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->flags());
|
||||
EXPECT_TRUE(String::Equals(isolate(), flags, converted_flags));
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ TEST_F(TestWithNativeContext, ConvertRegExpFlagsToStringNoFlags) {
|
||||
Handle<JSRegExp> regexp = RunJS<JSRegExp>("regexp");
|
||||
Handle<String> flags = RunJS<String>("regexp.flags");
|
||||
Handle<String> converted_flags =
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->GetFlags());
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->flags());
|
||||
EXPECT_TRUE(String::Equals(isolate(), flags, converted_flags));
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ TEST_F(TestWithNativeContext, ConvertRegExpFlagsToStringAllFlags) {
|
||||
Handle<JSRegExp> regexp = RunJS<JSRegExp>("regexp");
|
||||
Handle<String> flags = RunJS<String>("regexp.flags");
|
||||
Handle<String> converted_flags =
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->GetFlags());
|
||||
JSRegExp::StringFromFlags(isolate(), regexp->flags());
|
||||
EXPECT_TRUE(String::Equals(isolate(), flags, converted_flags));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user