diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/public/JitCodeAPI.h | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/public/JitCodeAPI.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/js/public/JitCodeAPI.h b/js/public/JitCodeAPI.h new file mode 100644 index 0000000000..20a33a778c --- /dev/null +++ b/js/public/JitCodeAPI.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +/* SpiderMonkey API for obtaining JitCode information. */ + +#ifndef js_JitCodeAPI_h +#define js_JitCodeAPI_h + +#include "js/AllocPolicy.h" +#include "js/Initialization.h" +#include "js/Printf.h" +#include "js/Vector.h" + +namespace JS { + +enum class JitTier { Baseline, IC, Ion, Other }; + +class JitOpcodeDictionary { + typedef js::Vector<UniqueChars, 0, js::SystemAllocPolicy> StringVector; + + public: + JitOpcodeDictionary(); + + StringVector& GetBaselineDictionary() { return baselineDictionary; } + StringVector& GetIonDictionary() { return ionDictionary; } + StringVector& GetInlineCacheDictionary() { return icDictionary; } + + private: + StringVector baselineDictionary; + StringVector icDictionary; + StringVector ionDictionary; +}; + +struct JitCodeSourceInfo { + UniqueChars filename; + uint32_t offset = 0; + uint32_t lineno = 0; + uint32_t colno = 0; +}; + +struct JitCodeIRInfo { + uint32_t offset = 0; + uint32_t opcode = 0; + UniqueChars str; +}; + +typedef js::Vector<JitCodeSourceInfo, 0, js::SystemAllocPolicy> + SourceInfoVector; +typedef js::Vector<JitCodeIRInfo, 0, js::SystemAllocPolicy> IRInfoVector; + +struct JitCodeRecord { + UniqueChars functionName; + uint64_t code_addr = 0; + uint32_t instructionSize = 0; + JitTier tier = JitTier::Other; + + SourceInfoVector sourceInfo; + IRInfoVector irInfo; +}; + +class JitCodeIterator { + void getDataForIndex(size_t iteratorIndex); + + public: + JitCodeIterator(); + ~JitCodeIterator(); + + void operator++(int) { + iteratorIndex++; + getDataForIndex(iteratorIndex); + } + + explicit operator bool() const { return data != nullptr; } + + SourceInfoVector& sourceData() { return data->sourceInfo; } + + IRInfoVector& irData() { return data->irInfo; } + + const char* functionName() const { return data->functionName.get(); } + uint64_t code_addr() const { return data->code_addr; } + uint32_t instructionSize() { return data->instructionSize; } + JitTier jit_tier() const { return data->tier; } + + private: + JitCodeRecord* data = nullptr; + size_t iteratorIndex = 0; +}; + +} // namespace JS + +#endif /* js_JitCodeAPI_h */ |