Skip to content

Commit dbc216a

Browse files
BridgeJS: Remove swift_js_pop_array_length
1 parent d9c0301 commit dbc216a

File tree

59 files changed

+136
-353
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

+136
-353
lines changed

Benchmarks/Sources/Generated/BridgeJS.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ public func _bjs_ArrayRoundtrip_init() -> UnsafeMutableRawPointer {
14881488
public func _bjs_ArrayRoundtrip_takeIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
14891489
#if arch(wasm32)
14901490
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeIntArray(_: {
1491-
let __count = Int(_swift_js_pop_array_length())
1491+
let __count = Int(_swift_js_pop_i32())
14921492
var __result: [Int] = []
14931493
__result.reserveCapacity(__count)
14941494
for _ in 0 ..< __count {
@@ -1520,7 +1520,7 @@ public func _bjs_ArrayRoundtrip_makeIntArray(_ _self: UnsafeMutableRawPointer) -
15201520
public func _bjs_ArrayRoundtrip_roundtripIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
15211521
#if arch(wasm32)
15221522
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripIntArray(_: {
1523-
let __count = Int(_swift_js_pop_array_length())
1523+
let __count = Int(_swift_js_pop_i32())
15241524
var __result: [Int] = []
15251525
__result.reserveCapacity(__count)
15261526
for _ in 0 ..< __count {
@@ -1555,7 +1555,7 @@ public func _bjs_ArrayRoundtrip_makeIntArrayLarge(_ _self: UnsafeMutableRawPoint
15551555
public func _bjs_ArrayRoundtrip_takeDoubleArray(_ _self: UnsafeMutableRawPointer) -> Void {
15561556
#if arch(wasm32)
15571557
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeDoubleArray(_: {
1558-
let __count = Int(_swift_js_pop_array_length())
1558+
let __count = Int(_swift_js_pop_i32())
15591559
var __result: [Double] = []
15601560
__result.reserveCapacity(__count)
15611561
for _ in 0 ..< __count {
@@ -1587,7 +1587,7 @@ public func _bjs_ArrayRoundtrip_makeDoubleArray(_ _self: UnsafeMutableRawPointer
15871587
public func _bjs_ArrayRoundtrip_roundtripDoubleArray(_ _self: UnsafeMutableRawPointer) -> Void {
15881588
#if arch(wasm32)
15891589
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripDoubleArray(_: {
1590-
let __count = Int(_swift_js_pop_array_length())
1590+
let __count = Int(_swift_js_pop_i32())
15911591
var __result: [Double] = []
15921592
__result.reserveCapacity(__count)
15931593
for _ in 0 ..< __count {
@@ -1609,7 +1609,7 @@ public func _bjs_ArrayRoundtrip_roundtripDoubleArray(_ _self: UnsafeMutableRawPo
16091609
public func _bjs_ArrayRoundtrip_takeStringArray(_ _self: UnsafeMutableRawPointer) -> Void {
16101610
#if arch(wasm32)
16111611
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeStringArray(_: {
1612-
let __count = Int(_swift_js_pop_array_length())
1612+
let __count = Int(_swift_js_pop_i32())
16131613
var __result: [String] = []
16141614
__result.reserveCapacity(__count)
16151615
for _ in 0 ..< __count {
@@ -1644,7 +1644,7 @@ public func _bjs_ArrayRoundtrip_makeStringArray(_ _self: UnsafeMutableRawPointer
16441644
public func _bjs_ArrayRoundtrip_roundtripStringArray(_ _self: UnsafeMutableRawPointer) -> Void {
16451645
#if arch(wasm32)
16461646
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripStringArray(_: {
1647-
let __count = Int(_swift_js_pop_array_length())
1647+
let __count = Int(_swift_js_pop_i32())
16481648
var __result: [String] = []
16491649
__result.reserveCapacity(__count)
16501650
for _ in 0 ..< __count {
@@ -1669,7 +1669,7 @@ public func _bjs_ArrayRoundtrip_roundtripStringArray(_ _self: UnsafeMutableRawPo
16691669
public func _bjs_ArrayRoundtrip_takePointArray(_ _self: UnsafeMutableRawPointer) -> Void {
16701670
#if arch(wasm32)
16711671
ArrayRoundtrip.bridgeJSLiftParameter(_self).takePointArray(_: {
1672-
let __count = Int(_swift_js_pop_array_length())
1672+
let __count = Int(_swift_js_pop_i32())
16731673
var __result: [Point] = []
16741674
__result.reserveCapacity(__count)
16751675
for _ in 0 ..< __count {
@@ -1701,7 +1701,7 @@ public func _bjs_ArrayRoundtrip_makePointArray(_ _self: UnsafeMutableRawPointer)
17011701
public func _bjs_ArrayRoundtrip_roundtripPointArray(_ _self: UnsafeMutableRawPointer) -> Void {
17021702
#if arch(wasm32)
17031703
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripPointArray(_: {
1704-
let __count = Int(_swift_js_pop_array_length())
1704+
let __count = Int(_swift_js_pop_i32())
17051705
var __result: [Point] = []
17061706
__result.reserveCapacity(__count)
17071707
for _ in 0 ..< __count {
@@ -1736,12 +1736,12 @@ public func _bjs_ArrayRoundtrip_makePointArrayLarge(_ _self: UnsafeMutableRawPoi
17361736
public func _bjs_ArrayRoundtrip_takeNestedIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
17371737
#if arch(wasm32)
17381738
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeNestedIntArray(_: {
1739-
let __count = Int(_swift_js_pop_array_length())
1739+
let __count = Int(_swift_js_pop_i32())
17401740
var __result: [[Int]] = []
17411741
__result.reserveCapacity(__count)
17421742
for _ in 0 ..< __count {
17431743
__result.append({
1744-
let __count = Int(_swift_js_pop_array_length())
1744+
let __count = Int(_swift_js_pop_i32())
17451745
var __result: [Int] = []
17461746
__result.reserveCapacity(__count)
17471747
for _ in 0 ..< __count {
@@ -1779,12 +1779,12 @@ public func _bjs_ArrayRoundtrip_makeNestedIntArray(_ _self: UnsafeMutableRawPoin
17791779
public func _bjs_ArrayRoundtrip_roundtripNestedIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
17801780
#if arch(wasm32)
17811781
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripNestedIntArray(_: {
1782-
let __count = Int(_swift_js_pop_array_length())
1782+
let __count = Int(_swift_js_pop_i32())
17831783
var __result: [[Int]] = []
17841784
__result.reserveCapacity(__count)
17851785
for _ in 0 ..< __count {
17861786
__result.append({
1787-
let __count = Int(_swift_js_pop_array_length())
1787+
let __count = Int(_swift_js_pop_i32())
17881788
var __result: [Int] = []
17891789
__result.reserveCapacity(__count)
17901790
for _ in 0 ..< __count {
@@ -1812,12 +1812,12 @@ public func _bjs_ArrayRoundtrip_roundtripNestedIntArray(_ _self: UnsafeMutableRa
18121812
public func _bjs_ArrayRoundtrip_takeNestedPointArray(_ _self: UnsafeMutableRawPointer) -> Void {
18131813
#if arch(wasm32)
18141814
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeNestedPointArray(_: {
1815-
let __count = Int(_swift_js_pop_array_length())
1815+
let __count = Int(_swift_js_pop_i32())
18161816
var __result: [[Point]] = []
18171817
__result.reserveCapacity(__count)
18181818
for _ in 0 ..< __count {
18191819
__result.append({
1820-
let __count = Int(_swift_js_pop_array_length())
1820+
let __count = Int(_swift_js_pop_i32())
18211821
var __result: [Point] = []
18221822
__result.reserveCapacity(__count)
18231823
for _ in 0 ..< __count {
@@ -1855,12 +1855,12 @@ public func _bjs_ArrayRoundtrip_makeNestedPointArray(_ _self: UnsafeMutableRawPo
18551855
public func _bjs_ArrayRoundtrip_roundtripNestedPointArray(_ _self: UnsafeMutableRawPointer) -> Void {
18561856
#if arch(wasm32)
18571857
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripNestedPointArray(_: {
1858-
let __count = Int(_swift_js_pop_array_length())
1858+
let __count = Int(_swift_js_pop_i32())
18591859
var __result: [[Point]] = []
18601860
__result.reserveCapacity(__count)
18611861
for _ in 0 ..< __count {
18621862
__result.append({
1863-
let __count = Int(_swift_js_pop_array_length())
1863+
let __count = Int(_swift_js_pop_i32())
18641864
var __result: [Point] = []
18651865
__result.reserveCapacity(__count)
18661866
for _ in 0 ..< __count {
@@ -1888,7 +1888,7 @@ public func _bjs_ArrayRoundtrip_roundtripNestedPointArray(_ _self: UnsafeMutable
18881888
public func _bjs_ArrayRoundtrip_takeOptionalIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
18891889
#if arch(wasm32)
18901890
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeOptionalIntArray(_: {
1891-
let __count = Int(_swift_js_pop_array_length())
1891+
let __count = Int(_swift_js_pop_i32())
18921892
var __result: [Optional<Int>] = []
18931893
__result.reserveCapacity(__count)
18941894
for _ in 0 ..< __count {
@@ -1923,7 +1923,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalIntArray(_ _self: UnsafeMutableRawPo
19231923
public func _bjs_ArrayRoundtrip_roundtripOptionalIntArray(_ _self: UnsafeMutableRawPointer) -> Void {
19241924
#if arch(wasm32)
19251925
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripOptionalIntArray(_: {
1926-
let __count = Int(_swift_js_pop_array_length())
1926+
let __count = Int(_swift_js_pop_i32())
19271927
var __result: [Optional<Int>] = []
19281928
__result.reserveCapacity(__count)
19291929
for _ in 0 ..< __count {
@@ -1948,7 +1948,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalIntArray(_ _self: UnsafeMutable
19481948
public func _bjs_ArrayRoundtrip_takeOptionalPointArray(_ _self: UnsafeMutableRawPointer) -> Void {
19491949
#if arch(wasm32)
19501950
ArrayRoundtrip.bridgeJSLiftParameter(_self).takeOptionalPointArray(_: {
1951-
let __count = Int(_swift_js_pop_array_length())
1951+
let __count = Int(_swift_js_pop_i32())
19521952
var __result: [Optional<Point>] = []
19531953
__result.reserveCapacity(__count)
19541954
for _ in 0 ..< __count {
@@ -1983,7 +1983,7 @@ public func _bjs_ArrayRoundtrip_makeOptionalPointArray(_ _self: UnsafeMutableRaw
19831983
public func _bjs_ArrayRoundtrip_roundtripOptionalPointArray(_ _self: UnsafeMutableRawPointer) -> Void {
19841984
#if arch(wasm32)
19851985
let ret = ArrayRoundtrip.bridgeJSLiftParameter(_self).roundtripOptionalPointArray(_: {
1986-
let __count = Int(_swift_js_pop_array_length())
1986+
let __count = Int(_swift_js_pop_i32())
19871987
var __result: [Optional<Point>] = []
19881988
__result.reserveCapacity(__count)
19891989
for _ in 0 ..< __count {
@@ -2012,7 +2012,7 @@ public func _bjs_ArrayRoundtrip_takeOptionalArray(_ _self: UnsafeMutableRawPoint
20122012
return Optional<[Int]>.none
20132013
} else {
20142014
return {
2015-
let __count = Int(_swift_js_pop_array_length())
2015+
let __count = Int(_swift_js_pop_i32())
20162016
var __result: [Int] = []
20172017
__result.reserveCapacity(__count)
20182018
for _ in 0 ..< __count {
@@ -2069,7 +2069,7 @@ public func _bjs_ArrayRoundtrip_roundtripOptionalArray(_ _self: UnsafeMutableRaw
20692069
return Optional<[Int]>.none
20702070
} else {
20712071
return {
2072-
let __count = Int(_swift_js_pop_array_length())
2072+
let __count = Int(_swift_js_pop_i32())
20732073
var __result: [Int] = []
20742074
__result.reserveCapacity(__count)
20752075
for _ in 0 ..< __count {

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ struct StackCodegen {
856856
let swiftTypeName = elementType.swiftType
857857
return """
858858
{
859-
let __count = Int(_swift_js_pop_array_length())
859+
let __count = Int(_swift_js_pop_i32())
860860
var __result: [\(raw: swiftTypeName)] = []
861861
__result.reserveCapacity(__count)
862862
for _ in 0..<__count {

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ public struct BridgeJSLink {
257257
"let \(JSGlueVariableScope.reservedTmpParamPointers) = [];",
258258
"let \(JSGlueVariableScope.reservedTmpStructCleanups) = [];",
259259
"let \(JSGlueVariableScope.reservedTmpRetArrayLengths) = [];",
260-
"let \(JSGlueVariableScope.reservedTmpParamArrayLengths) = [];",
261260
"const \(JSGlueVariableScope.reservedEnumHelpers) = {};",
262261
"const \(JSGlueVariableScope.reservedStructHelpers) = {};",
263262
"",
@@ -446,11 +445,6 @@ public struct BridgeJSLink {
446445
printer.write("\(JSGlueVariableScope.reservedTmpRetArrayLengths).push(len | 0);")
447446
}
448447
printer.write("}")
449-
printer.write("bjs[\"swift_js_pop_array_length\"] = function() {")
450-
printer.indent {
451-
printer.write("return \(JSGlueVariableScope.reservedTmpParamArrayLengths).pop();")
452-
}
453-
printer.write("}")
454448
printer.write("bjs[\"swift_js_struct_cleanup\"] = function(cleanupId) {")
455449
printer.indent {
456450
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
@@ -32,7 +32,6 @@ final class JSGlueVariableScope {
3232
static let reservedTmpParamPointers = "tmpParamPointers"
3333
static let reservedTmpStructCleanups = "tmpStructCleanups"
3434
static let reservedTmpRetArrayLengths = "tmpRetArrayLengths"
35-
static let reservedTmpParamArrayLengths = "tmpParamArrayLengths"
3635
static let reservedEnumHelpers = "enumHelpers"
3736
static let reservedStructHelpers = "structHelpers"
3837

@@ -63,7 +62,6 @@ final class JSGlueVariableScope {
6362
reservedTmpParamPointers,
6463
reservedTmpStructCleanups,
6564
reservedTmpRetArrayLengths,
66-
reservedTmpParamArrayLengths,
6765
reservedEnumHelpers,
6866
reservedStructHelpers,
6967
]
@@ -2172,7 +2170,7 @@ struct IntrinsicJSFragment: Sendable {
21722170
}
21732171
}
21742172
printer.write("}")
2175-
printer.write("\(JSGlueVariableScope.reservedTmpParamArrayLengths).push(\(arr).length);")
2173+
printer.write("\(JSGlueVariableScope.reservedTmpParamInts).push(\(arr).length);")
21762174
cleanupCode.write("for (const cleanup of \(cleanupArrayVar)) { cleanup(); }")
21772175
return []
21782176
}

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

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

@@ -107,9 +106,6 @@ export async function createInstantiator(options, swift) {
107106
bjs["swift_js_push_array_length"] = function(len) {
108107
tmpRetArrayLengths.push(len | 0);
109108
}
110-
bjs["swift_js_pop_array_length"] = function() {
111-
return tmpParamArrayLengths.pop();
112-
}
113109
bjs["swift_js_struct_cleanup"] = function(cleanupId) {
114110
if (cleanupId === 0) { return; }
115111
const index = (cleanupId | 0) - 1;

0 commit comments

Comments
 (0)