summaryrefslogtreecommitdiff
path: root/src/interp/interp-wasm-c-api.cc
Commit message (Collapse)AuthorAgeFilesLines
* Add support for the custom-page-sizes proposal (#2502)Keith Winstein2024-11-081-1/+4
| | | | This adds support in the binary/text parsers and writers, the validator and interpreter, and objdump (but not wasm2c).
* Update wasm-c-api support to current API (#2172)Keith Winstein2023-03-141-30/+32
| | | | | Updates wasm-c-api submodule Fixes #1600
* Replace MakeUnique with c++14 std::make_unique (#2152)Keith Winstein2023-02-271-15/+17
|
* Move headers to include/wabt/ (#1998)Alex Reinking2022-09-281-6/+6
| | | This makes things easier for users and packagers of libwabt.
* Clang-format codebase (#1684)Heejin Ahn2021-12-201-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This applies clang-format to the whole codebase. I noticed we have .clang-format in wabt but the codebase is not very well formatted. This kind of mass-formatting PR has fans and skeptics because it can mess with `git blame`, but we did a similar thing in Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in WebAssembly/binaryen#2059) and it was not very confusing after all. If we are ever going to format the codebase, I think it is easier to do it in a single big PR than dozens of smaller PRs. This is using the existing .clang-format file in this repo, which follows the style of Chromium. If we think this does not suit the current formatting style, we can potentially tweak .clang-format too. For example, I noticed the current codebase puts many `case` statements within a single line when they are short, but the current .clang-format does not allow that. This does not include files in src/prebuilt, because they are generated. This also manually fixes some comment lines, because mechanically applying clang-format to long inline comments can look weird. I also added a clang-format check hook in the Github CI in #1683, which I think can be less controversial, given that it only checks the diff. --- After discussions, we ended up reverting many changes, especially one-liner functions and switch-cases, which are too many to wrap in `// clang-format off` and `// clang-format on`. I also considered fixing `.clang-format` to allow those one-liners but it caused a larger churn in other parts. So currently the codebase does not conform to `.clang-format` 100%, but we decided it's fine.
* Fix type names for function references (#1787)Sam Clegg2021-12-131-4/+4
| | | | | | | | This requires `Type::GetName` to return to be dynamicllay created and return `std::string` rather then a `const char*` As this diff shows this type name is only used in textual output and error messages so should this change should not have a effect of binary parse time or the interpreter.
* Add error locations to BinaryReaderInterp (#1780)Sam Clegg2021-12-091-2/+2
| | | | I think it was always intended to work this way but was left as a TODO.
* [EH] Replace event with tag (#1678)Heejin Ahn2021-06-221-2/+2
| | | | | | | | | | | We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161
* Add wasm_importtype_* functions to wasm-c-api (#1586)Ben Smith2021-01-091-0/+43
|
* Use stderr for all logging and error output (#1579)Sam Clegg2020-12-031-1/+1
| | | | I'm not sure why we were using stdout but the convention is normally to write all logging and error message to stderr.
* [wasm-c-api] Implement missing functions (#1461)Ben Smith2020-06-101-0/+32
| | | | | | | | | For now, the wasm-c-api interface in wabt doesn't have its own tests, and relies on the wasm-c-api repo's examples for testing. This means that some functions that are not used in any examples were accidentally omitted. TODO: wabt (or wasm-c-api) should have explicit tests of the API surface.
* Reference types changes to remove subtyping (#1407)Ben Smith2020-05-281-29/+13
| | | | | | | | Main changes: * Rename `anyref` -> `externref` * Remove `nullref` * Rename `hostref` -> `externref` * `ref.null` and `ref.is_null` now have "ref kind" parameter * Add ref kind keywords: `func`, `extern`, `exn`
* Pass current Thread to host function callbacks (#1412)Sam Clegg2020-05-111-4/+4
| | | | | | | | | | | | | | | The for experimental WASI implementation I'm working on the WASI callbacks (implemented as HostFuncs) need to know which module a call is coming from. This is because the implicitly operate on the memory of the calling instance. This approach seems the match the current convention of passing in the Thread in `Func::DoCall`. The purpose here is to allow the HostCall callback to determine from which instance it is being called. An alternative approach that I considered was created different set of WASI HostCall object for each instance so that instance and its memory we bound to the WASI functions.
* Convert Type from an enum into a class (#1350)Ben Smith2020-02-281-2/+2
| | | | | | | | | | | | | | | | | This is similar to the way Opcode is structured, which allows us to hang member functions off of the enumeration. The primary motivator for this change is the GC proposal (and the function-references proposal) where a Type can be parameterized: (type $T (struct ...)) (func (local (ref $T) ... ) In this case the type is ref, with a parameter of the type index. Making Type a class will make it easier to store this additional information.
* New interpreter (#1330)Ben Smith2020-02-211-881/+690
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's modeled closely on the wasm-c-api. All runtime objects are garbage-collected. The GC'd objects are subclasses of `Object` and all stored in the `Store`. GC roots can be created using a RefPtr<T> struct. The `Module` stores no runtime objects, only description structs (named `*Desc`, e.g. `FuncDesc`). Instantiation takes these descriptors and turns them into runtime objects (e.g. `FuncDesc` is used to create a `Func`). Only import-matching occurs during instantiation; all other validation is assumed to have occurred during Module compilation. As with the previous interpreter, the wasm instructions are not executed directly, and instead compiled to an instruction stream that is easier to interpret (e.g. all branches become gotos). It's still a stack machine, though. The previous interpreter would always compile and instantiate in one step, which means that it was always known whether an imported function is a host function or wasm function. As a result, calls between modules that stayed in wasm could be very cheap (just update PC). Now that the module is compiled before instantiation, an imported function call always has to check first, which may be a slight performance hit. One major difference to the structure of the interpreter is that floating-point values are passed directly, instead of using their equivalent bit pattern. This is more convenient in general, but requires annotating all functions with WABT_VECTORCALL so Visual Studio x86 works properly (otherwise floats are passed in the x87 FP stack). Instruction stream decoding/tracing/disassembling is now all handled in the `Istream` class. This reduces a lot of duplication between the three, which makes the logging-all-opcodes and tracing-all-opcodes less valuable, so I've removed them. Here are the changes to files: binary-reader-metadata.{h,cc} -> [removed] interp-{disassemble.trace}.cc -> istream.{h,cc} There are new helper files: interp-util.{h,cc}: Primarily print debugging functions interp-math.h: Templates used for handling wasm math
* Initial WASM C API implementation. (#1250)Sam Clegg2020-01-161-0/+1432
All tests except `threads` pass.