sourcepawn/jit/BaseRuntime.h
author David Anderson <dvander@alliedmods.net>
Sun Oct 26 23:50:54 2008 -0500 (2008-10-26)
changeset 2377 6ee3bbd6fbdf
parent 2226 d10b38524be3
child 2545 9cb1a1fefc2c
permissions -rw-r--r--
Fixed leaking relocation table memory in JIT.
dvander@2193
     1
#ifndef _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
dvander@2193
     2
#define _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
dvander@2193
     3
dvander@2193
     4
#include <sp_vm_api.h>
dvander@2193
     5
#include "jit_shared.h"
dvander@2193
     6
#include "sp_vm_function.h"
dvander@2193
     7
dvander@2193
     8
class BaseContext;
dvander@2226
     9
class JitFunction;
dvander@2193
    10
dvander@2193
    11
class DebugInfo : public IPluginDebugInfo
dvander@2193
    12
{
dvander@2193
    13
public:
dvander@2193
    14
	DebugInfo(sp_plugin_t *plugin);
dvander@2193
    15
public:
dvander@2193
    16
	int LookupFile(ucell_t addr, const char **filename);
dvander@2193
    17
	int LookupFunction(ucell_t addr, const char **name);
dvander@2193
    18
	int LookupLine(ucell_t addr, uint32_t *line);
dvander@2193
    19
private:
dvander@2193
    20
	sp_plugin_t *m_pPlugin;
dvander@2193
    21
};
dvander@2193
    22
dvander@2193
    23
/* Jit wants fast access to this so we expose things as public */
dvander@2193
    24
class BaseRuntime : public SourcePawn::IPluginRuntime
dvander@2193
    25
{
dvander@2193
    26
public:
dvander@2226
    27
	BaseRuntime();
dvander@2193
    28
	~BaseRuntime();
dvander@2193
    29
public:
dvander@2226
    30
	virtual int CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base);
dvander@2193
    31
	virtual bool IsDebugging();
dvander@2193
    32
	virtual IPluginDebugInfo *GetDebugInfo();
dvander@2193
    33
	virtual int FindNativeByName(const char *name, uint32_t *index);
dvander@2193
    34
	virtual int GetNativeByIndex(uint32_t index, sp_native_t **native);
dvander@2193
    35
	virtual uint32_t GetNativesNum();
dvander@2193
    36
	virtual int FindPublicByName(const char *name, uint32_t *index);
dvander@2193
    37
	virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
dvander@2193
    38
	virtual uint32_t GetPublicsNum();
dvander@2193
    39
	virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
dvander@2193
    40
	virtual int FindPubvarByName(const char *name, uint32_t *index);
dvander@2193
    41
	virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
dvander@2193
    42
	virtual uint32_t GetPubVarsNum();
dvander@2193
    43
	virtual IPluginFunction *GetFunctionByName(const char *public_name);
dvander@2193
    44
	virtual IPluginFunction *GetFunctionById(funcid_t func_id);
dvander@2193
    45
	virtual IPluginContext *GetDefaultContext();
dvander@2193
    46
	virtual int ApplyCompilationOptions(ICompilation *co);
dvander@2193
    47
	virtual void SetPauseState(bool paused);
dvander@2193
    48
	virtual bool IsPaused();
dvander@2193
    49
	virtual size_t GetMemUsage();
dvander@2226
    50
	JitFunction *GetJittedFunction(uint32_t idx);
dvander@2226
    51
	uint32_t AddJittedFunction(JitFunction *fn);
dvander@2193
    52
public:
dvander@2193
    53
	BaseContext *GetBaseContext();
dvander@2193
    54
private:
dvander@2226
    55
	sp_plugin_t m_plugin;
dvander@2226
    56
	unsigned int m_NumFuncs;
dvander@2226
    57
	unsigned int m_MaxFuncs;
dvander@2226
    58
	JitFunction **m_FuncCache;
dvander@2193
    59
public:
dvander@2193
    60
	DebugInfo m_Debug;
dvander@2193
    61
	sp_plugin_t *m_pPlugin;
dvander@2193
    62
	BaseContext *m_pCtx;
dvander@2193
    63
	CFunction **m_PubFuncs;
dvander@2226
    64
	JitFunction **m_PubJitFuncs;
dvander@2226
    65
	ICompilation *m_pCo;
dvander@2226
    66
	unsigned int m_CompSerial;
dvander@2193
    67
};
dvander@2193
    68
dvander@2193
    69
#endif //_INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_