aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/LuaJIT-1.1.7/src/ljit.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/LuaJIT-1.1.7/src/ljit.h')
-rw-r--r--libraries/LuaJIT-1.1.7/src/ljit.h167
1 files changed, 0 insertions, 167 deletions
diff --git a/libraries/LuaJIT-1.1.7/src/ljit.h b/libraries/LuaJIT-1.1.7/src/ljit.h
deleted file mode 100644
index 347de3b..0000000
--- a/libraries/LuaJIT-1.1.7/src/ljit.h
+++ /dev/null
@@ -1,167 +0,0 @@
1/*
2** Interface to JIT engine.
3** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h
4*/
5
6#ifndef ljit_h
7#define ljit_h
8
9#include "lobject.h"
10
11
12/* Define this to enable assertions when debugging LuaJIT. */
13#ifdef LUAJIT_ASSERT
14#include <assert.h>
15#define jit_assert(x) assert(x)
16#define DASM_CHECKS
17#else
18/* A better idea is to define lua_assert() in luaconf.h. */
19#define jit_assert(x) lua_assert(x)
20#endif
21
22/* Define this to set the C stack size for the compiler thread. */
23/* The compiler runs on the callers C stack otherwise. */
24#undef LUAJIT_COMPILER_CSTACK
25
26/* Hardcoded limits for the backend to avoid useless work. */
27/* Note: mind you, these are very generous limits. Check jit.opt, too. */
28#define LUAJIT_LIM_BYTECODE 3000 /* Max. # of bytecodes. */
29#define LUAJIT_LIM_MCODE 128000 /* Max. mcode size of a function. */
30
31/* Global JIT engine flags. */
32#define JIT_F_ON 0x0001 /* JIT engine is on. */
33#define JIT_F_COMPILING 0x0002 /* Currently compiling. */
34#define JIT_F_INIT_FAILED 0x0004 /* Initialization failed. */
35
36#define JIT_F_CPU_CMOV 0x0010 /* CPU has conditional move support. */
37#define JIT_F_CPU_SSE2 0x0020 /* CPU has SSE2 support. */
38
39#define JIT_F_DEBUG_CALL 0x0100 /* Compile with call hooks. */
40#define JIT_F_DEBUG_INS 0x0200 /* Compile with instruction hooks. */
41#define JIT_F_DEBUG 0x0f00 /* Union of all debug flags. */
42
43/* Temporary backend flags. */
44#define JIT_TF_USED_DEOPT 0x0001 /* Used .deopt segment. */
45
46/* JIT engine status codes for prototypes (grep "ORDER JIT_S"). */
47enum {
48 JIT_S_OK, /* OK, code has been compiled. */
49 JIT_S_NONE, /* Nothing compiled yet (default). */
50
51 JIT_S_OFF, /* Compilation for this prototype disabled. */
52 JIT_S_ENGINE_OFF, /* JIT engine is turned off. */
53 JIT_S_DELAYED, /* Compilation delayed (recursive invocation). */
54
55 JIT_S_TOOLARGE, /* Bytecode or machine code is too large. */
56 JIT_S_COMPILER_ERROR, /* Error from compiler frontend. */
57 JIT_S_DASM_ERROR, /* Error from DynASM engine. */
58
59 JIT_S_MAX
60};
61
62/* Machine code trailer and mcode fragment map. */
63typedef struct jit_MCTrailer {
64 char *mcode; /* Pointer to next machine code block. */
65 size_t sz; /* Size of next machine code block. */
66} jit_MCTrailer;
67
68typedef unsigned short jit_Mfm;
69
70/* Deliberately return a void * because the trailer is not fully aligned. */
71#define JIT_MCTRAILER(mcode, sz) \
72 ((void *)(((char *)(mcode))+(sz)-sizeof(jit_MCTrailer)))
73#define JIT_MCMFM(mcode, sz) \
74 ((jit_Mfm *)(((char *)(mcode))+(sz)-sizeof(jit_MCTrailer)-sizeof(jit_Mfm)))
75
76#define JIT_MFM_MAX 0x7ff0 /* Max. mcode fragment length. */
77#define JIT_MFM_MASK 0x7fff /* Tag mask. */
78#define JIT_MFM_MARK 0x8000 /* Deoptimized (main mfm), seek (deopt mfm). */
79#define JIT_MFM_COMBINE 0xfffd /* Combined with prev. instruction(s). */
80#define JIT_MFM_DEAD 0xfffe /* Dead instruction. */
81#define JIT_MFM_STOP 0xffff /* End of map. */
82
83#define jit_mfm_ismain(mfm) (!(*(mfm) & JIT_MFM_MARK))
84#define jit_mfm_isdeoptpc(mfm, pc) ((mfm)[-(pc)] & JIT_MFM_MARK)
85
86/* Deoptimization hints at end of mfm. */
87#define JIT_MFM_DEOPT_PAIRS 0xfffc /* CALL+TFORLOOP inlined (i)pairs. */
88
89/* Preallocation for the hash part of the compiler state table. */
90#define COMSTATE_PREALLOC 128
91
92/* Forward declaration for DynASM state. */
93struct dasm_State;
94
95/* Frontend wrapper. */
96typedef int (*jit_FrontWrap)(lua_State *L, Table *st);
97
98/* Global JIT state. */
99typedef struct jit_State {
100 /* Permanent backend environment: */
101 struct dasm_State *D; /* DynASM state. Keep this as the first field. */
102 void *mcodeheap; /* Private heap to allocate executable memory from. */
103 void **jsub; /* Addresses of JIT subroutines. */
104 void *jsubmcode; /* Base address of JSUB mcode. */
105 size_t szjsubmcode; /* Size of JSUB mcode. */
106 int numjsub; /* Number of JSUBs. */
107
108 /* Temporary backend environment (valid only while running): */
109 lua_State *L; /* Compiler thread. */
110 Table *comstate; /* Compiler state table. */
111 Proto *pt; /* Currently compiled prototype. */
112 const Instruction *nextins; /* Pointer to next instruction. */
113 jit_Mfm *mfm; /* Position in temporary mcode fragment map. */
114 int nextpc; /* Next PC. */
115 int combine; /* Number of following instructions to combine. */
116 unsigned int tflags; /* Temporary flags. */
117 int dasmstatus; /* DynASM status code. */
118
119 /* JIT engine fields: */
120 jit_FrontWrap frontwrap; /* Compiler frontend wrapper. */
121 unsigned int flags; /* Global JIT engine flags. */
122} jit_State;
123
124
125/* --- ljit_core.c */
126
127/* Initialize and free JIT engine state. */
128LUAI_FUNC void luaJIT_initstate(lua_State *L);
129LUAI_FUNC void luaJIT_freestate(lua_State *L);
130
131/* Compile and run a function. */
132LUAI_FUNC int luaJIT_run(lua_State *L, StkId func, int nresults);
133/* Deoptimize the current instruction. Return new mcode addr to continue. */
134LUAI_FUNC void *luaJIT_deoptimize(lua_State *L);
135
136/* Find relative PC (0 based) for a bytecode pointer or a JIT mcode address. */
137LUAI_FUNC int luaJIT_findpc(Proto *pt, const Instruction *savedpc);
138/* Find mcode address for PC (1 based). */
139LUAI_FUNC void *luaJIT_findmcode(Proto *pt, int pc);
140
141
142/* --- ljit_backend.c */
143
144/* Arch string. */
145LUAI_DATA const char luaJIT_arch[];
146/* Initialize and free compiler backend. */
147LUAI_FUNC int luaJIT_initbackend(lua_State *L);
148LUAI_FUNC void luaJIT_freebackend(lua_State *L);
149/* Compiler backend. */
150LUAI_FUNC int luaJIT_backend(lua_State *L);
151/* Notify backend that the debug mode may have changed. */
152LUAI_FUNC void luaJIT_debugnotify(jit_State *J);
153
154
155/* ---- ljit_mem.c */
156
157/* Free the mcode heap. */
158LUAI_FUNC void luaJIT_freemcodeheap(jit_State *J);
159/* Free mcode. */
160LUAI_FUNC void luaJIT_freemcode(jit_State *J, void *mcode, size_t sz);
161/* Free JIT structures in function prototype. */
162LUAI_FUNC void luaJIT_freeproto(lua_State *L, Proto *pt);
163/* Link generated code. */
164LUAI_FUNC int luaJIT_link(jit_State *J, void **mcodep, size_t *szp);
165
166
167#endif