feat: add wasm SIMD support
This makes wasm version of llhttp around 5-6% faster on real-world payloads. The produced code looks roughly like this:
```c
/* Load input */
input = wasm_v128_load(p);
/* Find first character that does not match `ranges` */
single = wasm_i8x16_eq(input, wasm_u8x16_const_splat(0x9));
mask = single;
single = wasm_v128_and(
wasm_i8x16_ge(input, wasm_u8x16_const_splat(' ')),
wasm_i8x16_le(input, wasm_u8x16_const_splat('~'))
);
mask = wasm_v128_or(mask, single);
single = wasm_v128_or(
wasm_i8x16_ge(input, wasm_u8x16_const_splat(0x80)),
wasm_i8x16_le(input, wasm_u8x16_const_splat(0xff))
);
mask = wasm_v128_or(mask, single);
match_len = __builtin_ctz(
~wasm_i8x16_bitmask(mask)
);
```
It is conceptually similar to SSE vectorization that we already support except that we can't multiple comparisons at once and have to check ranges individually.
See previous attempt https://github.com/nodejs/llparse/pull/72
Benchmark: https://gist.github.com/indutny/d18d56fe3c7254d888a79eca98f39145
cc @nodejs/llhttp @mcollina
合并状态:未合并 关闭于 2025-04-19 7 条评论