Skip to content

Commit

Permalink
Merge branch 'main' into jc.update-docs-for-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles committed Nov 19, 2024
2 parents a21cf8b + d8fc3c3 commit d6c8003
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 323 deletions.
18 changes: 7 additions & 11 deletions .github/actions/ci-shared-setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
name: "Shared CI setup"
description: "Common setup for CI pipeline workflow jobs"
inputs:
os:
description: "The operating system for downloading binaries"
required: true
runs:
using: "composite"
steps:
- name: Cargo Cache
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
key: cargo-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo
cargo-${{ hashFiles('Cargo.toml') }}
cargo
- name: Cargo Target Cache
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
key: cargo-target-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
${{ runner.os }}-cargo-target
cargo-target-${{ hashFiles('Cargo.toml') }}
cargo-target
- name: Read wasmtime version
id: wasmtime_version
Expand All @@ -35,7 +31,7 @@ runs:
- name: Install wasmtime-cli
shell: bash
run: |
wget -nv 'https://github.com/bytecodealliance/wasmtime/releases/download/v${{ steps.wasmtime_version.outputs.wasmtime_version }}/wasmtime-v${{ steps.wasmtime_version.outputs.wasmtime_version }}-x86_64-${{ inputs.os }}.tar.xz' -O /tmp/wasmtime.tar.xz
wget -nv 'https://github.com/bytecodealliance/wasmtime/releases/download/v${{ steps.wasmtime_version.outputs.wasmtime_version }}/wasmtime-v${{ steps.wasmtime_version.outputs.wasmtime_version }}-x86_64-linux.tar.xz' -O /tmp/wasmtime.tar.xz
mkdir /tmp/wasmtime
tar xvf /tmp/wasmtime.tar.xz --strip-components=1 -C /tmp/wasmtime
echo "/tmp/wasmtime" >> $GITHUB_PATH
4 changes: 2 additions & 2 deletions .github/workflows/build-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
jobs:
compile_plugin:
name: compile_plugin
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand All @@ -34,7 +34,7 @@ jobs:
- name: Install wizer
shell: bash
run: |
wget -nv https://github.com/bytecodealliance/wizer/releases/download/v${{ steps.wizer_version.outputs.WIZER_VERSION }}/wizer-v${{ steps.wizer_version.outputs.WIZER_VERSION }}-x86_64-macos.tar.xz -O /tmp/wizer.tar.xz
wget -nv https://github.com/bytecodealliance/wizer/releases/download/v${{ steps.wizer_version.outputs.WIZER_VERSION }}/wizer-v${{ steps.wizer_version.outputs.WIZER_VERSION }}-x86_64-linux.tar.xz -O /tmp/wizer.tar.xz
mkdir /tmp/wizer
tar xvf /tmp/wizer.tar.xz --strip-components=1 -C /tmp/wizer
echo "/tmp/wizer" >> $GITHUB_PATH
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,13 @@ on:
jobs:
plugin:
name: test_plugin
# We test on `macos-latest` to accurately reflect
# the plugin Wasm binary that we attach to the releases,
# which is built on the latest macOS too.
# This is also helpful for testing fuel
# consumption in tests.
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: ./.github/actions/ci-shared-setup
with:
os: macos

- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
Expand Down Expand Up @@ -65,8 +58,6 @@ jobs:
- uses: actions/checkout@v4

- uses: ./.github/actions/ci-shared-setup
with:
os: linux

- uses: actions/download-artifact@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cli-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
- uses: actions/checkout@v4

- uses: ./.github/actions/ci-shared-setup
with:
os: linux

