Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
]

[workspace.package]
version = "0.10.10"
version = "0.10.11"
edition = "2021"
authors = ["Slice Runtime Team"]
license = "MIT OR Apache-2.0"
Expand Down
42 changes: 41 additions & 1 deletion crates/slice-engine/microbench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,51 @@ if (out.length < 20) throw new Error("stream decoder mismatch");
group.finish();
}

fn bench_wave3_als_intl_crypto_and_buffer(c: &mut Criterion) {
let mut group = c.benchmark_group("slice_engine::wave3");

let als_intl_src = r#"
const { AsyncLocalStorage } = require("node:async_hooks");
const als = new AsyncLocalStorage();
const nf = new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" });
const dtf = new Intl.DateTimeFormat("en-US", { timeZone: "Asia/Tokyo", hour: "2-digit", minute: "2-digit", hour12: false });
const seg = new Intl.Segmenter("en", { granularity: "grapheme" });
const buf = Buffer.from("slice-edge-runtime-buffer-search-needle-benchmark-payload");
const c1 = nf.format(1234567.89);
const d1 = dtf.format(new Date(0));
const gCount = [...seg.segment("a👍🏽é\r\n🇺🇸")].length;
const idx = buf.indexOf("needle");
const ab = new ArrayBuffer(64);
const ab2 = ab.transfer(64);
if (idx < 0 || gCount !== 5 || ab2.byteLength !== 64 || !c1 || !d1) throw new Error("wave3 bench mismatch");
"#;
let als_intl_bc = compile_source_to_bytecode(als_intl_src);
group.bench_function("intl_buffer_indexof_and_arraybuffer_transfer", |b| {
SliceIsolate::prewarm_boa_pool(1);
b.iter(|| {
let mut iso = SliceIsolate::spawn(
"bench-wave3",
1,
CapabilityToken::pure_compute(),
50_000_000,
16 * 1024 * 1024,
);
let res = iso
.execute_bytecode(black_box(&als_intl_bc), None)
.expect("wave3 bench execute");
black_box(res.highest_tier_reached)
});
});

group.finish();
}

criterion_group!(
benches,
bench_boacas_and_automaton,
bench_intrinsics_and_numeric_vm,
bench_json_operations,
bench_vfs_and_stream_operations
bench_vfs_and_stream_operations,
bench_wave3_als_intl_crypto_and_buffer
);
criterion_main!(benches);
9 changes: 4 additions & 5 deletions crates/slice-engine/src/bindings/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ fn try_eval_portable_shell_script(
let mut exited_early = false;
for (s_idx, stage) in stages.iter().enumerate() {
let trimmed = stage.trim();
let (st, out_b, err_b) =
try_eval_portable_shell_atom(trimmed, child_env, &pipe_data)?;
let (st, out_b, err_b) = try_eval_portable_shell_atom(trimmed, child_env, &pipe_data)?;
clause_status = st;
total_stderr.extend_from_slice(&err_b);
if s_idx + 1 < stages.len() {
Expand Down Expand Up @@ -621,9 +620,9 @@ pub(crate) fn register_child_process_host_functions(ctx: &mut boa_engine::Contex
if !has_meta {
let first_tok = full_cmd.split_whitespace().next().unwrap_or("");
!first_tok.is_empty()
&& allowed_bins
.iter()
.any(|allowed| slice_sandbox::exec_binary_matches(first_tok, allowed))
&& allowed_bins.iter().any(|allowed| {
slice_sandbox::exec_binary_matches(first_tok, allowed)
})
} else {
false
}
Expand Down
33 changes: 32 additions & 1 deletion crates/slice-engine/src/bindings/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use crate::boa_realm::{
BOA_ACTIVE_TENANT, BOA_DET_STATE, BOA_ENV_MAP, BOA_HTTP_REQ, BOA_KV_MEM_BUDGET, BOA_STDOUT,
BOA_VIOLATION, BOA_WAIT_UNTIL_COUNT,
};
use crate::event_loop::{cancel_timer, schedule_immediate, schedule_timer};
use crate::event_loop::{
cancel_timer, refresh_timer, schedule_immediate, schedule_timer, set_timer_ref,
};
use crate::intrinsics::{
base64_decode, base64_encode, bytes_to_hex, hmac_sha256_bytes, hmac_sha256_hex, sha256_bytes,
sha256_hex,
Expand Down Expand Up @@ -496,6 +498,35 @@ pub(crate) fn register_slice_native_host_functions(ctx: &mut boa_engine::Context
}),
);

let _ = ctx.register_global_builtin_callable(
js_string!("__slice_timer_ref"),
2,
NativeFunction::from_fn_ptr(|_this, args, _context| {
let id = args
.first()
.and_then(|v| v.as_number())
.map(|n| n.max(0.0) as u32)
.unwrap_or(0);
let refed = args.get(1).and_then(|v| v.as_boolean()).unwrap_or(true);
set_timer_ref(id, refed);
Ok(BoaVal::undefined())
}),
);

let _ = ctx.register_global_builtin_callable(
js_string!("__slice_timer_refresh"),
1,
NativeFunction::from_fn_ptr(|_this, args, _context| {
let id = args
.first()
.and_then(|v| v.as_number())
.map(|n| n.max(0.0) as u32)
.unwrap_or(0);
refresh_timer(id);
Ok(BoaVal::undefined())
}),
);

let _ = ctx.register_global_builtin_callable(
js_string!("__slice_http_is_active"),
0,
Expand Down
Loading
Loading