Revert "revert last rev (7faa37b7) and revert rev b7e45308 and 9824659d instead."

This reverts commit 4475b2d9f7 for landing
upstream fix.
This commit is contained in:
roytam1 2023-03-09 21:13:26 +08:00
commit 1b1d672dc6
3 changed files with 17 additions and 15 deletions

View file

@ -340,9 +340,6 @@ class TenuredCell : public Cell
static MOZ_ALWAYS_INLINE void writeBarrierPost(void* cellp, TenuredCell* prior,
TenuredCell* next);
// Default implementation for kinds that don't require finalization.
void finalize(FreeOp* fop) {}
// Default implementation for kinds that don't require fixup.
void fixupAfterMovingGC() {}

View file

@ -952,12 +952,6 @@ RegExpShared::RegExpShared(JSAtom* source, RegExpFlag flags)
numNamedCaptures_(0), groupsTemplate_(nullptr)
{}
RegExpShared::~RegExpShared()
{
for (size_t i = 0; i < tables.length(); i++)
js_delete(tables[i]);
}
void
RegExpShared::traceChildren(JSTracer* trc)
{
@ -978,6 +972,16 @@ RegExpShared::discardJitCode()
comp.jitCode = nullptr;
}
void
RegExpShared::finalize(FreeOp* fop)
{
for (auto& comp : compilationArray)
js_free(comp.byteCode);
for (size_t i = 0; i < tables.length(); i++)
js_free(tables[i]);
tables.~JitCodeTables();
}
/* static */ bool
RegExpShared::compile(JSContext* cx, MutableHandleRegExpShared re, HandleLinearString input,
CompilationMode mode, ForceByteCodeEnum force)

View file

@ -121,7 +121,6 @@ class RegExpShared : public gc::TenuredCell
uint8_t* byteCode;
RegExpCompilation() : byteCode(nullptr) {}
~RegExpCompilation() { js_free(byteCode); }
bool compiled(ForceByteCodeEnum force = DontForceByteCode) const {
return byteCode || (force == DontForceByteCode && jitCode);
@ -129,14 +128,14 @@ class RegExpShared : public gc::TenuredCell
};
/* Source to the RegExp, for lazy compilation. */
GCPtr<JSAtom*> source;
HeapPtr<JSAtom*> source;
RegExpFlag flags;
bool canStringMatch;
size_t parenCount;
uint32_t numNamedCaptures_;
GCPtr<PlainObject*> groupsTemplate_;
uint32_t numNamedCaptures_;
HeapPtr<PlainObject*> groupsTemplate_;
RegExpCompilation compilationArray[4];
@ -149,7 +148,8 @@ class RegExpShared : public gc::TenuredCell
}
// Tables referenced by JIT code.
Vector<uint8_t*, 0, SystemAllocPolicy> tables;
using JitCodeTables = Vector<uint8_t*, 0, SystemAllocPolicy>;
JitCodeTables tables;
/* Internal functions. */
RegExpShared(JSAtom* source, RegExpFlag flags);
@ -172,7 +172,7 @@ class RegExpShared : public gc::TenuredCell
}
public:
~RegExpShared();
~RegExpShared() = delete;
// Execute this RegExp on input starting from searchIndex, filling in
// matches if specified and otherwise only determining if there is a match.
@ -222,6 +222,7 @@ class RegExpShared : public gc::TenuredCell
void traceChildren(JSTracer* trc);
void discardJitCode();
void finalize(FreeOp* fop);
static size_t offsetOfSource() {
return offsetof(RegExpShared, source);