- name: Build test-plugin
# Need to build Javy default plugin and Javy CLI to run `javy init-plugin` on the test plugin.
run: |
cargo build --package=javy-test-plugin --release --target=wasm32-wasip1
cargo build --package=javy-plugin --release --target=wasm32-wasip1
CARGO_PROFILE_RELEASE_LTO=off cargo build --package=javy-cli --release
cargo build --package=javy-test-plugin --release --target=wasm32-wasip1
target/release/javy init-plugin target/wasm32-wasip1/release/test_plugin.wasm -o crates/runner/test_plugin.wasm
- name: Test `experimental_event_loop`
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/wpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
submodules: true

- uses: ./.github/actions/ci-shared-setup
with:
os: linux

- name: WPT
run: |
Expand Down
5 changes: 0 additions & 5 deletions crates/cli/src/codegen/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ impl CodeGenBuilder {

/// Build a [`CodeGenerator`].
pub fn build(self, ty: CodeGenType, js_runtime_config: JsConfig) -> Result<Generator> {
if let CodeGenType::Dynamic = ty {
if js_runtime_config.has_configs() {
bail!("Cannot set JS runtime options when building a dynamic module")
}
}
let mut generator = Generator::new(ty, js_runtime_config, self.plugin);
generator.source_compression = self.source_compression;
generator.wit_opts = self.wit_opts;
Expand Down
37 changes: 21 additions & 16 deletions crates/cli/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,21 @@ impl Generator {
canonical_abi_realloc_type,
);

let eval_bytecode_type = module.types.add(&[ValType::I32, ValType::I32], &[]);
let (eval_bytecode_fn_id, _) =
module.add_import_func(&import_namespace, "eval_bytecode", eval_bytecode_type);
// User plugins can use `invoke` with a null function name.
// User plugins also won't have an `eval_bytecode` function to
// import. We want to remove `eval_bytecode` from the default
// plugin so we don't want to emit more uses of it.
let eval_bytecode_fn_id = if self.plugin.is_v2_plugin() {
let eval_bytecode_type = module.types.add(&[ValType::I32, ValType::I32], &[]);
let (eval_bytecode_fn_id, _) = module.add_import_func(
&import_namespace,
"eval_bytecode",
eval_bytecode_type,
);
Some(eval_bytecode_fn_id)
} else {
None
};

let invoke_type = module.types.add(
&[ValType::I32, ValType::I32, ValType::I32, ValType::I32],
Expand All @@ -226,7 +238,7 @@ impl Generator {

Ok(Identifiers::new(
canonical_abi_realloc_fn_id,
Some(eval_bytecode_fn_id),
eval_bytecode_fn_id,
invoke_fn_id,
memory_id,
))
Expand Down Expand Up @@ -269,18 +281,12 @@ impl Generator {
.call(eval_bytecode);
} else {
// Assert we're not emitting a call with a null function to
// invoke for `javy_quickjs_provider_v*`.
// `javy_quickjs_provider_v2` will never support calling `invoke`
// with a null function. Older `javy_quickjs_provider_v3`'s do not
// support being called with a null function. User plugins and
// newer `javy_quickjs_provider_v3`s do support being called with a
// null function.
// Using `assert!` instead of `debug_assert!` because integration
// tests are executed with Javy built with the release profile so
// `debug_assert!`s are stripped out.
// invoke for the v2 plugin. `javy_quickjs_provider_v2` will never
// support calling `invoke` with a null function. The default
// plugin and user plugins do accept null functions.
assert!(
self.plugin.is_user_plugin(),
"Using invoke with null function only supported for user plugins"
!self.plugin.is_v2_plugin(),
"Using invoke with null function not supported for v2 plugin"
);
instructions
.local_get(bytecode_ptr_local) // ptr to bytecode
Expand Down Expand Up @@ -500,7 +506,6 @@ mod test {
JsConfig::default(),
Plugin::Default,
);
assert!(!gen.js_runtime_config.has_configs());
assert!(gen.source_compression);
assert!(matches!(gen.plugin, Plugin::Default));
assert_eq!(gen.wit_opts, WitOptions::default());
Expand Down
Loading

0 comments on commit d6c8003

Please sign in to comment.