tor-browser

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

commit fbe064140317cc4aeb5378bd40a1ddb9e9d9e1c5
parent 5eff2e1b632dc1c6bec60e6032bf7690acea8d2b
Author: Jan de Mooij <jdemooij@mozilla.com>
Date:   Tue, 18 Nov 2025 12:03:02 +0000

Bug 1992990 part 2 - Add WarpCacheIRBase base class for WarpCacheIR. r=iain

A later patch will add another class that derives from `WarpCacheIRBase`.

Differential Revision: https://phabricator.services.mozilla.com/D272478

Diffstat:
Mjs/src/jit/WarpCacheIRTranspiler.cpp | 7+++++--
Mjs/src/jit/WarpCacheIRTranspiler.h | 4++--
Mjs/src/jit/WarpSnapshot.cpp | 10++++++++--
Mjs/src/jit/WarpSnapshot.h | 39+++++++++++++++++++++++++++++----------
4 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/js/src/jit/WarpCacheIRTranspiler.cpp b/js/src/jit/WarpCacheIRTranspiler.cpp @@ -41,6 +41,7 @@ using namespace js::jit; class MOZ_RAII WarpCacheIRTranspiler : public WarpBuilderShared { WarpBuilder* builder_; BytecodeLocation loc_; + const WarpCacheIRBase* cacheIRSnapshot_; const CacheIRStubInfo* stubInfo_; const uint8_t* stubData_; @@ -326,11 +327,13 @@ class MOZ_RAII WarpCacheIRTranspiler : public WarpBuilderShared { public: WarpCacheIRTranspiler(WarpBuilder* builder, BytecodeLocation loc, - CallInfo* callInfo, const WarpCacheIR* cacheIRSnapshot) + CallInfo* callInfo, + const WarpCacheIRBase* cacheIRSnapshot) : WarpBuilderShared(builder->snapshot(), builder->mirGen(), builder->currentBlock()), builder_(builder), loc_(loc), + cacheIRSnapshot_(cacheIRSnapshot), stubInfo_(cacheIRSnapshot->stubInfo()), stubData_(cacheIRSnapshot->stubData()), callInfo_(callInfo) {} @@ -7236,7 +7239,7 @@ static void MaybeSetImplicitlyUsed(uint32_t numInstructionIdsBefore, } bool jit::TranspileCacheIRToMIR(WarpBuilder* builder, BytecodeLocation loc, - const WarpCacheIR* cacheIRSnapshot, + const WarpCacheIRBase* cacheIRSnapshot, std::initializer_list<MDefinition*> inputs, CallInfo* maybeCallInfo) { uint32_t numInstructionIdsBefore = diff --git a/js/src/jit/WarpCacheIRTranspiler.h b/js/src/jit/WarpCacheIRTranspiler.h @@ -18,12 +18,12 @@ namespace jit { class CallInfo; class MDefinition; class WarpBuilder; -class WarpCacheIR; +class WarpCacheIRBase; // Generate MIR from a Baseline ICStub's CacheIR. [[nodiscard]] bool TranspileCacheIRToMIR( WarpBuilder* builder, BytecodeLocation loc, - const WarpCacheIR* cacheIRSnapshot, + const WarpCacheIRBase* cacheIRSnapshot, std::initializer_list<MDefinition*> inputs, CallInfo* maybeCallInfo = nullptr); diff --git a/js/src/jit/WarpSnapshot.cpp b/js/src/jit/WarpSnapshot.cpp @@ -191,7 +191,7 @@ void WarpBailout::dumpData(GenericPrinter& out) const { // No fields. } -void WarpCacheIR::dumpData(GenericPrinter& out) const { +void WarpCacheIRBase::dumpData(GenericPrinter& out) const { out.printf(" stubCode: 0x%p\n", static_cast<JitCode*>(stubCode_)); out.printf(" stubInfo: 0x%p\n", stubInfo_); out.printf(" stubData: 0x%p\n", stubData_); @@ -203,6 +203,10 @@ void WarpCacheIR::dumpData(GenericPrinter& out) const { # endif } +void WarpCacheIR::dumpData(GenericPrinter& out) const { + WarpCacheIRBase::dumpData(out); +} + void WarpInlinedCall::dumpData(GenericPrinter& out) const { out.printf(" scriptSnapshot: 0x%p\n", scriptSnapshot_); out.printf(" info: 0x%p\n", info_); @@ -342,7 +346,7 @@ static void TraceWarpStubPtr(JSTracer* trc, uintptr_t word, const char* name) { TraceOffthreadGCPtr(trc, OffthreadGCPtr<T*>(ptr), name); } -void WarpCacheIR::traceData(JSTracer* trc) { +void WarpCacheIRBase::traceData(JSTracer* trc) { TraceOffthreadGCPtr(trc, stubCode_, "warp-stub-code"); if (stubData_) { uint32_t field = 0; @@ -425,6 +429,8 @@ void WarpCacheIR::traceData(JSTracer* trc) { } } +void WarpCacheIR::traceData(JSTracer* trc) { WarpCacheIRBase::traceData(trc); } + void WarpInlinedCall::traceData(JSTracer* trc) { // Note: scriptSnapshot_ is traced through WarpSnapshot. cacheIRSnapshot_->trace(trc); diff --git a/js/src/jit/WarpSnapshot.h b/js/src/jit/WarpSnapshot.h @@ -76,14 +76,19 @@ class WarpOpSnapshot : public TempObject, Kind kind() const { return kind_; } template <typename T> + bool is() const { + return kind_ == T::ThisKind; + } + + template <typename T> const T* as() const { - MOZ_ASSERT(kind_ == T::ThisKind); + MOZ_ASSERT(is<T>()); return static_cast<const T*>(this); } template <typename T> T* as() { - MOZ_ASSERT(kind_ == T::ThisKind); + MOZ_ASSERT(is<T>()); return static_cast<T*>(this); } @@ -214,8 +219,7 @@ class WarpBailout : public WarpOpSnapshot { #endif }; -// Information from a Baseline IC stub. -class WarpCacheIR : public WarpOpSnapshot { +class WarpCacheIRBase : public WarpOpSnapshot { // Baseline stub code. Stored here to keep the CacheIRStubInfo alive. OffthreadGCPtr<JitCode*> stubCode_; const CacheIRStubInfo* stubInfo_; @@ -223,18 +227,33 @@ class WarpCacheIR : public WarpOpSnapshot { // Copied Baseline stub data. Allocated in the same LifoAlloc. const uint8_t* stubData_; - public: - static constexpr Kind ThisKind = Kind::WarpCacheIR; - - WarpCacheIR(uint32_t offset, JitCode* stubCode, - const CacheIRStubInfo* stubInfo, const uint8_t* stubData) - : WarpOpSnapshot(ThisKind, offset), + protected: + WarpCacheIRBase(Kind kind, uint32_t offset, JitCode* stubCode, + const CacheIRStubInfo* stubInfo, const uint8_t* stubData) + : WarpOpSnapshot(kind, offset), stubCode_(stubCode), stubInfo_(stubInfo), stubData_(stubData) {} + void traceData(JSTracer* trc); + +#ifdef JS_JITSPEW + void dumpData(GenericPrinter& out) const; +#endif + + public: const CacheIRStubInfo* stubInfo() const { return stubInfo_; } const uint8_t* stubData() const { return stubData_; } +}; + +// Information from a Baseline IC stub. +class WarpCacheIR : public WarpCacheIRBase { + public: + static constexpr Kind ThisKind = Kind::WarpCacheIR; + + WarpCacheIR(uint32_t offset, JitCode* stubCode, + const CacheIRStubInfo* stubInfo, const uint8_t* stubData) + : WarpCacheIRBase(ThisKind, offset, stubCode, stubInfo, stubData) {} void traceData(JSTracer* trc);