Title: Dissolve small pure workers into saturated call sites (#211) by Unisay · Pull Request #285 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Dissolve small pure workers into saturated call sites (#211) by Unisay · Pull Request #285 · purescript-lua/purescript-lua
X Title: Dissolve small pure workers into saturated call sites (#211) by Unisay · Pull Request #285 · purescript-lua/purescript-lua
Description: Closes #211. Problem Issue #211 predates two changes that reshaped its landscape: the Capture/Complexity inlining lattices (#231) and the bare-primop worker unfolding (#281). #281 already dissolves sub$w(v, 1) into v - 1, but its predicate demands a single primop node over Trivial operands, so anything one step richer kept paying a Lua call per saturated site: local Golden_Uncurry_Test_alwaysFirst_S_w = function(x) return x end local Golden_Uncurry_Test_adderOf_S_w = function(x, y) return function(y_S_229) return x + y + y_S_229 end end local Golden_Uncurry_Test_add3_S_w = function(x, y, z) return x + y + z end (x + y) + z is a nested primop (the left operand is not Trivial), return x is not a primop at all, and a projection-chain operand like r.foo prices Deref, one notch above Trivial. All three declined. Change isBarePrimOpBody becomes isCheapWorkerBody: a tree of primops, equality tests and negations over leaves complexityOf classifies at most Deref (parameter references, scalar literals, cheap projection chains), possibly under nested lambdas. The paste is additionally bounded by smallInlineBudget — the constant whose documented meaning is exactly "duplication at every use site": isCheapWorkerBody ∷ RawExp ann → Bool isCheapWorkerBody = \case PrimBinOp _ _ a b → isCheapWorkerBody a && isCheapWorkerBody b Eq _ a b → isCheapWorkerBody a && isCheapWorkerBody b PrimNot _ e → isCheapWorkerBody e AbsN _ _params body → isCheapWorkerBody body leaf → complexityOf leaf <= Deref Everything else rides on existing machinery: the n-ary AbsN root is pasted under the original AppN, the exact-arity betaReduce consumes it in the same pass, and constantFolding finishes the job where arguments are literal. The former call sites in Golden.Uncurry.Test: -- before local _ = Effect_Console_logShow_S_w(Data_Show_showInt, Golden_Uncurry_Test_add3_S_w(1, 2, 3))() local _ = Effect_Console_logShow_S_w(Data_Show_showInt, Golden_Uncurry_Test_adderOf_S_w(1, 2)(3))() local _ = Effect_Console_logShow_S_w(Data_Show_showInt, Golden_Uncurry_Test_alwaysFirst_S_w(7, 8))() -- after local _ = Effect_Console_logShow_S_w(Data_Show_showInt, 6)() local _ = Effect_Console_logShow_S_w(Data_Show_showInt, 6)() local _ = Effect_Console_logShow_S_w(Data_Show_showInt, 7)() and the partially-applied residual closure folds its constants too: -- before Data_Functor_foreign.arrayMap(function(add3_S_p3_S_258) return Golden_Uncurry_Test_add3_S_w(1, 2, add3_S_p3_S_258) end) -- after Data_Functor_foreign.arrayMap(function(add3_S_p3_S_259) return 3 + add3_S_p3_S_259 end) All three workers above are gone from the output entirely: once every saturated site is inlined, DCE drops the worker, and the late uncurry run leaves the surviving manifest chain alone because a binding with no saturated site is never split. What deliberately stays shared IfThenElse bodies are not admitted, deviating from the issue's original allowed list: an IfThenElse in expression position lowers through chunkToExpression to a per-call IIFE — the exact allocation the case-of-case rules of #203 exist to remove — so pasting a decision tree would trade a named call for a closure allocation plus a call. Application bodies (sumTo$w, evenSteps$w, logShow$w, the monad workers), allocating bodies (Ctor, non-empty literals, Let) and oversized trees also keep sharing, each declining through the complexityOf fallback or the budget. Value-position uses are untouched by construction: the rule fires only at saturated AppN heads, so the sharing-vs-Capture concern that #231 codified for the local tiers never arises (no lambda literal lands in a branch or closure position — it is consumed by betaReduce on the spot). The issue's original sketch — extending the shared isInlinableExpr guard so the binding dissolves before uncurry — would have bypassed the CaptureNone gate of isDuplicatableClosedAbs and pasted lambda literals into value positions (the #204 trace-abort pathology). Keeping the admission per-call-site delivers the same end state for call uses while leaving every value use a shared reference, so this lands as a completion of #211 in the post-#231/#281 architecture rather than a literal transcription. Testing Unit tests mirror the #281 spec block: three positives (nested primop tree, parameter-selecting body, Deref-leaf operands — red before the change) and three negatives pinning the exclusions (application body, branching body, over-budget tree — green before and after). Golden churn is limited to Golden.Uncurry.Test, Golden.UncurriedLift.Test and Golden.Unbinding.Test; every eval oracle passes unchanged, and the full suite is stable across four hspec seeds (1, 42, 20260716, 999983).
Open Graph Description: Closes #211. Problem Issue #211 predates two changes that reshaped its landscape: the Capture/Complexity inlining lattices (#231) and the bare-primop worker unfolding (#281). #281 already dissolves...
X Description: Closes #211. Problem Issue #211 predates two changes that reshaped its landscape: the Capture/Complexity inlining lattices (#231) and the bare-primop worker unfolding (#281). #281 already dissolves...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/pull/285
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3d9af3ca-7999-0077-b4b1-add171229ab9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A642:2E124E:6FF4B1:907C80:6B00E484 |
| html-safe-nonce | 60973095b50f01a3640b675a451a9c66a5ab001345ff14a147b1f06bd3525717 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjQyOjJFMTI0RTo2RkY0QjE6OTA3QzgwOjZCMDBFNDg0IiwidmlzaXRvcl9pZCI6IjUyNDI0MTEzNzc5MTM1NTQwNTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e32f05cd4f3bb2a0599e334650de067b8892165eb41f178bd837626e5d531250 |
| hovercard-subject-tag | pull_request:4068884632 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/purescript-lua/purescript-lua/pull/285/files |
| twitter:image | https://avatars.githubusercontent.com/u/1009751?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1009751?s=400&v=4 |
| og:image:alt | Closes #211. Problem Issue #211 predates two changes that reshaped its landscape: the Capture/Complexity inlining lattices (#231) and the bare-primop worker unfolding (#281). #281 already dissolves... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width