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 5F6574912A7; Tue, 30 May 2023 19:57:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5F6574912A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1685465831; bh=CGhr5eHm2avXALg/o/ln8ZMRxQmxds/Ag3zPuCfKt+A=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Eg8Z7HTTrxLJGaSg/hlAN0jODvTL5NCK4UDI9lpBKT6EMKjlNzMFn8st5cHOrTzu7 +w+loSxoPNce+H/OGURti96BpSBCT2nEveJqWuznXSQn0BH/Vjo5nB/Oz3FyYjqNmy jU0p3J6SaRbewu9NsVuoAD9n/4JpilhkEBfgskBg= Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 9303148ED5B for ; Tue, 30 May 2023 19:57:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9303148ED5B Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-96fbe7fbdd4so860906666b.3 for ; Tue, 30 May 2023 09:57:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685465829; x=1688057829; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b3pxaZ2O15UqQjqSnzPAhedLWZ2ZPaI6kWiNm6wg9e4=; b=T8zt5udQ7kYox19bKqoRIPlqoFlea4/kq25PoBhig3WUVJcDGi0BEDJHuAEV9wTXb+ kWr/37hy8wdqCxt9+HOP1nRJeTKv4UONWj6613y3wLXBk0LDSXSAsI45Y0Y0CRe3h8cq GtilLXNPe8MD77THgFXUiN7EHa17FUR4YfZk2b8mkGz39m2Rx5HUXz27JkiQZ1pvPmsz Dp8yxqnusek3CmHby33CoWGDZfJSnCFyrzWvXmdaO2CsLFkziECy+7weVen4Ut4H2XZ+ LCRI+JNaNT2+BkNOUG1WnPmskTTIcumcLhSNRQnldCcZpNxvLUw5B8C2A6NQu6qMvTpd ov4g== X-Gm-Message-State: AC+VfDy5sni3INI1nzFRRwVaQWsolTAHTSBuyM2bto30tl5culSkI3FO T0lkMyGzHxnJieXZl+0abCx8dsIJiijomw== X-Google-Smtp-Source: ACHHUZ4uk89hiOsCK9cn6LBhK91bsTcMndpJ0YYTMm2wbV4FkTOooD36B0VlEc0I7sP8HDtoW2ogYA== X-Received: by 2002:a17:907:a414:b0:957:2e48:5657 with SMTP id sg20-20020a170907a41400b009572e485657mr2750696ejc.68.1685465829133; Tue, 30 May 2023 09:57:09 -0700 (PDT) Received: from pony.. ([185.6.247.97]) by smtp.gmail.com with ESMTPSA id z11-20020a170906714b00b0096f89fd4bf8sm7548519ejj.122.2023.05.30.09.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 09:57:08 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , Maxim Kokryashkin Date: Tue, 30 May 2023 19:56:11 +0300 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v1] Fix BC_UCLO insertion for returns. 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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Sergey Bronnikov Contributed by XmiliaH. (cherry-picked from commit 93a65d3cc263aef2d2feb3d7ff2206aca3bee17e) After emitting bytecode instruction BC_FNEW fixup is not required, because FuncState will set a flag PROTO_CHILD that will trigger emitting a pair of instructions BC_UCLO and BC_RET (see ) and BC_RET will close all upvalues from base equal to 0. Sergey Bronnikov: * added the description and the test for the problem Signed-off-by: Sergey Bronnikov Co-authored-by: Sergey Kaplun --- Branch: https://github.com/tarantool/luajit/tree/ligurio/gh-819-fix-missing-uclo PR: https://github.com/tarantool/tarantool/pull/8689 src/lj_parse.c | 2 +- .../lj-819-fix-missing-uclo.test.lua | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/lj-819-fix-missing-uclo.test.lua diff --git a/src/lj_parse.c b/src/lj_parse.c index af0dc53f..343fa797 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -1546,7 +1546,7 @@ static void fs_fixup_ret(FuncState *fs) /* Replace with UCLO plus branch. */ fs->bcbase[pc].ins = BCINS_AD(BC_UCLO, 0, offset); break; - case BC_UCLO: + case BC_FNEW: return; /* We're done. */ default: break; diff --git a/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua b/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua new file mode 100644 index 00000000..b3f1f78a --- /dev/null +++ b/test/tarantool-tests/lj-819-fix-missing-uclo.test.lua @@ -0,0 +1,27 @@ +local tap = require('tap') +local test = tap.test('lj-819-fix-missing-uclo') + +test:plan(1) + +local function missing_uclo() + while true do -- luacheck: ignore + if false then + break + end + local f + while true do + if f then + return f + end + f = function() + return f + end + end + end +end + +local f = missing_uclo() +local res = f() +test:ok(type(res) == 'function', 'type of returned value is correct') + +os.exit(test:check() and 0 or 1) -- 2.34.1