view release on metacpan or search on metacpan
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
GLOB_ff_next,
GLOB_fff_res2,
GLOB_fff_fallback_2,
GLOB_ff_pairs,
GLOB_fff_res,
GLOB_ff_ipairs_aux,
GLOB_fff_res0,
GLOB_ff_ipairs,
GLOB_ff_pcall,
GLOB_ff_xpcall,
GLOB_ff_coroutine_resume,
GLOB_ff_coroutine_wrap_aux,
GLOB_ff_coroutine_yield,
GLOB_ff_math_abs,
GLOB_ff_math_sqrt,
GLOB_fff_resxmm0,
GLOB_ff_math_floor,
GLOB_vm_floor_sse,
GLOB_ff_math_ceil,
GLOB_vm_ceil_sse,
GLOB_ff_math_log,
GLOB_ff_math_log10,
GLOB_ff_math_exp,
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
"ff_next",
"fff_res2",
"fff_fallback_2",
"ff_pairs",
"fff_res",
"ff_ipairs_aux",
"fff_res0",
"ff_ipairs",
"ff_pcall",
"ff_xpcall",
"ff_coroutine_resume",
"ff_coroutine_wrap_aux",
"ff_coroutine_yield",
"ff_math_abs",
"ff_math_sqrt",
"fff_resxmm0",
"ff_math_floor",
"vm_floor_sse",
"ff_math_ceil",
"vm_ceil_sse",
"ff_math_log",
"ff_math_log10",
"ff_math_exp",
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
"lj_meta_equal",
"lj_meta_equal_cd",
"lj_meta_istype",
"lj_meta_arith",
"lj_meta_len",
"lj_meta_call",
"lj_meta_for",
"lj_tab_get",
"lj_strfmt_num",
"lj_tab_next",
"lj_ffh_coroutine_wrap_err",
"log",
"log10",
"exp",
"sin",
"cos",
"tan",
"asin",
"acos",
"atan",
"sinh",
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
//| mov LFUNC:RB, [BASE] // Swap function and traceback.
//| mov [BASE], LFUNC:RA
//| mov [BASE+8], LFUNC:RB
//| lea RA, [BASE+24]
//| sub NARGS:RDd, 2
//| mov PCd, 24+FRAME_PCALL
//| jmp <1
//|
//|//-- Coroutine library --------------------------------------------------
//|
//|.macro coroutine_resume_wrap, resume
//|.if resume
//|.ffunc_1 coroutine_resume
//| mov L:RB, [BASE]
//| cleartp L:RB
//|.else
//|.ffunc coroutine_wrap_aux
//| mov CFUNC:RB, [BASE-16]
//| cleartp CFUNC:RB
//| mov L:RB, CFUNC:RB->upvalue[0].gcr
//| cleartp L:RB
//|.endif
//| mov PC, [BASE-8]
//| mov SAVE_PC, PC
//| mov TMP1, L:RB
//|.if resume
//| checktptp [BASE], LJ_TTHREAD, ->fff_fallback
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
//| mov L:RB->top, BASE
//|.if resume
//| lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move.
//|.else
//| lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move.
//|.endif
//| sub RB, PC // Relative to PC.
//|
//| cmp PC, RA
//| je >3
//|2: // Move args to coroutine.
//| mov RC, [PC+RB]
//| mov [PC-8], RC
//| sub PC, 8
//| cmp PC, RA
//| jne <2
//|3:
//| mov CARG2, RA
//| mov CARG1, TMP1
//| call ->vm_resume // (lua_State *L, TValue *base, 0, 0)
//|
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
//| mov L:PC, TMP1
//| mov BASE, L:RB->base
//| mov [DISPATCH+DISPATCH_GL(cur_L)], L:RB
//| set_vmstate INTERP
//|
//| cmp eax, LUA_YIELD
//| ja >8
//|4:
//| mov RA, L:PC->base
//| mov KBASE, L:PC->top
//| mov L:PC->top, RA // Clear coroutine stack.
//| mov PC, KBASE
//| sub PC, RA
//| je >6 // No results?
//| lea RD, [BASE+PC]
//| shr PCd, 3
//| cmp RD, L:RB->maxstack
//| ja >9 // Need to grow stack?
//|
//| mov RB, BASE
//| sub RB, RA
//|5: // Move results from coroutine.
//| mov RD, [RA]
//| mov [RA+RB], RD
//| add RA, 8
//| cmp RA, KBASE
//| jne <5
//|6:
//|.if resume
//| lea RDd, [PCd+2] // nresults+1 = 1 + true + results.
//| mov_true ITYPE // Prepend true to results.
//| mov [BASE-8], ITYPE
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/host/buildvm_arch.h view on Meta::CPAN
//| test PCd, FRAME_TYPE
//| jz ->BC_RET_Z
//| jmp ->vm_return
//|
//|8: // Coroutine returned with error (at co->top-1).
//|.if resume
//| mov_false ITYPE // Prepend false to results.
//| mov [BASE-8], ITYPE
//| mov RA, L:PC->top
//| sub RA, 8
//| mov L:PC->top, RA // Clear error from coroutine stack.
//| // Copy error message.
//| mov RD, [RA]
//| mov [BASE], RD
//| mov RDd, 1+2 // nresults+1 = 1 + false + error.
//| jmp <7
//|.else
//| mov CARG2, L:PC
//| mov CARG1, L:RB
//| call extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
//| // Error function does not return.
//|.endif
//|
//|9: // Handle stack expansion on return from yield.
//| mov L:RA, TMP1
//| mov L:RA->top, KBASE // Undo coroutine stack clearing.
//| mov CARG2, PC
//| mov CARG1, L:RB
//| call extern lj_state_growstack // (lua_State *L, int n)
//| mov L:PC, TMP1
//| mov BASE, L:RB->base
//| jmp <4 // Retry the stack move.
//|.endmacro
//|
//| coroutine_resume_wrap 1 // coroutine.resume
dasm_put(Dst, 3540, 2+1, Dt1(->maxstack), LJ_TFUNC, 24+FRAME_PCALL, 1+1);
dasm_put(Dst, 3626, LJ_TTHREAD, Dt1(->cframe), Dt1(->status), LUA_YIELD, Dt1(->top), Dt1(->base), Dt1(->maxstack));
dasm_put(Dst, 3731, Dt1(->top), Dt1(->base), Dt1(->top), Dt1(->base), DISPATCH_GL(cur_L), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, LUA_YIELD);
dasm_put(Dst, 3835, Dt1(->base), Dt1(->top), Dt1(->top), Dt1(->maxstack), (unsigned int)((int64_t)~((uint64_t)2<<47)), (unsigned int)(((int64_t)~((uint64_t)2<<47))>>32), FRAME_TYPE, (unsigned int)((int64_t)~((uint64_t)1<<47)), (unsigned int)(((int6...
#line 1643 "vm_x64.dasc"
//| coroutine_resume_wrap 0 // coroutine.wrap
dasm_put(Dst, 3955, Dt1(->top), Dt1(->top), 1+2, Dt1(->top), Dt1(->base), Dt8(->upvalue[0].gcr), Dt1(->cframe), Dt1(->status), LUA_YIELD);
dasm_put(Dst, 4079, Dt1(->top), Dt1(->base), Dt1(->maxstack), Dt1(->top), Dt1(->base), Dt1(->top));
dasm_put(Dst, 4182, Dt1(->base), DISPATCH_GL(cur_L), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, LUA_YIELD, Dt1(->base), Dt1(->top), Dt1(->top), Dt1(->maxstack));
#line 1644 "vm_x64.dasc"
//|
//|.ffunc coroutine_yield
//| mov L:RB, SAVE_L
//| test aword L:RB->cframe, CFRAME_RESUME
//| jz ->fff_fallback
//| mov L:RB->base, BASE
dasm_put(Dst, 4272, FRAME_TYPE, Dt1(->top), Dt1(->base), Dt1(->cframe), CFRAME_RESUME);
#line 1650 "vm_x64.dasc"
//| lea RD, [BASE+NARGS:RD*8-8]
//| mov L:RB->top, RD
//| xor RDd, RDd
//| mov aword L:RB->cframe, RD
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/jit/vmdef.lua view on Meta::CPAN
"pcall",
"xpcall",
"loadfile",
"load",
"loadstring",
"dofile",
"gcinfo",
"collectgarbage",
"newproxy",
"print",
"coroutine.status",
"coroutine.running",
"coroutine.isyieldable",
"coroutine.create",
"coroutine.yield",
"coroutine.resume",
"coroutine.wrap_aux",
"coroutine.wrap",
"math.abs",
"math.floor",
"math.ceil",
"math.sqrt",
"math.log10",
"math.exp",
"math.sin",
"math.cos",
"math.tan",
"math.asin",
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lib_base.c view on Meta::CPAN
/*
** Base and coroutine library.
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
*/
#include <stdio.h>
#define lib_base_c
#define LUA_LIB
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lib_base.c view on Meta::CPAN
return 0;
}
LJLIB_PUSH(top-3)
LJLIB_SET(_VERSION)
#include "lj_libdef.h"
/* -- Coroutine library --------------------------------------------------- */
#define LJLIB_MODULE_coroutine
LJLIB_CF(coroutine_status)
{
const char *s;
lua_State *co;
if (!(L->top > L->base && tvisthread(L->base)))
lj_err_arg(L, 1, LJ_ERR_NOCORO);
co = threadV(L->base);
if (co == L) s = "running";
else if (co->status == LUA_YIELD) s = "suspended";
else if (co->status != LUA_OK) s = "dead";
else if (co->base > tvref(co->stack)+1+LJ_FR2) s = "normal";
else if (co->top == co->base) s = "dead";
else s = "suspended";
lua_pushstring(L, s);
return 1;
}
LJLIB_CF(coroutine_running)
{
#if LJ_52
int ismain = lua_pushthread(L);
setboolV(L->top++, ismain);
return 2;
#else
if (lua_pushthread(L))
setnilV(L->top++);
return 1;
#endif
}
LJLIB_CF(coroutine_isyieldable)
{
setboolV(L->top++, cframe_canyield(L->cframe));
return 1;
}
LJLIB_CF(coroutine_create)
{
lua_State *L1;
if (!(L->base < L->top && tvisfunc(L->base)))
lj_err_argt(L, 1, LUA_TFUNCTION);
L1 = lua_newthread(L);
setfuncV(L, L1->top++, funcV(L->base));
return 1;
}
LJLIB_ASM(coroutine_yield)
{
lj_err_caller(L, LJ_ERR_CYIELD);
return FFH_UNREACHABLE;
}
static int ffh_resume(lua_State *L, lua_State *co, int wrap)
{
if (co->cframe != NULL || co->status > LUA_YIELD ||
(co->status == LUA_OK && co->top == co->base)) {
ErrMsg em = co->cframe ? LJ_ERR_CORUN : LJ_ERR_CODEAD;
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lib_base.c view on Meta::CPAN
setstrV(L, L->base-LJ_FR2, lj_err_str(L, em));
return FFH_RES(2);
}
if (lj_state_cpgrowstack(co, (MSize)(L->top - L->base)) != LUA_OK) {
cTValue *msg = --co->top;
lj_err_callermsg(L, strVdata(msg));
}
return FFH_RETRY;
}
LJLIB_ASM(coroutine_resume)
{
if (!(L->top > L->base && tvisthread(L->base)))
lj_err_arg(L, 1, LJ_ERR_NOCORO);
return ffh_resume(L, threadV(L->base), 0);
}
LJLIB_NOREG LJLIB_ASM(coroutine_wrap_aux)
{
return ffh_resume(L, threadV(lj_lib_upvalue(L, 1)), 1);
}
/* 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)
{
co->top--; copyTV(L, L->top, co->top); L->top++;
if (tvisstr(L->top-1))
lj_err_callermsg(L, strVdata(L->top-1));
else
lj_err_run(L);
}
/* Forward declaration. */
static void setpc_wrap_aux(lua_State *L, GCfunc *fn);
LJLIB_CF(coroutine_wrap)
{
GCfunc *fn;
lj_cf_coroutine_create(L);
fn = lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1);
setpc_wrap_aux(L, fn);
return 1;
}
#include "lj_libdef.h"
/* Fix the PC of wrap_aux. Really ugly workaround. */
static void setpc_wrap_aux(lua_State *L, GCfunc *fn)
{
setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]);
}
/* ------------------------------------------------------------------------ */
static void newproxy_weaktable(lua_State *L)
{
/* NOBARRIER: The table is new (marked white). */
GCtab *t = lj_tab_new(L, 0, 1);
settabV(L, L->top++, t);
setgcref(t->metatable, obj2gco(t));
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lib_base.c view on Meta::CPAN
}
LUALIB_API int luaopen_base(lua_State *L)
{
/* NOBARRIER: Table and value are the same. */
GCtab *env = tabref(L->env);
settabV(L, lj_tab_setstr(L, env, lj_str_newlit(L, "_G")), env);
lua_pushliteral(L, LUA_VERSION); /* top-3. */
newproxy_weaktable(L); /* top-2. */
LJ_LIB_REG(L, "_G", base);
LJ_LIB_REG(L, LUA_COLIBNAME, coroutine);
return 2;
}
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_dispatch.c view on Meta::CPAN
#include "lj_vm.h"
#include "luajit.h"
/* Bump GG_NUM_ASMFF in lj_dispatch.h as needed. Ugly. */
LJ_STATIC_ASSERT(GG_NUM_ASMFF == FF_NUM_ASMFUNC);
/* -- Dispatch table management ------------------------------------------- */
#if LJ_TARGET_MIPS
#include <math.h>
LJ_FUNCA_NORET void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L,
lua_State *co);
#if !LJ_HASJIT
#define lj_dispatch_stitch lj_dispatch_ins
#endif
#if !LJ_HASPROFILE
#define lj_dispatch_profile lj_dispatch_ins
#endif
#define GOTFUNC(name) (ASMFunction)name,
static const ASMFunction dispatch_got[] = {
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_dispatch.h view on Meta::CPAN
_(lj_meta_equal_cd) _(lj_ccallback_enter) _(lj_ccallback_leave)
#else
#define FFIGOTDEF(_)
#endif
#define GOTDEF(_) \
_(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \
_(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \
_(pow) _(fmod) _(ldexp) _(lj_vm_modi) \
_(lj_dispatch_call) _(lj_dispatch_ins) _(lj_dispatch_stitch) \
_(lj_dispatch_profile) _(lj_err_throw) \
_(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \
_(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \
_(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \
_(lj_meta_for) _(lj_meta_istype) _(lj_meta_len) _(lj_meta_tget) \
_(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_number) \
_(lj_str_new) _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) \
_(lj_tab_new) _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \
_(lj_tab_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \
_(lj_buf_putstr_upper) _(lj_buf_tostr) \
JITGOTDEF(_) FFIGOTDEF(_) SFGOTDEF(_)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_err.c view on Meta::CPAN
return NULL; /* Continue unwinding. */
#else
UNUSED(stopcf);
cf = cframe_prev(cf);
frame = frame_prevd(frame);
break;
#endif
case FRAME_CP: /* Protected C frame. */
if (cframe_canyield(cf)) { /* Resume? */
if (errcode) {
hook_leave(G(L)); /* Assumes nobody uses coroutines inside hooks. */
L->cframe = NULL;
L->status = (uint8_t)errcode;
}
return cf;
}
if (errcode) {
L->base = frame_prevd(frame) + 1;
L->cframe = cframe_prev(cf);
unwindstack(L, frame - LJ_FR2);
}
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_errmsg.h view on Meta::CPAN
ERRDEF(OPARITH, "perform arithmetic on")
ERRDEF(OPCAT, "concatenate")
ERRDEF(OPLEN, "get length of")
/* Type checks. */
ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)")
ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)")
ERRDEF(BADTYPE, "%s expected, got %s")
ERRDEF(BADVAL, "invalid value")
ERRDEF(NOVAL, "value expected")
ERRDEF(NOCORO, "coroutine expected")
ERRDEF(NOTABN, "nil or table expected")
ERRDEF(NOLFUNC, "Lua function expected")
ERRDEF(NOFUNCL, "function or level expected")
ERRDEF(NOSFT, "string/function/table expected")
ERRDEF(NOPROXY, "boolean or proxy expected")
ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number")
ERRDEF(FORLIM, LUA_QL("for") " limit must be a number")
ERRDEF(FORSTEP, LUA_QL("for") " step must be a number")
/* C API checks. */
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_errmsg.h view on Meta::CPAN
ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print"))
ERRDEF(NUMRNG, "number out of range")
ERRDEF(IDXRNG, "index out of range")
ERRDEF(BASERNG, "base out of range")
ERRDEF(LVLRNG, "level out of range")
ERRDEF(INVLVL, "invalid level")
ERRDEF(INVOPT, "invalid option")
ERRDEF(INVOPTM, "invalid option " LUA_QS)
ERRDEF(INVFMT, "invalid format")
ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object")
ERRDEF(CORUN, "cannot resume running coroutine")
ERRDEF(CODEAD, "cannot resume dead coroutine")
ERRDEF(COSUSP, "cannot resume non-suspended coroutine")
ERRDEF(PRNGSD, "PRNG seeding failed")
ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert"))
ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat"))
ERRDEF(TABSORT, "invalid order function for sorting")
ERRDEF(IOCLFL, "attempt to use a closed file")
ERRDEF(IOSTDCL, "standard file is closed")
ERRDEF(OSUNIQF, "unable to generate a unique filename")
ERRDEF(OSDATEF, "field " LUA_QS " missing in date table")
ERRDEF(STRDUMP, "unable to dump given function")
ERRDEF(STRSLC, "string slice too long")
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_ffdef.h view on Meta::CPAN
FFDEF(pcall)
FFDEF(xpcall)
FFDEF(loadfile)
FFDEF(load)
FFDEF(loadstring)
FFDEF(dofile)
FFDEF(gcinfo)
FFDEF(collectgarbage)
FFDEF(newproxy)
FFDEF(print)
FFDEF(coroutine_status)
FFDEF(coroutine_running)
FFDEF(coroutine_isyieldable)
FFDEF(coroutine_create)
FFDEF(coroutine_yield)
FFDEF(coroutine_resume)
FFDEF(coroutine_wrap_aux)
FFDEF(coroutine_wrap)
FFDEF(math_abs)
FFDEF(math_floor)
FFDEF(math_ceil)
FFDEF(math_sqrt)
FFDEF(math_log10)
FFDEF(math_exp)
FFDEF(math_sin)
FFDEF(math_cos)
FFDEF(math_tan)
FFDEF(math_asin)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_libdef.h view on Meta::CPAN
108,6,117,110,112,97,99,107,6,115,101,108,101,99,116,72,116,111,110,117,109,
98,101,114,72,116,111,115,116,114,105,110,103,5,101,114,114,111,114,69,112,
99,97,108,108,134,120,112,99,97,108,108,8,108,111,97,100,102,105,108,101,4,
108,111,97,100,10,108,111,97,100,115,116,114,105,110,103,6,100,111,102,105,
108,101,6,103,99,105,110,102,111,14,99,111,108,108,101,99,116,103,97,114,98,
97,103,101,252,2,8,110,101,119,112,114,111,120,121,200,116,111,115,116,114,
105,110,103,5,112,114,105,110,116,252,3,200,95,86,69,82,83,73,79,78,250,255
};
#endif
#ifdef LJLIB_MODULE_coroutine
#undef LJLIB_MODULE_coroutine
static const lua_CFunction lj_lib_cf_coroutine[] = {
lj_cf_coroutine_status,
lj_cf_coroutine_running,
lj_cf_coroutine_isyieldable,
lj_cf_coroutine_create,
lj_ffh_coroutine_yield,
lj_ffh_coroutine_resume,
lj_cf_coroutine_wrap
};
static const uint8_t lj_lib_init_coroutine[] = {
30,13,7,6,115,116,97,116,117,115,7,114,117,110,110,105,110,103,11,105,115,121,
105,101,108,100,97,98,108,101,6,99,114,101,97,116,101,69,121,105,101,108,100,
70,114,101,115,117,109,101,254,4,119,114,97,112,255
};
#endif
#ifdef LJLIB_MODULE_math
#undef LJLIB_MODULE_math
static const lua_CFunction lj_lib_cf_math[] = {
lj_ffh_math_abs,
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_opt_fold.c view on Meta::CPAN
LJFOLD(ULOAD any)
LJFOLDX(lj_opt_fwd_uload)
LJFOLD(ALEN any any)
LJFOLDX(lj_opt_fwd_alen)
/* Try to merge UREFO/UREFC into referenced instruction. */
static TRef merge_uref(jit_State *J, IRRef ref, IRIns* ir)
{
if (ir->o == IR_UREFO && irt_isguard(ir->t)) {
/* Might be pointing to some other coroutine's stack.
** And GC might shrink said stack, thereby repointing the upvalue.
** GC might even collect said coroutine, thereby closing the upvalue.
*/
if (gcstep_barrier(J, ref))
return EMITFOLD; /* So cannot merge. */
/* Current fins wants a check, but ir doesn't have one. */
if ((irt_t(fins->t) & (IRT_GUARD|IRT_TYPE)) == (IRT_GUARD|IRT_PGC) &&
irt_type(ir->t) == IRT_IGC)
ir->t.irt += IRT_PGC-IRT_IGC; /* So install a check. */
}
return ref; /* Not a TRef, but the caller doesn't care. */
}
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_opt_fold.c view on Meta::CPAN
lj_opt_fwd_href_nokey(J))
return lj_ir_kkptr(J, niltvg(J2G(J)));
return NEXTFOLD;
}
/* We can safely FOLD/CSE array/hash refs and field loads, since there
** are no corresponding stores. But we need to check for any NEWREF with
** an aliased table, as it may invalidate all of the pointers and fields.
** Only HREF needs the NEWREF check -- AREF and HREFK already depend on
** FLOADs. And NEWREF itself is treated like a store (see below).
** LREF is constant (per trace) since coroutine switches are not inlined.
*/
LJFOLD(FLOAD TNEW IRFL_TAB_ASIZE)
LJFOLDF(fload_tab_tnew_asize)
{
if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && lj_opt_fwd_tptr(J, fins->op1))
return INTFOLD(fleft->op1);
return NEXTFOLD;
}
LJFOLD(FLOAD TNEW IRFL_TAB_HMASK)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_opt_narrow.c view on Meta::CPAN
** this can be further reduced. See below.]
**
** Special care has to be taken to avoid narrowing across an operation
** which is potentially operating on non-integral operands. One obvious
** case is when an expression contains a non-integral constant, but ends
** up as an integer index at runtime (like t[x+1.5] with x=0.5).
**
** Operations with two non-constant operands illustrate a similar problem
** (like t[a+b] with a=1.5 and b=2.5). Backpropagation has to stop there,
** unless it can be proven that either operand is integral (e.g. by CSEing
** a previous conversion). As a not-so-obvious corollary this logic also
** applies for a whole expression tree (e.g. t[(a+1)+(b+1)]).
**
** Correctness of the transformation is guaranteed by avoiding to expand
** the tree by adding more conversions than the one we would need to emit
** if not backpropagating. TOBIT employs a more optimistic rule, because
** the conversion has special semantics, designed to make the life of the
** compiler writer easier. ;-)
**
** Using on-the-fly backpropagation of an expression tree doesn't work
** because it's unknown whether the transform is correct until the end.
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_record.c view on Meta::CPAN
/* Too many closures created? Probably not a monomorphic function. */
if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
TRef trpt = emitir(IRT(IR_FLOAD, IRT_PGC), tr, IRFL_FUNC_PC);
emitir(IRTG(IR_EQ, IRT_PGC), trpt, lj_ir_kptr(J, proto_bc(pt)));
(void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
return tr;
}
} else {
/* Don't specialize to non-monomorphic builtins. */
switch (fn->c.ffid) {
case FF_coroutine_wrap_aux:
case FF_string_gmatch_aux:
/* NYI: io_file_iter doesn't have an ffid, yet. */
{ /* Specialize to the ffid. */
TRef trid = emitir(IRT(IR_FLOAD, IRT_U8), tr, IRFL_FUNC_FFID);
emitir(IRTGI(IR_EQ), trid, lj_ir_kint(J, fn->c.ffid));
}
return tr;
default:
/* NYI: don't specialize to non-monomorphic C functions. */
break;
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_vm.S view on Meta::CPAN
.hidden lj_ff_xpcall
.type lj_ff_xpcall, @function
.size lj_ff_xpcall, 73
lj_ff_xpcall:
.byte 131,248,3,15,130,236,14,0,0,72,139,108,36,16,72,141
.byte 12,194,72,59,77,48,15,135,217,14,0,0,72,139,74,8
.byte 73,137,203,73,193,251,47,65,131,251,247,15,133,196,14,0
.byte 0,72,139,42,72,137,10,72,137,106,8,72,141,74,24,131
.byte 232,2,187,30,0,0,0,235,140
.globl lj_ff_coroutine_resume
.hidden lj_ff_coroutine_resume
.type lj_ff_coroutine_resume, @function
.size lj_ff_coroutine_resume, 387
lj_ff_coroutine_resume:
.byte 131,248,2,15,130,163,14,0,0,72,139,42,72,193,229,17
.byte 72,193,237,17,72,139,90,248,72,137,92,36,24,72,137,44
.byte 36,76,139,26,73,193,251,47,65,131,251,249,15,133,122,14
.byte 0,0,72,131,125,80,0,15,133,111,14,0,0,128,125,11
.byte 1,15,135,101,14,0,0,72,139,77,40,116,21,72,59,77
.byte 32,15,132,85,14,0,0,72,139,89,248,72,137,25,72,131
.byte 193,8,72,141,92,193,240,72,59,93,48,15,135,59,14,0
.byte 0,72,137,93,40,72,139,108,36,16,72,137,85,32,72,131
.byte 194,8,72,137,85,40,72,141,108,194,232,72,41,221,72,57
.byte 203,116,17,72,139,4,43,72,137,67,248,72,131,235,8,72
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lj_vm.S view on Meta::CPAN
.byte 255,255,255,255,255,255,254,255,76,137,90,248,72,139,92,36
.byte 24,137,4,36,72,199,193,248,255,255,255,247,195,3,0,0
.byte 0,15,132,233,235,255,255,233,247,241,255,255,73,187,255,255
.byte 255,255,255,127,255,255,76,137,90,248,72,139,75,40,72,131
.byte 233,8,72,137,75,40,72,139,1,72,137,2,184,3,0,0
.byte 0,235,185,72,139,12,36,76,137,121,40,72,137,222,72,137
.byte 239
call lj_state_growstack
.byte 72,139,28,36,72,139,85,32,233,81,255,255,255
.globl lj_ff_coroutine_wrap_aux
.hidden lj_ff_coroutine_wrap_aux
.type lj_ff_coroutine_wrap_aux, @function
.size lj_ff_coroutine_wrap_aux, 320
lj_ff_coroutine_wrap_aux:
.byte 72,139,106,240,72,193,229,17,72,193,237,17,72,139,109,48
.byte 72,193,229,17,72,193,237,17,72,139,90,248,72,137,92,36
.byte 24,72,137,44,36,72,131,125,80,0,15,133,249,12,0,0
.byte 128,125,11,1,15,135,239,12,0,0,72,139,77,40,116,21
.byte 72,59,77,32,15,132,223,12,0,0,72,139,89,248,72,137
.byte 25,72,131,193,8,72,141,92,193,248,72,59,93,48,15,135
.byte 197,12,0,0,72,137,93,40,72,139,108,36,16,72,137,85
.byte 32,72,137,85,40,72,141,108,194,240,72,41,221,72,57,203
.byte 116,17,72,139,4,43,72,137,67,248,72,131,235,8,72,57
.byte 203,117,239,72,137,206,72,139,60,36,232,158,242,255,255,72
.byte 139,108,36,16,72,139,28,36,72,139,85,32,73,137,174,232
.byte 241,255,255,65,199,134,48,241,255,255,255,255,255,255,131,248
.byte 1,119,85,72,139,75,32,76,139,123,40,72,137,75,40,76
.byte 137,251,72,41,203,116,35,72,141,4,26,193,235,3,72,59
.byte 69,48,119,63,72,137,213,72,41,205,72,139,1,72,137,4
.byte 41,72,131,193,8,76,57,249,117,240,141,67,1,72,139,92
.byte 36,24,137,4,36,49,201,247,195,3,0,0,0,15,132,138
.byte 234,255,255,233,152,240,255,255,72,137,222,72,137,239
call lj_ffh_coroutine_wrap_err
.byte 72,139,12,36,76,137,121,40,72,137,222,72,137,239
call lj_state_growstack
.byte 72,139,28,36,72,139,85,32,235,131
.globl lj_ff_coroutine_yield
.hidden lj_ff_coroutine_yield
.type lj_ff_coroutine_yield, @function
.size lj_ff_coroutine_yield, 48
lj_ff_coroutine_yield:
.byte 72,139,108,36,16,72,247,69,80,1,0,0,0,15,132,214
.byte 11,0,0,72,137,85,32,72,141,68,194,248,72,137,69,40
.byte 49,192,72,137,69,80,176,1,136,69,11,233,158,240,255,255
.globl lj_ff_math_abs
.hidden lj_ff_math_abs
.type lj_ff_math_abs, @function
.size lj_ff_math_abs, 45
lj_ff_math_abs:
.byte 131,248,2,15,130,176,11,0,0,72,139,42,73,137,235,73
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lua.h view on Meta::CPAN
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname);
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
/*
** coroutine functions
*/
LUA_API int (lua_yield) (lua_State *L, int nresults);
LUA_API int (lua_resume) (lua_State *L, int narg);
LUA_API int (lua_status) (lua_State *L);
/*
** garbage-collection function and options
*/
#define LUA_GCSTOP 0
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/lualib.h view on Meta::CPAN
** Copyright (C) 2005-2025 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LUALIB_H
#define _LUALIB_H
#include "lua.h"
#define LUA_FILEHANDLE "FILE*"
#define LUA_COLIBNAME "coroutine"
#define LUA_MATHLIBNAME "math"
#define LUA_STRLIBNAME "string"
#define LUA_TABLIBNAME "table"
#define LUA_IOLIBNAME "io"
#define LUA_OSLIBNAME "os"
#define LUA_LOADLIBNAME "package"
#define LUA_DBLIBNAME "debug"
#define LUA_BITLIBNAME "bit"
#define LUA_JITLIBNAME "jit"
#define LUA_FFILIBNAME "ffi"
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm.dasc view on Meta::CPAN
| strd CARG34, [BASE]
| tst RA, #HOOK_ACTIVE // Remember active hook before pcall.
| add BASE, BASE, #16
| moveq PC, #16+FRAME_PCALL
| movne PC, #16+FRAME_PCALLH
| sub NARGS8:RC, NARGS8:RC, #16
| b ->vm_call_dispatch
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| checktp CARG2, LJ_TTHREAD
| bne ->fff_fallback
|.else
|.ffunc coroutine_wrap_aux
| ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr
|.endif
| ldr PC, [BASE, FRAME_PC]
| str BASE, L->base
| ldr CARG2, L:CARG1->top
| ldrb RA, L:CARG1->status
| ldr RB, L:CARG1->base
| add CARG3, CARG2, NARGS8:RC
| add CARG4, CARG2, RA
| str PC, SAVE_PC
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm.dasc view on Meta::CPAN
| cmpls RB, #0
| bhi ->fff_fallback
|1:
|.if resume
| sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC.
| add BASE, BASE, #8
| sub NARGS8:RC, NARGS8:RC, #8
|.endif
| str CARG3, L:CARG1->top
| str BASE, L->top
|2: // Move args to coroutine.
| ldrd CARG34, [BASE, RB]
| cmp RB, NARGS8:RC
| strdne CARG34, [CARG2, RB]
| add RB, RB, #8
| bne <2
|
| mov CARG3, #0
| mov L:RA, L:CARG1
| mov CARG4, #0
| bl ->vm_resume // (lua_State *L, TValue *base, 0, 0)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm.dasc view on Meta::CPAN
| bhi >8
| subs RC, CARG4, CARG3
| ldr CARG1, L->maxstack
| add CARG2, BASE, RC
| beq >6 // No results?
| cmp CARG2, CARG1
| mov RB, #0
| bhi >9 // Need to grow stack?
|
| sub CARG4, RC, #8
| str CARG3, L:RA->top // Clear coroutine stack.
|5: // Move results from coroutine.
| ldrd CARG12, [CARG3, RB]
| cmp RB, CARG4
| strd CARG12, [BASE, RB]
| add RB, RB, #8
| bne <5
|6:
|.if resume
| mvn CARG3, #~LJ_TTRUE
| add RC, RC, #16
|7:
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm.dasc view on Meta::CPAN
| str PC, SAVE_PC
| str RC, SAVE_MULTRES
| beq ->BC_RET_Z
| b ->vm_return
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| ldrd CARG12, [CARG4, #-8]!
| mvn CARG3, #~LJ_TFALSE
| mov RC, #(2+1)*8
| str CARG4, L:RA->top // Remove error from coroutine stack.
| strd CARG12, [BASE] // Copy error message.
| b <7
|.else
| mov CARG1, L
| mov CARG2, L:RA
| bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
| // Never returns.
|.endif
|
|9: // Handle stack expansion on return from yield.
| mov CARG1, L
| lsr CARG2, RC, #3
| bl extern lj_state_growstack // (lua_State *L, int n)
| mov CRET1, #0
| b <4
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| ldr CARG1, L->cframe
| add CARG2, BASE, NARGS8:RC
| str BASE, L->base
| tst CARG1, #CFRAME_RESUME
| str CARG2, L->top
| mov CRET1, #LUA_YIELD
| mov CARG3, #0
| beq ->fff_fallback
| str CARG3, L->cframe
| strb CRET1, L->status
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm64.dasc view on Meta::CPAN
| add PC, TMP0, #24+FRAME_PCALL
| bne ->fff_fallback // Traceback must be a function.
| mov NARGS8:RC, NARGS8:TMP1
| add BASE, BASE, #24
| stp CARG2, CARG1, [RB] // Swap function and traceback.
| cbz NARGS8:RC, ->vm_call_dispatch
| b <1
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| checktp CARG1, LJ_TTHREAD, ->fff_fallback
|.else
|.ffunc coroutine_wrap_aux
| ldr L:CARG1, CFUNC:CARG3->upvalue[0].gcr
| and L:CARG1, CARG1, #LJ_GCVMASK
|.endif
| ldr PC, [BASE, FRAME_PC]
| str BASE, L->base
| ldp RB, CARG2, L:CARG1->base
| ldrb TMP1w, L:CARG1->status
| add TMP0, CARG2, TMP1
| str PC, SAVE_PC
| cmp TMP0, RB
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm64.dasc view on Meta::CPAN
| ccmp RB, #0, #2, ls
| bhi ->fff_fallback
|.if resume
| sub CARG3, CARG3, #8 // Keep resumed thread in stack for GC.
| add BASE, BASE, #8
| sub NARGS8:RC, NARGS8:RC, #8
|.endif
| str CARG3, L:CARG1->top
| str BASE, L->top
| cbz NARGS8:RC, >3
|2: // Move args to coroutine.
| ldr TMP0, [BASE, RB]
| cmp RB, NARGS8:RC
| str TMP0, [CARG2, RB]
| add RB, RB, #8
| bne <2
|3:
| mov CARG3, #0
| mov L:RA, L:CARG1
| mov CARG4, #0
| bl ->vm_resume // (lua_State *L, TValue *base, 0, 0)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm64.dasc view on Meta::CPAN
| bhi >8
| sub RC, CARG4, CARG3
| ldr CARG1, L->maxstack
| add CARG2, BASE, RC
| cbz RC, >6 // No results?
| cmp CARG2, CARG1
| mov RB, #0
| bhi >9 // Need to grow stack?
|
| sub CARG4, RC, #8
| str CARG3, L:RA->top // Clear coroutine stack.
|5: // Move results from coroutine.
| ldr TMP0, [CARG3, RB]
| cmp RB, CARG4
| str TMP0, [BASE, RB]
| add RB, RB, #8
| bne <5
|6:
|.if resume
| mov_true TMP1
| add RC, RC, #16
|7:
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_arm64.dasc view on Meta::CPAN
| str PC, SAVE_PC
| str RCw, SAVE_MULTRES
| beq ->BC_RET_Z
| b ->vm_return
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| ldr TMP0, [CARG4, #-8]!
| mov_false TMP1
| mov RC, #(2+1)*8
| str CARG4, L:RA->top // Remove error from coroutine stack.
| str TMP0, [BASE] // Copy error message.
| b <7
|.else
| mov CARG1, L
| mov CARG2, L:RA
| bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
| // Never returns.
|.endif
|
|9: // Handle stack expansion on return from yield.
| mov CARG1, L
| lsr CARG2, RC, #3
| bl extern lj_state_growstack // (lua_State *L, int n)
| mov CRET1, #0
| b <4
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| ldr TMP0, L->cframe
| add TMP1, BASE, NARGS8:RC
| mov CRET1, #LUA_YIELD
| stp BASE, TMP1, L->base
| tbz TMP0, #0, ->fff_fallback
| str xzr, L->cframe
| strb CRET1w, L->status
| b ->vm_leave_unw
|
|//-- Math library -------------------------------------------------------
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips.dasc view on Meta::CPAN
| sw CARG4, HI(TMP2)
| andi TMP3, TMP3, 1
| sw CARG1, 8+LO(TMP2)
| sw CARG2, 8+HI(TMP2)
| addiu PC, TMP3, 16+FRAME_PCALL
| b ->vm_call_dispatch
|. addiu NARGS8:RC, NARGS8:RC, -16
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc coroutine_resume
| lw CARG3, HI(BASE)
| beqz NARGS8:RC, ->fff_fallback
|. lw CARG1, LO(BASE)
| li AT, LJ_TTHREAD
| bne CARG3, AT, ->fff_fallback
|.else
|.ffunc coroutine_wrap_aux
| lw L:CARG1, CFUNC:RB->upvalue[0].gcr
|.endif
| lbu TMP0, L:CARG1->status
| lw TMP1, L:CARG1->cframe
| lw CARG2, L:CARG1->top
| lw TMP2, L:CARG1->base
| addiu TMP3, TMP0, -LUA_YIELD
| bgtz TMP3, ->fff_fallback // st > LUA_YIELD?
|. xor TMP2, TMP2, CARG2
| bnez TMP1, ->fff_fallback // cframe != 0?
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips.dasc view on Meta::CPAN
|1:
|.if resume
| addiu BASE, BASE, 8 // Keep resumed thread in stack for GC.
| addiu NARGS8:RC, NARGS8:RC, -8
| addiu TMP2, TMP2, -8
|.endif
| sw TMP2, L:CARG1->top
| addu TMP1, BASE, NARGS8:RC
| move CARG3, CARG2
| sw BASE, L->top
|2: // Move args to coroutine.
| lw SFRETHI, HI(BASE)
| lw SFRETLO, LO(BASE)
| sltu AT, BASE, TMP1
| beqz AT, >3
|. addiu BASE, BASE, 8
| sw SFRETHI, HI(CARG3)
| sw SFRETLO, LO(CARG3)
| b <2
|. addiu CARG3, CARG3, 8
|3:
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips.dasc view on Meta::CPAN
| sw L, DISPATCH_GL(cur_L)(DISPATCH)
| st_vmstate
| beqz AT, >8
|. subu RD, TMP3, TMP2
| lw TMP0, L->maxstack
| beqz RD, >6 // No results?
|. addu TMP1, BASE, RD
| sltu AT, TMP0, TMP1
| bnez AT, >9 // Need to grow stack?
|. addu TMP3, TMP2, RD
| sw TMP2, L:RA->top // Clear coroutine stack.
| move TMP1, BASE
|5: // Move results from coroutine.
| lw SFRETHI, HI(TMP2)
| lw SFRETLO, LO(TMP2)
| addiu TMP2, TMP2, 8
| sltu AT, TMP2, TMP3
| sw SFRETHI, HI(TMP1)
| sw SFRETLO, LO(TMP1)
| bnez AT, <5
|. addiu TMP1, TMP1, 8
|6:
| andi TMP0, PC, FRAME_TYPE
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips.dasc view on Meta::CPAN
|. move MULTRES, RD
| b ->vm_return
|. nop
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| addiu TMP3, TMP3, -8
| li TMP1, LJ_TFALSE
| lw SFRETHI, HI(TMP3)
| lw SFRETLO, LO(TMP3)
| sw TMP3, L:RA->top // Remove error from coroutine stack.
| li RD, (2+1)*8
| sw TMP1, -8+HI(BASE) // Prepend false to results.
| addiu RA, BASE, -8
| sw SFRETHI, HI(BASE) // Copy error message.
| sw SFRETLO, LO(BASE)
| b <7
|. andi TMP0, PC, FRAME_TYPE
|.else
| load_got lj_ffh_coroutine_wrap_err
| move CARG2, L:RA
| call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
|. move CARG1, L
|.endif
|
|9: // Handle stack expansion on return from yield.
| load_got lj_state_growstack
| srl CARG2, RD, 3
| call_intern lj_state_growstack // (lua_State *L, int n)
|. move CARG1, L
| b <4
|. li CRET1, 0
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| lw TMP0, L->cframe
| addu TMP1, BASE, NARGS8:RC
| sw BASE, L->base
| andi TMP0, TMP0, CFRAME_RESUME
| sw TMP1, L->top
| beqz TMP0, ->fff_fallback
|. li CRET1, LUA_YIELD
| sw r0, L->cframe
| b ->vm_leave_unw
|. sb CRET1, L->status
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips64.dasc view on Meta::CPAN
| sd CARG2, 0(TMP2) // Swap function and traceback.
| andi TMP3, TMP3, 1
| sd CARG1, 8(TMP2)
| beqz NARGS8:RC, ->vm_call_dispatch
|. daddiu PC, TMP3, 24+FRAME_PCALL
| b <1
|. nop
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| checktp CARG1, CARG1, -LJ_TTHREAD, ->fff_fallback
|.else
|.ffunc coroutine_wrap_aux
| ld L:CARG1, CFUNC:RB->upvalue[0].gcr
| cleartp L:CARG1
|.endif
| lbu TMP0, L:CARG1->status
| ld TMP1, L:CARG1->cframe
| ld CARG2, L:CARG1->top
| ld TMP2, L:CARG1->base
| addiu AT, TMP0, -LUA_YIELD
| daddu CARG3, CARG2, TMP0
| daddiu TMP3, CARG2, 8
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips64.dasc view on Meta::CPAN
|1:
|.if resume
| daddiu BASE, BASE, 8 // Keep resumed thread in stack for GC.
| daddiu NARGS8:RC, NARGS8:RC, -8
| daddiu TMP2, TMP2, -8
|.endif
| sd TMP2, L:CARG1->top
| daddu TMP1, BASE, NARGS8:RC
| move CARG3, CARG2
| sd BASE, L->top
|2: // Move args to coroutine.
| ld CRET1, 0(BASE)
| sltu AT, BASE, TMP1
| beqz AT, >3
|. daddiu BASE, BASE, 8
| sd CRET1, 0(CARG3)
| b <2
|. daddiu CARG3, CARG3, 8
|3:
| bal ->vm_resume // (lua_State *L, TValue *base, 0, 0)
|. move L:RA, L:CARG1
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips64.dasc view on Meta::CPAN
| sd L, DISPATCH_GL(cur_L)(DISPATCH)
| st_vmstate
| beqz AT, >8
|. dsubu RD, TMP3, TMP2
| ld TMP0, L->maxstack
| beqz RD, >6 // No results?
|. daddu TMP1, BASE, RD
| sltu AT, TMP0, TMP1
| bnez AT, >9 // Need to grow stack?
|. daddu TMP3, TMP2, RD
| sd TMP2, L:RA->top // Clear coroutine stack.
| move TMP1, BASE
|5: // Move results from coroutine.
| ld CRET1, 0(TMP2)
| daddiu TMP2, TMP2, 8
| sltu AT, TMP2, TMP3
| sd CRET1, 0(TMP1)
| bnez AT, <5
|. daddiu TMP1, TMP1, 8
|6:
| andi TMP0, PC, FRAME_TYPE
|.if resume
| mov_true TMP1
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_mips64.dasc view on Meta::CPAN
| beqz TMP0, ->BC_RET_Z
|. move MULTRES, RD
| b ->vm_return
|. nop
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| daddiu TMP3, TMP3, -8
| mov_false TMP1
| ld CRET1, 0(TMP3)
| sd TMP3, L:RA->top // Remove error from coroutine stack.
| li RD, (2+1)*8
| sd TMP1, -8(BASE) // Prepend false to results.
| daddiu RA, BASE, -8
| sd CRET1, 0(BASE) // Copy error message.
| b <7
|. andi TMP0, PC, FRAME_TYPE
|.else
| load_got lj_ffh_coroutine_wrap_err
| move CARG2, L:RA
| call_intern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
|. move CARG1, L
|.endif
|
|9: // Handle stack expansion on return from yield.
| load_got lj_state_growstack
| srl CARG2, RD, 3
| call_intern lj_state_growstack // (lua_State *L, int n)
|. move CARG1, L
| b <4
|. li CRET1, 0
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| ld TMP0, L->cframe
| daddu TMP1, BASE, NARGS8:RC
| sd BASE, L->base
| andi TMP0, TMP0, CFRAME_RESUME
| sd TMP1, L->top
| beqz TMP0, ->fff_fallback
|. li CRET1, LUA_YIELD
| sd r0, L->cframe
| b ->vm_leave_unw
|. sb CRET1, L->status
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_ppc.dasc view on Meta::CPAN
| stw CARG4, 4(TMP2)
| stw CARG1, 8(TMP2)
| stw CARG2, 12(TMP2)
|.endif
| subi NARGS8:RC, NARGS8:RC, 16
| addi PC, TMP1, 16+FRAME_PCALL
| b ->vm_call_dispatch
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| cmpwi CARG3, LJ_TTHREAD; bne ->fff_fallback
|.else
|.ffunc coroutine_wrap_aux
| lwz L:CARG1, CFUNC:RB->upvalue[0].gcr
|.endif
| lbz TMP0, L:CARG1->status
| lp TMP1, L:CARG1->cframe
| lp CARG2, L:CARG1->top
| cmplwi cr0, TMP0, LUA_YIELD
| lp TMP2, L:CARG1->base
| cmplwi cr1, TMP1, 0
| lwz TMP0, L:CARG1->maxstack
| cmplw cr7, CARG2, TMP2
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_ppc.dasc view on Meta::CPAN
| blt cr6, ->fff_fallback
|1:
|.if resume
| addi BASE, BASE, 8 // Keep resumed thread in stack for GC.
| subi NARGS8:RC, NARGS8:RC, 8
| subi TMP2, TMP2, 8
|.endif
| stp TMP2, L:CARG1->top
| li TMP1, 0
| stp BASE, L->top
|2: // Move args to coroutine.
| cmpw TMP1, NARGS8:RC
|.if FPU
| lfdx f0, BASE, TMP1
|.else
| add CARG3, BASE, TMP1
| lwz TMP2, 0(CARG3)
| lwz TMP3, 4(CARG3)
|.endif
| beq >3
|.if FPU
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_ppc.dasc view on Meta::CPAN
| sub RD, TMP3, TMP2
| lwz TMP0, L->maxstack
| cmplwi RD, 0
| add TMP1, BASE, RD
| beq >6 // No results?
| cmplw TMP1, TMP0
| li TMP1, 0
| bgt >9 // Need to grow stack?
|
| subi TMP3, RD, 8
| stp TMP2, L:SAVE0->top // Clear coroutine stack.
|5: // Move results from coroutine.
| cmplw TMP1, TMP3
|.if FPU
| lfdx f0, TMP2, TMP1
| stfdx f0, BASE, TMP1
|.else
| add CARG3, TMP2, TMP1
| lwz CARG1, 0(CARG3)
| lwz CARG2, 4(CARG3)
| add CARG3, BASE, TMP1
| stw CARG1, 0(CARG3)
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_ppc.dasc view on Meta::CPAN
|.if resume
| andix. TMP0, PC, FRAME_TYPE
| la TMP3, -8(TMP3)
| li TMP1, LJ_TFALSE
|.if FPU
| lfd f0, 0(TMP3)
|.else
| lwz CARG1, 0(TMP3)
| lwz CARG2, 4(TMP3)
|.endif
| stp TMP3, L:SAVE0->top // Remove error from coroutine stack.
| li RD, (2+1)*8
| stw TMP1, -8(BASE) // Prepend false to results.
| la RA, -8(BASE)
|.if FPU
| stfd f0, 0(BASE) // Copy error message.
|.else
| stw CARG1, 0(BASE) // Copy error message.
| stw CARG2, 4(BASE)
|.endif
| b <7
|.else
| mr CARG1, L
| mr CARG2, L:SAVE0
| bl extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
|.endif
|
|9: // Handle stack expansion on return from yield.
| mr CARG1, L
| srwi CARG2, RD, 3
| bl extern lj_state_growstack // (lua_State *L, int n)
| li CRET1, 0
| b <4
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| lp TMP0, L->cframe
| add TMP1, BASE, NARGS8:RC
| stp BASE, L->base
| andix. TMP0, TMP0, CFRAME_RESUME
| stp TMP1, L->top
| li CRET1, LUA_YIELD
| beq ->fff_fallback
| stp ZERO, L->cframe
| stb CRET1, L->status
| b ->vm_leave_unw
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x64.dasc view on Meta::CPAN
| mov LFUNC:RB, [BASE] // Swap function and traceback.
| mov [BASE], LFUNC:RA
| mov [BASE+8], LFUNC:RB
| lea RA, [BASE+24]
| sub NARGS:RDd, 2
| mov PCd, 24+FRAME_PCALL
| jmp <1
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| mov L:RB, [BASE]
| cleartp L:RB
|.else
|.ffunc coroutine_wrap_aux
| mov CFUNC:RB, [BASE-16]
| cleartp CFUNC:RB
| mov L:RB, CFUNC:RB->upvalue[0].gcr
| cleartp L:RB
|.endif
| mov PC, [BASE-8]
| mov SAVE_PC, PC
| mov TMP1, L:RB
|.if resume
| checktptp [BASE], LJ_TTHREAD, ->fff_fallback
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x64.dasc view on Meta::CPAN
| mov L:RB->top, BASE
|.if resume
| lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move.
|.else
| lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move.
|.endif
| sub RB, PC // Relative to PC.
|
| cmp PC, RA
| je >3
|2: // Move args to coroutine.
| mov RC, [PC+RB]
| mov [PC-8], RC
| sub PC, 8
| cmp PC, RA
| jne <2
|3:
| mov CARG2, RA
| mov CARG1, TMP1
| call ->vm_resume // (lua_State *L, TValue *base, 0, 0)
|
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x64.dasc view on Meta::CPAN
| mov L:PC, TMP1
| mov BASE, L:RB->base
| mov [DISPATCH+DISPATCH_GL(cur_L)], L:RB
| set_vmstate INTERP
|
| cmp eax, LUA_YIELD
| ja >8
|4:
| mov RA, L:PC->base
| mov KBASE, L:PC->top
| mov L:PC->top, RA // Clear coroutine stack.
| mov PC, KBASE
| sub PC, RA
| je >6 // No results?
| lea RD, [BASE+PC]
| shr PCd, 3
| cmp RD, L:RB->maxstack
| ja >9 // Need to grow stack?
|
| mov RB, BASE
| sub RB, RA
|5: // Move results from coroutine.
| mov RD, [RA]
| mov [RA+RB], RD
| add RA, 8
| cmp RA, KBASE
| jne <5
|6:
|.if resume
| lea RDd, [PCd+2] // nresults+1 = 1 + true + results.
| mov_true ITYPE // Prepend true to results.
| mov [BASE-8], ITYPE
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x64.dasc view on Meta::CPAN
| test PCd, FRAME_TYPE
| jz ->BC_RET_Z
| jmp ->vm_return
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| mov_false ITYPE // Prepend false to results.
| mov [BASE-8], ITYPE
| mov RA, L:PC->top
| sub RA, 8
| mov L:PC->top, RA // Clear error from coroutine stack.
| // Copy error message.
| mov RD, [RA]
| mov [BASE], RD
| mov RDd, 1+2 // nresults+1 = 1 + false + error.
| jmp <7
|.else
| mov CARG2, L:PC
| mov CARG1, L:RB
| call extern lj_ffh_coroutine_wrap_err // (lua_State *L, lua_State *co)
| // Error function does not return.
|.endif
|
|9: // Handle stack expansion on return from yield.
| mov L:RA, TMP1
| mov L:RA->top, KBASE // Undo coroutine stack clearing.
| mov CARG2, PC
| mov CARG1, L:RB
| call extern lj_state_growstack // (lua_State *L, int n)
| mov L:PC, TMP1
| mov BASE, L:RB->base
| jmp <4 // Retry the stack move.
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| mov L:RB, SAVE_L
| test aword L:RB->cframe, CFRAME_RESUME
| jz ->fff_fallback
| mov L:RB->base, BASE
| lea RD, [BASE+NARGS:RD*8-8]
| mov L:RB->top, RD
| xor RDd, RDd
| mov aword L:RB->cframe, RD
| mov al, LUA_YIELD
| mov byte L:RB->status, al
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x86.dasc view on Meta::CPAN
| mov PC, [BASE+8]
| mov [BASE+8], LFUNC:RB
| mov [BASE], PC
| lea RA, [BASE+16]
| sub NARGS:RD, 2
| mov PC, 16+FRAME_PCALL
| jmp <1
|
|//-- Coroutine library --------------------------------------------------
|
|.macro coroutine_resume_wrap, resume
|.if resume
|.ffunc_1 coroutine_resume
| mov L:RB, [BASE]
|.else
|.ffunc coroutine_wrap_aux
| mov CFUNC:RB, [BASE-8]
| mov L:RB, CFUNC:RB->upvalue[0].gcr
|.endif
| mov PC, [BASE-4]
| mov SAVE_PC, PC
|.if X64
| mov TMP1, L:RB
|.else
| mov ARG1, L:RB
|.endif
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x86.dasc view on Meta::CPAN
| mov L:RB->top, BASE
|.if resume
| lea RB, [BASE+NARGS:RD*8-24] // RB = end of source for stack move.
|.else
| lea RB, [BASE+NARGS:RD*8-16] // RB = end of source for stack move.
|.endif
| sub RBa, PCa // Relative to PC.
|
| cmp PC, RA
| je >3
|2: // Move args to coroutine.
|.if X64
| mov RCa, [PC+RB]
| mov [PC-8], RCa
|.else
| mov RC, [PC+RB+4]
| mov [PC-4], RC
| mov RC, [PC+RB]
| mov [PC-8], RC
|.endif
| sub PC, 8
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x86.dasc view on Meta::CPAN
|.endif
| mov BASE, L:RB->base
| mov [DISPATCH+DISPATCH_GL(cur_L)], L:RB
| set_vmstate INTERP
|
| cmp eax, LUA_YIELD
| ja >8
|4:
| mov RA, L:PC->base
| mov KBASE, L:PC->top
| mov L:PC->top, RA // Clear coroutine stack.
| mov PC, KBASE
| sub PC, RA
| je >6 // No results?
| lea RD, [BASE+PC]
| shr PC, 3
| cmp RD, L:RB->maxstack
| ja >9 // Need to grow stack?
|
| mov RB, BASE
| sub RBa, RAa
|5: // Move results from coroutine.
|.if X64
| mov RDa, [RA]
| mov [RA+RB], RDa
|.else
| mov RD, [RA]
| mov [RA+RB], RD
| mov RD, [RA+4]
| mov [RA+RB+4], RD
|.endif
| add RA, 8
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/build/src/vm_x86.dasc view on Meta::CPAN
|.endif
| test PC, FRAME_TYPE
| jz ->BC_RET_Z
| jmp ->vm_return
|
|8: // Coroutine returned with error (at co->top-1).
|.if resume
| mov dword [BASE-4], LJ_TFALSE // Prepend false to results.
| mov RA, L:PC->top
| sub RA, 8
| mov L:PC->top, RA // Clear error from coroutine stack.
| // Copy error message.
|.if X64
| mov RDa, [RA]
| mov [BASE], RDa
|.else
| mov RD, [RA]
| mov [BASE], RD
| mov RD, [RA+4]
| mov [BASE+4], RD
|.endif
| mov RD, 1+2 // nresults+1 = 1 + false + error.
| jmp <7
|.else
| mov FCARG2, L:PC
| mov FCARG1, L:RB
| call extern lj_ffh_coroutine_wrap_err@8 // (lua_State *L, lua_State *co)
| // Error function does not return.
|.endif
|
|9: // Handle stack expansion on return from yield.
|.if X64
| mov L:RA, TMP1
|.else
| mov L:RA, ARG1 // The callee doesn't modify SAVE_L.
|.endif
| mov L:RA->top, KBASE // Undo coroutine stack clearing.
| mov FCARG2, PC
| mov FCARG1, L:RB
| call extern lj_state_growstack@8 // (lua_State *L, int n)
|.if X64
| mov L:PC, TMP1
|.else
| mov L:PC, ARG1
|.endif
| mov BASE, L:RB->base
| jmp <4 // Retry the stack move.
|.endmacro
|
| coroutine_resume_wrap 1 // coroutine.resume
| coroutine_resume_wrap 0 // coroutine.wrap
|
|.ffunc coroutine_yield
| mov L:RB, SAVE_L
| test aword L:RB->cframe, CFRAME_RESUME
| jz ->fff_fallback
| mov L:RB->base, BASE
| lea RD, [BASE+NARGS:RD*8-8]
| mov L:RB->top, RD
| xor RD, RD
| mov aword L:RB->cframe, RDa
| mov al, LUA_YIELD
| mov byte L:RB->status, al
ffi/target/release/build/mlua-sys-6a99a2ae50f12319/out/luajit-build/include/lua.h view on Meta::CPAN
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname);
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
/*
** coroutine functions
*/
LUA_API int (lua_yield) (lua_State *L, int nresults);
LUA_API int (lua_resume) (lua_State *L, int narg);
LUA_API int (lua_status) (lua_State *L);
/*
** garbage-collection function and options
*/
#define LUA_GCSTOP 0