Skip to content

Commit

Permalink
Merge pull request #5 from lukego/bigbang
Browse files Browse the repository at this point in the history
Big bang: Remove all the features that I can live without
  • Loading branch information
lukego authored Mar 12, 2017
2 parents c2d3d70 + 40381fa commit 2fcc0a4
Show file tree
Hide file tree
Showing 113 changed files with 128 additions and 49,053 deletions.
125 changes: 125 additions & 0 deletions src/ifdef-defile
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// Config file for the 'unifdef' program to strip out unwanted source code.

#define LJ_GC64 1
#define LJ_HASFFI 1
#define LJ_HASJIT 1
#define LUAJIT_DISABLE_PROFILE 1
#define LUAJIT_DISABLE_VMEVENT 1
#define LUAJIT_ENABLE_GC64 1
#define LUAJIT_ENABLE_JIT 1
#undef LJ_HASPROFILE
#undef LUAJIT_DISABLE_FFI
#undef LUAJIT_DISABLE_JIT
#undef LUAJIT_NOFFI
#undef LUAJIT_USE_GDBJIT

#define LJ_64 1
#define LJ_ARCH_BITS 64
#define LJ_ARCH_ENDIAN == LUAJIT_LE
#define LJ_FR2 1
#define LJ_NUMMODE LJ_NUMMODE_SINGLE_DUAL
#define LJ_NUMMODE_DUAL 2
#define LJ_NUMMODE_DUAL_SINGLE 3
#define LJ_NUMMODE_SINGLE 0
#define LJ_NUMMODE_SINGLE_DUAL 1
#define LJ_TARGET_DLOPEN 1
#define LJ_TARGET_GC64 1
#define LJ_TARGET_LINUX 1
#define LJ_TARGET_POSIX 1
#define LJ_TARGET_X64 1
#define LJ_TARGET_X86ORX64 1
#define LUAJIT_ARCH_ARM 3
#define LUAJIT_ARCH_ARM64 4
#define LUAJIT_ARCH_MIPS 6
#define LUAJIT_ARCH_MIPS32 6
#define LUAJIT_ARCH_MIPS64 7
#define LUAJIT_ARCH_PPC 5
#define LUAJIT_ARCH_X64 2
#define LUAJIT_ARCH_X86 1
#define LUAJIT_ARCH_arm 3
#define LUAJIT_ARCH_arm64 4
#define LUAJIT_ARCH_mips 6
#define LUAJIT_ARCH_mips32 6
#define LUAJIT_ARCH_mips64 7
#define LUAJIT_ARCH_ppc 5
#define LUAJIT_ARCH_x64 2
#define LUAJIT_ARCH_x86 1
#define LUAJIT_LE 1
#define LUAJIT_OS LUAJIT_OS_LINUX
#define LUAJIT_OS_LINUX 2
#define LUAJIT_OS_WINDOWS 3
#define LUAJIT_TARGET LUAJIT_ARCH_X64
#define LUAJIT_TARGET_POSIX 1
#define __linux__
#undef JL_TARGET_PPC
#undef LJ_32
#undef LJ_ABI_EABI
#undef LJ_ABI_SOFTFP
#undef LJ_ABI_WIN
#undef LJ_ALLOC_NTAVM
#undef LJ_ALLOC_VIRTUALALLOC
#undef LJ_ARCH_NOFFI
#undef LJ_ARCH_PPC
#undef LJ_BE
#undef LJ_NOUNWIND
#undef LJ_OS_NOJIT
#undef LJ_SOFTFP
#undef LJ_TARGET_ARM
#undef LJ_TARGET_ARM64
#undef LJ_TARGET_CONSOLE
#undef LJ_TARGET_CYGWIN
#undef LJ_TARGET_IOS
#undef LJ_TARGET_MIPS
#undef LJ_TARGET_MIPS64
#undef LJ_TARGET_PPC
#undef LJ_TARGET_PS3
#undef LJ_TARGET_PS4
#undef LJ_TARGET_PSVITA
#undef LJ_TARGET_WINDOWS
#undef LJ_TARGET_WINDOWS
#undef LJ_TARGET_X86
#undef LJ_TARGET_XBOX360
#undef LJ_TARGET_XBOX360
#undef LUAJIT_ARCH_MIPS32
#undef LUAJIT_ARCH_X86
#undef LUAJIT_BE
#undef MINGW_SDK_INIT
#undef _ARCH_PPCSQ
#undef _ARCH_PWR4
#undef _ARCH_PWR5
#undef _ARCH_PWR5X
#undef _ARCH_PWR6
#undef _ARCH_PWR7
#undef _DURANGO
#undef _MIPSEL
#undef _MSC_VER
#undef _XBOX_VER
#undef __ANDROID__
#undef __ARM_ARCH_6T2__
#undef __ARM_ARCH_6T2__
#undef __ARM_ARCH_6Z__
#undef __ARM_ARCH_6__
#undef __ARM_ARCH_7A__
#undef __ARM_ARCH_7R__
#undef __ARM_ARCH_7S__
#undef __ARM_ARCH_7VE__
#undef __ARM_ARCH_7__
#undef __ARM_ARCH_8A__
#undef __ARM_ARCH____ARM_ARCH_8__
#undef __ARM_ARH_6J__
#undef __ARM_PCS_VFP
#undef __CELLOS_LV2__
#undef __FreeBSD__
#undef __FreeBSD_kernel__
#undef __MIPSEL
#undef __MIPSEL__
#undef __ORBIS__
#undef __OpenBSD__
#undef __arm__
#undef __i386__
#undef __mips_soft_float
#undef __psp2__
#undef __sun__
#undef __symbian__
#undef __symbian__
#undef ljamalg_c
25 changes: 0 additions & 25 deletions src/lib_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
#include "lj_trace.h"
#include "lj_lib.h"

