18 Commits

Author SHA1 Message Date
Guy Bedford dc01f95c01 feat: support top-level resources (#525) 2024-11-21 14:43:10 -08:00
Guy Bedford 1f85139522 fix: resource shadowing cross-reference case (#340) 2024-01-15 10:01:41 -08:00
Ivan Enderlin fa0832ed76 feat: Allow --instantiation to generate non-async code (#254)
* feat: Allow `--instantiation` to generate non-async code.

The goal of this patch is to allow `--instantiation` to generate non-
async code as discussed in
https://github.com/bytecodealliance/jco/issues/245.

First off, this patch updates the `--instantiation` option to receive
a string value instead of a being a switch. The possible values are
`async` (the default) or `sync`. The fact that `async` is the default
value ensures the backward compatibility.

Next, this patch updates the `TranspileOpts::instantiation` field to be
`Option<InstantiationMode>` instead of `bool`. `InstantiationMode` is a
enum with 2 variants: `Async` and `Sync`. The code is updated
accordingly.

Finally, the same patch adds non-async code during the bindgen pass.

Everything is done in one patch in order to be atomic.

Note: `function_bindgen.rs` is updated to improve an error message. It's
helpful when one needs to debug its code.

* test: Allow multiple test files per fixture.

This patch allows one fixture to be tested by multiple test files.

* test: Add the `strings.sync.ts` test.

* chore: Rename and simplify the `instantiate` signature.

`compileCore` becomes `getCoreModule`, and its function type
definition is now `(path: string)` instead of `(path: string, imports:
Record<string, any>)`.
2023-11-14 11:32:00 -08:00
Guy Bedford 6de98be626 fix: resource deduping (#190)
* fix: resource deduping

* fixup
2023-10-13 15:51:04 -07:00
Guy Bedford 3013f9459b feat: nodejs refactoring, windows support (#174) 2023-10-12 16:26:11 -07:00
Guy Bedford 506fd7bbbb deps: upgrade toolchain & WASI versions to latest (#162) 2023-09-20 12:47:49 -07:00
Guy Bedford 80881dcb79 feat: initial resources implementation (#128) 2023-08-18 17:35:55 -07:00
Guy Bedford f1a512f07e fix: identifier naming bug (#126) 2023-08-08 14:11:22 -07:00
Alex Crichton 31d3eab095 Support polyfilling multi-memory (#125)
* Support polyfilling multi-memory

Currently JS does not generally support the WebAssembly multi-memory
proposal. Wasmtime will, however, generate adapter modules which use
multi-memory to communicate between components. This means that composed
components are typically not compatible with the transpile process as
they produce a core module that doesn't actually run in any JS runtime.

This commit fixes this issue by adding polyfill support for
multi-memory. Whenever an adapter is produced that uses multi-memory jco
will now rewrite the module such that any references to memory that
isn't at index 0 to be indirected through functions. These imported
functions then operate on the specified memory on behalf of the wasm
itself. This is a horribly slow process because all memory reads/writes
become function calls, but given that the baseline is otherwise "does
not work" it's hopefully a bit better than before.

The end goal here is to work up towards strings between components, but
for now this just gets everything else working with multi-memory such as
transferring lists.

* Fill out comments

---------

Co-authored-by: Guy Bedford <gbedford@fastly.com>
2023-08-08 11:48:41 -07:00
Guy Bedford 5c78de8674 deps: latest toolchain (#86) 2023-06-13 11:48:03 -07:00
Guy Bedford 3d2f8725ec Wasi FS support (#77)
* feat: use wasi for internal builds

* finish basic fs support

* filesystem base-level support and better debugging

* fixup tests

* linting fixes

* remove log

* toolchain upgrade

* add preview2 shim dependency
2023-05-16 17:39:48 -07:00
Guy Bedford b3063ff95c fix: preview2 latest APIs (#54) 2023-03-23 15:33:09 -07:00
Guy Bedford bc767da6db Rename to jco (#32) 2023-02-16 18:14:05 -08:00
Guy Bedford 16609ee955 deps: latest toolchain updates (bytecodealliance/wit-bindgen#457) (#16) 2023-01-26 00:43:44 +02:00
Guy Bedford 6be20ae73a feat: rename --asm to --js 2023-01-03 19:32:26 +02:00
Guy Bedford 3ebb8e4620 fix ci 2022-12-21 15:54:14 -08:00
Guy Bedford d18b2d11ba fixup tests & asm.js cases 2022-12-21 15:54:14 -08:00
Guy Bedford a3bbd41d8c setup tests 2022-12-21 15:54:14 -08:00