Repository navigation
Implement AssemblyScript WASM UDF ABI - #104606
Conversation
5cf3392 to
14d5083
Compare
|
Workflow [PR], commit [2537e89] Summary: ✅ AI ReviewSummaryThis PR adds the Findings
💡 Nits
Final VerdictStatus: Minimum required actions:
|
14d5083 to
983342c
Compare
There was a problem hiding this comment.
You do a lot of memcpy here while ignoring endianess, I assume we need to cover all those places with proper check and std::byteswap? Maybe a helper functions would help here.
There was a problem hiding this comment.
Added functions and use it for all other ABIs as well
ClickHouse/src/Interpreters/WebAssembly/WasmTypes.h
Lines 25 to 41 in ed4c485
| case WasmValKind::I32: return compartment->invoke<uint32_t>(function_name, wasm_args, stop_token); | ||
| case WasmValKind::I64: return compartment->invoke<int64_t>(function_name, wasm_args, stop_token); | ||
| case WasmValKind::F32: return compartment->invoke<float>(function_name, wasm_args, stop_token); | ||
| case WasmValKind::F64: return compartment->invoke<double>(function_name, wasm_args, stop_token); |
There was a problem hiding this comment.
Do we want to add support for V128 in case it gets supported in the future?
There was a problem hiding this comment.
Added v128 arguments support
| /// runtime init) runs as part of `Linker::instantiate` below — set a very large relative | ||
| /// deadline now so module instantiation can complete. Per-call cancellation is still | ||
| /// handled through the `epoch_deadline_callback` configured in `WasmTimeCompartment`. | ||
| store.context().set_epoch_deadline(std::numeric_limits<uint64_t>::max()); |
There was a problem hiding this comment.
seems like this can allow users to initiate unkillable query if they have an infinite loop on module level.
There was a problem hiding this comment.
That is good catch. It's not assemblyscript specific actually, since start function can appear in any wasm module. I tried to solve it passing stop_token to instantiate and added a testcase https://github.com/ClickHouse/ClickHouse/blob/ed4c48543a19eeed48c9de2588b6ea4683b5c820/tests/queries/0_stateless/wasm/as_infinite_start.ts
4277980 to
5abb531
Compare
|
|
|
||
| **Supported types**: | ||
|
|
||
| - Numeric: `Int8`/`UInt8`, `Int16`/`UInt16` (widened to `i32` at the boundary), `Int32`/`UInt32`, `Int64`/`UInt64`, `Float32`, `Float64` |
There was a problem hiding this comment.
This supported-types list omits Int128 / UInt128, but the implementation and the new as_add128 test support them via v128. Please add them here so the ABI ASSEMBLYSCRIPT docs match the actual behavior.
| for (WasmSizeT i = 0; i + 1 < data.size(); i += 2) | ||
| { | ||
| uint32_t code_unit = static_cast<uint32_t>(data[i]) | (static_cast<uint32_t>(data[i + 1]) << 8); | ||
| /// Naive transcoding: emit ASCII as-is, replace anything else with '?'. |
There was a problem hiding this comment.
decodeAssemblyScriptString currently maps every non-ASCII UTF-16 code unit to '?', so env.abort messages / file names with Unicode become lossy (for example Привет becomes ??????). Since this PR documents that abort surfaces the decoded message and location, can we use real UTF-16LE -> UTF-8 decoding here (similar to appendUTF16LEAsUTF8) instead of ASCII-only fallback?
LLVM Coverage Report
Changed lines: 75.26% (295/392) · Uncovered code |
…blyscipt-abi Implement AssemblyScript WASM UDF ABI
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Documentation entry for user-facing changes