#pragma once
#include "JSCJSValue.h"
#include "Opcode.h"
#include <array>
namespace JSC {
class VM;
struct Instruction;
#if !ENABLE(JIT)
typedef OpcodeID LLIntCode;
#else
typedef void (*LLIntCode)();
#endif
namespace LLInt {
struct OpcodeStats {
OpcodeID id;
size_t count { 0 };
size_t slowPathCount { 0 };
};
typedef std::array<OpcodeStats, numOpcodeIDs> OpcodeStatsArray;
class Data {
public:
static void performAssertions(VM&);
static OpcodeStats& opcodeStats(OpcodeID id) { return (*s_opcodeStatsArray)[id]; }
JS_EXPORT_PRIVATE static void finalizeStats();
static void dumpStats();
static void loadStats();
private:
static void ensureStats();
static void resetStats();
static void saveStats();
static Instruction* s_exceptionInstructions;
static Opcode s_opcodeMap[numOpcodeIDs];
static OpcodeStatsArray* s_opcodeStatsArray;
friend void initialize();
friend Instruction* exceptionInstructions();
friend Opcode* opcodeMap();
friend Opcode getOpcode(OpcodeID);
friend void* getCodePtr(OpcodeID);
};
void initialize();
inline Instruction* exceptionInstructions()
{
return Data::s_exceptionInstructions;
}
inline Opcode* opcodeMap()
{
return Data::s_opcodeMap;
}
inline Opcode getOpcode(OpcodeID id)
{
#if ENABLE(COMPUTED_GOTO_OPCODES)
return Data::s_opcodeMap[id];
#else
return static_cast<Opcode>(id);
#endif
}
ALWAYS_INLINE void* getCodePtr(OpcodeID id)
{
return reinterpret_cast<void*>(getOpcode(id));
}
#if ENABLE(JIT)
ALWAYS_INLINE LLIntCode getCodeFunctionPtr(OpcodeID codeId)
{
return reinterpret_cast<LLIntCode>(getCodePtr(codeId));
}
#endif
ALWAYS_INLINE void* getCodePtr(JSC::EncodedJSValue glueHelper())
{
return bitwise_cast<void*>(glueHelper);
}
} }