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 B75AE38155E; Tue, 28 Mar 2023 03:05:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B75AE38155E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1679961923; bh=o0hCdqPQE9rsfoKu1J9t8V5zaxX520vqhKTtViQRw2I=; 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=esTVZSF7Crzs+uraC9p+LNKbz/o4cqG/UEAAZJixE5lmjak8dDShKsZvfUcvrsCux yIMQHqQDiI50rg4VRlaS0imDZdx4AJaHwVQ/P7BckRzyO0bX59q/NyZwoWpqIuVPdS hMG/zlom1KXXMzyCuQniHEuCju4grD9vwVO3y2Wg= Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 1E8A538155E for ; Tue, 28 Mar 2023 03:03:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1E8A538155E Received: by mail-lj1-f182.google.com with SMTP id y35so8284810ljq.4 for ; Mon, 27 Mar 2023 17:03:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679961818; 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=pORJAa+mGqFda+Px76pF2qswV/okXJuUkfa4KFdy0aY=; b=FTXHv952BE0K8UFjF4w2xOP4f1ewoJShIJL+PgVQF3vZjocYXUBUkYBPXBqWFnVl7y rH3OGmyebFMFQ5NH/r3kKCoDr1kEManpfVF2lWqdOLCrU93z7YkNtNRFqh40R9oSkSOT 3QEwfJwX5U0w0BvDb7adC6PfMaYLcLUuQJ9G8EniTLKTCQNvK9nZkyP95oLxazsz9ScR e0o19PzFF5tYX7fOhm3MsnbKi2H8s9lsoHaie81tlc/rJTfnoN3GE2WZKhrib5QV4axn MjW8bVvq0IK79n4ilHv5EgzpQ2wm50+o2LB4Ndk3QOArEBGzwp0jQn9JuvqizRNeUDyV cN2w== X-Gm-Message-State: AAQBX9dEXqZjzupd8BTyLCxQB49jzKzRBgwzd+YViGDo6lu9EWAp69UP Tv9p4UnW8gT9A8Joh/ec6656+BjW2jCxqA== X-Google-Smtp-Source: AKy350aVjbsSXhQf9KOfmmBjeXi80HXsI0rxuoSBQrp1xVXp1ypoaDcsKQECngLyxC5wdPMSy9e6Tg== X-Received: by 2002:a2e:9d87:0:b0:294:712a:5190 with SMTP id c7-20020a2e9d87000000b00294712a5190mr4476761ljj.28.1679961817920; Mon, 27 Mar 2023 17:03:37 -0700 (PDT) Received: from localhost.localdomain (89-179-106-78.broadband.corbina.ru. [89.179.106.78]) by smtp.gmail.com with ESMTPSA id x9-20020a2e7c09000000b00298a81f5d70sm4837508ljc.136.2023.03.27.17.03.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Mar 2023 17:03:37 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, sergos@tarantool.org, skaplun@tarantool.org, m.kokryashkin@tarantool.org Date: Tue, 28 Mar 2023 03:03:17 +0300 Message-Id: <20230328000317.33238-5-max.kokryashkin@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230328000317.33238-1-max.kokryashkin@gmail.com> References: <20230328000317.33238-1-max.kokryashkin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v3 4/4] 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: Maksim Kokryashkin via Tarantool-patches Reply-To: Maksim 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 --- 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.37.1 (Apple Git-137.1)