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 B71796EFDA; Wed, 1 Jun 2022 19:28:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B71796EFDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1654100919; bh=HwafjnXcoB2stfIIl8JH0HOYvceWcIIfqMCCr8gG6Xk=; 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=B7ehGMq9NTCCJ/HI5w1D1Sh3XQfxbrysk3/5Sk7jac7HMo59iNVgqy1kpImLO+G7a 55NPMcIHSNjxu1ccOYj7tAH/94Cmmd5JN/4j9OwjYxaV43ERGtusrOo+9w9zjUV+tI O3iHEwGTEfgzRTj+G8HKO/bhTh7f5l7eDnYnb7Vg= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 D6B336EFDA for ; Wed, 1 Jun 2022 19:28:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D6B336EFDA Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1nwRD3-0004xP-Im; Wed, 01 Jun 2022 19:28:38 +0300 Date: Wed, 1 Jun 2022 19:21:34 +0300 To: Maxim Kokryashkin Message-ID: References: <20211013123744.2418018-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211013123744.2418018-1-m.kokryashkin@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD93ED3C6BF6FFA701F29BCC495C22726AC3DDC642A338CB7A3182A05F53808504033782C0C6DD716D96CB8B0106DD0530D84FD51FD4A1220000D9A1C87D248A4CC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F544D30F1A6FA191EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370BEBC60587DC626C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D839FCCB6719FAB5F11039A48752787C17117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D635BA3ABDB36C18089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A53FADF6EB727F7502020BDF3D9408AD65A53EA1B9CFADB285D59269BC5F550898D99A6476B3ADF6B4886A5961035A09600383DAD389E261318FB05168BE4CE3AF X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AEC7C2AC3C44791DDA3764004B670B467A0B32BA3B82974C26E9E950815BED4C56A0EE301C8104DC1D7E09C32AA3244CE508B4464A85D356BC69B528E1396C3D3E8609A02908F2718D5DD81C2BAB7D1D X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojRxBGqISLOzCWI3o6YK0wTg== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D675FEA647C9C63573311EB892BB7EFF30A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E3365FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v2] test: adapt test checking tail calls debug info 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" Max, Thanks for the patch! LGTM, except a couple of nits, I've fixed by myself. On 13.10.21, Maxim Kokryashkin wrote: > LuaJIT does not provide information about tail calls, > unlike Lua does. getfenv() behavior for this test set is also different in Typo: This text is out of bounds (72 symbols for commit message). > LuaJIT, because tail calls do not provide additional call frame. > Typo: "Resolves tarantool/tarantool#5702" is missing. > Part of tarantool/tarantool#5870 > --- > GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5702-adapt-getfenv-getinfo-PUC-Rio > CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5702-adapt-getfenv-getinfo-PUC-Rio > Issue: https://github.com/tarantool/tarantool/issues/5702 > See also: https://luajit.org/status.html > > test/PUC-Rio-Lua-5.1-tests/db.lua | 58 +++++++++++++------------------ > 1 file changed, 24 insertions(+), 34 deletions(-) > > diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua > index 56f59ea8..cfe54cac 100644 > --- a/test/PUC-Rio-Lua-5.1-tests/db.lua > +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua > @@ -380,19 +380,20 @@ end > > > -- tests for tail calls > +-- LuaJIT does not provide information about tail calls, > +-- unlike Lua does. See also https://luajit.org/status.html. > +-- getfenv() behavior is also different here, because tail calls > +-- do not provide additional call frame for LuaJIT. > +-- See also https://github.com/tarantool/tarantool/issues/5702. > +-- This function is adapted to LuaJIT behavior. > local function f (x) > if x then > assert(debug.getinfo(1, "S").what == "Lua") > local tail = debug.getinfo(2) > - assert(not pcall(getfenv, 3)) > - assert(tail.what == "tail" and tail.short_src == "(tail call)" and > - tail.linedefined == -1 and tail.func == nil) > - assert(debug.getinfo(3, "f").func == g1) > + assert(pcall(getfenv, 3)) Minor: this assertion is excess, considering the another one below. > + assert(tail.what == "Lua" and tail.linedefined == 403 and tail.func == g1) > assert(getfenv(3)) > - assert(debug.getinfo(4, "S").what == "tail") > - assert(not pcall(getfenv, 5)) > - assert(debug.getinfo(5, "S").what == "main") > - assert(getfenv(5)) > + assert(debug.getinfo(3, "S").what == "main") > print"+" > end > end > @@ -403,43 +404,32 @@ function g1(x) g(x) end > > local function h (x) local f=g1; return f(x) end > > --- FIXME: LuaJIT does not provide information about tail calls, > --- unlike Lua does. See also https://luajit.org/status.html. > --- getfenv() behaviour is also different here, because tail calls > --- do not provide additional call frame for LuaJIT and level > --- number should be changed. > --- Test is disabled for LuaJIT. > --- See also https://github.com/tarantool/tarantool/issues/5702. > --- h(true) > +h(true) > > local b = {} > --- FIXME: Behavior is different for LuaJIT. See the comment above. > --- Test is disabled for LuaJIT. > --- debug.sethook(function (e) table.insert(b, e) end, "cr") > --- h(false) > --- debug.sethook() > -local res = {"return", -- first return (from sethook) > - "call", "call", "call", "call", > - "return", "tail return", "return", "tail return", > - "call", -- last call (to sethook) > +debug.sethook(function (e) table.insert(b, e) end, "cr") > +-- This fucntions is adapted to LuaJIT behavior. See the comment above. Typo: s/fucntions/function/. > +h(false) > +debug.sethook() > +-- This chunk is adapted to LuaJIT behavior. See the comment above. > +local res = {"call", -- first return (from sethook) Minor: The comment is not relevant to the code. Furthermore, I see no comment why there is no "return" entry for return. > + "call", "call", "call", "return", > + "return", "call" Minor: The comment is missing, since last "call" entry belongs to debug.sethook. > } > --- FIXME: Behavior is different for LuaJIT. See the comment above. > --- Test is disabled for LuaJIT. > --- for _, k in ipairs(res) do assert(k == table.remove(b, 1)) end > +for _, k in ipairs(res) do assert(k == table.remove(b, 1)) end > > > -lim = 30000 > +lim = 2 > +-- This function is adapted to LuaJIT behavior. See the comment above. > local function foo (x) > if x==0 then > - assert(debug.getinfo(lim+2).what == "main") > - for i=2,lim do assert(debug.getinfo(i, "S").what == "tail") end > + assert(debug.getinfo(lim + 1,"S").what == "main") > + assert(debug.getinfo(lim, "S").what == "main") Minor: Again, the comment for such change is missing here. > else return foo(x-1) > end > end > > --- FIXME: Behavior is different for LuaJIT. > --- See the comment to `h()` above. Test is disabled for LuaJIT. > --- foo(lim) > +foo(lim) > > > print"+" > -- > 2.33.0 > -- Best regards, IM