7875fe1acd
1) JIT compilation/optimization now occurs per-function, and only when functions are first used. We're now officially a whole-method JIT rather than an AOT compiler (albiet, still a simple JIT). This has two implications: Functions are now much better abstracted internally, and loading a plugin is now much less expensive. If a function contains calls to other functions, THOSE functions are only compiled when they're invoked as well. 2) I've removed debug mode. We always show full backtraces now, as there was a very cheap way to implement this which really cleaned up everything. This is great for a number of reasons -- there's less code, the JIT is better designed, we don't need to relocate debug tables, and best of all we no longer have to tell users to enable debug mode at their own expense. --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402459
60 lines
1.3 KiB
C++
60 lines
1.3 KiB
C++
#ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|
|
#define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|
|
|
|
#include <sp_vm_types.h>
|
|
#include <sh_list.h>
|
|
|
|
class CPlugin;
|
|
struct NativeEntry;
|
|
|
|
struct WeakNative
|
|
{
|
|
WeakNative(CPlugin *plugin, uint32_t index) :
|
|
pl(plugin), idx(index), entry(NULL)
|
|
{
|
|
pl = plugin;
|
|
idx = index;
|
|
}
|
|
WeakNative(CPlugin *plugin, uint32_t index, NativeEntry *pEntry) :
|
|
pl(plugin), idx(index), entry(pEntry)
|
|
{
|
|
pl = plugin;
|
|
idx = index;
|
|
}
|
|
CPlugin *pl;
|
|
uint32_t idx;
|
|
NativeEntry *entry;
|
|
};
|
|
|
|
using namespace SourceHook;
|
|
|
|
class CNativeOwner
|
|
{
|
|
public:
|
|
CNativeOwner();
|
|
public:
|
|
virtual void DropEverything();
|
|
public:
|
|
void AddNatives(const sp_nativeinfo_t *info);
|
|
public:
|
|
void SetMarkSerial(unsigned int serial);
|
|
unsigned int GetMarkSerial();
|
|
void PropogateMarkSerial(unsigned int serial);
|
|
public:
|
|
void AddDependent(CPlugin *pPlugin);
|
|
void AddWeakRef(const WeakNative & ref);
|
|
void DropRefsTo(CPlugin *pPlugin);
|
|
void AddReplacedNative(NativeEntry *pEntry);
|
|
private:
|
|
void DropWeakRefsTo(CPlugin *pPlugin);
|
|
void UnbindWeakRef(const WeakNative & ref);
|
|
protected:
|
|
List<CPlugin *> m_Dependents;
|
|
unsigned int m_nMarkSerial;
|
|
List<WeakNative> m_WeakRefs;
|
|
List<NativeEntry *> m_Natives;
|
|
List<NativeEntry *> m_ReplacedNatives;
|
|
};
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
|