Skip to content

Commit d4d98ab

Browse files
committed
luajit: revert all holylib changes since here we want to match gmod!
1 parent 73d3e85 commit d4d98ab

16 files changed

Lines changed: 38 additions & 225 deletions

File tree

.github/workflows/buildjit.yml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ jobs:
3030
path: LuaJIT-2.1/src/lua51_64.lib
3131
retention-days: 1
3232

33-
- uses: actions/upload-artifact@v4
34-
name: Upload luajit executable (64x)
35-
with:
36-
name: luajit.exe (64x)
37-
path: LuaJIT-2.1/src/luajit.exe
38-
retention-days: 1
39-
4033
- uses: actions/upload-artifact@v4
4134
if: false
4235
name: Upload luajit.lib
@@ -69,18 +62,11 @@ jobs:
6962
path: LuaJIT-2.1/src/lua51_32.lib
7063
retention-days: 1
7164

72-
- uses: actions/upload-artifact@v4
73-
name: Upload luajit executable (32x)
74-
with:
75-
name: luajit.exe
76-
path: LuaJIT-2.1/src/luajit.exe
77-
retention-days: 1
78-
7965
- uses: actions/upload-artifact@v4
8066
if: false
8167
name: Upload luajit.lib
8268
with:
83-
name: luajit_32.lib (32x)
69+
name: luajit_32.lib
8470
path: LuaJIT-2.1/src/luajit_32.lib
8571
retention-days: 1
8672

@@ -110,13 +96,6 @@ jobs:
11096
path: LuaJIT-2.1/src/libluajit_64.a
11197
retention-days: 1
11298

113-
- uses: actions/upload-artifact@v4
114-
name: Upload luajit executable (64x)
115-
with:
116-
name: luajit (64x)
117-
path: LuaJIT-2.1/src/luajit
118-
retention-days: 1
119-
12099
build-linux-32:
121100
runs-on: ubuntu-latest
122101
container: debian:bullseye
@@ -142,11 +121,4 @@ jobs:
142121
with:
143122
name: libluajit_32.a
144123
path: LuaJIT-2.1/src/libluajit_32.a
145-
retention-days: 1
146-
147-
- uses: actions/upload-artifact@v4
148-
name: Upload luajit executable (32x)
149-
with:
150-
name: luajit (32x)
151-
path: LuaJIT-2.1/src/luajit
152124
retention-days: 1

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ development/
99
lua-shared.vpc.sentinel
1010
Bootil/projects/Makefile
1111
Bootil/projects/**/*.lib
12-
Bootil/projects/**/*.a
13-
LuaJIT-2.1/src/.vs/**
12+
Bootil/projects/**/*.a

LuaJIT-2.1/src/gmod.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
extern "C"
2-
{
3-
#include "gmod.h"
4-
#include "lua.h"
5-
}
6-
#include "stdio.h"
1+
#include "gmod.h"
72

83
namespace std
94
{
@@ -205,37 +200,18 @@ extern "C" void lua_init_stack_gmod(lua_State* L1, lua_State* L)
205200
}
206201
}
207202

208-
extern "C" void GMOD_LuaPrint(const char* str, lua_State* L) // Should be how gmod does it
203+
extern "C" void GMOD_LuaPrint(const char* str, lua_State* L) // Idk how gmod does it
209204
{
210-
if (!L->luabase) // except for this, gmod doesn't do this, but we do making testing jit less of a pain
211-
{
212-
printf(str);
213-
return;
214-
}
215-
216205
((ILuaInterface*)L->luabase)->Msg("%s", str);
217206
}
218207

219-
struct UserData {
220-
void* data;
221-
unsigned char type;
222-
};
223-
224208
extern "C" void GMOD_LuaCreateEmptyUserdata(lua_State* L)
225209
{
226210
//ILuaBase::UserData* udata = (ILuaBase::UserData*)((ILuaBase*)L->luabase)->NewUserdata(sizeof(ILuaBase::UserData)); // Gmod uses CLuaInterface::PushUserType(NULL, 7) Instead
227211
//udata->data = nullptr;
228212
//udata->type = 7; // 7 = Userdata
229213

230214
//return udata;
231-
232-
if (!L->luabase) // just to make testing easier. Gmod doesn't have this.
233-
{
234-
UserData* pData = (UserData*)lua_newuserdata(L, sizeof(ILuaBase::UserData));
235-
pData->data = nullptr;
236-
pData->type = 7;
237-
return;
238-
}
239215

240216

241217
((ILuaBase*)L->luabase)->PushUserType(NULL, 7);

LuaJIT-2.1/src/lib_base.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ LJLIB_ASM(setmetatable) LJLIB_REC(.)
141141
return FFH_RES(1);
142142
}
143143

