diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /js/src/jit/WarpOracle.h | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit/WarpOracle.h')
-rw-r--r-- | js/src/jit/WarpOracle.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/jit/WarpOracle.h b/js/src/jit/WarpOracle.h new file mode 100644 index 0000000000..970cf325ac --- /dev/null +++ b/js/src/jit/WarpOracle.h @@ -0,0 +1,61 @@ +/* -*- 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_; + + // 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); +}; + +} // namespace jit +} // namespace js + +#endif /* jit_WarpOracle_h */ |