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
38 lines
798 B
C++
38 lines
798 B
C++
#ifndef _INCLUDE_KNIGHT_ALLOCATOR_H_
|
|
#define _INCLUDE_KNIGHT_ALLOCATOR_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
|
|
struct ke_allocator_s;
|
|
typedef struct ke_allocator_s ke_allocator_t;
|
|
|
|
typedef void *(*KEFN_ALLOCATOR)(ke_allocator_t *, size_t);
|
|
typedef void (*KEFN_DEALLOCATOR)(ke_allocator_t *, void *);
|
|
|
|
struct ke_allocator_s
|
|
{
|
|
KEFN_ALLOCATOR alloc;
|
|
KEFN_DEALLOCATOR dealloc;
|
|
void *user;
|
|
};
|
|
|
|
inline void *operator new(size_t size, ke_allocator_t *alloc)
|
|
{
|
|
return alloc->alloc(alloc, size);
|
|
}
|
|
|
|
inline void *operator new [](size_t size, ke_allocator_t *alloc)
|
|
{
|
|
return alloc->alloc(alloc, size);
|
|
}
|
|
|
|
template <typename T>
|
|
void ke_destroy(ke_allocator_t *alloc, T * data)
|
|
{
|
|
data->~T();
|
|
alloc->dealloc(alloc, data);
|
|
}
|
|
|
|
#endif //_INCLUDE_KNIGHT_ALLOCATOR_H_
|