issue #110 Bring JIT C codegen up to date

pull/167/head
Dibyendu Majumdar 6 years ago
parent 5afdd3f6bb
commit 8f105712b5

@ -26,7 +26,27 @@
#include <stddef.h>
#include <assert.h>
/*
* Only 64-bits supported right now
* Following must be kept in sync with changes in the actual header files
*/
static const char Lua_header[] = ""
"typedef __SIZE_TYPE__ size_t;\n"
"typedef long long ptrdiff_t;\n"
"typedef long long intptr_t;\n"
"typedef long long int64_t;\n"
"typedef unsigned long long uint64_t;\n"
"typedef int int32_t;\n"
"typedef unsigned int uint32_t;\n"
"typedef short int16_t;\n"
"typedef unsigned short uint16_t;\n"
"typedef char int8_t;\n"
"typedef unsigned char uint8_t;\n"
"typedef size_t lu_mem;\n"
"typedef ptrdiff_t l_mem;\n"
"typedef unsigned char lu_byte;\n"
"typedef uint16_t LuaType;\n"
"#define NULL ((void *)0)\n"
"typedef struct lua_State lua_State;\n"
"#define LUA_TNONE (-1)\n"
@ -40,16 +60,9 @@ static const char Lua_header[] = ""
"#define LUA_TUSERDATA 7\n"
"#define LUA_TTHREAD 8\n"
"typedef double lua_Number;\n"
"typedef long long lua_Integer;\n"
"typedef unsigned long long lua_Unsigned;\n"
"typedef int64_t lua_Integer;\n"
"typedef uint64_t lua_Unsigned;\n"
"typedef int (*lua_CFunction) (lua_State *L);\n"
"typedef __SIZE_TYPE__ size_t;\n"
"typedef long long ptrdiff_t;\n"
"typedef long long intptr_t;\n"
"typedef size_t lu_mem;\n"
"typedef ptrdiff_t l_mem;\n"
"typedef unsigned char lu_byte;\n"
"typedef unsigned short LuaType;\n"
"typedef union {\n"
" lua_Number n;\n"
" double u;\n"
@ -80,6 +93,7 @@ static const char Lua_header[] = ""
"#define LUA_TLCL (LUA_TFUNCTION | (0 << 4))\n"
"#define LUA_TLCF (LUA_TFUNCTION | (1 << 4))\n"
"#define LUA_TCCL (LUA_TFUNCTION | (2 << 4))\n"
"#define RAVI_TFCF (LUA_TFUNCTION | (4 << 4))\n"
"#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4))\n"
"#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4))\n"
"#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4))\n"
@ -109,7 +123,7 @@ static const char Lua_header[] = ""
"#define val_(o) ((o)->value_)\n"
"#define rttype(o) ((o)->tt_)\n"
"#define novariant(x) ((x) & 0x0F)\n"
"#define ttype(o) (rttype(o) & 0x3F)\n"
"#define ttype(o) (rttype(o) & 0x7F)\n"
"#define ttnov(o) (novariant(rttype(o)))\n"
"#define checktag(o,t) (rttype(o) == (t))\n"
"#define checktype(o,t) (ttnov(o) == (t))\n"
@ -131,6 +145,7 @@ static const char Lua_header[] = ""
"#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))\n"
"#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))\n"
"#define ttislcf(o) checktag((o), LUA_TLCF)\n"
"#define ttisfcf(o) (ttype(o) == RAVI_TFCF)\n"
"#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA))\n"
"#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))\n"
"#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)\n"
@ -146,6 +161,7 @@ static const char Lua_header[] = ""
"#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))\n"
"#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))\n"
"#define fvalue(o) check_exp(ttislcf(o), val_(o).f)\n"
"#define fcfvalue(o) check_exp(ttisfcf(o), val_(o).p)\n"
"#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))\n"
"#define bvalue(o) check_exp(ttisboolean(o), val_(o).b)\n"
"#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))\n"
@ -168,6 +184,13 @@ static const char Lua_header[] = ""
"#define setnilvalue(obj) settt_(obj, LUA_TNIL)\n"
"#define setfvalue(obj,x) \\\n"
" { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }\n"
"#define setfvalue_fastcall(obj, x, tag) \\\n"
"{ \\\n"
" TValue *io = (obj); \\\n"
" lua_assert(tag >= 1 && tag < 0x80); \\\n"
" val_(io).p = (x); \\\n"
" settt_(io, ((tag << 8) | RAVI_TFCF)); \\\n"
"}\n"
"#define setpvalue(obj,x) \\\n"
" { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }\n"
"#define setbvalue(obj,x) \\\n"
@ -426,6 +449,7 @@ static const char Lua_header[] = ""
" unsigned short callstatus;\n"
" unsigned short stacklevel;\n"
" lu_byte jitstatus;\n"
" lu_byte magic;\n"
"} CallInfo;\n"
"#define CIST_OAH (1<<0)\n"
"#define CIST_LUA (1<<1)\n"
@ -465,6 +489,7 @@ static const char Lua_header[] = ""
" lu_byte hookmask;\n"
" lu_byte allowhook;\n"
" unsigned short nci;\n"
" lu_byte magic;\n"
"};\n"
"#define G(L) (L->l_G)\n"
"union GCUnion {\n"

Loading…
Cancel
Save