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 0AE4E6E46D; Wed, 13 Oct 2021 15:37:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0AE4E6E46D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1634128676; bh=ddG0JELrGyPH0f9LO5FFBRhTa2lGaMtBQhBzbmHgtLI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OqT2sa+o2+37XFW3zGtdnl8Uc7AOF01II+AYsdAmKgAgW2aSZ2MLuSyDtf/WgrtOg STvl6Seutm0yEM22964y/MXTjuEyucsB6r0a0I2AvfKTqyMEljLPdM+Rfb+PXrJfME h0hBRVeoDwCuPlN+Up82W9JZK6sp8PheA7qcEtZM= Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 283976E46D for ; Wed, 13 Oct 2021 15:37:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 283976E46D Received: by mail-lf1-f41.google.com with SMTP id x27so11278146lfu.5 for ; Wed, 13 Oct 2021 05:37:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k/z7OF2ZhS94U+CuAZrM/it80OzFFlZaIFpL12UWgdU=; b=7DAozfEZ+N1UzkMrnhd7FIXQXxY9rkOABCiScoO0qGoW238WHhs/MDES2J/7m6ailr bxDRPPyXOC7oaqH82GlKi13r/1F9CimSvgvXt+XNx3/xf1BxAHJ7owLvnJLDmL3PVZkp J1FGifWzNBZVl9p+d5bWTJSFut3CcjnKtJ+xPhTFV2Ic/JKNxyfpnk3JunBWde7QdknL WI4AOTC4tzje/sVyTKqg9dONF0TAvI7gZkVEHBw3rRF+fpuZ61EGq/CY6YjOgXKp0Gtc iXhB1Ry5e8DittNy2kgxaz7oEARydslmwKb7JXkGqx+wQpFmN/no3azq3fIZNCg0ggVK W+jQ== X-Gm-Message-State: AOAM532dz/bIhAThRG4eCf+gpvuTUHnuoNNdb+PYWLeY0yl2yZl/F8ip Y3w8o+b/N4iaC29ZmGb5sxd49s7+Gl8= X-Google-Smtp-Source: ABdhPJz/+5ZVGxb62xjeomf7tMXhF1zU7FdmDRS5PkRwrHZa2FGK7sUT2hp2H3uUiOyX2odZt1bOSQ== X-Received: by 2002:a2e:9601:: with SMTP id v1mr21002206ljh.478.1634128672299; Wed, 13 Oct 2021 05:37:52 -0700 (PDT) Received: from localhost.localdomain ([93.175.11.199]) by smtp.gmail.com with ESMTPSA id r9sm1420036ljk.101.2021.10.13.05.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 05:37:51 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org, m.shishatskiy@tarantool.org Date: Wed, 13 Oct 2021 15:37:44 +0300 Message-Id: <20211013123744.2418018-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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. 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)) + 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. +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 +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") 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