wasi: optimizes args/environ parsing (#885)

While most compilers will only read args/environ once, tools like WAGI
make heavy use of environment, possibly dozens of long variables. This
optimizes both args and environ for this reason and also to setup for
optimizing other functions.

Here are the notable changes:
* eagerly coerce to byte slices instead of strings
* re-use null terminated length for writing values
* avoid loops that call mem.WriteXXX internally

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-12-05 11:07:51 +08:00
committed by GitHub
parent dca3bfa683
commit 6f30a42828
9 changed files with 115 additions and 89 deletions

View File

@@ -639,8 +639,8 @@ func requireSysContext(
) *internalsys.Context {
sysCtx, err := internalsys.NewContext(
max,
args,
environ,
toByteSlices(args),
toByteSlices(environ),
stdin,
stdout,
stderr,