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 E3C976F861; Fri, 27 Nov 2026 15:59:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E3C976F861 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1795784370; bh=f4lPe+uDzOZIKffYlXY7SQ4ammpluQA8LGlIs+MY/Rw=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=OWN+rlTaEPRF4qxPgFUa1C5FMfKw3dO/Szt5IbZkvF8QR40b3M3A2Lzk+TaeWrJa5 /hpAQJ06KHq3hGr41IdvtI5i30RAVeyUZD5W9QDFTq7V++HO2B7RdePqgY0N7qthoD SWMC9zuxYRtHvMzmdP+ingnFFfO/5BAuutxFd4PQ= Received: from send276.i.mail.ru (send276.i.mail.ru [95.163.59.115]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 EA8D86F861 for ; Fri, 27 Nov 2026 15:59:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EA8D86F861 Received: by exim-smtp-558c69478d-755q7 with esmtpa (envelope-from ) id 1xWvXz-00000000MPX-1m4n; Fri, 27 Nov 2026 15:59:28 +0300 Date: Fri, 27 Nov 2026 16:01:42 +0300 To: Sergey Bronnikov Cc: Sergey Bronnikov , tarantool-patches@dev.tarantool.org Message-ID: References: <02dcf0b6-e145-4bf4-a9c4-37726f80ea0d@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D70A5F1A44F40AC43D0E6C000425B11C04362336E679F555182A05F538085040BA718D791EC9F2B53DE06ABAFEAF6705EE715F9CD11AA1A47BC706BD9B4A9BA2357F9E8F5AEEDED5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CB1634DB9A2F7B99EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566597B7DDA0B2A6E4B2396D73E7B265776EB1E7674B462431C0ABA92A698EA7824389733CBF5DBD5E9D5E8D9A59859A8B65FF0BFC5AEE34BE6CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8090A508E0FED6299176DF2183F8FC7C0ACC3F41996DF3BC2CD04E86FAF290E2DB606B96278B59C421DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B69DC5D3EDC80DC730089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5A04820011F3C459B5002B1117B3ED69625D9BD40165C4F2954BB1175C6E7DD94823CB91A9FED034534781492E4B8EEAD0942DC5495D0595EBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6590E8728BBD841047DC3D9CF769E2FE155CD3F4985E53B3615C0C331110BA64186B351EE52B8A94925B8341EE9D5BE9A0AAB964AF9400B54889F3530B055FBF9AB88596872C74A3DA06536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXOcIETfglQORZ0zpDET4Zrk3igikrdHlWMKUeL2GR1tRnNR0l9D9uPM= X-Mailru-Sender: 520A125C2F17F0B17094CDC02B85F11B603573AE854EC8073DE06ABAFEAF6705EE715F9CD11AA1A4B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Optionally return PC position in jit.util.tracesnap(). 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for the fixes! LGTM. Side note: the second comment is also fixed (I've checked it on branch). Just not mentioned here. On 27.11.26, Sergey Bronnikov wrote: > Hi, Sergey, > > see the comment below > > >>>> +local snap, pos = jutil.tracesnap(1, 0, true) > >>>> +test:istable(snap, 'the snapshot table is returned') > >>>> +test:is(pos, loop_entry, 'the PC position points to the loop entry') > >>>> + > >>>> +local _, pos_without = jutil.tracesnap(1, 0) > >>>> +test:is(pos_without, nil, 'no PC position without getpos') > >>>> + > >>>> +local _, pos_false = jutil.tracesnap(1, 0, false) > >>>> +test:is(pos_false, nil, 'no PC position with getpos=false') > >>>> + > >>>> +local all_valid = true > >>>> +for sn = 0, info.nexit - 1 do > >>>> + local _, p = jutil.tracesnap(1, sn, true) > >>>> + if type(p) ~= 'number' or p < 0 or p >= nbc or > >>>> + jutil.funcbc(payload, p) == nil then > >>>> + all_valid = false > >>>> + end > >>>> +end > >>>> +test:ok(all_valid, 'positions of all snapshots are valid offsets') > >>>> + > >>>> +test:is(select('#', jutil.tracesnap(1, info.nexit, true)), 0, > >>>> + 'out-of-range snapshot returns nothing') > >>>> + > >>> It would be nice to add any correctness test. > >>> The most trivial in mind is the following: > >>> > >>> | src/luajit -Ohotloop=1 -e ' > >>> | local jutil = require"jit.util" > >>> | local function trivial() > >>> | local a = 0 > >>> | return a > >>> | end > >>> | trivial() > >>> | trivial() > >>> | > >>> | local _, b = jutil.tracesnap(1, 0, true) > >>> | print(b) > >>> | local _, b = jutil.tracesnap(1, 1, true) > >>> | print(b) > >>> | ' > >>> | 1 > >>> | 2 > >>> > >>> The snapshot is emitted at the function entry and before returning the > >>> result which makes it trivial to detect: > >>> > >>> | ---- TRACE 1 start (command line):3 > >>> | 0001 KSHORT 0 0 > >>> | 0002 RET1 0 2 > >>> | ---- TRACE 1 IR > >>> | .... SNAP #0 [ ---- ] > >>> | .... SNAP #1 [ ---- +0 ] > >>> > >>> Don't forget to reset the hotcounters during the recording of this > >>> example. > >> ok, thanks, added: > >> > >>  }) > >> > >> -test:plan(8) > >> +test:plan(10) > >> > >>  -- Entries in `vmdef.bcnames` are 6 characters long. > >>  local BC_NAME_LENGTH = 6 > >> @@ -87,4 +87,21 @@ test:ok(all_valid, 'positions of all snapshots are > >> valid offsets') > >>  test:is(select('#', jutil.tracesnap(1, info.nexit, true)), 0, > >>          'out-of-range snapshot returns nothing') > >> > >> +-- The same correctness check for a trace without a loop: the > >> +-- first and the last snapshots of the trivial function point to > >> +-- its first and second bytecode instructions, respectively. > >> +jit.flush() > > You should update the hotloop counters after flush to avoid clashing. Fixed on branch. > > > >> +local function trivial() > >> +  local a = 0 > >> +  return a > >> +end > >> +trivial() > >> +trivial() > >> + > >> +local _, pos_first = jutil.tracesnap(1, 0, true) > >> +test:is(pos_first, 1, 'the first snapshot points to the first instruction') > >> + > >> +local _, pos_last = jutil.tracesnap(1, 1, true) > >> +test:is(pos_last, 2, 'the second snapshot points to the second > >> instruction') > >> + > >>  test:done(true) > >> > >>>> +test:done(true) > >>>> -- > >>>> 2.51.0 > >>>> -- Best regards, Sergey Kaplun