From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 1CFC270358; Wed, 15 Sep 2021 18:31:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1CFC270358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1631719884; bh=qiIXLTWHCATLK53Jb5uX3MQkqUzxqQ/oeVZ/EdtZq7c=; h=In-Reply-To:Date:References:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ePmwP0Bt0QPn7fdVlFr3aDYo37bBOxtLJKoSg+z+eW2VPCH2oPIAXRm8GQg9GZdqq TP8Wg8pqkyBA+CVEt8KfFMGp/2Mk9urEBT/kX5vrx1l2/TAMmvNhP7p19aA1CIhKGV kSIiCUUzs51d2CQC2g6hXqO+lfUEA6wgoJIxdgbA= Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 1D67E70358 for ; Wed, 15 Sep 2021 18:31:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1D67E70358 Received: by smtp50.i.mail.ru with esmtpa (envelope-from ) id 1mQWsF-0005Tc-E2; Wed, 15 Sep 2021 18:30:59 +0300 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) In-Reply-To: <369e050ce6799ca94ac08205fdbedad94b56ff87.1631170629.git.skaplun@tarantool.org> Date: Wed, 15 Sep 2021 18:30:59 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <47908C94-AB2E-4E82-AE4A-ADF6F58AA616@tarantool.org> References: <369e050ce6799ca94ac08205fdbedad94b56ff87.1631170629.git.skaplun@tarantool.org> To: Sergey Kaplun X-Mailer: Apple Mail (2.3654.120.0.1.13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2FF3F790D2CFB1565D68082CE688654CB400894C459B0CD1B9348D0F8263885241A32320C25D1256ACCF4949AA5CD683923ED127E0E40C37DC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72E2D36A15E1833D8EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063748789019239639CB8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D877F58AF62B5BB9DC18A79AA165995824117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6BDB3AEF73D8456A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A56DFE1D619E59CC9DC74A6ED13383130DF57A286DBBAAFC26D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34ECB3E21D3CD9CB4F8C4B2AC25E7FF5E1EED257580995DFEBC99CF1D5AFED59C461B0D817B3D439041D7E09C32AA3244CE96028F7FB22B7672C552BBB3FDFAEEA97FE24653F78E668FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmwY/hTp72s8GGIi+f/TqEQ== X-Mailru-Sender: 3B9A0136629DC912F4AABCEFC589C81E74844DF9CD1EF62D6C6C27B82AB2EE07932997F95CA482A3AD07DD1419AC565FA614486B47F28B67C5E079CCF3B0523AED31B7EB2E253A9E112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 2/3] Reorganize lightuserdata interning code. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: sergos via Tarantool-patches Reply-To: sergos Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! I would put something in description about the fact it=E2=80=99s pulled = in just to ease following the upstream - in particular, the following 3/3 is = done in this very moved code. LGTM with above. Sergos > On 9 Sep 2021, at 10:03, Sergey Kaplun wrote: >=20 > From: Mike Pall >=20 > This patch only performs a code movement of lightuserdata interning to > file and does nothing else. >=20 > Sergey Kaplun: > * added the description for the patch >=20 > Needed for tarantool/tarantool#5629 > --- > src/lj_api.c | 30 ++---------------------------- > src/lj_udata.c | 27 +++++++++++++++++++++++++++ > src/lj_udata.h | 3 +++ > 3 files changed, 32 insertions(+), 28 deletions(-) >=20 > diff --git a/src/lj_api.c b/src/lj_api.c > index c7a0b327..b6655e5a 100644 > --- a/src/lj_api.c > +++ b/src/lj_api.c > @@ -716,36 +716,10 @@ LUA_API void lua_pushboolean(lua_State *L, int = b) > incr_top(L); > } >=20 > -#if LJ_64 > -static void *lightud_intern(lua_State *L, void *p) > -{ > - global_State *g =3D G(L); > - uint64_t u =3D (uint64_t)p; > - uint32_t up =3D lightudup(u); > - uint32_t *segmap =3D mref(g->gc.lightudseg, uint32_t); > - MSize segnum =3D g->gc.lightudnum; > - if (segmap) { > - MSize seg; > - for (seg =3D 0; seg <=3D segnum; seg++) > - if (segmap[seg] =3D=3D up) /* Fast path. */ > - return (void *)(((uint64_t)seg << LJ_LIGHTUD_BITS_LO) | = lightudlo(u)); > - segnum++; > - } > - if (!((segnum-1) & segnum) && segnum !=3D 1) { > - if (segnum >=3D (1 << LJ_LIGHTUD_BITS_SEG)) lj_err_msg(L, = LJ_ERR_BADLU); > - lj_mem_reallocvec(L, segmap, segnum, segnum ? 2*segnum : 2u, = uint32_t); > - setmref(g->gc.lightudseg, segmap); > - } > - g->gc.lightudnum =3D segnum; > - segmap[segnum] =3D up; > - return (void *)(((uint64_t)segnum << LJ_LIGHTUD_BITS_LO) | = lightudlo(u)); > -} > -#endif > - > LUA_API void lua_pushlightuserdata(lua_State *L, void *p) > { > #if LJ_64 > - p =3D lightud_intern(L, p); > + p =3D lj_lightud_intern(L, p); > #endif > setrawlightudV(L->top, p); > incr_top(L); > @@ -1197,7 +1171,7 @@ static TValue *cpcall(lua_State *L, = lua_CFunction func, void *ud) > setfuncV(L, top++, fn); > if (LJ_FR2) setnilV(top++); > #if LJ_64 > - ud =3D lightud_intern(L, ud); > + ud =3D lj_lightud_intern(L, ud); > #endif > setrawlightudV(top++, ud); > cframe_nres(L->cframe) =3D 1+0; /* Zero results. */ > diff --git a/src/lj_udata.c b/src/lj_udata.c > index 70c722a3..6808b1bc 100644 > --- a/src/lj_udata.c > +++ b/src/lj_udata.c > @@ -8,6 +8,7 @@ >=20 > #include "lj_obj.h" > #include "lj_gc.h" > +#include "lj_err.h" > #include "lj_udata.h" >=20 > GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) > @@ -34,3 +35,29 @@ void LJ_FASTCALL lj_udata_free(global_State *g, = GCudata *ud) > lj_mem_free(g, ud, sizeudata(ud)); > } >=20 > +#if LJ_64 > +void *lj_lightud_intern(lua_State *L, void *p) > +{ > + global_State *g =3D G(L); > + uint64_t u =3D (uint64_t)p; > + uint32_t up =3D lightudup(u); > + uint32_t *segmap =3D mref(g->gc.lightudseg, uint32_t); > + MSize segnum =3D g->gc.lightudnum; > + if (segmap) { > + MSize seg; > + for (seg =3D 0; seg <=3D segnum; seg++) > + if (segmap[seg] =3D=3D up) /* Fast path. */ > + return (void *)(((uint64_t)seg << LJ_LIGHTUD_BITS_LO) | = lightudlo(u)); > + segnum++; > + } > + if (!((segnum-1) & segnum) && segnum !=3D 1) { > + if (segnum >=3D (1 << LJ_LIGHTUD_BITS_SEG)) lj_err_msg(L, = LJ_ERR_BADLU); > + lj_mem_reallocvec(L, segmap, segnum, segnum ? 2*segnum : 2u, = uint32_t); > + setmref(g->gc.lightudseg, segmap); > + } > + g->gc.lightudnum =3D segnum; > + segmap[segnum] =3D up; > + return (void *)(((uint64_t)segnum << LJ_LIGHTUD_BITS_LO) | = lightudlo(u)); > +} > +#endif > + > diff --git a/src/lj_udata.h b/src/lj_udata.h > index f271a42d..d97936d4 100644 > --- a/src/lj_udata.h > +++ b/src/lj_udata.h > @@ -10,5 +10,8 @@ >=20 > LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); > LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); > +#if LJ_64 > +LJ_FUNC void * LJ_FASTCALL lj_lightud_intern(lua_State *L, void *p); > +#endif >=20 > #endif > --=20 > 2.31.0 >=20