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 C4F266F3F6; Mon, 11 Oct 2021 18:05:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C4F266F3F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633964736; bh=NCls8Q3yUSALCt62ujCsYQHCZjiBoboevTVbJ9iwS3M=; 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=Ho8NfAyLxa11AC77ZQR8VkGjajmzthxHc4HIQU6oXSGle+fdhCNpz8xVl0yqSZLJl 1NGfLkn1vted0RhL6h0Mf2mWi3z/Vcw6BAuwHcxclC2l537wO9nicjYUm7M/XpvwCY 5Mqbw6e/U1X1I6jATguC9V+2DxnPvolJ5A+wRSPE= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 343346F3F2 for ; Mon, 11 Oct 2021 18:05:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 343346F3F2 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mZwrs-0006lK-0h; Mon, 11 Oct 2021 18:05:32 +0300 Date: Mon, 11 Oct 2021 18:03:51 +0300 To: Maxim Kokryashkin Message-ID: References: <20210930144056.1679061-1-m.kokryashkin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210930144056.1679061-1-m.kokryashkin@tarantool.org> X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD922964B4BA091D9AC4A5E31101C019806E4A135B03F27DD0C182A05F5380850404048BEF52EDF843E4A9D573D3B53468D82C488B2F7AF79819F25BE6134A8BC77 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F8E53417176C7207EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BB46061768088B55EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2AB3C25206999A3C7216C66BAC2EEAA03CC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8EDCF5861DED71B2F389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E73557739F23D657EF2BB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5ADC1AA5957F15611037F6441A7437F6B2F8D143418FB8B8CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341E08D7EE1804B7631A897BCE38FB65118DE25ABE0733E3D3E1E457BDE2592925D1211A666D3A53C21D7E09C32AA3244CF5CA357DB7C0D9AEC9EDBE1A0AC3C666C86C126E7119A0FE83B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioju/+AAevgYAU6HUFkNUfJ2g== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D3103042773032944B7D8E75F935291690FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED567EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] 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: 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" Hi, Maxim! Thanks for the patch! LGTM, except a few nits below. On 30.09.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 > LuaJIT, because tail calls do not provide additional call frame. > > Closes tarantool/tarantool#5702 > Part of tarantool/tarantool#5845 > Part of tarantool/tarantool#4473 Looks like it should be 5870 instead 4473. Also, 5845 is already closed. > --- > GitHub branch: https://github.com/tarantool/luajit/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 | 61 +++++++++++++------------------ > 1 file changed, 26 insertions(+), 35 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..a94f07ab 100644 > --- a/test/PUC-Rio-Lua-5.1-tests/db.lua > +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua > @@ -378,21 +378,22 @@ if jit_is_enabled then > jit.on() > end > > - Nit: this change is excess. > -- 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)) > + assert(tail.what == "Lua" and tail.linedefined == 403 and tail.func == g1) > + -- End of single assert Don't get this comment. > 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,33 @@ 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) > +-- This fucntions is adapted to LuaJIT behavior. See the comment above. Nit: This comment is excess IMHO: here nothing is changed. Feel free to ignore. > +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. > +h(false) > +debug.sethook() > +-- This chunk is adapted to LuaJIT behavior. See the comment above. > +local res = {"call", -- first return (from sethook) > + "call", "call", "call", "return", > + "return", "call" > } > --- 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 > +-- This chunk is adapted to LuaJIT behavior. See the comment above. Please mention the function nearby the comment as it was done before. Here and above. > +lim = 2 > 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") > 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, Sergey Kaplun