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 B92876EC5F; Mon, 2 Aug 2021 17:57:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B92876EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627916240; bh=6qV2VJ1Vuh86nBEfLRpH03sBXaweQWRSr8BTZhLqy24=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gpz+b6vlNwQcdd6yhs1PQk6/V4pyLQl1Y+3WZbsnbfIJNbXZAHu+GCCmET086TAnb X0PCglGB+o2DB8syO5xSMlbRVCyEJNFdglpm70kjJOyQrlxUHP0Hr835fOdNZv6uDd LPTSjYCa2sk6CFzG3aDu/gyz24BBfRNjUXnAmMVY= Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (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 A338D6EC5F for ; Mon, 2 Aug 2021 17:57:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A338D6EC5F Received: by smtp34.i.mail.ru with esmtpa (envelope-from ) id 1mAZNW-0007lX-PS; Mon, 02 Aug 2021 17:57:19 +0300 Date: Mon, 2 Aug 2021 17:56:05 +0300 To: Igor Munkin Message-ID: References: <1733a6045e7ae1ff2cac8c4a49bcdca3388f65aa.1625587322.git.skaplun@tarantool.org> <20210727135941.GR27855@tarantool.org> <20210801103615.GW27855@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210801103615.GW27855@tarantool.org> X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C33D83595CA30D6DC5179D1C9A908C47E5182A05F538085040071965DF4B128F63B0FE5B1B313A372CCE38CE03338ABCDDAE585DC2677C5DBA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE727FD6E7FC3A8F857EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CAA352D56883AEE98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82E4474E8A028EB4562711086B39D5265117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B55B19328CBC4F849A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C565C1E6824D8037B43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5E13028964A9D785DAD1E3909C95D376CE68066951D88ACE1D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA751B940EDA0DFB0535410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344EF254DC71474AA38DB85E58EBABD6651F5EB1A9485853F2A238D3EC5C3C26260E957EE0B7ACA0501D7E09C32AA3244C2FECD7F7D801104F5BAB5BA8227F9EA8FE8DA44ABE2443F7FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj9N286KAyvN5Cv4dr/NYsLQ== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB409F44E14E655D97B18427B705A580C88DD02C8119DC19B26F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Add support for full-range 64 bit lightuserdata. 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Igor, On 01.08.21, Igor Munkin wrote: > Sergey, > > Thanks for the fixes and comments! LGTM then, except the three typos > I've missed in the previous review. > > On 28.07.21, Sergey Kaplun wrote: > > Igor, > > Thanks for the review! > > > > > > > > > The new commit message is the following: > > > > =================================================================== > > Add support for full-range 64 bit lightuserdata. > > > > (cherry picked from commit e9af1abec542e6f9851ff2368e7f196b6382a44c) > > > > LuaJIT uses special NaN-tagging technique to store internal type on > > the Lua stack. In case LJ_GC64 first 13 bits are set in special NaN > > type (0xfff8...). FPU generates the only one type. The next 4 bits are > > used for an internal LuaJIT type of object on stack. The next 47 bits > > are used for storing this object's content. For userdata, it is its > > address. In case arm64 the pointer can have more than 47 significant > > bits [1]. In this case the error BADLU error is raised. > > > > For the support of full 64-bit range lightuserdata pointers two new > > fields in GCState are added: > > > > `lightudseg` - vector of segments of lightuserdata. Each element keeps > > 32-bit value. 25 MSB equal to MSB of lightuserdata address, the rest are > > filled with zeros. The lentgh of the vector is power of 2. > > Typo: s/lentgh/length/. Fixed. > > > > > `lightudnum` - the length - 1 of aforementioned vector (up to 255). > > > > When lightuserdata is pushed on the stack, if its segment is not stored > > in vector new value is appended on top of this vector. The maximum > > amount of segments is 256. BADLU error is raised in case when user tried > > Typo: s/tried/tries/. Fixed. > > > to add userdata with the new 257-th segment, so the whole VA-space > > isn't covered by this patch. > > > > Also, in this patch all internal usage of lightuserdata (for hooks, > > profilers, built-in package, IR and so on) is changed to special values > > on Lua Stack. > > > > Also, conversion of TValue to FFI C type with store is no longer > > compiled for lightuserdata. > > > > [1]: https://www.kernel.org/doc/html/latest/arm64/memory.html > > > > Sergey Kaplun: > > * added the description and the test for the problem > > > > Resolves tarantool/tarantool#2712 > > Needed for tarantool/tarantool#6154 > > Minor: Why #5629 is not mentioned? Added. > > > =================================================================== > > > > > > > > > See the iterative patch below. > > > > =================================================================== > > > > > diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c b/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c > > index 801c7fe1..c958841f 100644 > > --- a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c > > +++ b/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c > > > > > @@ -26,8 +34,8 @@ static int longptr(lua_State *L) > > * equals -1. > > Typo: s/hint equals -1/hint that equals to -1/. Fixed: =================================================================== diff --git a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c b/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c index c958841f..1b909fc6 100644 --- a/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c +++ b/test/tarantool-tests/lj-49-bad-lightuserdata/testlightuserdata.c @@ -30,8 +30,8 @@ static int mmaped_ptr(lua_State *L) /* * If start mapping address is not NULL, then the kernel * takes it as a hint about where to place the mapping, so - * we try to get the highest memory address by hint - * equals -1. + * we try to get the highest memory address by hint, that + * equals to -1. */ const size_t pagesize = getpagesize(); void *mmaped = mmap(START, pagesize, PROT_NONE, MAP_PRIVATE | MAP_ANON, =================================================================== > > > */ > > const size_t pagesize = getpagesize(); > > - void *mmaped = mmap(START, pagesize, PROT_NONE, > > - MAP_PRIVATE | MAP_ANON, -1, 0); > > + void *mmaped = mmap(START, pagesize, PROT_NONE, MAP_PRIVATE | MAP_ANON, > > + -1, 0); > > if (mmaped != MAP_FAILED) { > > lua_pushlightuserdata(L, mmaped); > > assert(mmaped == lua_topointer(L, -1)); > > > > > =================================================================== > > > > > > > > > -- > > Best regards, > > Sergey Kaplun > > -- > Best regards, > IM -- Best regards, Sergey Kaplun