#if LJ_TARGET_POSIX
#include <sys/wait.h>
#endif

/* -- I/O error handling -------------------------------------------------- */

Expand All @@ -49,7 +47,6 @@ LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
{
if (stat != -1) {
#if LJ_TARGET_POSIX
if (WIFSIGNALED(stat)) {
stat = WTERMSIG(stat);
setnilV(L->top++);
Expand All @@ -63,13 +60,6 @@ LUALIB_API int luaL_execresult(lua_State *L, int stat)
setnilV(L->top++);
lua_pushliteral(L, "exit");
}
#else
if (stat == 0)
setboolV(L->top++, 1);
else
setnilV(L->top++);
lua_pushliteral(L, "exit");
#endif
setintV(L->top++, stat);
return 3;
}
Expand Down Expand Up @@ -302,9 +292,6 @@ static int panic(lua_State *L)

#ifdef LUAJIT_USE_SYSMALLOC

#if LJ_64 && !LJ_GC64 && !defined(LUAJIT_USE_VALGRIND)
#error "Must use builtin allocator for 64 bit target"
#endif

static void *mem_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
{
Expand Down Expand Up @@ -334,23 +321,11 @@ LUALIB_API lua_State *luaL_newstate(void)
lua_State *L;
void *ud = lj_alloc_create();
if (ud == NULL) return NULL;
#if LJ_64 && !LJ_GC64
L = lj_state_newstate(lj_alloc_f, ud);
#else
L = lua_newstate(lj_alloc_f, ud);
#endif
if (L) G(L)->panic = panic;
return L;
}

#if LJ_64 && !LJ_GC64
LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
{
UNUSED(f); UNUSED(ud);
fputs("Must use luaL_newstate() for 64 bit target\n", stderr);
return NULL;
}
#endif

#endif

10 changes: 0 additions & 10 deletions src/lib_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
#include "lj_meta.h"
#include "lj_state.h"
#include "lj_frame.h"
#if LJ_HASFFI
#include "lj_ctype.h"
#include "lj_cconv.h"
#endif
#include "lj_bc.h"
#include "lj_ff.h"
#include "lj_dispatch.h"
Expand Down Expand Up @@ -81,7 +79,6 @@ LJLIB_ASM(next)
return FFH_UNREACHABLE;
}

#if LJ_52 || LJ_HASFFI
static int ffh_pairs(lua_State *L, MMS mm)
{
TValue *o = lj_lib_checkany(L, 1);
Expand All @@ -98,9 +95,6 @@ static int ffh_pairs(lua_State *L, MMS mm)
return FFH_RES(3);
}
}
#else
#define ffh_pairs(L, mm) (lj_lib_checktab(L, 1), FFH_UNREACHABLE)
#endif

LJLIB_PUSH(lastcl)
LJLIB_ASM(pairs) LJLIB_REC(xpairs 0)
Expand Down Expand Up @@ -265,7 +259,6 @@ LJLIB_ASM(tonumber) LJLIB_REC(.)
copyTV(L, L->base-1-LJ_FR2, o);
return FFH_RES(1);
}
#if LJ_HASFFI
if (tviscdata(o)) {
CTState *cts = ctype_cts(L);
CType *ct = lj_ctype_rawref(cts, cdataV(o)->ctypeid);
Expand All @@ -283,7 +276,6 @@ LJLIB_ASM(tonumber) LJLIB_REC(.)
return FFH_RES(1);
}
}
#endif
} else {
const char *p = strdata(lj_lib_checkstr(L, 1));
char *ep;
Expand Down Expand Up @@ -608,10 +600,8 @@ LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux)

/* Inline declarations. */
LJ_ASMF void lj_ff_coroutine_wrap_aux(void);
#if !(LJ_TARGET_MIPS && defined(ljamalg_c))
LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L,
lua_State *co);
#endif

