Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench/goldens/fnew_Bench.CtorBuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ function-body FNEW sites:
Bench.CtorBuild.lua:52
Bench.CtorBuild.lua:66
Bench.CtorBuild.lua:65
Bench.CtorBuild.lua:71
Bench.CtorBuild.lua:73
Bench.CtorBuild.lua:75
Bench.CtorBuild.lua:72
Bench.CtorBuild.lua:70
4 changes: 2 additions & 2 deletions bench/goldens/fnew_Bench.RecordSet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ function-body FNEW sites:
Bench.RecordSet.lua:54
Bench.RecordSet.lua:53
Bench.RecordSet.lua:52
Bench.RecordSet.lua:61
Bench.RecordSet.lua:63
Bench.RecordSet.lua:65
Bench.RecordSet.lua:62
Bench.RecordSet.lua:60
2 changes: 1 addition & 1 deletion bench/goldens/tnew_Bench.RecordSet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ prototypes: 18
function-body TNEW+TDUP sites:
Bench.RecordSet.lua:5 TNEW
Bench.RecordSet.lua:36 TNEW
Bench.RecordSet.lua:64 TDUP
Bench.RecordSet.lua:62 TDUP
7 changes: 1 addition & 6 deletions bench/goldens/trace_array_foldl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ bytecode end state (J*=compiled, I*=blacklisted):
Bench.ArrayFoldl.lua:28 JLOOP
Bench.ArrayFoldl.lua:49 IFUNCF
Bench.ArrayFoldl.lua:50 JFUNCF
array_foldl.lua:23 JFUNCF
array_foldl.lua:25 JFORI
array_foldl.lua:25 JFORL
array_foldl.lua:29 JFORI
array_foldl.lua:29 JFORL
counts: aborts=6 compiled=7 blacklisted=2
counts: aborts=6 compiled=2 blacklisted=2
6 changes: 1 addition & 5 deletions bench/goldens/trace_bind_chain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@ bytecode end state (J*=compiled, I*=blacklisted):
Bench.BindChain.lua:13 IFUNCF
Bench.BindChain.lua:17 JFUNCF
Bench.BindChain.lua:9 IFUNCF
bind_chain.lua:10 IFORL
bind_chain.lua:15 JFUNCF
bind_chain.lua:17 JFORI
bind_chain.lua:17 JFORL
counts: aborts=3 compiled=5 blacklisted=3
counts: aborts=3 compiled=2 blacklisted=2
12 changes: 5 additions & 7 deletions bench/goldens/trace_ctor_build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ aborts (distinct site -- reason):
Bench.CtorBuild.lua:29 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:30 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:38 -- inner loop in root trace
Bench.CtorBuild.lua:72 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:73 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:75 -- NYI: bytecode UCLO
Bench.CtorBuild.lua:70 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:71 -- NYI: bytecode FNEW
Bench.CtorBuild.lua:73 -- NYI: bytecode UCLO
Bench.CtorBuild.lua:8 -- NYI: bytecode FNEW
bytecode end state (J*=compiled, I*=blacklisted):
Bench.CtorBuild.lua:27 IFORL
Expand All @@ -18,7 +18,5 @@ bytecode end state (J*=compiled, I*=blacklisted):
Bench.CtorBuild.lua:6 JFORL
Bench.CtorBuild.lua:69 IFUNCF
Bench.CtorBuild.lua:70 JFUNCF
Bench.CtorBuild.lua:73 JFUNCF
ctor_build.lua:20 JFORI
ctor_build.lua:20 JFORL
counts: aborts=7 compiled=9 blacklisted=2
Bench.CtorBuild.lua:71 JFUNCF
counts: aborts=7 compiled=7 blacklisted=2
5 changes: 1 addition & 4 deletions bench/goldens/trace_curried_step.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ aborts (distinct site -- reason):
Bench.CurriedStep.lua:6 -- inner loop in root trace
bytecode end state (J*=compiled, I*=blacklisted):
Bench.CurriedStep.lua:5 JLOOP
curried_step.lua:10 JFUNCF
curried_step.lua:12 JFORI
curried_step.lua:12 JFORL
counts: aborts=1 compiled=4 blacklisted=0
counts: aborts=1 compiled=1 blacklisted=0
5 changes: 1 addition & 4 deletions bench/goldens/trace_effect_step.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ bytecode end state (J*=compiled, I*=blacklisted):
Bench.EffectStep.lua:36 IFUNCF
Bench.EffectStep.lua:37 IFUNCF
Bench.EffectStep.lua:9 JFUNCF
effect_step.lua:11 JFUNCF
effect_step.lua:13 JFORI
effect_step.lua:13 JFORL
counts: aborts=5 compiled=6 blacklisted=6
counts: aborts=5 compiled=3 blacklisted=6
4 changes: 1 addition & 3 deletions bench/goldens/trace_fibonacci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ spec: fibonacci
runtime: LuaJIT 2.1.1741730670
workload: n=30 reps=4 result=832040
aborts (distinct site -- reason):
fibonacci.lua:19 -- NYI: bytecode FNEW
bytecode end state (J*=compiled, I*=blacklisted):
Bench.Fib.lua:2 JFUNCF
fibonacci.lua:11 JFUNCF
counts: aborts=1 compiled=2 blacklisted=0
counts: aborts=0 compiled=1 blacklisted=0
5 changes: 1 addition & 4 deletions bench/goldens/trace_mutual_step.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ aborts (distinct site -- reason):
Bench.MutualStep.lua:8 -- inner loop in root trace
bytecode end state (J*=compiled, I*=blacklisted):
Bench.MutualStep.lua:7 JLOOP
mutual_step.lua:11 JFUNCF
mutual_step.lua:13 JFORI
mutual_step.lua:13 JFORL
counts: aborts=2 compiled=4 blacklisted=0
counts: aborts=2 compiled=1 blacklisted=0
12 changes: 5 additions & 7 deletions bench/goldens/trace_record_set.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ aborts (distinct site -- reason):
Bench.RecordSet.lua:29 -- NYI: bytecode FNEW
Bench.RecordSet.lua:30 -- NYI: bytecode FNEW
Bench.RecordSet.lua:38 -- inner loop in root trace
Bench.RecordSet.lua:62 -- NYI: bytecode FNEW
Bench.RecordSet.lua:63 -- NYI: bytecode FNEW
Bench.RecordSet.lua:65 -- NYI: bytecode UCLO
Bench.RecordSet.lua:60 -- NYI: bytecode FNEW
Bench.RecordSet.lua:61 -- NYI: bytecode FNEW
Bench.RecordSet.lua:63 -- NYI: bytecode UCLO
Bench.RecordSet.lua:8 -- NYI: bytecode FNEW
bytecode end state (J*=compiled, I*=blacklisted):
Bench.RecordSet.lua:27 IFORL
Expand All @@ -17,7 +17,5 @@ bytecode end state (J*=compiled, I*=blacklisted):
Bench.RecordSet.lua:6 JFORI
Bench.RecordSet.lua:6 JFORL
Bench.RecordSet.lua:60 JFUNCF
Bench.RecordSet.lua:63 JFUNCF
record_set.lua:21 JFORI
record_set.lua:21 JFORL
counts: aborts=7 compiled=8 blacklisted=2
Bench.RecordSet.lua:61 JFUNCF
counts: aborts=7 compiled=6 blacklisted=2
6 changes: 1 addition & 5 deletions bench/goldens/trace_state_step.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ runtime: LuaJIT 2.1.1741730670
workload: n=100000 reps=4 result=99998
aborts (distinct site -- reason):
Bench.StateStep.lua:9 -- NYI: bytecode FNEW
state_step.lua:32 -- NYI: bytecode FNEW
bytecode end state (J*=compiled, I*=blacklisted):
Bench.StateStep.lua:13 IFUNCF
Bench.StateStep.lua:35 ILOOP
Bench.StateStep.lua:4 IFUNCF
Bench.StateStep.lua:5 JFUNCF
state_step.lua:13 JFUNCF
state_step.lua:34 JFORI
state_step.lua:34 JFORL
counts: aborts=2 compiled=4 blacklisted=3
counts: aborts=1 compiled=1 blacklisted=3
4 changes: 1 addition & 3 deletions bench/goldens/trace_tuple_fold.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ aborts (distinct site -- reason):
Bench.TupleFold.lua:12 -- NYI: bytecode FNEW
Bench.TupleFold.lua:13 -- NYI: bytecode UCLO
Bench.TupleFold.lua:6 -- inner loop in root trace
tuple_fold.lua:22 -- inner loop in root trace
bytecode end state (J*=compiled, I*=blacklisted):
Bench.TupleFold.lua:5 JLOOP
tuple_fold.lua:21 JLOOP
counts: aborts=4 compiled=2 blacklisted=0
counts: aborts=3 compiled=1 blacklisted=0
15 changes: 12 additions & 3 deletions bench/tools/trace_report.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Runs a macrobenchmark spec hot under the tracing JIT and reports two
-- signals per source location:
-- signals per source location of the linked artifact (the spec harness's
-- own bytecode is excluded -- see the note in measure):
--
-- * the set of distinct trace-abort sites (location + reason), collected
-- via jit.attach("trace"). A set, not a count: how many retries happen
Expand Down Expand Up @@ -101,6 +102,13 @@ local function measure(spec_path)
local artifact_path = here .. "/../_build/" .. spec.artifact .. ".lua"
local artifact_chunk = assert(loadfile(artifact_path))
local mod = artifact_chunk()
-- The report covers the linked artifact's bytecode only. The spec file's
-- own drive/ideal wrappers also run hot, but whether such a wrapper's
-- entry compiles is an order race against its inner loop's counter --
-- a pure function of per-process address layout, with a probability the
-- majority vote cannot pin when it sits near one half -- and it carries
-- no information about the emitted code these oracles exist to pin.
local artifact_base = spec.artifact .. ".lua"