144-
void blockDebug(lua_State* L, GCfunc* func);
145144
LJLIB_CF(getfenv) LJLIB_REC(.)
146145
{
147146
GCfunc *fn;
@@ -156,7 +155,6 @@ LJLIB_CF(getfenv) LJLIB_REC(.)
156155
if (LJ_FR2) o--;
157156
}
158157
fn = &gcval(o)->fn;
159-
blockDebug(L, fn);
160158
settabV(L, L->top++, isluafunc(fn) ? tabref(fn->l.env) : tabref(L->env));
161159
return 1;
162160
}
@@ -183,7 +181,6 @@ LJLIB_CF(setfenv)
183181
fn = &gcval(o)->fn;
184182
if (!isluafunc(fn))
185183
lj_err_caller(L, LJ_ERR_SETFENV);
186-
blockDebug(L, fn);
187184
setgcref(fn->l.env, obj2gco(t));
188185
lj_gc_objbarrier(L, obj2gco(fn), t);
189186
setfuncV(L, L->top++, fn);

LuaJIT-2.1/src/lib_debug.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ LJLIB_CF(debug_getregistry)
3131

3232
LJLIB_CF(debug_getmetatable) LJLIB_REC(.)
3333
{
34-
TValue* o = lj_lib_checkany(L, 1);
35-
if (o && tviscdata(o))
36-
lj_err_arg(L, 1, LJ_ERR_DENYCDATA);
37-
34+
lj_lib_checkany(L, 1);
3835
if (!lua_getmetatable(L, 1)) {
3936
setnilV(L->top-1);
4037
}
@@ -43,10 +40,6 @@ LJLIB_CF(debug_getmetatable) LJLIB_REC(.)
4340

4441
LJLIB_CF(debug_setmetatable)
4542
{
46-
TValue* o = lj_lib_checkany(L, 1);
47-
if (o && tviscdata(o))
48-
lj_err_arg(L, 1, LJ_ERR_DENYCDATA);
49-
5043
lj_lib_checktabornil(L, 2);
5144
L->top = L->base+2;
5245
lua_setmetatable(L, 1);
@@ -56,26 +49,15 @@ LJLIB_CF(debug_setmetatable)
5649
return 1;
5750
}
5851

59-
void blockDebug(lua_State* L, GCfunc* func)
60-
{
61-
if (func && isblockdebug(func->c))
62-
lj_err_arg(L, 1, LJ_ERR_BLOCKDEBUG);
63-
}
64-
6552
LJLIB_CF(debug_getfenv)
6653
{
67-
TValue* o = lj_lib_checkany(L, 1);
68-
if (o && tvisfunc(o))
69-
blockDebug(L, o);
54+
lj_lib_checkany(L, 1);
7055
lua_getfenv(L, 1);
7156
return 1;
7257
}
7358

7459
LJLIB_CF(debug_setfenv)
7560
{
76-
TValue* o = lj_lib_checkany(L, 1);
77-
if (o && tvisfunc(o))
78-
blockDebug(L, o);
7961
lj_lib_checktab(L, 2);
8062
L->top = L->base+2;
8163
if (!lua_setfenv(L, 1))
@@ -220,7 +202,7 @@ static int debug_getupvalue(lua_State *L, int get)
220202
{
221203
int32_t n = lj_lib_checkint(L, 2);
222204
const char *name;
223-
blockDebug(L, lj_lib_checkfunc(L, 1));
205+
lj_lib_checkfunc(L, 1);
224206
name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
225207
if (name) {
226208
lua_pushstring(L, name);
@@ -246,7 +228,6 @@ LJLIB_CF(debug_setupvalue)
246228
LJLIB_CF(debug_upvalueid)
247229
{
248230
GCfunc *fn = lj_lib_checkfunc(L, 1);
249-
blockDebug(L, fn);
250231
int32_t n = lj_lib_checkint(L, 2) - 1;
251232
if ((uint32_t)n >= fn->l.nupvalues)
252233
lj_err_arg(L, 2, LJ_ERR_IDXRNG);
@@ -263,7 +244,6 @@ LJLIB_CF(debug_upvaluejoin)
263244
for (i = 0; i < 2; i++) {
264245
int32_t n;
265246
fn[i] = lj_lib_checkfunc(L, 2*i+1);
266-
blockDebug(L, fn[i]);
267247
if (!isluafunc(fn[i]))
268248
lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC);
269249
n = lj_lib_checkint(L, 2*i+2) - 1;

LuaJIT-2.1/src/lib_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ LJLIB_CF(jit_profile_dumpstack)
610610

611611
#include "lj_libdef.h"
612612

613-
LUALIB_API int luaopen_jit_profile(lua_State *L)
613+
static int luaopen_jit_profile(lua_State *L)
614614
{
615615
LJ_LIB_REG(L, NULL, jit_profile);
616616
return 1;

LuaJIT-2.1/src/lib_table.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -286,24 +286,6 @@ LJLIB_CF(table_pack)
286286
}
287287
#endif
288288

289-
LJLIB_CF(table_setreadonly)
290-
{
291-
GCtab *t = lj_lib_checktab(L, 1);
292-
int readOnly = lj_lib_checkint(L, 2) != 0;
293-
294-
lj_tab_setreadonly(t, readOnly);
295-
return 0;
296-
}
297-
298-
LJLIB_CF(table_isreadonly)
299-
{
300-
GCtab *t = lj_lib_checktab(L, 1);
301-
int readOnly = lj_lib_checkint(L, 2) != 0;
302-
303-
lua_pushboolean(L, lj_tab_isreadonly(t));
304-
return 1;
305-
}
306-
307289
LJLIB_NOREG LJLIB_CF(table_new) LJLIB_REC(.)
308290
{
309291
int32_t a = lj_lib_checkint(L, 1);
@@ -314,7 +296,7 @@ LJLIB_NOREG LJLIB_CF(table_new) LJLIB_REC(.)
314296

315297
LJLIB_NOREG LJLIB_CF(table_clear) LJLIB_REC(.)
316298
{
317-
lj_tab_clear(L, lj_lib_checktab(L, 1));
299+
lj_tab_clear(lj_lib_checktab(L, 1));
318300
return 0;
319301
}
320302

LuaJIT-2.1/src/lj_api.c

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include "lj_strscan.h"
2727
#include "lj_strfmt.h"
2828

29-
#include "lj_ctype.h"
30-
#include "lj_cconv.h"
31-
3229
/* -- Common helper functions --------------------------------------------- */
3330

3431
#define lj_checkapi_slot(idx) \
@@ -233,18 +230,16 @@ LUA_API int lua_type(lua_State *L, int idx)
233230
#endif
234231
} else if (o == niltv(L)) {
235232
return LUA_TNONE;
236-
} else if(tviscdata(o)) {
237-
return LUA_TUSERDATA; // we would return 10 which conflicts with gmod!
238-
} /* Magic internal/external tag conversion. ORDER LJ_T */
239-
240-
uint32_t t = ~itype(o);
233+
} else { /* Magic internal/external tag conversion. ORDER LJ_T */
234+
uint32_t t = ~itype(o);
241235
#if LJ_64
242-
int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u);
236+
int tt = (int)((U64x(75a06,98042110) >> 4*t) & 15u);
243237
#else
244-
int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u);
238+
int tt = (int)(((t < 8 ? 0x98042110u : 0x75a06u) >> 4*(t&7)) & 15u);
245239
#endif
246-
lj_assertL(tt != LUA_TNIL || tvisnil(o), "bad tag conversion");
247-
return tt;
240+
lj_assertL(tt != LUA_TNIL || tvisnil(o), "bad tag conversion");
241+
return tt;
242+
}
248243
}
249244

250245
LUALIB_API void luaL_checktype(lua_State *L, int idx, int tt)
@@ -262,37 +257,25 @@ LUALIB_API void luaL_checkany(lua_State *L, int idx)
262257
// Based off https://github.com/meepen/gluajit/blob/master/src/lj_api.c#L225-L247
263258
/*extern "C"*/ const char* GMODLUA_GetUserType(lua_State* L, int iStackPos)
264259
{
265-
static char strName[128];
266-
const char* strTypeName = "UserData";
267-
cTValue *o = index2adr(L, iStackPos);
268-
GCtab *mt = NULL;
269-
if (tvistab(o))
270-
mt = tabref(tabV(o)->metatable);
271-
else if (tvisudata(o))
272-
mt = tabref(udataV(o)->metatable);
273-
else if (tviscdata(o))
274-
{
275-
strTypeName = "cdata";
276-
CTState *cts = ctype_cts(L);
277-
CType *ct = ctype_raw(cts, cdataV(o)->ctypeid);
278-
mt = tabV(lj_tab_getinth(cts->miscmap, -(int32_t)ctype_typeid(cts, ct)));
279-
} else
280-
mt = tabref(basemt_obj(G(L), o));
260+
static char strName[128];
261+
const char* strTypeName = "UserData";
262+
if (lua_getmetatable(L, iStackPos))
263+
{
264+
lua_pushstring(L, "MetaName");
265+
lua_gettable(L, -2);
281266

282-
if (mt)
283-
{
284-
GCstr* str = lj_str_newlit(L, "MetaName");
285-
cTValue* val = lj_tab_getstr(mt, str);
286-
// lj_str_free(G(L), str); // Lua GC takes care of our string
267+
if (lua_isstring(L, -1))
268+
{
269+
strncpy(strName, lua_tostring(L, -1), sizeof(strName));
270+
strTypeName = strName;
271+
}
287272

288-
if (val && tvisstr(val))
289-
{
290-
strncpy(strName, strdata(strV(val)), sizeof(strName));
291-
strTypeName = strName;
292-
}
293-
}
273+
lua_pop(L, 1);
274+
}
275+
276+
lua_pop(L, 1);
294277

295-
return strTypeName;
278+
return strTypeName;
296279
}
297280

298281
LUA_API const char *lua_typename(lua_State *L, int t, int stackpos)

LuaJIT-2.1/src/lj_cdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ GCcdata *lj_cdata_newv(lua_State *L, CTypeID id, CTSize sz, CTSize align)
4343
setgcrefr(cd->nextgc, g->gc.root);
4444
setgcref(g->gc.root, obj2gco(cd));
4545
newwhite(g, obj2gco(cd));
46-
cd->marked |= LJ_GC_ISCDATA;
46+
cd->marked |= 0x80;
4747
cd->gct = ~LJ_TCDATA;
4848
cd->ctypeid = id;
4949
return cd;

LuaJIT-2.1/src/lj_errmsg.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ ERRDEF(TABOV, "table overflow")
2121
ERRDEF(NANIDX, "table index is NaN")
2222
ERRDEF(NILIDX, "table index is nil")
2323
ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next"))
24-
ERRDEF(READONLY, "table is in read only")
2524

2625
/* Metamethod resolving. */
2726
ERRDEF(BADCALL, "attempt to call a %s value")
@@ -42,7 +41,6 @@ ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)")
4241
ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)")
4342
ERRDEF(BADTYPE, "%s expected, got %s")
4443
ERRDEF(BADVAL, "invalid value")
45-
ERRDEF(DENYCDATA, "cdata is not allowed to be used here")
4644
ERRDEF(NOVAL, "value expected")
4745
ERRDEF(NOCORO, "coroutine expected")
4846
ERRDEF(NOTABN, "nil or table expected")
@@ -53,7 +51,6 @@ ERRDEF(NOPROXY, "boolean or proxy expected")
5351
ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number")
5452
ERRDEF(FORLIM, LUA_QL("for") " limit must be a number")
5553
ERRDEF(FORSTEP, LUA_QL("for") " step must be a number")
56-
ERRDEF(BLOCKDEBUG, "function is marked to block any debug access")
5754

5855
/* C API checks. */
5956
ERRDEF(NOENV, "no calling environment")

0 commit comments

Comments
 (0)