diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/jit/WarpOracle.h | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit/WarpOracle.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/js/src/jit/WarpOracle.h b/js/src/jit/WarpOracle.h new file mode 100644 index 0000000000..f8db42d15b --- /dev/null +++ b/js/src/jit/WarpOracle.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jit_WarpOracle_h +#define jit_WarpOracle_h + +#include "jit/JitAllocPolicy.h" +#include "jit/JitContext.h" +#include "jit/WarpSnapshot.h" + +namespace js { +namespace jit { + +class MIRGenerator; + +// WarpOracle creates a WarpSnapshot data structure that's used by WarpBuilder +// to generate the MIR graph off-thread. +class MOZ_STACK_CLASS WarpOracle { + JSContext* cx_; + MIRGenerator& mirGen_; + TempAllocator& alloc_; + HandleScript outerScript_; + WarpBailoutInfo bailoutInfo_; + WarpScriptSnapshotList scriptSnapshots_; + size_t accumulatedBytecodeSize_ = 0; +#ifdef DEBUG + mozilla::HashNumber runningScriptHash_ = 0; +#endif + + // List of nursery objects to copy to the snapshot. See WarpObjectField. + // The HashMap is used to de-duplicate the Vector. It maps each object to the + // corresponding nursery index (index into the Vector). + // Note: this stores raw object pointers because WarpOracle can't GC. + Vector<JSObject*, 8, SystemAllocPolicy> nurseryObjects_; + using NurseryObjectsMap = + HashMap<JSObject*, uint32_t, DefaultHasher<JSObject*>, SystemAllocPolicy>; + NurseryObjectsMap nurseryObjectsMap_; + + public: + WarpOracle(JSContext* cx, MIRGenerator& mirGen, HandleScript outerScript); + ~WarpOracle() { scriptSnapshots_.clear(); } + + MIRGenerator& mirGen() { return mirGen_; } + WarpBailoutInfo& bailoutInfo() { return bailoutInfo_; } + + [[nodiscard]] bool registerNurseryObject(JSObject* obj, + uint32_t* nurseryIndex); + + AbortReasonOr<WarpSnapshot*> createSnapshot(); + + mozilla::GenericErrorResult<AbortReason> abort(HandleScript script, + AbortReason r); + mozilla::GenericErrorResult<AbortReason> abort(HandleScript script, + AbortReason r, + const char* message, ...); + void addScriptSnapshot(WarpScriptSnapshot* scriptSnapshot, ICScript* icScript, + size_t bytecodeLength); + + size_t accumulatedBytecodeSize() { return accumulatedBytecodeSize_; } +}; + +} // namespace jit +} // namespace js + +#endif /* jit_WarpOracle_h */ |