diff options
author | stephan <stephan@noemail.net> | 2023-01-01 12:22:16 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-01-01 12:22:16 +0000 |
commit | a347927d60c70686c995bd453bd3ca7b1e3f24c8 (patch) | |
tree | 832807f7b6733774f02a52b52c7ecd971dae29c6 /ext/wasm/api/sqlite3-api-glue.js | |
parent | 206db97ddd781f526805a9bea534b90b5565bf05 (diff) | |
download | sqlite-a347927d60c70686c995bd453bd3ca7b1e3f24c8.tar.gz sqlite-a347927d60c70686c995bd453bd3ca7b1e3f24c8.zip |
An alternative solution to mapping SQLITE_WASM_DEALLOC to the proper function pointer in JS, to account for a Safari-specific quirk reported in [forum:e5b20e1feb|forum post e5b20e1feb].
FossilOrigin-Name: 688c5c13d156f987b895df1d5a5b770616b0d9caec4726e03ba122eb8539e7b2
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-glue.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js index 8cb5dff8b..e88694fa3 100644 --- a/ext/wasm/api/sqlite3-api-glue.js +++ b/ext/wasm/api/sqlite3-api-glue.js @@ -24,7 +24,20 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ self.WhWasmUtilInstaller(wasm); delete self.WhWasmUtilInstaller; - { + if(0){ + /** + This block inexplicably fails on Safari, per report at + https://sqlite.org/forum/forumpost/e5b20e1feb. In its place, + we instead add an unsightly snippet to + sqlite3_wasm_enum_json() which emits the SQLITE_WASM_DEALLOC + pointer as an integer. + + "The problem" with that approach is that in order to honor + sqlite3.config.deallocExportName, we have to have the + following loop (or something equivalent). Because we cannot + (for Safari) do so, we are currently implicitly hard-coded to + using sqlite3.config.deallocExportName==='sqlite3_free'. + */ /** Find a mapping for SQLITE_WASM_DEALLOC, which the API guarantees is a WASM pointer to the same underlying function as @@ -796,6 +809,14 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){ capi[e[0]] = e[1]; } } + if(wasm.exports[sqlite3.config.deallocExportName] + !== wasm.functionEntry(capi.SQLITE_WASM_DEALLOC)){ + toss("Internal error: sqlite3.wasm.exports["+ + sqlite3.config.deallocExportName+"]", + "is not the same pointer as SQLITE_WASM_DEALLOC.", + "These must match in order to accommodate allocator-related", + "API guarantees."); + } const __rcMap = Object.create(null); for(const t of ['resultCodes']){ for(const e of Object.entries(wasm.ctype[t])){ |