Standard library wipeout (1d1b7ec)

This commit is contained in:
GenericHeroGuy committed 2024-11-13 17:15:08 +01:00
1 parent a5baa052e2
commit 11155cc609
13 files changed
+109 -21

No files matched your search

+1 -1
View File
@@ -630,7 +630,7 @@ clean:
$(REMOVE) *~ *.flc
$(REMOVE) $(OBJDIR)/*.o
ifndef NOBLUAJIT
$(REMOVE) $(OBJDIR)/buildvm* $(OBJDIR)/minilua* $(OBJDIR)/lj_vm*
$(REMOVE) $(OBJDIR)/buildvm* $(OBJDIR)/minilua* $(OBJDIR)/lj_vm* $(ALL_HDRGEN)
endif
ifdef MINGW
+20 -3
View File
@@ -24,6 +24,15 @@ XCFLAGS+= -DLUAJIT_DISABLE_FFI
#XCFLAGS+= -DLUA_USE_APICHECK
#XCFLAGS+= -DLUA_USE_ASSERT
# load standard libraries in debug mode, so jit.dump etc works
ifndef DEBUGMODE
XCFLAGS+= -DLUAJIT_SRB2LIB -DLUAJIT_DISABLE_BUFFER
endif
# additional functions
#XCFLAGS+= -DLUAJIT_SRB2LIB_OS
XCFLAGS+= -DLUAJIT_SRB2LIB_DEBUG
XCFLAGS+= -DLUAJIT_SRB2LIB_IO
# don't touch these unless you wanna have a bad time
XCFLAGS+= -DLUAJIT_NUMMODE=2
XCFLAGS+= -DLUAJIT_INTONLY
@@ -310,9 +319,17 @@ LJVM_O= $(OBJDIR)/lj_vm.o
LJVM_BOUT= $(LJVM_S)
LJVM_MODE= elfasm
LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o \
lib_buffer.o
LJLIB_O= lib_base.o lib_string.o lib_table.o lib_io.o lib_jit.o
ifeq (,$(filter -DLUAJIT_SRB2LIB,$(XCFLAGS)))
LJLIB_O+= lib_math.o lib_bit.o lib_os.o lib_package.o lib_debug.o lib_ffi.o lib_buffer.o
else
ifneq (,$(filter -DLUAJIT_SRB2LIB_OS,$(XCFLAGS)))
LJLIB_O+= lib_os.o
endif
ifneq (,$(filter -DLUAJIT_SRB2LIB_DEBUG,$(XCFLAGS)))
LJLIB_O+= lib_debug.o
endif
endif
LJLIB_C= $(addprefix bluajit/,$(LJLIB_O:.o=.c))
LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
+4
View File
@@ -394,6 +394,10 @@ void emit_lib(BuildCtx *ctx)
ok = LJ_HASFFI;
else if (!strcmp(buf, "#if LJ_HASBUFFER"))
ok = LJ_HASBUFFER;
else if (!strcmp(buf, "#if !LJ_SRB2LIB"))
ok = !LJ_SRB2LIB;
else if (!strcmp(buf, "#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO)"))
ok = !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO); /* whacky! */
if (!ok) {
int lvl = 1;
while (fgets(buf, sizeof(buf), fp) != NULL) {
+2
View File
@@ -357,6 +357,7 @@ LJLIB_ASM_(xpcall) LJLIB_REC(.)
/* -- Base library: load Lua code ----------------------------------------- */
#if !LJ_SRB2LIB
static int load_aux(lua_State *L, int status, int envarg)
{
if (status == LUA_OK) {
@@ -453,6 +454,7 @@ LJLIB_CF(dofile)
lua_call(L, 0, LUA_MULTRET);
return (int)(L->top - L->base) - 1;
}
#endif
/* -- Base library: GC control -------------------------------------------- */
+8
View File
@@ -23,6 +23,7 @@
#define LJLIB_MODULE_debug
#if !LJ_SRB2LIB
LJLIB_CF(debug_getregistry)
{
copyTV(L, L->top++, registry(L));
@@ -64,6 +65,7 @@ LJLIB_CF(debug_setfenv)
lj_err_caller(L, LJ_ERR_SETFENV);
return 1;
}
#endif
/* ------------------------------------------------------------------------ */
@@ -184,6 +186,7 @@ LJLIB_CF(debug_getlocal)
}
}
#if !LJ_SRB2LIB
LJLIB_CF(debug_setlocal)
{
int arg;
@@ -197,6 +200,7 @@ LJLIB_CF(debug_setlocal)
lua_pushstring(L, lua_setlocal(L1, &ar, lj_lib_checkint(L, arg+2)));
return 1;
}
#endif
static int debug_getupvalue(lua_State *L, int get)
{
@@ -219,6 +223,7 @@ LJLIB_CF(debug_getupvalue)
return debug_getupvalue(L, 1);
}
#if !LJ_SRB2LIB
LJLIB_CF(debug_setupvalue)
{
lj_lib_checkany(L, 3);
@@ -280,6 +285,7 @@ LJLIB_CF(debug_setuservalue)
return 1;
}
#endif
#endif
/* ------------------------------------------------------------------------ */
@@ -359,6 +365,7 @@ LJLIB_CF(debug_gethook)
/* ------------------------------------------------------------------------ */
#if !LJ_SRB2LIB
LJLIB_CF(debug_debug)
{
for (;;) {
@@ -376,6 +383,7 @@ LJLIB_CF(debug_debug)
lua_settop(L, 0); /* remove eventual returns */
}
}
#endif
/* ------------------------------------------------------------------------ */
+10
View File
@@ -17,14 +17,24 @@
static const luaL_Reg lj_lib_load[] = {
{ "", luaopen_base },
#if !LJ_SRB2LIB
{ LUA_LOADLIBNAME, luaopen_package },
#endif
{ LUA_TABLIBNAME, luaopen_table },
{ LUA_IOLIBNAME, luaopen_io },
#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2OS)
{ LUA_OSLIBNAME, luaopen_os },
#endif
{ LUA_STRLIBNAME, luaopen_string },
#if !LJ_SRB2LIB
{ LUA_MATHLIBNAME, luaopen_math },
#endif
#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2DEBUG)
{ LUA_DBLIBNAME, luaopen_debug },
#endif
#if !LJ_SRB2LIB
{ LUA_BITLIBNAME, luaopen_bit },
#endif
{ LUA_JITLIBNAME, luaopen_jit },
{ NULL, NULL }
};
+8
View File
@@ -60,6 +60,7 @@ static IOFileUD *io_tofile(lua_State *L)
return iof;
}
#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO)
static IOFileUD *io_stdfile(lua_State *L, ptrdiff_t id)
{
IOFileUD *iof = IOSTDF_IOF(L, id);
@@ -67,6 +68,7 @@ static IOFileUD *io_stdfile(lua_State *L, ptrdiff_t id)
lj_err_caller(L, LJ_ERR_IOSTDCL);
return iof;
}
#endif
static IOFileUD *io_file_new(lua_State *L)
{
@@ -80,6 +82,7 @@ static IOFileUD *io_file_new(lua_State *L)
return iof;
}
#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO)
static IOFileUD *io_file_open(lua_State *L, const char *mode)
{
const char *fname = strdata(lj_lib_checkstr(L, 1));
@@ -89,6 +92,7 @@ static IOFileUD *io_file_open(lua_State *L, const char *mode)
luaL_argerror(L, 1, lj_strfmt_pushf(L, "%s: %s", fname, strerror(errno)));
return iof;
}
#endif
static int io_file_close(lua_State *L, IOFileUD *iof)
{
@@ -416,6 +420,7 @@ LJLIB_CF(io_open)
return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname);
}
#if !LJ_SRB2LIB
LJLIB_CF(io_popen)
{
#if LJ_TARGET_POSIX || (LJ_TARGET_WINDOWS && !LJ_TARGET_XBOXONE && !LJ_TARGET_UWP)
@@ -435,6 +440,7 @@ LJLIB_CF(io_popen)
return luaL_error(L, LUA_QL("popen") " not supported");
#endif
}
#endif
LJLIB_CF(io_tmpfile)
{
@@ -452,6 +458,7 @@ LJLIB_CF(io_close)
return lj_cf_io_method_close(L);
}
#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO)
LJLIB_CF(io_read)
{
return io_file_read(L, io_stdfile(L, GCROOT_IO_INPUT), 0);
@@ -507,6 +514,7 @@ LJLIB_CF(io_lines)
}
return io_file_lines(L);
}
#endif
LJLIB_CF(io_type)
{
+4
View File
@@ -37,6 +37,7 @@
#define LJLIB_MODULE_os
#if !LJ_SRB2LIB
LJLIB_CF(os_execute)
{
#if LJ_NO_SYSTEM
@@ -121,6 +122,7 @@ LJLIB_CF(os_exit)
exit(status);
return 0; /* Unreachable. */
}
#endif
LJLIB_CF(os_clock)
{
@@ -260,6 +262,7 @@ LJLIB_CF(os_difftime)
/* ------------------------------------------------------------------------ */
#if !LJ_SRB2LIB
LJLIB_CF(os_setlocale)
{
#if LJ_TARGET_PSVITA
@@ -279,6 +282,7 @@ LJLIB_CF(os_setlocale)
#endif
return 1;
}
#endif
/* ------------------------------------------------------------------------ */
+6
View File
@@ -113,6 +113,7 @@ LJLIB_ASM_(string_upper) LJLIB_REC(string_op IRCALL_lj_buf_putstr_upper)
/* ------------------------------------------------------------------------ */
#if !LJ_SRB2LIB
static int writer_buf(lua_State *L, const void *p, size_t size, void *sb)
{
lj_buf_putmem((SBuf *)sb, p, (MSize)size);
@@ -146,6 +147,7 @@ LJLIB_CF(string_dump)
lj_gc_check(L);
return 1;
}
#endif
/* ------------------------------------------------------------------------ */
@@ -684,6 +686,10 @@ LUALIB_API int luaopen_string(lua_State *L)
mt->nomm = (uint8_t)(~(1u<<MM_index));
#if LJ_HASBUFFER
lj_lib_prereg(L, LUA_STRLIBNAME ".buffer", luaopen_string_buffer, tabV(L->top-1));
#endif
#if LJ_SRB2LIB
lua_getfield(L, -1, "gmatch");
lua_setfield(L, -2, "gfind"); /* Ugh, can we get rid of this already? */
#endif
return 1;
}
+27 -1
View File
@@ -549,8 +549,10 @@
#define LJ_DUALNUM 0
#endif
#if LUAJIT_INTONLY
#if defined(LUAJIT_INTONLY)
#define LJ_INTONLY 1
#else
#define LJ_INTONLY 0
#endif
#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
@@ -596,6 +598,30 @@
#define LJ_HASBUFFER 1
#endif
#if defined(LUAJIT_SRB2LIB)
#define LJ_SRB2LIB 1
#else
#define LJ_SRB2LIB 0
#endif
#if defined(LUAJIT_SRB2LIB_OS)
#define LJ_SRB2OS 1
#else
#define LJ_SRB2OS 0
#endif
#if defined(LUAJIT_SRB2LIB_DEBUG)
#define LJ_SRB2DEBUG 1
#else
#define LJ_SRB2DEBUG 0
#endif
#if defined(LUAJIT_SRB2LIB_IO)
#define LJ_SRB2IO 1
#else
#define LJ_SRB2IO 0
#endif
#if defined(LUAJIT_DISABLE_PROFILE)
#define LJ_HASPROFILE 0
#elif LJ_TARGET_POSIX
+4
View File
@@ -79,7 +79,11 @@ typedef uint16_t HotCount;
#define HOTCOUNT_CALL 1
/* This solves a circular dependency problem -- bump as needed. Sigh. */
#if LJ_SRB2LIB
#define GG_NUM_ASMFF 22
#else
#define GG_NUM_ASMFF 57
#endif
#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF)
#define GG_LEN_SDISP BC_FUNCF
+14
View File
@@ -172,7 +172,9 @@ static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
op == BC_RETM || op == BC_TSETM)) {
switch (J->fn->c.ffid) {
case FF_error:
#if !LJ_SRB2LIB
case FF_debug_sethook:
#endif
case FF_jit_flush:
break; /* Don't stitch across special builtins. */
default:
@@ -570,6 +572,8 @@ static void LJ_FASTCALL recff_next(jit_State *J, RecordFFData *rd)
/* -- Math library fast functions ----------------------------------------- */
#if !LJ_SRB2LIB
static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
{
TRef tr = lj_ir_tonum(J, J->base[0]);
@@ -701,8 +705,12 @@ static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd)
UNUSED(rd);
}
#endif
/* -- Bit library fast functions ------------------------------------------ */
#if !LJ_SRB2LIB
/* Record bit.tobit. */
static void LJ_FASTCALL recff_bit_tobit(jit_State *J, RecordFFData *rd)
{
@@ -776,6 +784,8 @@ static void LJ_FASTCALL recff_bit_tohex(jit_State *J, RecordFFData *rd)
#endif
}
#endif
/* -- String library fast functions --------------------------------------- */
/* Specialize to relative starting position for string. */
@@ -1553,6 +1563,8 @@ static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd)
/* -- Debug library fast functions ---------------------------------------- */
#if !LJ_SRB2LIB
static void LJ_FASTCALL recff_debug_getmetatable(jit_State *J, RecordFFData *rd)
{
GCtab *mt;
@@ -1573,6 +1585,8 @@ static void LJ_FASTCALL recff_debug_getmetatable(jit_State *J, RecordFFData *rd)
J->base[0] = mt ? mtref : TREF_NIL;
}
#endif
/* -- Record calls to fast functions -------------------------------------- */
#include "lj_recdef.h"
+1 -16
View File
@@ -340,15 +340,9 @@ static void jit_library(lua_State *L) {
lua_rawset(L, -4); \
lua_pop(L, 1);
#define DELEET(name) \
lua_pushliteral(L, name); \
lua_pushnil(L); \
lua_rawset(L, -3); \
// replace io.open, delete io.popen
// replace io.open
lua_getglobal(L, "io");
REPLACE("open", namechecker)
DELEET("popen")
lua_pop(L, 1);
// replace file:write
@@ -356,16 +350,7 @@ static void jit_library(lua_State *L) {
REPLACE("write", sizechecker)
lua_pop(L, 1);
// delete various base library functions
lua_pushvalue(L, LUA_GLOBALSINDEX);
DELEET("dofile")
DELEET("loadfile")
DELEET("load")
DELEET("loadstring")
lua_pop(L, 1);
#undef REPLACE
#undef DELEET
}
#endif // ifndef NOBLUAJIT