Commit Graph

224 Commits

Author SHA1 Message Date
Chris Fallin
6e8666826d Docs: add section on running under qemu. 2020-05-18 11:43:53 -07:00
Alex Crichton
f22f415b14 Document cross-compiling Wasmtime (#1721)
Closes #1720
2020-05-18 10:52:00 -05:00
Austin Abell
e40fd9d6ab Fix Wasm from rust docs (#1719)
* Update Wasm from Rust docs

* oops

* oops x2
2020-05-18 06:58:21 -05:00
Alex Crichton
d6b1589926 Fix broken links to old embed.html (#1604)
Closes #1596
2020-04-27 08:43:04 -07:00
Dan Gohman
cfe5c4b8e8 Add a documentation link to the official application-abi.md document. (#1562) 2020-04-21 09:10:52 -05:00
Dan Gohman
9364eb1d98 Refactor (#1524)
* Compute instance exports on demand.

Instead having instances eagerly compute a Vec of Externs, and bumping
the refcount for each Extern, compute Externs on demand.

This also enables `Instance::get_export` to avoid doing a linear search.

This also means that the closure returned by `get0` and friends now
holds an `InstanceHandle` to dynamically hold the instance live rather
than being scoped to a lifetime.

* Compute module imports and exports on demand too.

And compute Extern::ty on demand too.

* Add a utility function for computing an ExternType.

* Add a utility function for looking up a function's signature.

* Add a utility function for computing the ValType of a Global.

* Rename wasmtime_environ::Export to EntityIndex.

This helps differentiate it from other Export types in the tree, and
describes what it is.

* Fix a typo in a comment.

* Simplify module imports and exports.

* Make `Instance::exports` return the export names.

This significantly simplifies the public API, as it's relatively common
to need the names, and this avoids the need to do a zip with
`Module::exports`.

This also changes `ImportType` and `ExportType` to have public members
instead of private members and accessors, as I find that simplifies the
usage particularly in cases where there are temporary instances.

* Remove `Instance::module`.

This doesn't quite remove `Instance`'s `module` member, it gets a step
closer.

* Use a InstanceHandle utility function.

* Don't consume self in the `Func::get*` methods.

Instead, just create a closure containing the instance handle and the
export for them to call.

* Use `ExactSizeIterator` to avoid needing separate `num_*` methods.

* Rename `Extern::func()` etc. to `into_func()` etc.

* Revise examples to avoid using `nth`.

* Add convenience methods to instance for getting specific extern types.

* Use the convenience functions in more tests and examples.

* Avoid cloning strings for `ImportType` and `ExportType`.

* Remove more obviated clone() calls.

* Simplify `Func`'s closure state.

* Make wasmtime::Export's fields private.

This makes them more consistent with ExportType.

* Fix compilation error.

* Make a lifetime parameter explicit, and use better lifetime names.

Instead of 'me, use 'instance and 'module to make it clear what the
lifetime is.

* More lifetime cleanups.
2020-04-20 15:55:33 -05:00
Alex Crichton
44e897ddad Add Go as an embedding to the book (#1481)
* Add Go as an embedding to the book

Also take this time to list out all embeddings in the README of wasmtime
itself.
2020-04-08 11:03:30 -05:00
Peter Huene
9de0ab302c Remove the .NET implementation. (#1477)
This commit removes the .NET implementation from Wasmtime.

It now exists at https://github.com/bytecodealliance/wasmtime-dotnet.

Also updates the Wasmtime book to include information about using Wasmtime from
.NET.
2020-04-06 20:03:49 -05:00
Johnnie Birch
dff789c7c6 Adds JIT profiling support for VTune (#819)
This patch adds initial support for ittapi which is an open
source profiling api for instrumentation and tracing and profiling
of jitted code. Result files can be read by VTune for analysis

Build:
    cargo build --features=vtune
Profile: // Using amplxe-cl from VTune
    amplxe-cl -v -collect hostpost target/debug/wasmtime --vtune test.wasm
2020-04-02 09:04:08 -05:00
Alex Crichton
1a0325014f Remove the wasmtime Python extension from this repo (#1457)
* Remove the wasmtime Python extension from this repo

This commit removes the `crates/misc/py` folder and all associated
doo-dads like CI. This module has been rewritten to use the C API
natively and now lives at
https://github.com/bytecodealliance/wasmtime-py as discussed on #1390
2020-04-01 13:52:59 -05:00
EchoSysBen
00200504b1 correct typo in the docs profiling section (#1442) 2020-03-31 09:22:56 -05:00
Dan Gohman
6c0c9a46f3 Fixes for cargo publish (#1416)
* Publishing fixes.

* Make WASI a symlink.

* More fixes.

* Cargo doesn't allow dev-dependencies to have optional features.

* Remove the symlink.

* Add WASI as another git submodule.
2020-03-26 20:31:12 -07:00
Dan Gohman
5cfcbeb59d Correctly capitalize "WebAssembly" in docs. (#1399) 2020-03-24 21:46:58 -05:00
John Sullivan
222a73c150 Initial documentation for python users (#1378)
* Fix instructions for building rust modules in python examples

When I ran `rustc +nightly ...` the compiler just looked for a source file
called `+nightly`. I changed these instructions to use rustup + rustc instead.

* Initial documentation for python users

Added documentation for using the Wasmtime loader in python, and explained the
first two examples in the repo. Changed the import example to demonstrate
working with module linear memory.

* Fix include in python guide

* Wording

* Clarify memory usage

* Flow through the example better

* More word choice

* Make rustup a prereq

* Fix source code paths in python guide

* Fix rustup example in python guide

Co-Authored-By: Samrat Man Singh <samratmansingh@gmail.com>

* Replace command examples with preformat blocks

* Revert "Fix instructions for building rust modules in python examples"

This reverts commit 1738888a2df4e15aba1e26c8ef42058e7a2053bb.

* Left a block quote in a preformat example

Co-authored-by: Samrat Man Singh <samratmansingh@gmail.com>
2020-03-24 09:44:05 -05:00
Dan Gohman
66460f2139 Miscellaneous doc updates (#1383)
* Add additional links to embedding and tutorial documentation.

* Fix a broken link to CONTRIBUTING.md.

Fixes #1280.
2020-03-23 09:58:08 -07:00
Alex Crichton
e245e6dd9c Add examples of linking and WASI (#1369)
* Add examples of linking and WASI

This commit adds two example programs, one for linking two modules
together and one for instantiating WASI. The linkage example
additionally uses WASI to get some meaningful output at this time.

cc #1272

* Add examples to the book as well

* More links!

* Ignore examples from rustdoc testsing

* More example updates

* More ignored
2020-03-20 18:10:53 -05:00
Alex Crichton
adff432767 Fix build of the book (#1368) 2020-03-20 12:18:57 -05:00
Alex Crichton
3b7cb6ee64 Enable jitdump profiling support by default (#1310)
* Enable jitdump profiling support by default

This the result of some of the investigation I was doing for #1017. I've
done a number of refactorings here which culminated in a number of
changes that all amount to what I think should result in jitdump support being
enabled by default:

* Pass in a list of finished functions instead of just a range to
  ensure that we're emitting jit dump data for a specific module rather
  than a whole `CodeMemory` which may have other modules.
* Define `ProfilingStrategy` in the `wasmtime` crate to have everything
  locally-defined
* Add support to the C API to enable profiling
* Documentation added for profiling with jitdump to the book
* Split out supported/unsupported files in `jitdump.rs` to avoid having
  lots of `#[cfg]`.
* Make dependencies optional that are only used for `jitdump`.
* Move initialization up-front to `JitDumpAgent::new()` instead of
  deferring it to the first module.
* Pass around `Arc<dyn ProfilingAgent>` instead of
  `Option<Arc<Mutex<Box<dyn ProfilingAgent>>>>`

The `jitdump` Cargo feature is now enabled by default which means that
our published binaries, C API artifacts, and crates will support
profiling at runtime by default. The support I don't think is fully
fleshed out and working but I think it's probably in a good enough spot
we can get users playing around with it!
2020-03-20 11:44:51 -05:00
Gabor Greif
1d0026e4f5 Tweak the submodule update command (#1364) 2020-03-19 16:04:44 -05:00
Alex Crichton
f63c3c814e Add a first-class way of accessing caller's exports (#1290)
* Add a first-class way of accessing caller's exports

This commit is a continuation of #1237 and updates the API of `Func` to
allow defining host functions which have easy access to a caller's
memory in particular. The new APIs look like so:

* The `Func::wrap*` family of functions was condensed into one
  `Func::wrap` function.
* The ABI layer of conversions in `WasmTy` were removed
* An optional `Caller<'_>` argument can be at the front of all
  host-defined functions now.

The old way the wasi bindings looked up memory has been removed and is
now replaced with the `Caller` type. The `Caller` type has a
`get_export` method on it which allows looking up a caller's export by
name, allowing you to get access to the caller's memory easily, and even
during instantiation.

* Add a temporary note

* Move some docs
2020-03-18 16:57:31 -05:00
Dan Gohman
3f8fb37b22 Add some high-level sandboxing documentation. (#1353)
* Add some high-level sandboxing documentation.

* Update docs/security-sandboxing.md

Co-Authored-By: Nick Fitzgerald <fitzgen@gmail.com>

* Update docs/security-sandboxing.md

Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>

* Grammar fixes.

* Mention that ANSI-style escape sequences sometimes augment other attacks.

* Fix another wordo.

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-18 12:42:28 -07:00
Nick Fitzgerald
612b806ac3 Update contributing docs with new script name 2020-03-17 12:56:58 -07:00
Prathyush
e2f6c08052 Remove superfluous are (#1326) 2020-03-15 13:15:32 +01:00
Alex Crichton
34f768ddd5 Temporarily remove support for interface types (#1292)
* Temporarily remove support for interface types

This commit temporarily removes support for interface types from the
`wasmtime` CLI and removes the `wasmtime-interface-types` crate. An
error is now printed for any input wasm modules that have wasm interface
types sections to indicate that support has been removed and references
to two issues are printed as well:

* #677 - tracking work for re-adding interface types support
* #1271 - rationale for removal and links to other discussions

Closes #1271

* Update the python extension
2020-03-12 15:05:39 -05:00
Ifenna Ozoekwe-Awagu
67b3a890dc Add tutorial for building and running hello-world.wasm (#1285)
* Add tutorial for building and running hello-world.wasm

* Fix issues with directory trees in last commit

* Add more information on various ways of creating .wasm files and running them with Wasmtime

* Fix internal links and add more information on Wasmtime CLI installation
2020-03-12 10:49:31 -05:00
Dan Gohman
ac0ee271b1 Log to stderr by default. (#1266)
Change the default from file-per-thread-logger to pretty-env-logger,
which is more common in Rust projects, and change the option from `-d`
to `--log-to-files`.
2020-03-10 09:36:56 -05:00
Till Schneidereit
2ee35c9d3a Add instructions to initialize git submodules to build docs 2020-03-09 08:44:19 -07:00
Till Schneidereit
8f824a9fc1 Update outdated references to the Cranelift repository
This patch updates or removes all references to the Cranelift repository. It affects links in README documents, issues that were transferred to the Wasmtime repository, CI badges, and a small bunch of sundry items.
2020-03-09 14:06:24 +01:00
Dan Gohman
fbe29da5cc Miscelaneous docs updates and fixes. (#1249)
Update references to things in CraneStation which have moved, WASI documentation
which has moved to the WASI repo, and fix a few typos.
2020-03-08 16:11:17 +01:00
Alex Crichton
7e09c4c94f Fill out CI docs in the contributing section of the book (#1239)
* Fill out CI docs in the contributing section of the book

Figured it'd be good to document at least at a high level what in the
world is happening on all our PR runs.

* Tweak fuzz test comments
2020-03-06 13:13:52 -06:00
Alex Crichton
85fab0ab56 Expand Func documentation, rewrite Rust embed docs (#1236)
This commit expands the documentation of the `Func` type as well as
updating the Rust embedding tutorial with more recent APIs. I wanted to
also leave space in the Rust tutorial to get more ambitious over time
with what it's documenting, but I stopped around here, curious to see
what others think about it!
2020-03-05 12:54:42 -06:00
Takanori Ishibashi
3848bf54f7 Fix link (#1203) 2020-03-02 08:57:28 -06:00
Alex Crichton
e287a87948 Merge pull request #1021 from ggreif/patch-1
wasmtime now in Bytecode Alliance
2020-02-28 17:40:33 -06:00
Gabor Greif
d7b0644cac wasmtime now in Bytecode Alliance 2020-02-28 23:16:27 +01:00
Alex Crichton
986f9f79e1 Merge the CONTRIBUTING.md files 2020-02-28 09:22:06 -08:00
Alex Crichton
8caa5a9476 Spice up the project README, fill out more docs (#1010)
* Spice up the project README, fill out more docs

This is an attempt to spruce up wasmtime's README.md file as well as
fill out more of the missing documentation in the `docs/` folder.
There's still a long way to go but I hoped here to mostly move around
existing information and add new information. As always happy to have
feedback!

* Tweak CLI wording

* Remove no-longer relevant clause

* Update sandboxing docs

* Handle comments
2020-02-27 17:28:08 -06:00
Alex Crichton
35d5c6bdde Add a RELEASES.md file to track release notes (#1011)
This is intended to be a form of release notes for wasmtime where we can
keep track of what's changed over time in a more dense way than `git
log` that should be interesting for most users.
2020-02-27 13:00:13 -06:00
Dan Gohman
e41cae7db9 Fix the WASI-tutorial to handle short writes properly. (#991)
If write doesn't write the full buffer, start the next write at the
point where the write left off.

Also, usize `ssize_t` for the return types of `read` and `write`.
2020-02-25 23:12:43 -06:00
Alex Crichton
c7fb135452 Test book documentation on CI
Make sure the embedding API follows what's currently implemented!
2020-02-25 08:52:43 -08:00
Gustav Eiman
09a091802b Update rust embed example (#967) (#968)
* Update rust embed example (#967)

Ensures that the example works with the current API.
Drops mention of HostRef as the example is complete without it.

* Cleanup
2020-02-25 09:45:21 -06:00
Alex Crichton
12cff023b6 Document and codify the release process
The `wasmtime` release procees seems like it's been a bit ad-hoc up to
this point, so I figured it'd be good to try to document what we do
today and codify what should be done as well as a form of release
checklist.

I've noticed that we have a number of releases (like v0.11.0) but the
`Cargo.toml` files in the repository don't reflect the current version
of `wasmtime`. Additionally I've noticed that the [most recent release]
ended up having failed tests because `Cargo.toml` was modified but
`Cargo.lock` wasn't updated. I'm hoping that by having a checklist we
can avoid these sorts of accidental issues in the future!

[release]: https://github.com/bytecodealliance/wasmtime/runs/434690272
2020-02-24 10:46:50 -08:00
Benjamin Brittain
372cc9fa7a Update broken URL to Fuchsia docs (#936) 2020-02-12 15:37:09 +01:00
Alex Crichton
045d6a7310 Remove the need for HostRef<Store> (#771)
* Remove the need for `HostRef<Store>`

This commit goes through the public API of the `wasmtime` crate and
removes the need for `HostRef<Store>`, as discussed in #708. This commit
is accompanied with a few changes:

* The `Store` type now also implements `Default`, creating a new
  `Engine` with default settings and returning that.

* The `Store` type now implements `Clone`, and is documented as being a
  "cheap clone" aka being reference counted. As before there is no
  supported way to create a deep clone of a `Store`.

* All APIs take/return `&Store` or `Store` instead of `HostRef<Store>`,
  and `HostRef<T>` is left as purely a detail of the C API.

* The `global_exports` function is tagged as `#[doc(hidden)]` for now
  while we await its removal.

* The `Store` type is not yet `Send` nor `Sync` due to the usage of
  `global_exports`, but it is intended to become so eventually.

* Touch up comments on some examples

* Run rustfmt
2020-01-07 16:29:44 -06:00
Peter Huene
59258730c2 Use structopt instead of docopt.
This commit refactors the Wasmtime CLI tools to use `structopt` instead of
`docopt`.

The `wasmtime` tool now has the following subcommands:

* `config new` - creates a new Wasmtime configuration file.
* `run` - runs a WebAssembly module.
* `wasm2obj` - translates a Wasm module to native object file.
* `wast` - runs a test script file.

If no subcommand is specified, the `run` subcommand is used. Thus,
`wasmtime foo.wasm` should continue to function as expected.

The `wasm2obj` and `wast` tools still exist, but delegate to the same
implementation as the `wasmtime` subcommands.  The standalone `wasm2obj` and
`wast` tools may be removed in the future in favor of simply using `wasmtime`.

Included in this commit is a breaking change to the default Wasmtime
configuration file: it has been renamed from `wasmtime-cache-config.toml` to
simply `config.toml`.  The new name is less specific which will allow for
additional (non-cache-related) settings in the future.

There are some breaking changes to improve command line UX:

* The `--cache-config` option has been renamed to `--config`.
* The `--create-config-file` option has moved to the `config new` subcommand.
As a result, the `wasm2obj` and `wast` tools cannot be used to create a new
config file.
* The short form of the `--optimize` option has changed from
`-o` to `-O` for consistency.
* The `wasm2obj` command takes the output object file as a
required positional argument rather than the former required output *option*
(e.g. `wasmtime wasm2obj foo.wasm foo.obj`).
2020-01-07 13:15:28 -08:00
Alex Crichton
b9dc38f4e1 Remove need for HostRef<Engine> (#762)
This commit removes the need to use `HostRef<Engine>` in the Rust API.
Usage is retained in the C API in one location, but otherwise `Engine`
can always be used directly.

This is the first step of progress on #708 for the `Engine` type.
Changes here include:

* `Engine` is now `Clone`, and is documented as being cheap. It's not
  intended that cloning an engine creates a deep copy.
* `Engine` is now both `Send` and `Sync`, and asserted to be so.
* Usage of `Engine` in APIs no longer requires or uses `HostRef`.
2020-01-06 15:17:03 -06:00
Las
1f8921ef09 Fix typo in WASI-background.md (#755)
"loose" -> "lose"
"waidpid" -> "waitpid"
2019-12-31 12:29:27 -06:00
Mischa Spiegelmock
0e3dcaeb6e typo (#752) 2019-12-31 12:26:02 -06:00
pk
6c97cfed1e Fix broken link to polyfill source (#745)
Fix a broken link to polyfill source
2019-12-24 11:40:59 -08:00
Jonathan Reyes
fe34c8e2e5 Update WASI API C header file path (#717)
The [previous link][1] was 404ing.

[1]: https://github.com/CraneStation/wasi-libc/blob/master/libc-bottom-half/headers/public/wasi/core.h
2019-12-16 10:18:13 -06:00
Cedric Hutchings
bb5f063edf Replace 'traget' with 'target' (#687) 2019-12-09 07:28:32 -08:00