Lines Matching refs:L

22 static inline void _proxy_advance_lastkb(lua_State *L, LIBEVENT_THREAD *t) {  in _proxy_advance_lastkb()  argument
23 int new_kb = lua_gc(L, LUA_GCCOUNT); in _proxy_advance_lastkb()
50 lua_State *L = t->L; in proxy_gc_poke() local
52 int vm_kb = lua_gc(L, LUA_GCCOUNT) + t->proxy_vm_extra_kb; in proxy_gc_poke()
79 done = lua_gc(L, LUA_GCSTEP, 0); in proxy_gc_poke()
82 int vm_kb_after = lua_gc(L, LUA_GCCOUNT); in proxy_gc_poke()
90 _proxy_advance_lastkb(L, t); in proxy_gc_poke()
133 if (t->proxy_vm_gcrunning == -1 && lua_gc(t->L, LUA_GCSTEP, 0)) { in proxy_gc_timerpoke()
134 _proxy_advance_lastkb(t->L, t); in proxy_gc_timerpoke()
291 lua_State *L = ctx->proxy_sharedvm; in process_proxy_funcstats() local
295 lua_pushnil(L); in process_proxy_funcstats()
296 while (lua_next(L, SHAREDVM_FGEN_IDX) != 0) { in process_proxy_funcstats()
297 int n = lua_tointeger(L, -1); in process_proxy_funcstats()
298 lua_pop(L, 1); // drop the value, leave the key. in process_proxy_funcstats()
301 lua_pushvalue(L, -1); in process_proxy_funcstats()
302 lua_rawget(L, SHAREDVM_FGENSLOT_IDX); in process_proxy_funcstats()
303 int slots = lua_tointeger(L, -1); in process_proxy_funcstats()
304 lua_pop(L, 1); // drop the slot count. in process_proxy_funcstats()
307 const char *name = lua_tostring(L, -1); in process_proxy_funcstats()
327 lua_State *L = ctx->proxy_sharedvm; in process_proxy_bestats() local
331 lua_pushnil(L); in process_proxy_bestats()
332 while (lua_next(L, SHAREDVM_BACKEND_IDX) != 0) { in process_proxy_bestats()
333 int n = lua_tointeger(L, -1); in process_proxy_bestats()
334 lua_pop(L, 1); // drop the value, leave the key. in process_proxy_bestats()
337 const char *name = lua_tostring(L, -1); in process_proxy_bestats()
343 const char *name = lua_tostring(L, -1); in process_proxy_bestats()
344 lua_pushnil(L); in process_proxy_bestats()
345 lua_setfield(L, SHAREDVM_BACKEND_IDX, name); in process_proxy_bestats()
383 lua_State *L = NULL; in proxy_init() local
387 L = lua_newstate(mcp_profile_alloc, prof); in proxy_init()
389 L = luaL_newstate(); in proxy_init()
391 ctx->proxy_state = L; in proxy_init()
392 luaL_openlibs(L); in proxy_init()
394 proxy_register_libs(ctx, NULL, L); in proxy_init()
396 lua_newtable(L); in proxy_init()
397 ctx->cron_ref = luaL_ref(L, LUA_REGISTRYINDEX); in proxy_init()
445 lua_State *L = NULL; in proxy_thread_init() local
449 L = lua_newstate(mcp_profile_alloc, prof); in proxy_thread_init()
451 L = luaL_newstate(); in proxy_thread_init()
460 lua_gc(L, LUA_GCINC, 199, 100, 12); in proxy_thread_init()
461 lua_gc(L, LUA_GCSTOP); // handle GC on our own schedule. in proxy_thread_init()
462 thr->L = L; in proxy_thread_init()
463 luaL_openlibs(L); in proxy_thread_init()
464 proxy_register_libs(ctx, thr, L); in proxy_thread_init()
707 lua_State *L = thr->L; in complete_nread_proxy() local
721 lua_settop(L, 0); // clear anything remaining on the main thread. in complete_nread_proxy()
744 lua_settop(L, 0); // clear anything remaining on the main thread. in complete_nread_proxy()
752 void proxy_lua_error(lua_State *L, const char *s) { in proxy_lua_error() argument
753 lua_pushstring(L, s); in proxy_lua_error()
754 lua_error(L); in proxy_lua_error()
1010 lua_State *L = thr->L; in proxy_process_command() local
1170 mcp_rcontext_t *rctx = mcp_funcgen_start(L, hook_ref.ctx, &pr); in proxy_process_command()
1210 lua_settop(L, 0); in proxy_process_command()
1230 lua_settop(L, 0); // clear any junk from the main thread. in proxy_process_command()
1233 mcp_resp_t *mcp_prep_bare_resobj(lua_State *L, LIBEVENT_THREAD *t) { in mcp_prep_bare_resobj() argument
1234 mcp_resp_t *r = lua_newuserdatauv(L, sizeof(mcp_resp_t), 0); in mcp_prep_bare_resobj()
1242 luaL_getmetatable(L, "mcp.response"); in mcp_prep_bare_resobj()
1243 lua_setmetatable(L, -2); in mcp_prep_bare_resobj()
1284 mcp_resp_t *mcp_prep_resobj(lua_State *L, mcp_request_t *rq, mcp_backend_t *be, LIBEVENT_THREAD *t)… in mcp_prep_resobj() argument
1285 mcp_resp_t *r = lua_newuserdatauv(L, sizeof(mcp_resp_t), 0); in mcp_prep_resobj()
1288 luaL_getmetatable(L, "mcp.response"); in mcp_prep_resobj()
1289 lua_setmetatable(L, -2); in mcp_prep_resobj()
1363 lua_State *L = ctx->proxy_sharedvm; in mcp_sharedvm_delta() local
1366 if (lua_getfield(L, tidx, name) == LUA_TNIL) { in mcp_sharedvm_delta()
1367 lua_pop(L, 1); in mcp_sharedvm_delta()
1368 lua_pushinteger(L, delta); in mcp_sharedvm_delta()
1369 lua_setfield(L, tidx, name); in mcp_sharedvm_delta()
1371 lua_pushinteger(L, delta); in mcp_sharedvm_delta()
1372 lua_arith(L, LUA_OPADD); in mcp_sharedvm_delta()
1373 lua_setfield(L, tidx, name); in mcp_sharedvm_delta()
1380 lua_State *L = ctx->proxy_sharedvm; in mcp_sharedvm_remove() local
1383 lua_pushnil(L); in mcp_sharedvm_remove()
1384 lua_setfield(L, tidx, name); in mcp_sharedvm_remove()
1406 void mcp_gobj_ref(lua_State *L, struct mcp_globalobj_s *g) { in mcp_gobj_ref() argument
1419 g->self_ref = -luaL_ref(L, LUA_REGISTRYINDEX); in mcp_gobj_ref()
1421 proxy_ctx_t *ctx = PROXY_GET_CTX(L); in mcp_gobj_ref()
1424 lua_pop(L, 1); // drop the reference we didn't end up using. in mcp_gobj_ref()
1523 __attribute__((unused)) void dump_stack(lua_State *L, const char *msg) { in dump_stack() argument
1524 int top = lua_gettop(L); in dump_stack()
1528 int type = lua_type(L, i); in dump_stack()
1531 if (lua_getmetatable(L, i) != 0) { in dump_stack()
1532 lua_pushstring(L, "__name"); in dump_stack()
1533 if (lua_rawget(L, -2) != LUA_TNIL) { in dump_stack()
1535 udata = lua_touserdata(L, i); in dump_stack()
1537 …fprintf(stderr, "--|%d| [%s] (%s) [ptr: %p]\n", i, lua_typename(L, type), lua_tostring(L, -1), uda… in dump_stack()
1538 lua_pop(L, 2); in dump_stack()
1541 lua_pop(L, 2); in dump_stack()
1544 fprintf(stderr, "--|%d| [%s] | %s\n", i, lua_typename(L, type), lua_tostring(L, i)); in dump_stack()
1547 udata = lua_touserdata(L, i); in dump_stack()
1549 fprintf(stderr, "--|%d| [%s] [ptr: %p]\n", i, lua_typename(L, type), udata); in dump_stack()
1559 __attribute__((unused)) void dump_registry(lua_State *L, const char *msg) { in dump_registry() argument
1560 int ref_size = lua_rawlen(L, LUA_REGISTRYINDEX); in dump_registry()
1563 int ridx = lua_absindex(L, LUA_REGISTRYINDEX); in dump_registry()
1569 lua_pushnil(L); in dump_registry()
1570 while (lua_next(L, ridx) != 0) { in dump_registry()
1571 dump_stack(L, "===registry entry==="); in dump_registry()
1572 int type = lua_type(L, -1); in dump_registry()
1584 lua_pop(L, 1); // drop value in dump_registry()
1598 __attribute__((unused)) void dump_funcgen(lua_State *L, const char *name, const char *msg) { in dump_funcgen() argument
1599 int ref_size = lua_rawlen(L, LUA_REGISTRYINDEX); in dump_funcgen()
1602 int ridx = lua_absindex(L, LUA_REGISTRYINDEX); in dump_funcgen()
1603 lua_pushnil(L); in dump_funcgen()
1604 while (lua_next(L, ridx) != 0) { in dump_funcgen()
1605 int type = lua_type(L, -1); in dump_funcgen()
1607 mcp_funcgen_t *f = luaL_testudata(L, -1, "mcp.funcgen"); in dump_funcgen()
1610 lua_getiuservalue(L, -1, 1); in dump_funcgen()
1611 int tidx = lua_absindex(L, -1); in dump_funcgen()
1612 lua_pushnil(L); in dump_funcgen()
1613 while (lua_next(L, tidx) != 0) { in dump_funcgen()
1614 mcp_rcontext_t *rctx = lua_touserdata(L, -1); in dump_funcgen()
1618 lua_pop(L, 1); // drop value in dump_funcgen()
1620 lua_pop(L, 1); // drop slot table in dump_funcgen()
1623 lua_pop(L, 1); // drop value in dump_funcgen()
1652 __attribute__((unused)) void dump_pools(lua_State *L, const char *msg) { in dump_pools() argument
1653 int ref_size = lua_rawlen(L, LUA_REGISTRYINDEX); in dump_pools()
1656 int ridx = lua_absindex(L, LUA_REGISTRYINDEX); in dump_pools()
1657 lua_pushnil(L); in dump_pools()
1658 while (lua_next(L, ridx) != 0) { in dump_pools()
1659 int type = lua_type(L, -1); in dump_pools()
1661 mcp_pool_t *p = luaL_testudata(L, -1, "mcp.pool"); in dump_pools()
1665 mcp_pool_proxy_t *pp = luaL_testudata(L, -1, "mcp.pool_proxy"); in dump_pools()
1671 lua_pop(L, 1); // drop value in dump_pools()