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 23B7E6EC40; Mon, 20 Sep 2021 12:38:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 23B7E6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632130696; bh=JvITRJiKTRHQXLXI1MKReNLjv1Oy8bpytVKfzqzN4eA=; h=Date:In-Reply-To:To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=j/dFiVHI9+r36/g8sk34YgDOYcSpcRPzLMFhPzjlZ5k/RneuzfjgYiB0i2aDQ4dxc qBCDkMppPDbLzFS+vr87obsEPCWHXSYg7JonxQbww4831sd36DCAT0l6x3/JZT018r wKlbQ0clSdBDDa1jthRx7+4hy6HJyPbq6lCkFdjI= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 90E5F6EC40 for ; Mon, 20 Sep 2021 12:37:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 90E5F6EC40 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1mSFkH-0003o0-Bn; Mon, 20 Sep 2021 12:37:53 +0300 Message-Id: <91CFF19A-C295-4E72-AC7D-12CE78698B39@tarantool.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_02150FFD-83EB-461C-871B-6B01554BDF72" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Date: Mon, 20 Sep 2021 12:37:53 +0300 In-Reply-To: To: Sergey Kaplun References: <369e050ce6799ca94ac08205fdbedad94b56ff87.1631170629.git.skaplun@tarantool.org> <47908C94-AB2E-4E82-AE4A-ADF6F58AA616@tarantool.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2F250B8A21226859B08342E9AB5F4ECC3300894C459B0CD1B9868128A59728D42A70046FB6B8D99F1A29E88886021A938758021F299768AAFE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7747FD4AFDBA6C67AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E724D704EAF55A818638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D814BD537D3472B2974BD9575CC5B09E25117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A1DCCEB63E2F10FB089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5EA7F61A5D0928245080339878928475765BF8B6D34947D82D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75DD5744CF7ED0C6846D6546786ADF492D5A0AA20F8A030721787CBDA4B9FA07AC4DDFAF11955870C28E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34FD9114F69CA58D1EFD60C41D5D748EF67E807880A75718679436F7BB205F34DD49FA761981D746E41D7E09C32AA3244C3738B06D14E847D6CFC78E703F20A3AB4DBEAD0ED6C55A80FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsFc9NKou+3ixgA3nM690KQ== X-Mailru-Sender: 3B9A0136629DC912F4AABCEFC589C81EAC31BDF4125C9C843A76FAFCC64737ED56F721F4092211F1AD07DD1419AC565FA614486B47F28B67C5E079CCF3B0523AED31B7EB2E253A9E112434F685709FCF0DA7A0AF5A3A8387 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" --Apple-Mail=_02150FFD-83EB-461C-871B-6B01554BDF72 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks! LGTM. Sergos > On 20 Sep 2021, at 11:32, Sergey Kaplun wrote: >=20 > Hi, Sergos! >=20 > Thanks for the review! >=20 > On 15.09.21, sergos wrote: >> Hi! Thanks for the patch! >>=20 >> 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. >>=20 >> LGTM with above. >=20 > Updated the commit message to the following: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Reorganize lightuserdata interning code. >=20 > This patch only performs a code movement of lightuserdata interning to > file and does nothing else. This patch is backported to > simplify syncing with the upstream. >=20 > Sergey Kaplun: > * added the description for the patch >=20 > Needed for tarantool/tarantool#5629 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > Branch is force pushed. >=20 >>=20 >> Sergos >>=20 >>=20 >>> 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 >>=20 >=20 > --=20 > Best regards, > Sergey Kaplun --Apple-Mail=_02150FFD-83EB-461C-871B-6B01554BDF72 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Thanks!

LGTM.

Sergos

On 20 Sep 2021, at 11:32, = Sergey Kaplun <skaplun@tarantool.org> wrote:

Hi, Sergos!

Thanks for the review!

On 15.09.21, sergos wrote:
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.

Updated the commit message to the following:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Reorganize = lightuserdata interning code.

This patch only performs a code movement of lightuserdata = interning to
<lj_udata.c> file and does nothing else. This patch is = backported to
simplify = syncing with the upstream.

Sergey Kaplun:
* added the description for the patch

Needed for = tarantool/tarantool#5629
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Branch is = force pushed.


Sergos


On 9 Sep 2021, at 10:03, Sergey Kaplun <skaplun@tarantool.org> wrote:

From: Mike Pall <mike>

This = patch only performs a code movement of lightuserdata interning to
<lj_udata.c> file and does nothing else.

Sergey Kaplun:
* added the = description for the patch

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(-)

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);
}

-#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 @@

#include = "lj_obj.h"
#include "lj_gc.h"
+#include = "lj_err.h"
#include "lj_udata.h"

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));
}

+#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 @@

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

#endif
-- 
2.31.0



-- 
Best = regards,
Sergey = Kaplun

= --Apple-Mail=_02150FFD-83EB-461C-871B-6B01554BDF72--