mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-21 14:23:26 +00:00
Compare commits
6 Commits
5bf05586f8
...
2c1183e12c
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2c1183e12c | ||
![]() |
538a82133a | ||
![]() |
84cb21ffaf | ||
![]() |
4f2bb199fe | ||
![]() |
dc809beb57 | ||
![]() |
89213015a6 |
@ -224,7 +224,7 @@ LJLIB_CF(rawlen) LJLIB_REC(.)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LJLIB_CF(unpack)
|
LJLIB_CF(unpack) LJLIB_REC(.)
|
||||||
{
|
{
|
||||||
GCtab *t = lj_lib_checktab(L, 1);
|
GCtab *t = lj_lib_checktab(L, 1);
|
||||||
int32_t n, i = lj_lib_optint(L, 2, 1);
|
int32_t n, i = lj_lib_optint(L, 2, 1);
|
||||||
|
@ -191,7 +191,7 @@ static void bcread_ktabk(LexState *ls, TValue *o, GCtab *t)
|
|||||||
} else if (tp == BCDUMP_KTAB_NUM) {
|
} else if (tp == BCDUMP_KTAB_NUM) {
|
||||||
o->u32.lo = bcread_uleb128(ls);
|
o->u32.lo = bcread_uleb128(ls);
|
||||||
o->u32.hi = bcread_uleb128(ls);
|
o->u32.hi = bcread_uleb128(ls);
|
||||||
} else if (tp == BCDUMP_KTAB_NIL) { /* Restore nil value marker. */
|
} else if (t && tp == BCDUMP_KTAB_NIL) { /* Restore nil value marker. */
|
||||||
settabV(ls->L, o, t);
|
settabV(ls->L, o, t);
|
||||||
} else {
|
} else {
|
||||||
lj_assertLS(tp <= BCDUMP_KTAB_TRUE, "bad constant type %d", tp);
|
lj_assertLS(tp <= BCDUMP_KTAB_TRUE, "bad constant type %d", tp);
|
||||||
@ -209,13 +209,13 @@ static GCtab *bcread_ktab(LexState *ls)
|
|||||||
MSize i;
|
MSize i;
|
||||||
TValue *o = tvref(t->array);
|
TValue *o = tvref(t->array);
|
||||||
for (i = 0; i < narray; i++, o++)
|
for (i = 0; i < narray; i++, o++)
|
||||||
bcread_ktabk(ls, o, t);
|
bcread_ktabk(ls, o, NULL);
|
||||||
}
|
}
|
||||||
if (nhash) { /* Read hash entries. */
|
if (nhash) { /* Read hash entries. */
|
||||||
MSize i;
|
MSize i;
|
||||||
for (i = 0; i < nhash; i++) {
|
for (i = 0; i < nhash; i++) {
|
||||||
TValue key;
|
TValue key;
|
||||||
bcread_ktabk(ls, &key, t);
|
bcread_ktabk(ls, &key, NULL);
|
||||||
lj_assertLS(!tvisnil(&key), "nil key");
|
lj_assertLS(!tvisnil(&key), "nil key");
|
||||||
bcread_ktabk(ls, lj_tab_set(ls->L, t, &key), t);
|
bcread_ktabk(ls, lj_tab_set(ls->L, t, &key), t);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ static void *callback_mcode_init(global_State *g, uint32_t *page)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for macOS hardened runtime. */
|
/* Check for macOS hardened runtime. */
|
||||||
#if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
|
#if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define CCMAP_CREATE MAP_JIT
|
#define CCMAP_CREATE MAP_JIT
|
||||||
#else
|
#else
|
||||||
|
@ -568,6 +568,44 @@ static void LJ_FASTCALL recff_next(jit_State *J, RecordFFData *rd)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void LJ_FASTCALL recff_unpack(jit_State *J, RecordFFData *rd)
|
||||||
|
{
|
||||||
|
TRef tab = J->base[0], trstart = J->base[1], trend = J->base[2];
|
||||||
|
if (tref_istab(tab) && trstart && trend && tref_isk2(trstart, trend) &&
|
||||||
|
!tref_isnil(trend)) {
|
||||||
|
if (!tref_isnil(trstart))
|
||||||
|
trstart = lj_opt_narrow_toint(J, trstart);
|
||||||
|
trend = lj_opt_narrow_toint(J, trend);
|
||||||
|
if (tref_isk2(trstart, trend)) {
|
||||||
|
uint32_t nu;
|
||||||
|
int32_t start = tref_isnil(trstart) ? 1 : IR(tref_ref(trstart))->i;
|
||||||
|
int32_t end = IR(tref_ref(trend))->i;
|
||||||
|
if (start > end) {
|
||||||
|
rd->nres = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nu = (uint32_t)end - (uint32_t)start;
|
||||||
|
/* Check for space for the return values. */
|
||||||
|
if (nu <= INT32_MAX - LJ_MAX_JSLOTS && J->baseslot + nu < LJ_MAX_JSLOTS) {
|
||||||
|
int32_t i, n = (int32_t)(nu+1);
|
||||||
|
RecordIndex ix;
|
||||||
|
ix.tab = tab;
|
||||||
|
settabV(J->L, &ix.tabv, tabV(&rd->argv[0]));
|
||||||
|
ix.val = 0;
|
||||||
|
ix.idxchain = 0;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
ix.key = lj_ir_kint(J, start + i);
|
||||||
|
setintV(&ix.keyv, start + i);
|
||||||
|
J->base[i] = lj_record_idx(J, &ix);
|
||||||
|
}
|
||||||
|
rd->nres = n;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recff_nyiu(J, rd);
|
||||||
|
}
|
||||||
|
|
||||||
/* -- Math library fast functions ----------------------------------------- */
|
/* -- Math library fast functions ----------------------------------------- */
|
||||||
|
|
||||||
static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
|
static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
|
||||||
|
@ -99,7 +99,7 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for macOS hardened runtime. */
|
/* Check for macOS hardened runtime. */
|
||||||
#if LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
|
#if defined(LUAJIT_ENABLE_OSX_HRT) && LUAJIT_SECURITY_MCODE != 0 && defined(MAP_JIT) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define MCMAP_CREATE MAP_JIT
|
#define MCMAP_CREATE MAP_JIT
|
||||||
#else
|
#else
|
||||||
@ -111,6 +111,8 @@ static int mcode_setprot(void *p, size_t sz, DWORD prot)
|
|||||||
#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
|
#define MCPROT_RWX (PROT_READ|PROT_WRITE|PROT_EXEC)
|
||||||
#ifdef PROT_MPROTECT
|
#ifdef PROT_MPROTECT
|
||||||
#define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX))
|
#define MCPROT_CREATE (PROT_MPROTECT(MCPROT_RWX))
|
||||||
|
#elif MCMAP_CREATE
|
||||||
|
#define MCPROT_CREATE PROT_EXEC
|
||||||
#else
|
#else
|
||||||
#define MCPROT_CREATE 0
|
#define MCPROT_CREATE 0
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user