Skip to content

Commit 8c82550

Browse files
BridgeJS: Remove swift_js_push_array_length
1 parent dbc216a commit 8c82550

File tree

59 files changed

+127
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+127
-346
lines changed

Benchmarks/Sources/Generated/BridgeJS.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ public func _bjs_ArrayRoundtrip_makeIntArray(_ _self: UnsafeMutableRawPointer) -
15091509
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeIntArray()
15101510
for __bjs_elem_ret in ret {
15111511
_swift_js_push_int(Int32(__bjs_elem_ret))}
1512-
_swift_js_push_array_length(Int32(ret.count))
1512+
_swift_js_push_int(Int32(ret.count))
15131513
#else
15141514
fatalError("Only available on WebAssembly")
15151515
#endif
@@ -1531,7 +1531,7 @@ public func _bjs_ArrayRoundtrip_roundtripIntArray(_ _self: UnsafeMutableRawPoint
15311531
}())
15321532
for __bjs_elem_ret in ret {
15331533
_swift_js_push_int(Int32(__bjs_elem_ret))}
1534-
_swift_js_push_array_length(Int32(ret.count))
1534+
_swift_js_push_int(Int32(ret.count))
15351535
#else
15361536
fatalError("Only available on WebAssembly")
15371537
#endif
@@ -1544,7 +1544,7 @@ public func _bjs_ArrayRoundtrip_makeIntArrayLarge(_ _self: UnsafeMutableRawPoint
15441544
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeIntArrayLarge()
15451545
for __bjs_elem_ret in ret {
15461546
_swift_js_push_int(Int32(__bjs_elem_ret))}
1547-
_swift_js_push_array_length(Int32(ret.count))
1547+
_swift_js_push_int(Int32(ret.count))
15481548
#else
15491549
fatalError("Only available on WebAssembly")
15501550
#endif
@@ -1576,7 +1576,7 @@ public func _bjs_ArrayRoundtrip_makeDoubleArray(_ _self: UnsafeMutableRawPointer
15761576
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makeDoubleArray()
15771577
for __bjs_elem_ret in ret {
15781578
_swift_js_push_f64(__bjs_elem_ret)}
1579-
_swift_js_push_array_length(Int32(ret.count))
1579+
_swift_js_push_int(Int32(ret.count))
15801580
#else
15811581
fatalError("Only available on WebAssembly")
15821582
#endif
@@ -1598,7 +1598,7 @@ public func _bjs_ArrayRoundtrip_roundtripDoubleArray(_ _self: UnsafeMutableRawPo
15981598
}())
15991599
for __bjs_elem_ret in ret {
16001600
_swift_js_push_f64(__bjs_elem_ret)}
1601-
_swift_js_push_array_length(Int32(ret.count))
1601+
_swift_js_push_int(Int32(ret.count))
16021602
#else
16031603
fatalError("Only available on WebAssembly")
16041604
#endif
@@ -1633,7 +1633,7 @@ public func _bjs_ArrayRoundtrip_makeStringArray(_ _self: UnsafeMutableRawPointer
16331633
__bjs_ret_elem.withUTF8 { ptr in
16341634
_swift_js_push_string(ptr.baseAddress, Int32(ptr.count))
16351635
}}
1636-
_swift_js_push_array_length(Int32(ret.count))
1636+
_swift_js_push_int(Int32(ret.count))
16371637
#else
16381638
fatalError("Only available on WebAssembly")
16391639
#endif
@@ -1658,7 +1658,7 @@ public func _bjs_ArrayRoundtrip_roundtripStringArray(_ _self: UnsafeMutableRawPo
16581658
__bjs_ret_elem.withUTF8 { ptr in
16591659
_swift_js_push_string(ptr.baseAddress, Int32(ptr.count))
16601660
}}
1661-
_swift_js_push_array_length(Int32(ret.count))
1661+
_swift_js_push_int(Int32(ret.count))
16621662
#else
16631663
fatalError("Only available on WebAssembly")
16641664
#endif
@@ -1690,7 +1690,7 @@ public func _bjs_ArrayRoundtrip_makePointArray(_ _self: UnsafeMutableRawPointer)
16901690
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makePointArray()
16911691
for __bjs_elem_ret in ret {
16921692
__bjs_elem_ret.bridgeJSLowerReturn()}
1693-
_swift_js_push_array_length(Int32(ret.count))
1693+
_swift_js_push_int(Int32(ret.count))
16941694
#else
16951695
fatalError("Only available on WebAssembly")
16961696
#endif
@@ -1712,7 +1712,7 @@ public func _bjs_ArrayRoundtrip_roundtripPointArray(_ _self: UnsafeMutableRawPoi
17121712
}())
17131713
for __bjs_elem_ret in ret {
17141714
__bjs_elem_ret.bridgeJSLowerReturn()}
1715-
_swift_js_push_array_length(Int32(ret.count))
1715+
_swift_js_push_int(Int32(ret.count))
17161716
#else
17171717
fatalError("Only available on WebAssembly")
17181718
#endif
@@ -1725,7 +1725,7 @@ public func _bjs_ArrayRoundtrip_makePointArrayLarge(_ _self: UnsafeMutableRawPoi
17251725
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).makePointArrayLarge()
17261726
for __bjs_elem_ret in ret {
17271727
__bjs_elem_ret.bridgeJSLowerReturn()}
1728-
_swift_js_push_array_length(Int32(ret.count))
1728+
_swift_js_push_int(Int32(ret.count))
17291729
#else
17301730
fatalError("Only available on WebAssembly")
17311731
#endif
@@ -1767,8 +1767,8 @@ public func _bjs_ArrayRoundtrip_makeNestedIntArray(_ _self: UnsafeMutableRawPoin
17671767
for __bjs_elem_ret in ret {
17681768
for __bjs_elem_ret_elem in __bjs_elem_ret {
17691769
_swift_js_push_int(Int32(__bjs_elem_ret_elem))}
1770-
_swift_js_push_array_length(Int32(__bjs_elem_ret.count))}
1771-
_swift_js_push_array_length(Int32(ret.count))
1770+
_swift_js_push_int(Int32(__bjs_elem_ret.count))}
1771+
_swift_js_push_int(Int32(ret.count))
17721772
#else
17731773
fatalError("Only available on WebAssembly")
17741774
#endif
@@ -1800,8 +1800,8 @@ public func _bjs_ArrayRoundtrip_roundtripNestedIntArray(_ _self: UnsafeMutableRa
18001800
for __bjs_elem_ret in ret {
18011801
for __bjs_elem_ret_elem in __bjs_elem_ret {
18021802
_swift_js_push_int(Int32(__bjs_elem_ret_elem))}
1803-
_swift_js_push_array_length(Int32(__bjs_elem_ret.count))}
1804-
_swift_js_push_array_length(Int32(ret.count))
1803+
_swift_js_push_int(Int32(__bjs_elem_ret.count))}
1804+
_swift_js_push_int(Int32(ret.count))
18051805
#else
18061806
fatalError("Only available on WebAssembly")
18071807
#endif
@@ -1843,8 +1843,8 @@ public func _bjs_ArrayRoundtrip_makeNestedPointArray(_ _self: UnsafeMutableRawPo
18431843
for __bjs_elem_ret in ret {
18441844
for __bjs_elem_ret_elem in __bjs_elem_ret {
18451845
__bjs_elem_ret_elem.bridgeJSLowerReturn()}
1846-
_swift_js_push_array_length(Int32(__bjs_elem_ret.count))}
1847-
_swift_js_push_array_length(Int32(ret.count))
1846+
_swift_js_push_int(Int32(__bjs_elem_ret.count))}
1847+
_swift_js_push_int(Int32(ret.count))
18481848
#else
18491849
fatalError("Only available on WebAssembly")
18501850
#endif
@@ -1876,8 +1876,8 @@ public func _bjs_ArrayRoundtrip_roundtripNestedPointArray(_ _self: UnsafeMutable
18761876
for __bjs_elem_ret in ret {
18771877
for __bjs_elem_ret_elem in __bjs_elem_ret {
18781878
__bjs_elem_ret_elem.bridgeJSLowerReturn()}
1879-
_swift_js_push_array_length(Int32(__bjs_elem_ret.count))}
1880-
_swift_js_push_array_length(Int32(ret.count))
1879+
_swift_js_push_int(Int32(__bjs_elem_ret.count))}
1880+
_swift_js_push_int(Int32(ret.count))
18811881
#else
18821882
fatalError("Only available on WebAssembly")
18831883
#endif
@@ -1912,7 +1912,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalIntArray(_ _self: UnsafeMutableRawPo
19121912
if let __bjs_unwrapped_ret_elem = __bjs_elem_ret {
19131913
_swift_js_push_int(Int32(__bjs_unwrapped_ret_elem))}
19141914
_swift_js_push_int(__bjs_isSome_ret_elem ? 1 : 0)}
1915-
_swift_js_push_array_length(Int32(ret.count))
1915+
_swift_js_push_int(Int32(ret.count))
19161916
#else
19171917
fatalError("Only available on WebAssembly")
19181918
#endif
@@ -1937,7 +1937,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalIntArray(_ _self: UnsafeMutable
19371937
if let __bjs_unwrapped_ret_elem = __bjs_elem_ret {
19381938
_swift_js_push_int(Int32(__bjs_unwrapped_ret_elem))}
19391939
_swift_js_push_int(__bjs_isSome_ret_elem ? 1 : 0)}
1940-
_swift_js_push_array_length(Int32(ret.count))
1940+
_swift_js_push_int(Int32(ret.count))
19411941
#else
19421942
fatalError("Only available on WebAssembly")
19431943
#endif
@@ -1972,7 +1972,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalPointArray(_ _self: UnsafeMutableRaw
19721972
if let __bjs_unwrapped_ret_elem = __bjs_elem_ret {
19731973
__bjs_unwrapped_ret_elem.bridgeJSLowerReturn()}
19741974
_swift_js_push_int(__bjs_isSome_ret_elem ? 1 : 0)}
1975-
_swift_js_push_array_length(Int32(ret.count))
1975+
_swift_js_push_int(Int32(ret.count))
19761976
#else
19771977
fatalError("Only available on WebAssembly")
19781978
#endif
@@ -1997,7 +1997,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalPointArray(_ _self: UnsafeMutab
19971997
if let __bjs_unwrapped_ret_elem = __bjs_elem_ret {
19981998
__bjs_unwrapped_ret_elem.bridgeJSLowerReturn()}
19991999
_swift_js_push_int(__bjs_isSome_ret_elem ? 1 : 0)}
2000-
_swift_js_push_array_length(Int32(ret.count))
2000+
_swift_js_push_int(Int32(ret.count))
20012001
#else
20022002
fatalError("Only available on WebAssembly")
20032003
#endif
@@ -2037,7 +2037,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalArraySome(_ _self: UnsafeMutableRawP
20372037
if let __bjs_unwrapped_ret = ret {
20382038
for __bjs_elem_ret in __bjs_unwrapped_ret {
20392039
_swift_js_push_int(Int32(__bjs_elem_ret))}
2040-
_swift_js_push_array_length(Int32(__bjs_unwrapped_ret.count))}
2040+
_swift_js_push_int(Int32(__bjs_unwrapped_ret.count))}
20412041
_swift_js_push_int(__bjs_isSome_ret ? 1 : 0)
20422042
#else
20432043
fatalError("Only available on WebAssembly")
@@ -2053,7 +2053,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalArrayNone(_ _self: UnsafeMutableRawP
20532053
if let __bjs_unwrapped_ret = ret {
20542054
for __bjs_elem_ret in __bjs_unwrapped_ret {
20552055
_swift_js_push_int(Int32(__bjs_elem_ret))}
2056-
_swift_js_push_array_length(Int32(__bjs_unwrapped_ret.count))}
2056+
_swift_js_push_int(Int32(__bjs_unwrapped_ret.count))}
20572057
_swift_js_push_int(__bjs_isSome_ret ? 1 : 0)
20582058
#else
20592059
fatalError("Only available on WebAssembly")
@@ -2084,7 +2084,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalArray(_ _self: UnsafeMutableRaw
20842084
if let __bjs_unwrapped_ret = ret {
20852085
for __bjs_elem_ret in __bjs_unwrapped_ret {
20862086
_swift_js_push_int(Int32(__bjs_elem_ret))}
2087-
_swift_js_push_array_length(Int32(__bjs_unwrapped_ret.count))}
2087+
_swift_js_push_int(Int32(__bjs_unwrapped_ret.count))}
20882088
_swift_js_push_int(__bjs_isSome_ret ? 1 : 0)
20892089
#else
20902090
fatalError("Only available on WebAssembly")

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ struct StackCodegen {
10141014
}
10151015