local aborts = {}
local function on_trace(what, _tr, func, pc, code, extra)
Expand Down Expand Up @@ -137,7 +145,9 @@ local function measure(spec_path)
reason = msg:find("%%") and string.format(msg, extra) or msg
end
local file, line = location(func, pc)
aborts[string.format("%s:%d -- %s", file, line, reason)] = true
if file == artifact_base then
aborts[string.format("%s:%d -- %s", file, line, reason)] = true
end
end

jit.attach(on_trace, "trace")
Expand All @@ -156,7 +166,6 @@ local function measure(spec_path)
end
end
bc.walk(artifact_chunk, visit)
bc.walk(spec_chunk, visit)

return {
spec = spec_name,
Expand Down
10 changes: 10 additions & 0 deletions changelog.d/20260726_120000_unisay_renumber_minted_locals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Changed

- Compiler-minted local names are renumbered at emission time, immediately
before printing: every supply-drawn index (`x_S_223`, `_S_cse1413`, and the
index a derived dispatcher name embeds, `b_S_5_S_loop`) is rewritten in
first-occurrence order per base name, counted from 0. Emitted names are now
a function of the artifact's own structure, so upstream changes that merely
shift name-supply consumption no longer rename binders in unrelated modules.
One-time whole-corpus renaming of generated Lua; runtime semantics are
unchanged (#306).
8 changes: 6 additions & 2 deletions lib/Language/PureScript/Backend/Lua/Optimizer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Language.PureScript.Backend.Lua.Linker.Foreign (chunkScopeUsesVararg)
import Language.PureScript.Backend.Lua.Localize (localizeChunk, namesInBlock)
import Language.PureScript.Backend.Lua.Name qualified as Lua
import Language.PureScript.Backend.Lua.Promote (promoteChunk)
import Language.PureScript.Backend.Lua.Renumber (renumberChunk)
import Language.PureScript.Backend.Lua.Traversal
( everywhereExp
, everywhereInChunkM
Expand All @@ -35,11 +36,14 @@ can eliminate module-table reads, and the reads that remain are the
ones worth counting. Promotion (stage 2) precedes localization
(stage 1): whatever stays in the module table after promotion — the
unpromoted tail plus demoted references — is exactly what per-function
caching still speeds up.
caching still speeds up. Renumbering runs last, once no pass mints
names anymore: a fresh name introduced after it would carry supply
history into the artifact ("Language.PureScript.Backend.Lua.Renumber").
-}
optimizeChunk ∷ LuaLimits → Chunk → Chunk
optimizeChunk limits =
localizeChunk limits Fixture.moduleName
renumberChunk
. localizeChunk limits Fixture.moduleName
. promoteChunk limits Fixture.moduleName
. fmap (optimizeStatement limits)

Expand Down
Loading