PCToCodeOriginMap.h [plain text]
#pragma once
#if ENABLE(JIT)
#include "CodeOrigin.h"
#include "MacroAssembler.h"
#include "VM.h"
#include <wtf/Optional.h>
#include <wtf/Vector.h>
namespace JSC {
#if ENABLE(FTL_JIT)
namespace B3 {
class PCToOriginMap;
}
#endif
class LinkBuffer;
class PCToCodeOriginMapBuilder;
class PCToCodeOriginMapBuilder {
WTF_MAKE_NONCOPYABLE(PCToCodeOriginMapBuilder);
friend class PCToCodeOriginMap;
public:
PCToCodeOriginMapBuilder(VM&);
PCToCodeOriginMapBuilder(PCToCodeOriginMapBuilder&& other);
#if ENABLE(FTL_JIT)
PCToCodeOriginMapBuilder(VM&, B3::PCToOriginMap&&);
#endif
void appendItem(MacroAssembler::Label, const CodeOrigin&);
static CodeOrigin defaultCodeOrigin() { return CodeOrigin(0, nullptr); }
bool didBuildMapping() const { return m_shouldBuildMapping; }
private:
struct CodeRange {
MacroAssembler::Label start;
MacroAssembler::Label end;
CodeOrigin codeOrigin;
};
VM& m_vm;
Vector<CodeRange> m_codeRanges;
bool m_shouldBuildMapping;
};
class PCToCodeOriginMap {
WTF_MAKE_NONCOPYABLE(PCToCodeOriginMap);
public:
PCToCodeOriginMap(PCToCodeOriginMapBuilder&&, LinkBuffer&);
~PCToCodeOriginMap();
std::optional<CodeOrigin> findPC(void* pc) const;
double memorySize();
private:
size_t m_compressedPCBufferSize;
size_t m_compressedCodeOriginsSize;
uint8_t* m_compressedPCs;
uint8_t* m_compressedCodeOrigins;
uintptr_t m_pcRangeStart;
uintptr_t m_pcRangeEnd;
};
}
#endif // ENABLE(JIT)