Skip to content

Commit 516fb9d

Browse files
BridgeJS: Make Stack ABI storage direction agnostic
1 parent 20457f4 commit 516fb9d

Some content is hidden

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

42 files changed

+1268
-1440
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,12 @@ public struct BridgeJSLink {
246246
"let \(JSGlueVariableScope.reservedStorageToReturnOptionalFloat);",
247247
"let \(JSGlueVariableScope.reservedStorageToReturnOptionalDouble);",
248248
"let \(JSGlueVariableScope.reservedStorageToReturnOptionalHeapObject);",
249-
"let \(JSGlueVariableScope.reservedTmpRetTag) = [];",
250-
"let \(JSGlueVariableScope.reservedTmpRetStrings) = [];",
251-
"let \(JSGlueVariableScope.reservedTmpRetInts) = [];",
252-
"let \(JSGlueVariableScope.reservedTmpRetF32s) = [];",
253-
"let \(JSGlueVariableScope.reservedTmpRetF64s) = [];",
254-
"let \(JSGlueVariableScope.reservedTmpParamInts) = [];",
255-
"let \(JSGlueVariableScope.reservedTmpParamF32s) = [];",
256-
"let \(JSGlueVariableScope.reservedTmpParamF64s) = [];",
257-
"let \(JSGlueVariableScope.reservedTmpRetPointers) = [];",
258-
"let \(JSGlueVariableScope.reservedTmpParamPointers) = [];",
249+
"let \(JSGlueVariableScope.reservedTagStack) = [];",
250+
"let \(JSGlueVariableScope.reservedStringStack) = [];",
251+
"let \(JSGlueVariableScope.reservedI32Stack) = [];",
252+
"let \(JSGlueVariableScope.reservedF32Stack) = [];",
253+
"let \(JSGlueVariableScope.reservedF64Stack) = [];",
254+
"let \(JSGlueVariableScope.reservedPointerStack) = [];",
259255
"let \(JSGlueVariableScope.reservedTmpStructCleanups) = [];",
260256
"const \(JSGlueVariableScope.reservedEnumHelpers) = {};",
261257
"const \(JSGlueVariableScope.reservedStructHelpers) = {};",
@@ -388,22 +384,22 @@ public struct BridgeJSLink {
388384
printer.write("}")
389385
printer.write("bjs[\"swift_js_push_tag\"] = function(tag) {")
390386
printer.indent {
391-
printer.write("\(JSGlueVariableScope.reservedTmpRetTag).push(tag);")
387+
printer.write("\(JSGlueVariableScope.reservedTagStack).push(tag);")
392388
}
393389
printer.write("}")
394390
printer.write("bjs[\"swift_js_push_i32\"] = function(v) {")
395391
printer.indent {
396-
printer.write("\(JSGlueVariableScope.reservedTmpRetInts).push(v | 0);")
392+
printer.write("\(JSGlueVariableScope.reservedI32Stack).push(v | 0);")
397393
}
398394
printer.write("}")
399395
printer.write("bjs[\"swift_js_push_f32\"] = function(v) {")
400396
printer.indent {
401-
printer.write("\(JSGlueVariableScope.reservedTmpRetF32s).push(Math.fround(v));")
397+
printer.write("\(JSGlueVariableScope.reservedF32Stack).push(Math.fround(v));")
402398
}
403399
printer.write("}")
404400
printer.write("bjs[\"swift_js_push_f64\"] = function(v) {")
405401
printer.indent {
406-
printer.write("\(JSGlueVariableScope.reservedTmpRetF64s).push(v);")
402+
printer.write("\(JSGlueVariableScope.reservedF64Stack).push(v);")
407403
}
408404
printer.write("}")
409405
printer.write("bjs[\"swift_js_push_string\"] = function(ptr, len) {")
@@ -412,32 +408,32 @@ public struct BridgeJSLink {
412408
"const bytes = new Uint8Array(\(JSGlueVariableScope.reservedMemory).buffer, ptr, len)\(sharedMemory ? ".slice()" : "");"
413409
)
414410
printer.write("const value = \(JSGlueVariableScope.reservedTextDecoder).decode(bytes);")
415-
printer.write("\(JSGlueVariableScope.reservedTmpRetStrings).push(value);")
411+
printer.write("\(JSGlueVariableScope.reservedStringStack).push(value);")
416412
}
417413
printer.write("}")
418414
printer.write("bjs[\"swift_js_pop_i32\"] = function() {")
419415
printer.indent {
420-
printer.write("return \(JSGlueVariableScope.reservedTmpParamInts).pop();")
416+
printer.write("return \(JSGlueVariableScope.reservedI32Stack).pop();")
421417
}
422418
printer.write("}")
423419
printer.write("bjs[\"swift_js_pop_f32\"] = function() {")
424420
printer.indent {
425-
printer.write("return \(JSGlueVariableScope.reservedTmpParamF32s).pop();")
421+
printer.write("return \(JSGlueVariableScope.reservedF32Stack).pop();")
426422
}
427423
printer.write("}")
428424
printer.write("bjs[\"swift_js_pop_f64\"] = function() {")
429425
printer.indent {
430-
printer.write("return \(JSGlueVariableScope.reservedTmpParamF64s).pop();")
426+
printer.write("return \(JSGlueVariableScope.reservedF64Stack).pop();")
431427
}
432428
printer.write("}")
433429
printer.write("bjs[\"swift_js_push_pointer\"] = function(pointer) {")
434430
printer.indent {
435-
printer.write("\(JSGlueVariableScope.reservedTmpRetPointers).push(pointer);")
431+
printer.write("\(JSGlueVariableScope.reservedPointerStack).push(pointer);")
436432
}
437433
printer.write("}")
438434
printer.write("bjs[\"swift_js_pop_pointer\"] = function() {")
439435
printer.indent {
440-
printer.write("return \(JSGlueVariableScope.reservedTmpParamPointers).pop();")
436+
printer.write("return \(JSGlueVariableScope.reservedPointerStack).pop();")
441437
}
442438
printer.write("}")
443439
printer.write("bjs[\"swift_js_struct_cleanup\"] = function(cleanupId) {")

0 commit comments

Comments
 (0)