aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-glue.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-10-04 01:11:10 +0000
committerstephan <stephan@noemail.net>2022-10-04 01:11:10 +0000
commit2b776ee2d6d550ab4b106603c0664251bc12259f (patch)
treec1447962b170b0957986bc7437c3f002d6def529 /ext/wasm/api/sqlite3-api-glue.js
parent3c272ba380084e48e583c13898aeac1aa3cc4f86 (diff)
downloadsqlite-2b776ee2d6d550ab4b106603c0664251bc12259f.tar.gz
sqlite-2b776ee2d6d550ab4b106603c0664251bc12259f.zip
Minor cleanups and additions in sqlite3.capi.wasm.pstack.
FossilOrigin-Name: 97bd670d3859bd3f2e62c15065b238b85ef614f26479e56a14be42c5784aedf4
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.js')
-rw-r--r--ext/wasm/api/sqlite3-api-glue.js50
1 files changed, 0 insertions, 50 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.js b/ext/wasm/api/sqlite3-api-glue.js
index 27d75682a..2347a40c0 100644
--- a/ext/wasm/api/sqlite3-api-glue.js
+++ b/ext/wasm/api/sqlite3-api-glue.js
@@ -560,56 +560,6 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
};
}/*sqlite3_prepare_v2/v3()*/;
- if(1){// Extend wasm.pstack, now that the wasm utils are installed
- /**
- Allocates n chunks, each sz bytes, as a single memory block and
- returns the addresses as an array of n element, each holding
- the address of one chunk.
-
- Throws a WasmAllocError if allocation fails.
-
- Example:
-
- ```
- const [p1, p2, p3] = wasm.pstack.allocChunks(3,4);
- ```
- */
- wasm.pstack.allocChunks = (n,sz)=>{
- const mem = wasm.pstack.alloc(n * sz);
- const rc = [];
- let i = 0, offset = 0;
- for(; i < n; offset = (sz * ++i)){
- rc.push(mem + offset);
- }
- return rc;
- };
-
- /**
- A convenience wrapper for allocChunks() which sizes each chunks
- as either 8 bytes (safePtrSize is truthy) or wasm.ptrSizeof (if
- safePtrSize is falsy).
-
- How it returns its result differs depending on its first
- argument: if it's 1, it returns a single pointer value. If it's
- more than 1, it returns the same as allocChunks().
-
- When a returned pointers will refer to a 64-bit value, e.g. a
- double or int64, and that value must be written or fetched,
- e.g. using wasm.setMemValue() or wasm.getMemValue(), it is
- important that the pointer in question be aligned to an 8-byte
- boundary or else it will not be fetched or written properly and
- will corrupt or read neighboring memory.
-
- However, when all pointers involved point to "small" data, it
- is safe to pass a falsy value to save to memory.
- */
- wasm.pstack.allocPtr = (n=1,safePtrSize=true) =>{
- return 1===n
- ? wasm.pstack.alloc(safePtrSize ? 8 : wasm.ptrSizeof)
- : wasm.pstack.allocChunks(n, safePtrSize ? 8 : wasm.ptrSizeof);
- };
- }/*wasm.pstack filler*/
-
{/* Import C-level constants and structs... */
const cJson = wasm.xCall('sqlite3_wasm_enum_json');
if(!cJson){