/* Error handler, called from assembler VM. */
void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co)
Expand Down
54 changes: 0 additions & 54 deletions src/lib_bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,82 +15,48 @@
#include "lj_buf.h"
#include "lj_strscan.h"
#include "lj_strfmt.h"
#if LJ_HASFFI
#include "lj_ctype.h"
#include "lj_cdata.h"
#include "lj_cconv.h"
#include "lj_carith.h"
#endif
#include "lj_ff.h"
#include "lj_lib.h"

/* ------------------------------------------------------------------------ */

#define LJLIB_MODULE_bit

#if LJ_HASFFI
static int bit_result64(lua_State *L, CTypeID id, uint64_t x)
{
GCcdata *cd = lj_cdata_new_(L, id, 8);
*(uint64_t *)cdataptr(cd) = x;
setcdataV(L, L->base-1-LJ_FR2, cd);
return FFH_RES(1);
}
#else
static int32_t bit_checkbit(lua_State *L, int narg)
{
TValue *o = L->base + narg-1;
if (!(o < L->top && lj_strscan_numberobj(o)))
lj_err_argt(L, narg, LUA_TNUMBER);
if (LJ_LIKELY(tvisint(o))) {
return intV(o);
} else {
int32_t i = lj_num2bit(numV(o));
if (LJ_DUALNUM) setintV(o, i);
return i;
}
}
#endif

LJLIB_ASM(bit_tobit) LJLIB_REC(bit_tobit)
{
#if LJ_HASFFI
CTypeID id = 0;
setintV(L->base-1-LJ_FR2, (int32_t)lj_carith_check64(L, 1, &id));
return FFH_RES(1);
#else
lj_lib_checknumber(L, 1);
return FFH_RETRY;
#endif
}

LJLIB_ASM(bit_bnot) LJLIB_REC(bit_unary IR_BNOT)
{
#if LJ_HASFFI
CTypeID id = 0;
uint64_t x = lj_carith_check64(L, 1, &id);
return id ? bit_result64(L, id, ~x) : FFH_RETRY;
#else
lj_lib_checknumber(L, 1);
return FFH_RETRY;
#endif
}

LJLIB_ASM(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP)
{
#if LJ_HASFFI
CTypeID id = 0;
uint64_t x = lj_carith_check64(L, 1, &id);
return id ? bit_result64(L, id, lj_bswap64(x)) : FFH_RETRY;
#else
lj_lib_checknumber(L, 1);
return FFH_RETRY;
#endif
}

LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL)
{
#if LJ_HASFFI
CTypeID id = 0, id2 = 0;
uint64_t x = lj_carith_check64(L, 1, &id);
int32_t sh = (int32_t)lj_carith_check64(L, 2, &id2);
Expand All @@ -100,11 +66,6 @@ LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL)
}
if (id2) setintV(L->base+1, sh);
return FFH_RETRY;
#else
lj_lib_checknumber(L, 1);
bit_checkbit(L, 2);
return FFH_RETRY;
#endif
}
LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR)
LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR)
Expand All @@ -113,7 +74,6 @@ LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR)

LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND)
{
#if LJ_HASFFI
CTypeID id = 0;
TValue *o = L->base, *top = L->top;
int i = 0;
Expand All @@ -131,11 +91,6 @@ LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND)
return bit_result64(L, id, y);
}
return FFH_RETRY;
#else
int i = 0;
do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top);
return FFH_RETRY;
#endif
}
LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR)
LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR)
Expand All @@ -144,24 +99,15 @@ LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR)

LJLIB_CF(bit_tohex) LJLIB_REC(.)
{
#if LJ_HASFFI
CTypeID id = 0, id2 = 0;
uint64_t b = lj_carith_check64(L, 1, &id);
int32_t n = L->base+1>=L->top ? (id ? 16 : 8) :
(int32_t)lj_carith_check64(L, 2, &id2);
#else
uint32_t b = (uint32_t)bit_checkbit(L, 1);
int32_t n = L->base+1>=L->top ? 8 : bit_checkbit(L, 2);
#endif
SBuf *sb = lj_buf_tmp_(L);
SFormat sf = (STRFMT_UINT|STRFMT_T_HEX);
if (n < 0) { n = -n; sf |= STRFMT_F_UPPER; }
sf |= ((SFormat)((n+1)&255) << STRFMT_SH_PREC);
#if LJ_HASFFI
if (n < 16) b &= ((uint64_t)1 << 4*n)-1;
#else
if (n < 8) b &= (1u << 4*n)-1;
#endif
sb = lj_strfmt_putfxint(sb, sf, b);
setstrV(L, L->top-1, lj_buf_str(L, sb));
lj_gc_check(L);
Expand Down
Loading

0 comments on commit 2fcc0a4

Please sign in to comment.