From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D1D2A45C30A for ; Wed, 16 Dec 2020 22:14:39 +0300 (MSK) From: Sergey Kaplun Date: Wed, 16 Dec 2020 22:13:41 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v1 06/11] core: introduce new mem_L field List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin , Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org This patch adds new field to global_State structure named mem_L. It will be used in the next patches by memory profiler to determine which coroutine triggers memory allocation. Part of tarantool/tarantool#5442 --- src/lj_gc.c | 2 ++ src/lj_obj.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/lj_gc.c b/src/lj_gc.c index 44c8aa1..800fb2c 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c @@ -852,6 +852,8 @@ void *lj_mem_realloc(lua_State *L, void *p, GCSize osz, GCSize nsz) { global_State *g = G(L); lua_assert((osz == 0) == (p == NULL)); + + setgcref(g->mem_L, obj2gco(L)); p = g->allocf(g->allocd, p, osz, nsz); if (p == NULL && nsz > 0) lj_err_mem(L); diff --git a/src/lj_obj.h b/src/lj_obj.h index 7fb715e..c94617d 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h @@ -649,6 +649,7 @@ typedef struct global_State { BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ GCRef cur_L; /* Currently executing lua_State. */ + GCRef mem_L; /* Currently allocating lua_State. */ MRef jit_base; /* Current JIT code L->base or NULL. */ MRef ctype_state; /* Pointer to C type state. */ GCRef gcroot[GCROOT_MAX]; /* GC roots. */ -- 2.28.0