Commit 77906a70 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

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