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 ECFA6372539; Tue, 14 Mar 2023 15:04:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org ECFA6372539 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1678795465; bh=mtipl6UDEByZvpstKjYlSoLlI6jDKRTtJNVeMxZZbmg=; 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=GsrID3UprQ4qFxpvuJoBBjmtVnUAtIbcZ80NtzmxYDKyR5tymQ3gQhK+sEuSv8OPC 9nvRSmfIE+GG2Kd9O1+uAuKK3IbITvkejYN9u+TBpYFGNKUVtJJ04AQ2ek9Qa53vUn lbYyf1CWo7w1Zi8VnaKgvblOzvHnxPMw/YwOg1M4= Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.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 42E8737253A for ; Tue, 14 Mar 2023 15:02:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 42E8737253A Received: by mail-lf1-f46.google.com with SMTP id x17so3551288lfu.5 for ; Tue, 14 Mar 2023 05:02:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678795335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sqtceJNzU5lVmzBdJUNXsvvhgHTxBOSRK3eENJqGJ9o=; b=eHOMl1CRDM3XY+fNQ+dSl755ZGCwqAP1Zg9wM027UKPiXdgKDf4x+JWaj3A5oRebtq VqmoQCs7Yz27GfZazTk1gH5bjF86tdBGb2ezNmmV66eYZzdm8d1Md9ehp5rbJHyckiSG JM+cFNshAr5KDVhfQ97xUQVjq2dEnKPNTaGYthMShXMIzfIiqAq3L3jn/oMYHjBqNKq9 ysEOcB1s6a3HGblAb53Dm4HLqR4QPWlELyMGwX06GtXj3idIBAw5GkjEjvR+5/89e1jT E8PNXql4pyE42MCP6EJmkrHbeVyxok9v96g8GpWHsB+OesS34VJqhD7bojaJoosYRAMY 2oTA== X-Gm-Message-State: AO0yUKU3s9l19QkX5NR6nz0P1jn65Waz4fpbS1X+Ll/ulrCWdgYFt5j0 oNb8MOBnx1dPxZt7XU5F35RsamIFDWi5qw== X-Google-Smtp-Source: AK7set8jmIRSZ+3jK/wmfArDGH9/mCLeDy0cYARIBP6d1a5aDo3s9icREEAWPPw4n7ULGr/7YhdIKg== X-Received: by 2002:a05:6512:906:b0:4e8:43a4:2baf with SMTP id e6-20020a056512090600b004e843a42bafmr579989lft.33.1678795335494; Tue, 14 Mar 2023 05:02:15 -0700 (PDT) Received: from localhost.localdomain (128-69-253-162.broadband.corbina.ru. [128.69.253.162]) by smtp.gmail.com with ESMTPSA id n5-20020ac242c5000000b004db51387ad6sm375106lfl.129.2023.03.14.05.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 05:02:14 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, skaplun@tarantool.org, sergos@tarantool.org Date: Tue, 14 Mar 2023 15:01:47 +0300 Message-Id: <4d5e9afef83bdbacb2b5f5ca140e941ced04b36f.1678794695.git.m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v2 5/5] Fix IR_RENAME snapshot number. Follow-up fix for a32aeadc. 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" From: Mike Pall Reported by Victor Bombi, analyzed by XmiliaH. Thanks! (cherry-picked from commit bf51d3535109c4745bfbbe19a5587a9eac00259a) If the `snapalloc` flag is set, then the allocation hasn't occurred yet, meaning that rename is applied to the next snapshot. Otherwise, refs are already allocated and rename is applied to the current snapshot. Maxim Kokryashkin: * added the description and the test for the problem Part of tarantool/tarantool#7745 Part of tarantool/tarantool#8069 --- Note: The part with os.exit(test:check() and 0 or 1) replaced by os.exit(test:check()) is required, since in the first case, when the trace is recorded, arithmetic register is not allocated yet by the time th `ra_left` is called. Because of that, the PHI optimization occurs differently and there is no RENAME. src/lj_asm.c | 9 ++++++++- .../gh-7745-ir-rename.test.lua | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/gh-7745-ir-rename.test.lua diff --git a/src/lj_asm.c b/src/lj_asm.c index adfaf286..929a6da6 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -682,7 +682,14 @@ static void ra_rename(ASMState *as, Reg down, Reg up) RA_DBGX((as, "rename $f $r $r", regcost_ref(as->cost[up]), down, up)); emit_movrr(as, ir, down, up); /* Backwards codegen needs inverse move. */ if (!ra_hasspill(IR(ref)->s)) { /* Add the rename to the IR. */ - ra_addrename(as, down, ref, as->snapno); + /* + ** The rename is effective at the subsequent (already emitted) exit + ** branch. This is for the current snapshot (as->snapno). Except if we + ** haven't yet allocated any refs for the snapshot (as->snapalloc == 1), + ** then it belongs to the next snapshot. + ** See also the discussion at asm_snap_checkrename(). + */ + ra_addrename(as, down, ref, as->snapno + as->snapalloc); } } diff --git a/test/tarantool-tests/gh-7745-ir-rename.test.lua b/test/tarantool-tests/gh-7745-ir-rename.test.lua new file mode 100644 index 00000000..d03f6da5 --- /dev/null +++ b/test/tarantool-tests/gh-7745-ir-rename.test.lua @@ -0,0 +1,20 @@ +local tap = require('tap') +local test = tap.test('IR_RENAME on snapshot allocation'):skipcond({ + ['Test requires JIT enabled'] = not jit.status(), +}) +test:plan(1) + +jit.opt.start('hotloop=1') + +local vals = {-0.1, 0.1, -0.1, 0.1} +local i = 1 +local _ +while i < 5 do + assert(i ~= 1.1) + local l1 = vals[i] + _ = l1 > 0 + i = i + 1 +end + +test:ok(true, 'IR_RENAME is fine') +os.exit(test:check()) -- 2.39.0