Skip to content

NFC: BridgeJS: Delegate nested container codegen to generic runtime conformances#619

Merged
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
PassiveLogic:kr/container-codegen-simplification
Feb 12, 2026
Merged

NFC: BridgeJS: Delegate nested container codegen to generic runtime conformances#619
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
PassiveLogic:kr/container-codegen-simplification

Conversation

@krodak
Copy link
Member

@krodak krodak commented Feb 11, 2026

Overview

This PR aims to simplify codegen for nested container types ([[Int]], [String: [Double]], etc.) by delegating to existing generic runtime conformances (Array: _BridgedSwiftStackType, Dictionary: _BridgedSwiftStackType) instead of generating inline for-loops in Swift thunks.

Previously, when the element type of an array (or value type of a dictionary) was itself an array or dictionary, the codegen emitted inline loops that manually iterated and pushed/popped each element. The runtime already has generic conformances that do exactly this - Array<Element>.bridgeJSLiftParameter() and .bridgeJSLowerReturn() handle recursion through the generic Element: _BridgedSwiftStackType constraint. This PR routes those cases through the generic conformance path instead.

@krodak krodak self-assigned this Feb 11, 2026
@krodak krodak force-pushed the kr/container-codegen-simplification branch from f2de436 to 38af37b Compare February 11, 2026 20:16
@krodak krodak changed the title BridgeJS: Delegate nested container codegen to generic runtime conformances NFC: BridgeJS: Delegate nested container codegen to generic runtime conformances Feb 11, 2026
Copy link
Member

@kateinoigakukun kateinoigakukun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kateinoigakukun kateinoigakukun merged commit 9ab70c6 into swiftwasm:main Feb 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants