Skip to content

Commit ca43536

Browse files
author
Guy Bedford
authored
deps: update to latest starlingmonkey (#111)
1 parent 544b4ed commit ca43536

8 files changed

Lines changed: 39 additions & 113 deletions

File tree

.github/workflows/main.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ jobs:
2828
with:
2929
submodules: recursive
3030

31-
- name: Install Rust 1.68.2, 1.76.0
31+
- name: Install Rust Toolchain
3232
run: |
33-
rustup toolchain install 1.68.2
34-
rustup toolchain install 1.76.0
35-
rustup target add wasm32-unknown-unknown --toolchain 1.76.0
36-
rustup target add wasm32-wasi --toolchain 1.68.2
33+
rustup toolchain install 1.77.1
34+
rustup target add wasm32-wasi --toolchain 1.77.1
3735
3836
- uses: actions/setup-node@v2
3937
with:

StarlingMonkey

Submodule StarlingMonkey updated 70 files

crates/spidermonkey-embedding-splicer/src/splice.rs

Lines changed: 25 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
use walrus::{
2-
ir::{
3-
BinaryOp, Binop, Const, Instr, LoadKind, LocalGet, LocalSet, LocalTee, MemArg, Store,
4-
StoreKind, UnaryOp, Unop, Value,
5-
},
2+
ir::{BinaryOp, Binop, Const, Instr, LoadKind, MemArg, Store, StoreKind, UnaryOp, Unop, Value},
63
ExportId, ExportItem, FunctionBuilder, FunctionId, LocalId, ValType,
74
};
85

96
use crate::*;
107

11-
const DEBUG: bool = false;
12-
138
//
149
// Parses the Spidermonkey binary into section data for reserialization
1510
// into an output binary, and in the process:
@@ -39,10 +34,7 @@ pub fn splice(
3934
exports: Vec<(String, CoreFn)>,
4035
debug: bool,
4136
) -> Result<Vec<u8>> {
42-
let mut config = walrus::ModuleConfig::new();
43-
if debug {
44-
config.generate_dwarf(true);
45-
}
37+
let config = walrus::ModuleConfig::new();
4638
let mut module = config.parse(&engine)?;
4739

4840
// since StarlingMonkey implements CLI Run and incoming handler,
@@ -76,7 +68,7 @@ pub fn splice(
7668
// extract the native instructions from sample functions
7769
// then inline the imported functions and main import gating function
7870
// (erasing sample functions in the process)
79-
synthesize_import_functions(&mut module, &imports)?;
71+
synthesize_import_functions(&mut module, &imports, debug)?;
8072

8173
// create the exported functions as wrappers around the "cabi_call" function
8274
synthesize_export_functions(&mut module, &exports)?;
@@ -94,6 +86,7 @@ fn get_export_fid(module: &walrus::Module, expt_id: &ExportId) -> FunctionId {
9486
fn synthesize_import_functions(
9587
module: &mut walrus::Module,
9688
imports: &Vec<(String, String, CoreFn, Option<i32>)>,
89+
debug: bool,
9790
) -> Result<()> {
9891
let mut coreabi_get_import: Option<ExportId> = None;
9992
let mut cabi_realloc: Option<ExportId> = None;
@@ -116,8 +109,26 @@ fn synthesize_import_functions(
116109

117110
let cabi_realloc_fid = get_export_fid(module, &cabi_realloc.unwrap());
118111

119-
let coreabi_sample_fid = get_export_fid(module, coreabi_sample_ids.first().unwrap());
120-
let coreabi_sample_i32 = module.funcs.get(coreabi_sample_fid).kind.unwrap_local();
112+
let coreabi_sample_i32 = module
113+
.funcs
114+
.get(get_export_fid(module, &coreabi_sample_ids[0]))
115+
.kind
116+
.unwrap_local();
117+
let _coreabi_sample_i64 = module
118+
.funcs
119+
.get(get_export_fid(module, &coreabi_sample_ids[1]))
120+
.kind
121+
.unwrap_local();
122+
let _coreabi_sample_f32 = module
123+
.funcs
124+
.get(get_export_fid(module, &coreabi_sample_ids[2]))
125+
.kind
126+
.unwrap_local();
127+
let _coreabi_sample_f64 = module
128+
.funcs
129+
.get(get_export_fid(module, &coreabi_sample_ids[3]))
130+
.kind
131+
.unwrap_local();
121132

122133
// These functions retrieve the corresponding type
123134
// from a JS::HandleValue
@@ -179,7 +190,7 @@ fn synthesize_import_functions(
179190
let tmp_local = module.locals.add(ValType::I64);
180191

181192
for (impt_specifier, impt_name, impt_sig, retptr_size) in imports.iter() {
182-
if DEBUG {
193+
if debug {
183194
println!(
184195
"> IMPORT {} {} > {:?}",
185196
impt_specifier, impt_name, &impt_sig
@@ -226,55 +237,6 @@ fn synthesize_import_functions(
226237

227238
let mut func_body = func.func_body();
228239

229-
// copy the prelude instructions from the sample function (first block)
230-
let coreabi_sample_i32 = module.funcs.get(coreabi_sample_fid).kind.unwrap_local();
231-
let prelude_block = &coreabi_sample_i32
232-
.block(coreabi_sample_i32.entry_block())
233-
.instrs[0]
234-
.0;
235-
let prelude_seq = match prelude_block {
236-
Instr::Block(prelude_block) => prelude_block.seq,
237-
_ => {
238-
eprintln!("Splicer error: unable to read prelude sequence, continuing for debug build but note binding functions will not work!");
239-
return Ok(());
240-
}
241-
};
242-
243-
let prelude_block = coreabi_sample_i32.block(prelude_seq);
244-
func_body.block(None, |prelude| {
245-
for (instr, _) in &prelude_block.instrs {
246-
match instr {
247-
Instr::LocalGet(LocalGet { local }) => {
248-
if local.eq(&vp_arg) {
249-
prelude.instr(instr.clone());
250-
} else {
251-
prelude.local_get(tmp_local);
252-
}
253-
}
254-
Instr::LocalSet(LocalSet { local }) => {
255-
if local.eq(&vp_arg) {
256-
prelude.instr(instr.clone());
257-
} else {
258-
prelude.local_set(tmp_local);
259-
}
260-
}
261-
Instr::LocalTee(LocalTee { local }) => {
262-
if local.eq(&vp_arg) {
263-
prelude.instr(instr.clone());
264-
} else {
265-
prelude.local_tee(tmp_local);
266-
}
267-
}
268-
Instr::BrIf(_) => {
269-
prelude.br_if(prelude.id());
270-
}
271-
_ => {
272-
prelude.instr(instr.clone());
273-
}
274-
};
275-
}
276-
});
277-
278240
// stack the return arg now as it chains with the
279241
// args we're about to add to the stack
280242
if impt_sig.ret.is_some() {

embedding/embedding.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,23 @@ extern "C"
7070
{
7171
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
7272
int64_t arg1 = from_bigint64(args[1]);
73-
args.rval().setBigInt(to_bigint64(cx, arg1));
73+
args.rval().setBigInt(to_bigint64(cx, arg1 * 32771));
7474
return true;
7575
}
7676

7777
__attribute__((export_name("coreabi_sample_f32"))) bool CoreAbiSampleF32(JSContext *cx, unsigned argc, JS::Value *vp)
7878
{
7979
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
8080
float arg2 = static_cast<float>(args[2].toDouble());
81-
args.rval().setDouble(arg2);
81+
args.rval().setDouble(arg2 * 32771);
8282
return true;
8383
}
8484

8585
__attribute__((export_name("coreabi_sample_f64"))) bool CoreAbiSampleF64(JSContext *cx, unsigned argc, JS::Value *vp)
8686
{
8787
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
8888
double arg3 = args[3].toDouble();
89-
args.rval().setDouble(arg3);
89+
args.rval().setDouble(arg3 * 32771);
9090
return true;
9191
}
9292

@@ -274,7 +274,6 @@ extern "C"
274274
}
275275
Runtime.free_list.clear();
276276
RootedValue result(Runtime.cx);
277-
Runtime.engine->run_event_loop(&result);
278277
LOG("(post_call) end");
279278
}
280279

src/componentize.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,14 @@ export async function componentize(jsSource, witWorld, opts) {
6060
const features = [];
6161
if (!disableFeatures.includes('stdio')) {
6262
features.push('stdio');
63-
} else if (imports.some(([module]) => module.startsWith('wasi:cli/std') || module.startsWith('wasi:cli/terminal'))) {
64-
throw new Error(
65-
'Cannot disable "stdio" as it is already an import in the target world.'
66-
);
6763
}
6864
if (!disableFeatures.includes('random')) {
6965
features.push('random');
70-
} else if (imports.some(([module]) => module.startsWith('wasi:random/'))) {
71-
throw new Error(
72-
'Cannot disable "random" as it is already an import in the target world.'
73-
);
7466
}
7567
if (!disableFeatures.includes('clocks')) {
7668
features.push('clocks');
77-
} else if (imports.some(([module]) => module.startsWith('wasi:clocks/'))) {
78-
throw new Error(
79-
'Cannot disable "clocks" as it is already an import in the target world.'
80-
);
8169
}
82-
if (
83-
enableFeatures.includes('http') ||
84-
imports.some(([module]) => module.startsWith('wasi:http/'))
85-
) {
70+
if (!disableFeatures.includes('http')) {
8671
features.push('http');
8772
}
8873

test/builtins/console-object.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export const source = `
5353

5454
export async function test (run) {
5555
const { stdout, stderr } = await run();
56-
strictEqual(stdout, `{ a: { value: "a" }, b: { c: "d" }, e: ["f"], g: [{ g: "i" }], l: [Function l], m: [Getter], n: [Getter], o: [Function], p: [Function], q: 5, s: 29879287298374924, t: Set(3) { 1, 2, 3 }, u: Map(3) { 1 => 2, 3 => 4, [Function foo] => {} }, v: Symbol.for("blah"), w: Symbol(), x: undefined, y: null, z: URL { hash: "", host: "site.com", hostname: "site.com", href: "https://site.com/x?a&b", origin: "https://site.com", password: "", pathname: "/x", port: "", protocol: "https:", search: "?a&b", searchParams: URLSearchParams {}, username: "" }, zz: Uint8Array [1, 2, 3], zzz: Z {} }\n`);
56+
strictEqual(stdout, `{ a: { value: "a" }, b: { c: "d" }, e: ["f"], g: [{ g: "i" }], l: [ l () {
57+
58+
}], m: [Getter], n: [Getter], o: [ function () {
59+
60+
}], p: [ () => {}], q: 5, s: 29879287298374924, t: Set(3) { 1, 2, 3 }, u: Map(3) { 1 => 2, 3 => 4, [ function foo () {}] => {} }, v: Symbol.for("blah"), w: Symbol(), x: undefined, y: null, z: URL { hash: "", host: "site.com", hostname: "site.com", href: "https://site.com/x?a&b", origin: "https://site.com", password: "", pathname: "/x", port: "", protocol: "https:", search: "?a&b", searchParams: URLSearchParams {}, username: "" }, zz: Uint8Array [1, 2, 3], zzz: Z {} }\n`);
5761
strictEqual(stderr, '');
5862
}

test/builtins/globals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function test(run) {
1313
const { stdout, stderr } = await run();
1414
strictEqual(
1515
stdout,
16-
`["undefined", "Function", "Object", "eval", "globalThis", "Array", "Boolean", "JSON", "Date", "Math", "isNaN", "isFinite", "parseInt", "parseFloat", "NaN", "Infinity", "Number", "escape", "unescape", "decodeURI", "encodeURI", "decodeURIComponent", "encodeURIComponent", "String", "RegExp", "Error", "InternalError", "AggregateError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "ArrayBuffer", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Uint8ClampedArray", "BigInt64Array", "BigUint64Array", "BigInt", "Proxy", "WeakMap", "Map", "Set", "DataView", "Symbol", "Reflect", "WeakSet", "Promise", "FinalizationRegistry", "WeakRef", "ReadableStream", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableByteStreamController", "WritableStream", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "self", "URL", "URLSearchParams", "atob", "btoa", "console", "DOMException", "Performance", "queueMicrotask", "structuredClone", "setInterval", "setTimeout", "clearInterval", "clearTimeout", "WorkerLocation", "location", "TextEncoder", "TextDecoder", "TransformStream", "CompressionStream", "DecompressionStream", "fetch", "Request", "Response", "Headers", "addEventListener", "SubtleCrypto", "Crypto", "crypto", "CryptoKey"]\n`
16+
`["undefined", "Function", "Object", "eval", "globalThis", "Array", "Boolean", "JSON", "Date", "Math", "isNaN", "isFinite", "parseInt", "parseFloat", "NaN", "Infinity", "Number", "escape", "unescape", "decodeURI", "encodeURI", "decodeURIComponent", "encodeURIComponent", "String", "RegExp", "Error", "InternalError", "AggregateError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "ArrayBuffer", "Int8Array", "Uint8Array", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "Uint8ClampedArray", "BigInt64Array", "BigUint64Array", "BigInt", "Proxy", "WeakMap", "Map", "Set", "DataView", "Symbol", "Reflect", "WeakSet", "Promise", "FinalizationRegistry", "WeakRef", "ReadableStream", "ReadableStreamBYOBReader", "ReadableStreamBYOBRequest", "ReadableStreamDefaultReader", "ReadableStreamDefaultController", "ReadableByteStreamController", "WritableStream", "ByteLengthQueuingStrategy", "CountQueuingStrategy", "self", "queueMicrotask", "structuredClone", "atob", "btoa", "DOMException", "URL", "URLSearchParams", "console", "Performance", "performance", "setInterval", "setTimeout", "clearInterval", "clearTimeout", "WorkerLocation", "location", "TextEncoder", "TextDecoder", "TransformStream", "CompressionStream", "DecompressionStream", "fetch", "Request", "Response", "Headers", "addEventListener", "SubtleCrypto", "Crypto", "crypto", "CryptoKey"]\n`
1717
);
1818
strictEqual(stderr, '');
1919
}

test/builtins/timeout.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)