Skip to content

Commit d6c8003

Browse files
committed
Merge branch 'main' into jc.update-docs-for-plugins
2 parents a21cf8b + d8fc3c3 commit d6c8003

File tree

18 files changed

+131
-323
lines changed

18 files changed

+131
-323
lines changed
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
name: "Shared CI setup"
22
description: "Common setup for CI pipeline workflow jobs"
3-
inputs:
4-
os:
5-
description: "The operating system for downloading binaries"
6-
required: true
73
runs:
84
using: "composite"
95
steps:
106
- name: Cargo Cache
117
uses: actions/cache@v3
128
with:
139
path: ~/.cargo
14-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
10+
key: cargo-${{ hashFiles('Cargo.toml') }}
1511
restore-keys: |
16-
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
17-
${{ runner.os }}-cargo
12+
cargo-${{ hashFiles('Cargo.toml') }}
13+
cargo
1814
1915
- name: Cargo Target Cache
2016
uses: actions/cache@v3
2117
with:
2218
path: target
23-
key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
19+
key: cargo-target-${{ hashFiles('Cargo.toml') }}
2420
restore-keys: |
25-
${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.toml') }}
26-
${{ runner.os }}-cargo-target
21+
cargo-target-${{ hashFiles('Cargo.toml') }}
22+
cargo-target
2723
2824
- name: Read wasmtime version
2925
id: wasmtime_version
@@ -35,7 +31,7 @@ runs:
3531
- name: Install wasmtime-cli
3632
shell: bash
3733
run: |
38-
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
34+
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
3935
mkdir /tmp/wasmtime
4036
tar xvf /tmp/wasmtime.tar.xz --strip-components=1 -C /tmp/wasmtime
4137
echo "/tmp/wasmtime" >> $GITHUB_PATH

.github/workflows/build-assets.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
jobs:
2121
compile_plugin:
2222
name: compile_plugin
23-
runs-on: macos-latest
23+
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v4
2626

@@ -34,7 +34,7 @@ jobs:
3434
- name: Install wizer
3535
shell: bash
3636
run: |
37-
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
37+
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
3838
mkdir /tmp/wizer
3939
tar xvf /tmp/wizer.tar.xz --strip-components=1 -C /tmp/wizer
4040
echo "/tmp/wizer" >> $GITHUB_PATH

.github/workflows/ci.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@ on:
99
jobs:
1010
plugin:
1111
name: test_plugin
12-
# We test on `macos-latest` to accurately reflect
13-
# the plugin Wasm binary that we attach to the releases,
14-
# which is built on the latest macOS too.
15-
# This is also helpful for testing fuel
16-
# consumption in tests.
17-
runs-on: macos-latest
12+
runs-on: ubuntu-latest
1813
steps:
1914
- uses: actions/checkout@v4
2015
with:
2116
submodules: true
2217

2318
- uses: ./.github/actions/ci-shared-setup
24-
with:
25-
os: macos
2619

2720
- name: Install cargo-hack
2821
uses: taiki-e/install-action@cargo-hack
@@ -65,8 +58,6 @@ jobs:
6558
- uses: actions/checkout@v4
6659

6760
- uses: ./.github/actions/ci-shared-setup
68-
with:
69-
os: linux
7061

7162
- uses: actions/download-artifact@v4
7263
with:

.github/workflows/cli-features.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
- uses: actions/checkout@v4
1515

1616
- uses: ./.github/actions/ci-shared-setup
17-
with:
18-
os: linux
1917

2018
- name: Build test-plugin
19+
# Need to build Javy default plugin and Javy CLI to run `javy init-plugin` on the test plugin.
2120
run: |
22-
cargo build --package=javy-test-plugin --release --target=wasm32-wasip1
21+
cargo build --package=javy-plugin --release --target=wasm32-wasip1
2322
CARGO_PROFILE_RELEASE_LTO=off cargo build --package=javy-cli --release
23+
cargo build --package=javy-test-plugin --release --target=wasm32-wasip1
2424
target/release/javy init-plugin target/wasm32-wasip1/release/test_plugin.wasm -o crates/runner/test_plugin.wasm
2525
2626
- name: Test `experimental_event_loop`

.github/workflows/wpt.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
submodules: true
1717

1818
- uses: ./.github/actions/ci-shared-setup
19-
with:
20-
os: linux
2119

2220
- name: WPT
2321
run: |

crates/cli/src/codegen/builder.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ impl CodeGenBuilder {
8484

8585
/// Build a [`CodeGenerator`].
8686
pub fn build(self, ty: CodeGenType, js_runtime_config: JsConfig) -> Result<Generator> {
87-
if let CodeGenType::Dynamic = ty {
88-
if js_runtime_config.has_configs() {
89-
bail!("Cannot set JS runtime options when building a dynamic module")
90-
}
91-
}
9287
let mut generator = Generator::new(ty, js_runtime_config, self.plugin);
9388
generator.source_compression = self.source_compression;
9489
generator.wit_opts = self.wit_opts;

crates/cli/src/codegen/mod.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,21 @@ impl Generator {
203203
canonical_abi_realloc_type,
204204
);
205205

206-
let eval_bytecode_type = module.types.add(&[ValType::I32, ValType::I32], &[]);
207-
let (eval_bytecode_fn_id, _) =
208-
module.add_import_func(&import_namespace, "eval_bytecode", eval_bytecode_type);
206+
// User plugins can use `invoke` with a null function name.
207+
// User plugins also won't have an `eval_bytecode` function to
208+
// import. We want to remove `eval_bytecode` from the default
209+
// plugin so we don't want to emit more uses of it.
210+
let eval_bytecode_fn_id = if self.plugin.is_v2_plugin() {
211+
let eval_bytecode_type = module.types.add(&[ValType::I32, ValType::I32], &[]);
212+
let (eval_bytecode_fn_id, _) = module.add_import_func(
213+
&import_namespace,
214+
"eval_bytecode",
215+
eval_bytecode_type,
216+
);
217+
Some(eval_bytecode_fn_id)
218+
} else {
219+
None
220+
};
209221

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

227239
Ok(Identifiers::new(
228240
canonical_abi_realloc_fn_id,
229-
Some(eval_bytecode_fn_id),
241+
eval_bytecode_fn_id,
230242
invoke_fn_id,
231243
memory_id,
232244
))
@@ -269,18 +281,12 @@ impl Generator {
269281
.call(eval_bytecode);
270282
} else {
271283
// Assert we're not emitting a call with a null function to
272-
// invoke for `javy_quickjs_provider_v*`.
273-
// `javy_quickjs_provider_v2` will never support calling `invoke`
274-
// with a null function. Older `javy_quickjs_provider_v3`'s do not
275-
// support being called with a null function. User plugins and
276-
// newer `javy_quickjs_provider_v3`s do support being called with a
277-
// null function.
278-
// Using `assert!` instead of `debug_assert!` because integration
279-
// tests are executed with Javy built with the release profile so
280-
// `debug_assert!`s are stripped out.
284+
// invoke for the v2 plugin. `javy_quickjs_provider_v2` will never
285+
// support calling `invoke` with a null function. The default
286+
// plugin and user plugins do accept null functions.
281287
assert!(
282-
self.plugin.is_user_plugin(),
283-
"Using invoke with null function only supported for user plugins"
288+
!self.plugin.is_v2_plugin(),
289+
"Using invoke with null function not supported for v2 plugin"
284290
);
285291
instructions
286292
.local_get(bytecode_ptr_local) // ptr to bytecode
@@ -500,7 +506,6 @@ mod test {
500506
JsConfig::default(),
501507
Plugin::Default,
502508
);
503-
assert!(!gen.js_runtime_config.has_configs());
504509
assert!(gen.source_compression);
505510
assert!(matches!(gen.plugin, Plugin::Default));
506511
assert_eq!(gen.wit_opts, WitOptions::default());

0 commit comments

Comments
 (0)