Commit graph

18 commits

Author SHA1 Message Date
Amaan Qureshi
27bc78698d feat(lib): implement Send + Sync for WasmStore 2025-01-21 00:21:35 -05:00
Amaan Qureshi
26d4b19006 build(rust): bump the lib's MSRV to 1.76 2025-01-12 04:47:59 -05:00
Will Lillis
5c6445edea
chore: misc clippy lints 2024-10-06 17:55:00 -04:00
Ryan Patterson
b5e4ef6d9a
clone wasm store engine (#3542)
This resolves https://github.com/tree-sitter/tree-sitter/issues/3454.

This brings the usage of wasmtime::Engine in line with how wasmtime
intends it to be used. All wasmtime functions that receive an Engine
always receive an `&Engine`, never an owned `Engine`.  They are always
responsible for cloning the reference if they need it.

This brings the usage of wasmtime::Engine in line with how TSParser
treats TSLanguages: when setting a language to the parser, the parser is
responsible for cloning the reference to the TSLanguage. It is
counterintuitive for TSParser to have different behavior when receiving
wasmtime_engine_t.

C API users also expect this behavior, see "Memory Management"
[here](https://docs.wasmtime.dev/c-api/wasm_8h.html). Talking about the
C API: without this change, failing to clone the `wasmtime_engine_t`
(which, again, is never something API users need to do in wasmtime) and
then reusing the engine in multiple TSLanguages results in a use after
free. With this change, failing to call `wasm_engine_delete` on your
owned Engine results in a memory leak. Memory leaks are safer than
use-after-free.
2024-08-22 08:01:37 -07:00
Amaan Qureshi
b35efa8f33 style: format imports 2024-04-11 22:35:43 -04:00
Max Brunsfeld
b7fcf9878e Upgrade wasmtime 2024-03-20 18:23:44 -07:00
Max Brunsfeld
8dded3ab60 Fix crash when attempting to load ancient languages via wasm 2024-02-23 11:48:14 -08:00
dundargoc
c8bd6705cf
chore: clippy 2024-02-06 23:34:14 -05:00
Max Brunsfeld
e054de4191 Return an error from build-wasm if scanner uses unavailable functions 2024-02-02 12:04:49 -08:00
Max Brunsfeld
d351f81b4a Release stale instances from wasm store when languages are dropped 2024-01-29 10:17:49 -08:00
Max Brunsfeld
675da7bfe8 Free C error message properly when loading wasm language fails 2023-12-31 10:05:42 -08:00
Max Brunsfeld
13dd76e444 Return an informative error on failing to construct a WasmStore 2023-11-27 17:48:29 -08:00
Max Brunsfeld
6fd7a1e44e Return informative error when load_language fails 2023-11-26 12:15:05 -08:00
Max Brunsfeld
2c0b52eec6 Add a comment about how wasmtime-c-api is linked by cargo 2023-10-27 21:53:31 +01:00
Max Brunsfeld
7715e2477a Use Box::leak when passing wasm engine to C code 2023-10-27 21:32:28 +01:00
Max Brunsfeld
555277a102 Allow testing highlight and tag queries when testing wasm build
Replace non-mutating `ts_parser_wasm_store` function with
`ts_parser_take_wasm_store`, which removes and returns the wasm
store, in order to facilitate single ownership.
2023-01-23 11:46:59 -08:00
Max Brunsfeld
042e6f9d57 Restucture wasm module, return a normal TSLanguage from load_language 2022-11-15 17:14:33 -08:00
Max Brunsfeld
3f1a7f9cd4 Start work on ability to load wasm languages from native lib, via wasmtime 2022-11-15 17:14:33 -08:00