Title: Revisit the foreign-accessor `@inline always` default: stage-2 promotion made the shared form free · Issue #248 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Revisit the foreign-accessor `@inline always` default: stage-2 promotion made the shared form free · Issue #248 · purescript-lua/purescript-lua
X Title: Revisit the foreign-accessor `@inline always` default: stage-2 promotion made the shared form free · Issue #248 · purescript-lua/purescript-lua
Description: Problem The linker binds every foreign name to an ObjectProp accessor annotated @inline always by default (Note [Inline annotations and inlining heuristics]), so each use site re-materializes a field read off the foreign table: Data_Show...
Open Graph Description: Problem The linker binds every foreign name to an ObjectProp accessor annotated @inline always by default (Note [Inline annotations and inlining heuristics]), so each use site re-materializes a fie...
X Description: Problem The linker binds every foreign name to an ObjectProp accessor annotated @inline always by default (Note [Inline annotations and inlining heuristics]), so each use site re-materializes a fie...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/248
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Revisit the foreign-accessor `@inline always` default: stage-2 promotion made the shared form free","articleBody":"## Problem\n\nThe linker binds every foreign name to an `ObjectProp` accessor annotated `@inline always` by default (Note [Inline annotations and inlining heuristics]), so each use site re-materializes a field read off the foreign table: `Data_Show_foreign.showIntImpl(x)`. The default buys wrapper transparency, but per-use cost has always mildly favored the shared form for multi-use names, and stage 2 of #174 (PR #246) made the gap decisive: an accessor kept as a binding is now promoted to a chunk local, so every use is a register or upvalue access with zero table reads, while the dissolved form still pays a field read per site. Promotion also drops `M` entirely from most modules, which leaves foreign accessor reads as the only inter-binding references still going through a table, and stage-1 caching cannot reach them because it caches `M.x` shapes only.\n\n## Approach\n\nDecide a better default for accessors with more than one use site, keeping `always` where it still wins. Candidate shapes: flip the effective default to `never` when the accessor has multiple uses (single-use names stay dissolved: no binding, no local slot), or drop the forced annotation and teach the use-count heuristic that a field read repeated N times is worth a shared binding. Constraints: ForeignLift-lifted accessors must keep `always`, since their bodies exist to beta-reduce at saturated sites; the alias bindings consume the promotion locals budget, so selection should flow through Promote's existing accounting; DCE is unaffected either way, since a `never` accessor is still an `ObjectProp` that prunes when unreachable; and magic-do recognition of Effect/ST chains must still fire after the flip changes which shape reaches it (#182, #228). Fork-side per-name pragmas remain the escape hatch in both directions, and #176 (flip `@inline unit always`) becomes a special case: with the flip plus promotion, every `unit` use is a reference to one promoted local holding the singleton.\n\n## Verification / Measurement\n\nGoldens: a multi-use accessor materializes as a promoted local (`local Data_Show_showIntImpl = Data_Show_foreign.showIntImpl`) and call sites reference it; single-use accessors keep today's dissolved shape; eval goldens unchanged. The field-read-versus-local microbenchmark from ADR 0001 (2.4x on PUC 5.1) bounds the per-read win.\n\n## Prerequisites / Relations\n\nRequires stage 2 (#174, PR #246). Related: #176 (unit-specific flip, allocation-motivated), #175 (why per-site duplication of table values is unsound), #171 (dissolving an alias to an `@inline always` binding multiplies the body across use sites).\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-12T10:53:39Z","url":"https://github.com/purescript-lua/purescript-lua/issues/248"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:39c82889-c6da-7eb3-b8e4-196f1d6e0276 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFEE:395430:7C9075:A6E66D:6B00DB6B |
| html-safe-nonce | 87740ea28cc641d5a830736fbfbca091bf8f51efdb91d1aaade70c69406dcac0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkVFOjM5NTQzMDo3QzkwNzU6QTZFNjZEOjZCMDBEQjZCIiwidmlzaXRvcl9pZCI6IjE4NTA3MDcwNjYxMTM1NDcxMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 551d508d8c4a8964b294b2447173309c222081791026b7e35a62d12cb69b50aa |
| hovercard-subject-tag | issue:4866741013 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/purescript-lua/purescript-lua/248/issue_layout |
| twitter:image | https://opengraph.githubassets.com/921a7b2e852899879433dfd7b2d2cda69a450567a3be1d8d7e845dcad0f999d6/purescript-lua/purescript-lua/issues/248 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/921a7b2e852899879433dfd7b2d2cda69a450567a3be1d8d7e845dcad0f999d6/purescript-lua/purescript-lua/issues/248 |
| og:image:alt | Problem The linker binds every foreign name to an ObjectProp accessor annotated @inline always by default (Note [Inline annotations and inlining heuristics]), so each use site re-materializes a fie... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width