Commit Graph

32 Commits

Author SHA1 Message Date
Takeshi Yoneda
d63c747d53 asm,compiler: reduce allocations during compilation (#936)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-12-20 12:49:47 +09:00
Crypt Keeper
329ccca6b1 Switches from gofmt to gofumpt (#848)
This switches to gofumpt and applies changes, as I've noticed working
in dapr (who uses this) that it finds some things that are annoying,
such as inconsistent block formatting in test tables.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-11-09 05:48:24 +01:00
Takeshi Yoneda
087ab9d9fc amd64: do not load/store higher bits of 32-bit int/float (#742)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-08-12 12:08:20 +08:00
Vladislav
ec1f595225 Optimize memory bulk operations: fill on x86 (#735)
Signed-off-by: Vladislav Oleshko <vladislav.oleshko@gmail.com>
2022-08-11 12:06:26 +08:00
Vladislav
63e438aa66 Optimize memory bulk operations: copy on x86 (#700)
Signed-off-by: Vladislav Oleshko <vladislav.oleshko@gmail.com>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2022-07-26 18:22:47 +09:00
Takeshi Yoneda
c5f1d84914 asm: backfills unit tests and fixes node formatting (#669)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-30 11:07:35 +09:00
Takeshi Yoneda
cbe6170473 compiler: always allocate register to save conditional values (#666)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-29 09:26:50 +09:00
Takeshi Yoneda
2fa67b83bf asm(amd64): resolve NOP padding TODO after golang-asm removal (#663)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-28 09:39:19 +09:00
Takeshi Yoneda
b8c94fd0b9 asm: remove integration tests with golang-asm (#659)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-28 09:19:21 +09:00
Takeshi Yoneda
3b4544ee48 compiler: remove embedding of pointers of jump tables (#650)
This removes the embedding of pointers of jump tables (uintptr of []byte)
used by BrTable operations. That is the last usage of unsafe.Pointer in
compiler implementations.
Alternatively, we treat jump tables as asm.StaticConst and emit them
into the constPool already implemented and used by various places.

Notably, now the native code compiled by compilers can be reusable
across multiple processes, meaning that they are independent of
any runtime pointers.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-23 13:42:46 +09:00
Takeshi Yoneda
4136a360ac amd64: removes embeddings of pointers of bit masks for FP arithmetic (#648)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-22 13:31:26 +09:00
Takeshi Yoneda
8a2776c2b4 arm64: implement SIMD Integer arithmetics (#641)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-20 15:04:20 +09:00
Takeshi Yoneda
3068d17c77 interpreter,compiler(amd64): complete SIMD instructions (#624)
This completes the implementation of SIMD proposal for both
the interpreter and compiler(amd64).
This also fixes #210 by adding the complete documentation
over all the wazeroir operations.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2022-06-15 11:52:47 +09:00
Takeshi Yoneda
94d1d31733 SIMD: implements comparison instructions (#617)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
2022-06-03 16:04:08 +09:00
Takeshi Yoneda
6e458acdbc SIMD: implements bitshift operations (#613)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-02 16:51:57 +09:00
Takeshi Yoneda
2e131a1a2c SIMD: implements boolean and bitwise instructions. (#611)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-01 16:42:35 +09:00
Takeshi Yoneda
41a3dd341c Backfill func validation unit tests for SIMD load, store, and lane manipulations (#609)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-01 12:18:08 +09:00
Takeshi Yoneda
0c303258c7 SIMD: implements v128 load, store and lane manipulations. (#588)
This implements various SIMD instructions related to
load, store, and lane manipulations for all engines.

Notablely, now our engines pass the following specification tests:

* simd_address.wast
* simd_const.wast
* simd_align.wast
* simd_laod16_lane.wast
* simd_laod32_lane.wast
* simd_laod64_lane.wast
* simd_laod8_lane.wast
* simd_lane.wast
* simd_load_extend.wast
* simd_load_splat.wast
* simd_load_zero.wast
* simd_store.wast
* simd_store16_lane.wast
* simd_store32_lane.wast
* simd_store64_lane.wast
* simd_store8_lane.wast

part of #484


Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2022-06-01 09:30:05 +09:00
Anuraag Agrawal
296b5f56b7 Follows go style for amd64 constants. (#586)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-05-23 12:51:37 +09:00
Anuraag Agrawal
ec3ada35a0 Use correct pattern for table tests everywhere (#582)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-05-20 16:55:01 +09:00
Takeshi Yoneda
9a9b361ac8 Vector values support in ahead-of-time compiler (#572)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-05-19 11:02:15 -06:00
Anuraag Agrawal
685492583b Applies some automatic lint fixes. (#578)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-05-19 21:39:46 +09:00
Anuraag Agrawal
fe8d12f187 Renames asm packages to match folder name (#568)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-05-17 11:48:44 +09:00
Crypt Keeper
c815060196 Renames JIT to Compiler and notes it is AOT (#564)
This notably changes NewRuntimeJIT to NewRuntimeCompiler as well renames
packages from jit to compiler.

This clarifies the implementation is AOT, not JIT, at least when
clarified to where it occurs (Runtime.CompileModule). In doing so, we
reduce any concern that compilation will happen during function
execution. We also free ourselves to create a JIT option without
confusion in the future via CompileConfig or otherwise.

Fixes #560

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-05-17 08:50:56 +09:00
Takeshi Yoneda
68756acbd5 bulk memory: memory.{fill, copy, init} and data.drop (#504)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-04-27 13:22:32 +08:00
Takeshi Yoneda
cd7dfee636 Adds support for nontrapping float to int conversion proposal (#490)
This commit adds support for "nontrapping float to int conversion" proposal
which is one of the finished proposals at this point and is included in the 2.0 draft.

https://github.com/WebAssembly/spec/blob/main/proposals/nontrapping-float-to-int-conversion/Overview.md

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2022-04-23 21:33:26 +09:00
Crypt Keeper
ce1052a097 Isolates testify to one file, so that it is easier to remove (#460)
This starts the process of removing all dependencies from wazero, by
isolating all assertions we use into a single file. This allows us to
port those assertions as we have time, and when twitchy is gone, the
project literally has no dependencies except go!

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-04-14 10:05:38 +08:00
Takeshi Yoneda
8fc5d36efa jit: decouple compiled code from moduleInstance's pointer (#454)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-04-13 11:29:47 +09:00
Takeshi Yoneda
ecb35e2b94 asm: complete arm64 instruction encodings for homemade assembler (#431)
This commit implements all the arm64 instruction encodings necessary
for our JIT compiler and replaces the golang-asm assembler with our
handmade assembler on arm64 platform. Notably, this allows us to do
concurrent compilations.

This closes #233 combined with #406.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2022-04-12 09:13:27 +09:00
Crypt Keeper
2664b1eb62 Simplifies API per feedback (#427)
During #425, @neilalexander gave constructive feedback that the API is
both moving fast, and not good enough yet. This attempts to reduce the
incidental complexity at the cost of a little conflation.

### odd presence of `wasm` and `wasi` packages -> `api` package

We had public API packages in wasm and wasi, which helped us avoid
leaking too many internals as public. That these had names that look
like there should be implementations in them cause unnecessary
confusion. This squashes both into one package "api" which has no
package collission with anything.

We've long struggled with the poorly specified and non-uniformly
implemented WASI specification. Trying to bring visibility to its
constraints knowing they are routinely invalid taints our API for no
good reason. This removes all `WASI` commands for a default to invoke
the function `_start` if it exists. In doing so, there's only one path
to start a module.

Moreover, this puts all wasi code in a top-level package "wasi" as it
isn't re-imported by any internal types.

### Reuse of Module for pre and post instantiation to `Binary` -> `Module`

Module is defined by WebAssembly in many phases, from decoded to
instantiated. However, using the same noun in multiple packages is very
confusing. We at one point tried a name "DecodedModule" or
"InstantiatedModule", but this is a fools errand. By deviating slightly
from the spec we can make it unambiguous what a module is.

This make a result of compilation a `Binary`, retaining `Module` for an
instantiated one. In doing so, there's no longer any name conflicts
whatsoever.

### Confusion about config -> `ModuleConfig`

Also caused by splitting wasm into wasm+wasi is configuration. This
conflates both into the same type `ModuleConfig` as it is simpler than
trying to explain a "will never be finished" api of wasi snapshot-01 in
routine use of WebAssembly. In other words, this further moves WASI out
of the foreground as it has been nothing but burden.

```diff
--- a/README.md
+++ b/README.md
@@ -49,8 +49,8 @@ For example, here's how you can allow WebAssembly modules to read
-wm, err := r.InstantiateModule(wazero.WASISnapshotPreview1())
-defer wm.Close()
+wm, err := wasi.InstantiateSnapshotPreview1(r)
+defer wm.Close()

-sysConfig := wazero.NewSysConfig().WithFS(os.DirFS("/work/home"))
-module, err := wazero.StartWASICommandWithConfig(r, compiled, sysConfig)
+config := wazero.ModuleConfig().WithFS(os.DirFS("/work/home"))
+module, err := r.InstantiateModule(binary, config)
 defer module.Close()
 ...
```
2022-04-02 06:42:36 +08:00
Takeshi Yoneda
a351daa858 asm(amd64): ROL and ROR on Register To Memory type. (#423)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-03-31 15:36:38 +09:00
Takeshi Yoneda
be3aed46be asm: complete amd64 instruction encodings (#406)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
2022-03-31 13:30:38 +08:00