aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api')
-rw-r--r--ext/wasm/api/sqlite3-api-glue.js39
-rw-r--r--ext/wasm/api/sqlite3-wasm.c8
2 files changed, 22 insertions, 25 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js
index 239af7c9a..7db23bacc 100644
--- a/ext/wasm/api/sqlite3-api-glue.js
+++ b/ext/wasm/api/sqlite3-api-glue.js
@@ -26,17 +26,21 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
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'.
+ Please keep this block around as a maintenance reminder
+ that we cannot rely on this type of check.
+
+ This block fails on Safari, per a report at
+ https://sqlite.org/forum/forumpost/e5b20e1feb.
+
+ It turns out that what Safari serves from the indirect function
+ table (e.g. wasm.functionEntry(X)) is anonymous functions which
+ wrap the WASM functions, rather than returning the WASM
+ functions themselves. That means comparison of such functions
+ is useless for determining whether or not we have a specific
+ function from wasm.exports. i.e. if function X is indirection
+ function table entry N then wasm.exports.X is not equal to
+ wasm.functionEntry(N) in Safari, despite being so in the other
+ browsers.
*/
/**
Find a mapping for SQLITE_WASM_DEALLOC, which the API
@@ -809,16 +813,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
capi[e[0]] = e[1];
}
}
- /* Exporting SQLITE_WASM_DEALLOC via the wasm.ctype entries fails
- in Safari. One final thing to try: */
- capi.SQLITE_WASM_DEALLOC = wasm.exports.sqlite3_wasm_ptr_to_sqlite3_free();
- 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.");
+ if(!wasm.functionEntry(capi.SQLITE_WASM_DEALLOC)){
+ toss("Internal error: cannot resolve exported function",
+ "entry SQLITE_WASM_DEALLOC (=="+capi.SQLITE_WASM_DEALLOC+").");
}
const __rcMap = Object.create(null);
for(const t of ['resultCodes']){
diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c
index ba629481c..e7513509c 100644
--- a/ext/wasm/api/sqlite3-wasm.c
+++ b/ext/wasm/api/sqlite3-wasm.c
@@ -464,12 +464,8 @@ const char * sqlite3_wasm_enum_json(void){
/* SQLITE_STATIC/TRANSIENT need to be handled explicitly as
** integers to avoid casting-related warnings. */
out("\"SQLITE_STATIC\":0, \"SQLITE_TRANSIENT\":-1");
-#if 0
- /* This approach to exporting SQLITE_WASM_DEALLOC as a pointer to
- sqlite3_free fails in Safari. */
outf(",\"SQLITE_WASM_DEALLOC\": %lld",
(sqlite3_int64)(sqlite3_free));
-#endif
} _DefGroup;
DefGroup(changeset){
@@ -1597,6 +1593,9 @@ int sqlite3_wasm_config_j(int op, sqlite3_int64 arg){
return sqlite3_config(op, arg);
}
+#if 0
+// Pending removal after verification of a workaround discussed in the
+// forum post linked to below.
/*
** This function is NOT part of the sqlite3 public API. It is strictly
** for use by the sqlite project's own JS/WASM bindings.
@@ -1622,6 +1621,7 @@ SQLITE_WASM_KEEP
void * sqlite3_wasm_ptr_to_sqlite3_free(void){
return (void*)sqlite3_free;
}
+#endif
#if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS)
#include <emscripten/wasmfs.h>