Commit Graph

59 Commits

Author SHA1 Message Date
Takeshi Yoneda
a1706eb05c asm(arm64): fixes stack pointer add/sub for large consts (#962)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-12-26 16:26:23 +09:00
Takeshi Yoneda
69688468f8 asm(arm64): adds UDF instruction (#961)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-12-26 15:58:35 +09:00
Takeshi Yoneda
3d70c85032 asm(arm64): adds support for stack pointer manipulation (#960)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-12-26 10:07:13 +09:00
Crypt Keeper
796fca4689 cli: adds compile command and -cachedir option (#945)
This adds a `compile` command and a `-cachedir` option to expose our
compilation cache to end users. This allows substantial speedup
especially for large wasm.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-12-20 13:56:29 +08:00
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
Takeshi Yoneda
76ed3047cf arm64: adds support for large in-block jumps with ADR (#851)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-11-10 05:46:46 +01:00
Crypt Keeper
7e3cda8680 Adds more context for ADR offset overrun (#850)
See #847

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-11-09 08:27:10 +01: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
Takeshi Yoneda
c5daf5a218 interpreter,compiler(arm64): clears higher bits in i32.load_8/16_s (#725)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-07-28 15:45:07 +09: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
97e3216eb2 asm(arm64): fixes the source register of CMEQ(vector,zero) (#719)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-07-26 15:59:45 +09:00
Takeshi Yoneda
37d2c6d803 asm(arm64): fixes unaligned vector stores (#718)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-07-26 12:10:26 +09:00
Crypt Keeper
939403c10b Makes it possible to implement FunctionListener and Factory (#716)
This simplifies FunctionListener definition by making it possible to
implement both interfaces without intermediate state. Passing the
function definition to the before/after callbacks is the key.

This also continues efforts towards Go 1.19 doc formatting.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-07-25 12:53:41 +08:00
Anuraag Agrawal
66d43a2a52 Fix computation of offset in arm64 compiler (#677)
* Fix computation of offset in arm64 compiler

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-07-07 16:13:00 +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
fd318d4be9 asm: unexport arm64 pkg implementations (#657)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-26 20:26:22 +09:00
Takeshi Yoneda
1489a9f19f arm64: remove golang-asm integeration test (#655)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-24 14:49:50 +09:00
Takeshi Yoneda
70a69c24d0 arm64: remove CompileJumpToMemory (#654)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-24 12:14:56 +09:00
Takeshi Yoneda
c983e2c972 Delete debug assembler (#652)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-23 16:22:58 +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
b0588a98c9 Completes arm64 backend for SIMD instructions (#644)
This completes the implementation of arm64 backend for SIMD instructions.
Notably, now the arm64 compiler passes 100% of WebAssemby 2.0 draft
specification tests.

Combined with the completion of the interpreter and amd64 backend (#624),
this finally resolves #484. Therefore, this also documents that wazero is
100% compatible with WebAssembly 1.0 and 2.0.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-21 10:51:02 +09:00
Takeshi Yoneda
fdfcd47224 arm64: SIMD extadd, extmul, int-to-int/float-to-int conversions (#642)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-20 17:28:23 +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
2301afd94b arm64: FP SIMD arithmetic/rounding instructions (#634)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-20 09:08:08 +09:00
Takeshi Yoneda
cd00799b57 arm64: implement vector comparisons (#632)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-17 14:50:57 +09:00
Takeshi Yoneda
338652a182 arm64: bitwise, bit shift, boolean SIMD instructions (#628)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-06-17 12:31:23 +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
4b0084217e Follows go style for arm64 constants. (#587)
* Follows go style for arm64 constants.

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>

* ZERO -> RZR

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2022-05-23 16:30:08 +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
Takeshi Yoneda
e42dac040a compiler(arm64): allow large type index during compilation (#584)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-05-23 10:25:32 +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
db465e512e ci: upgrade golangci-lint, enable matrix on check job (#539)
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-05-11 07:10:25 +08:00
Crypt Keeper
8f8c9ee205 Extracts CompileConfig and consolidates code. (#533)
This performs several changes to allow compilation config to be
centralized and scoped properly. The immediate effects are that we can
now process external types during `Runtime.CompileModule` instead of
doing so later during `Runtime.InstantiateModule`. Another nice side
effect is memory size problems can err at a source line instead of
having to be handled in several places.

There are some API effects to this, and to pay for them, some less used
APIs were removed. The "easy APIs" are left alone. For example, the APIs
to compile and instantiate a module from Go or Wasm in one step are left
alone.

Here are the changes, some of which are only for consistency. Rationale
is summarized in each point.
* ModuleBuilder.Build -> ModuleBuilder.Compile
  * The result of this is similar to `CompileModule`, and pairs better
    with `ModuleBuilder.Instantiate` which is like `InstantiateModule`.
* CompiledCode -> CompiledModule
  * We punted on this name, the result is more than just code. This is
    better I think and more consistent as it introduces less terms.
* Adds CompileConfig param to Runtime.CompileModule.
  * This holds existing features and will have future ones, such as
    mapping externtypes to uint64 for wasm that doesn't yet support it.
* Merges Runtime.InstantiateModuleWithConfig with Runtime.InstantiateModule
  * This allows us to explain APIs in terms of implicit or explicit
    compilation and config, vs implicit, kindof implicit, and explicit.
* Removes Runtime.InstantiateModuleFromCodeWithConfig
  * Similar to above, this API only saves the compilation step and also
    difficult to reason with from a name POV.
* RuntimeConfig.WithMemory(CapacityPages|LimitPages) -> CompileConfig.WithMemorySizer
  * This allows all error handling to be attached to the source line
  * This also allows someone to reduce unbounded memory while knowing
    what its minimum is.
* ModuleConfig.With(Import|ImportModule) -> CompileConfig.WithImportRenamer
  * This allows more types of import manipulation, also without
    conflating functions with globals.
* Adds api.ExternType
  * Needed for ImportRenamer and will be needed later for ExportRenamer.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-05-09 11:02:32 +08:00
Takeshi Yoneda
266320e257 Complete bulk memory operations proposal (#511)
This commit implements the rest of the unimplemented instructions in the
bulk-memory-operations proposal.

Notably, this adds support for table.init, table.copy and elem.drop
instructions toggled by FeatureBulkMemoryOperations.

Given that, now wazero has the complete support for the  bulk-memory-operations
proposal as described in https://github.com/WebAssembly/spec/blob/main/proposals/bulk-memory-operations/Overview.md

fixes #321

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-04-28 15:08:24 +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