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 C54066EC58; Sun, 1 Aug 2021 13:59:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C54066EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627815595; bh=HdNjg/YRMICxSVPKUaBE3+Xc4JQB1q/WsZvhH/rpGu8=; 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=PMHU8zqxF0xv0JQ5rAEB/wLz8PjZA/Ygbpx0baarJJpFrhKkq9CDUY5NoSr3YPAVX AS5bUGmNm+UsKfyCKfQjl3dJm4uLPZ97rE3rVe66b0N52FpqluZXBqjB6tvbcDq/a+ VvO3C57P1Eqa+ssi3eT7ALFXqRFuBapC2IhD5+w8= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 298176EC58 for ; Sun, 1 Aug 2021 13:59:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 298176EC58 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mA9CD-0008Qf-1Y; Sun, 01 Aug 2021 13:59:53 +0300 Date: Sun, 1 Aug 2021 13:36:15 +0300 To: Sergey Kaplun Message-ID: <20210801103615.GW27855@tarantool.org> References: <1733a6045e7ae1ff2cac8c4a49bcdca3388f65aa.1625587322.git.skaplun@tarantool.org> <20210727135941.GR27855@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD941C43E597735A9C351B198F4576AC7B21928AAE70459C21B182A05F53808504023F28D6E4CAC30B83326948DA13E87E8FC7804B059ABA059701F0EF8CB33EB85 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70A10A23A3B64B805EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379E389E29EFC3C6B78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CDA9875678BAB23807A4E3F0E56CFA47117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B55D5BE2F85BDEC5FA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CB1724D34C644744043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5AB1A1179955276C46028228A1A6EDE907CDCC6B3B8C11623D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA751B940EDA0DFB0535410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F3735C80F9F4B96DC7F95AAD6C02677921E521CA73B7065ACA63DF027B142219F744B3A600894F3F1D7E09C32AA3244CC0383552721654D4ED1AADF1F097B31F9CA7333006C390A0927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMCfuYI4PreeOlkstZVr4GA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D82A8B4857DA0CE9E1B439C98C7080D98A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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/. > > `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/. > 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? > =================================================================== > > > 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/. > */ > 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