10161016
statements.append("}")
1017-
statements.append("_swift_js_push_array_length(Int32(\(raw: accessor).count))")
1017+
statements.append("_swift_js_push_int(Int32(\(raw: accessor).count))")
10181018
return statements
10191019
}
10201020

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ public struct BridgeJSLink {
256256
"let \(JSGlueVariableScope.reservedTmpRetPointers) = [];",
257257
"let \(JSGlueVariableScope.reservedTmpParamPointers) = [];",
258258
"let \(JSGlueVariableScope.reservedTmpStructCleanups) = [];",
259-
"let \(JSGlueVariableScope.reservedTmpRetArrayLengths) = [];",
260259
"const \(JSGlueVariableScope.reservedEnumHelpers) = {};",
261260
"const \(JSGlueVariableScope.reservedStructHelpers) = {};",
262261
"",
@@ -440,11 +439,6 @@ public struct BridgeJSLink {
440439
printer.write("return \(JSGlueVariableScope.reservedTmpParamPointers).pop();")
441440
}
442441
printer.write("}")
443-
printer.write("bjs[\"swift_js_push_array_length\"] = function(len) {")
444-
printer.indent {
445-
printer.write("\(JSGlueVariableScope.reservedTmpRetArrayLengths).push(len | 0);")
446-
}
447-
printer.write("}")
448442
printer.write("bjs[\"swift_js_struct_cleanup\"] = function(cleanupId) {")
449443
printer.indent {
450444
printer.write("if (cleanupId === 0) { return; }")

Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ final class JSGlueVariableScope {
3131
static let reservedTmpRetPointers = "tmpRetPointers"
3232
static let reservedTmpParamPointers = "tmpParamPointers"
3333
static let reservedTmpStructCleanups = "tmpStructCleanups"
34-
static let reservedTmpRetArrayLengths = "tmpRetArrayLengths"
3534
static let reservedEnumHelpers = "enumHelpers"
3635
static let reservedStructHelpers = "structHelpers"
3736

@@ -61,7 +60,6 @@ final class JSGlueVariableScope {
6160
reservedTmpRetPointers,
6261
reservedTmpParamPointers,
6362
reservedTmpStructCleanups,
64-
reservedTmpRetArrayLengths,
6563
reservedEnumHelpers,
6664
reservedStructHelpers,
6765
]
@@ -2186,7 +2184,7 @@ struct IntrinsicJSFragment: Sendable {
21862184
let lenVar = scope.variable("arrayLen")
21872185
let iVar = scope.variable("i")
21882186

2189-
printer.write("const \(lenVar) = \(JSGlueVariableScope.reservedTmpRetArrayLengths).pop();")
2187+
printer.write("const \(lenVar) = \(JSGlueVariableScope.reservedTmpRetInts).pop();")
21902188
printer.write("const \(resultVar) = [];")
21912189
printer.write("for (let \(iVar) = 0; \(iVar) < \(lenVar); \(iVar)++) {")
21922190
printer.indent {

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export async function createInstantiator(options, swift) {
2929
let tmpRetPointers = [];
3030
let tmpParamPointers = [];
3131
let tmpStructCleanups = [];
32-
let tmpRetArrayLengths = [];
3332
const enumHelpers = {};
3433
const structHelpers = {};
3534

@@ -103,9 +102,6 @@ export async function createInstantiator(options, swift) {
103102
bjs["swift_js_pop_pointer"] = function() {
104103
return tmpParamPointers.pop();
105104
}
106-
bjs["swift_js_push_array_length"] = function(len) {
107-
tmpRetArrayLengths.push(len | 0);
108-
}
109105
bjs["swift_js_struct_cleanup"] = function(cleanupId) {
110106
if (cleanupId === 0) { return; }
111107
const index = (cleanupId | 0) - 1;

0 commit comments

Comments
 (0)