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
25 changes: 15 additions & 10 deletions crates/qjs-cli/hot-functions.order
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# budget 0x300 __RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute16boxed_truthiness
# budget 0x300 __RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute14boxed_equality
# budget 0x500 __RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute9get_named
# pinned: typed-loop executor at 0x200, interpreter's at 0xc40 mod 4 KiB (python3 -m tools.benchmark.layout_pin), head 44
# pinned: typed-loop executor at 0x200, interpreter's at 0xc40 mod 4 KiB (python3 -m tools.benchmark.layout_pin), head 49
__RNvMsz_NtNtNtCs1OjIl8oxbrv_5alloc11collections5btree3mapINtB5_8IntoIteryNtNtNtCscUtGwbhD4WH_5gimli4read6abbrev12AbbreviationE10dying_nextCsg55jX0GwzBC_3std
__RNvXs7_NtNtCsg55jX0GwzBC_3std2io5errorNtB5_5ErrorNtNtCsl8K0bEFm1U0_4core3fmt7Display3fmt
__RINvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute3runNtNtB6_2vm2VmEB8_
Expand All @@ -27,7 +27,8 @@ __RINvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute18try_run_ty
__RNvYINtNvNtCsg55jX0GwzBC_3std2io17default_write_fmt7AdapterINtNtCs1OjIl8oxbrv_5alloc3vec3VechEENtNtCsl8K0bEFm1U0_4core3fmt5Write10write_charB9_
__RNvYNtNtNtNtCsg55jX0GwzBC_3std3sys5stdio4unix6StderrNtNtBa_2io5Write9write_allBa_
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute16get_named_object
__RNvNvNtCsg55jX0GwzBC_3std2fs4read5inner
__RNvXso_NtNtCsg55jX0GwzBC_3std2io5stdioRNtB5_6StderrNtB7_5Write9write_fmt
__RNvXse_NtNtCsg55jX0GwzBC_3std2io5stdioRNtB5_6StdoutNtB7_5Write9write_fmt
__RNvMs4_NtNtCs9nYd1Hk1rek_11qjs_runtime5value5arrayNtB5_8ArrayRef24direct_dense_index_value
__RNvMsn_NtCs1OjIl8oxbrv_5alloc4syncINtB5_3ArcINtNtNtCscUtGwbhD4WH_5gimli4read5dwarf5DwarfINtNtBL_12endian_slice11EndianSliceNtNtBN_9endianity12LittleEndianEEE9drop_slowCsg55jX0GwzBC_3std
__RNvXs7_NtNtCsg55jX0GwzBC_3std2io5stdioNtB5_9StdinLockNtB7_7BufRead9read_line
Expand All @@ -36,26 +37,30 @@ __RNvYINtNtNtCscUtGwbhD4WH_5gimli4read12endian_slice11EndianSliceNtNtB9_9endiani
__RNvNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode15vm_numeric_leaf21try_eval_numeric_leaf
__RNvXNvNtCsg55jX0GwzBC_3std2io17default_write_fmtINtB2_7AdapterNtNtNtNtB6_3sys5stdio4unix6StderrENtNtCsl8K0bEFm1U0_4core3fmt5Write9write_strB6_
__RNvMs3_NtNtCs9nYd1Hk1rek_11qjs_runtime5value5arrayNtB5_9ArrayData21has_property_at_index
__RNvXso_NtNtCsg55jX0GwzBC_3std2io5stdioRNtB5_6StderrNtB7_5Write9write_fmt
__RNvNtNtCsg55jX0GwzBC_3std2io5stdio7__eprint
__RNvNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode15vm_numeric_leaf20direct_number_binary
__RNvXse_NtNtCsg55jX0GwzBC_3std2io5stdioRNtB5_6StdoutNtB7_5Write9write_fmt
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute22ordinary_data_property
__RNvXs_NvNtCsg55jX0GwzBC_3std9panicking13panic_handlerNtB4_19FormatStringPayloadNtNtCsl8K0bEFm1U0_4core5panic12PanicPayload3get
__RNvXNvNtCsg55jX0GwzBC_3std2io17default_write_fmtINtB2_7AdapterINtNtB4_6cursor6CursorQShEENtNtCsl8K0bEFm1U0_4core3fmt5Write9write_strB6_
__RNvMs_NtNtNtCsg55jX0GwzBC_3std2io8buffered9bufwriterINtB4_9BufWriterNtNtB8_5stdio9StdoutRawE14write_all_coldBa_
__RNvNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode15vm_numeric_leaf20direct_number_binary
__RNvMsn_NtCs1OjIl8oxbrv_5alloc4syncINtB5_3ArcINtNtNtNtCsg55jX0GwzBC_3std4sync6poison5mutex5MutexINtNtB7_3vec3VechEEE9drop_slowBP_
__RNvXs1g_NtCsl8K0bEFm1U0_4core3fmtRINtNtCs1OjIl8oxbrv_5alloc3vec3VechENtB6_5Debug3fmtCsg55jX0GwzBC_3std
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute22ordinary_data_property
__RNvNtNtCsg55jX0GwzBC_3std2io5stdio7__eprint
__RNvNtNtCsg55jX0GwzBC_3std3sys9backtrace4lock
__RNvMNtNtNtCs9nYd1Hk1rek_11qjs_runtime5value6object10slot_readsNtB4_9ObjectRef22own_data_property_read
__RNvMs1_NtNtNtNtCsg55jX0GwzBC_3std3sys4sync6rwlock5queueNtB5_6RwLock21read_unlock_contended
__RNvMs1_NtNtNtNtCsg55jX0GwzBC_3std3sys4sync6rwlock5queueNtB5_6RwLock16unlock_contended
__RNvMs6_NtNtCs9nYd1Hk1rek_11qjs_runtime5value6objectNtB5_9ObjectRef32write_existing_own_data_property
__RNvNtNtNtCsg55jX0GwzBC_3std12backtrace_rs9symbolize5gimli4mmap
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute16boxed_truthiness
__RNvNtNtNtNtCsg55jX0GwzBC_3std3sys2io5error4unix17decode_error_kind
__RNvXNvNtCsg55jX0GwzBC_3std2io17default_write_fmtINtB2_7AdapterINtNtB4_6cursor6CursorQShEENtNtCsl8K0bEFm1U0_4core3fmt5Write9write_strB6_
__RNvNtNtCsg55jX0GwzBC_3std3sys2fs8read_dir
__RNvMsn_NtCs1OjIl8oxbrv_5alloc4syncINtB5_3ArcNtNtNtCsg55jX0GwzBC_3std6thread6thread5InnerNtNtBM_5alloc6SystemE9drop_slowBM_
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute14boxed_equality
__RNvMsn_NtCs1OjIl8oxbrv_5alloc4syncINtB5_3ArcNtNtNtNtCsg55jX0GwzBC_3std3sys2fs4unix12InnerReadDirE9drop_slowBO_
__RNvYINtNvNtCsg55jX0GwzBC_3std2io17default_write_fmt7AdapterNtNtNtNtB9_3sys5stdio4unix6StderrENtNtCsl8K0bEFm1U0_4core3fmt5Write10write_charB9_
__RNvNtNtNtCs9nYd1Hk1rek_11qjs_runtime8bytecode10typed_loop7execute9get_named
__RNvNtNtCsg55jX0GwzBC_3std3sys2fs8read_dir
__RNvNtNtCsg55jX0GwzBC_3std3sys2fs12canonicalize
__RNvMs4_NtCs1OjIl8oxbrv_5alloc7raw_vecINtB5_11RawVecInnerNtNtCsg55jX0GwzBC_3std5alloc6SystemE14grow_amortizedBW_
__RNvXs1i_NtCsl8K0bEFm1U0_4core3fmtRNtNtNtB8_5panic8location8LocationNtB6_7Display3fmtCsg55jX0GwzBC_3std
__RNvXs1_NtCs9nYd1Hk1rek_11qjs_runtime5valueNtB5_5ValueNtNtCsl8K0bEFm1U0_4core5clone5Clone5clone
__RINvNtCsl8K0bEFm1U0_4core3ptr13drop_in_placeNtNtCs9nYd1Hk1rek_11qjs_runtime5value5ValueEBK_
__RNvNtNtCs9nYd1Hk1rek_11qjs_runtime8function4call25call_direct_leaf_function
Expand Down
22 changes: 17 additions & 5 deletions crates/qjs-runtime/src/bytecode/typed_loop/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,19 @@ fn boxed_truthiness(value: &Value) -> Typed {
Typed::Boolean(crate::conversion::is_truthy(value))
}

fn typed_numbers(args: &[Typed]) -> Option<[f64; super::helper_graph::MAX_HELPER_ARITY]> {
/// The arguments as numbers: each must be one unless `convert`, when a
/// boolean or `undefined` takes its `ToNumber` value.
fn typed_numbers(
args: &[Typed],
convert: bool,
) -> Option<[f64; super::helper_graph::MAX_HELPER_ARITY]> {
let mut numbers = [0.0; super::helper_graph::MAX_HELPER_ARITY];
for (number, arg) in numbers.iter_mut().zip(args) {
let Typed::Number(value) = arg else {
return None;
*number = match arg {
Typed::Number(value) => *value,
other if convert => other.to_numeric().number()?,
_ => return None,
};
*number = *value;
}
Some(numbers)
}
Expand All @@ -1000,7 +1006,13 @@ fn call_number_only_leaf(
bytecode: &crate::bytecode::Bytecode,
args: &[Typed],
) -> Option<Value> {
let numbers = typed_numbers(args)?;
// `x[i + j]` past the end of a hash's input is `undefined`, which
// `safe_add` turns to NaN and then 0 like any number operator would;
// declining it deoptimized crypto-sha1's whole block loop.
let numbers = typed_numbers(
args,
super::super::vm_numeric_leaf::number_only_leaf_converts_arguments(bytecode),
)?;
let value = super::super::vm_numeric_leaf::eval_number_only_leaf(
bytecode,
&function.params,
Expand Down
7 changes: 4 additions & 3 deletions crates/qjs-runtime/src/bytecode/typed_loop/helper_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ impl HelperGraph {
return None;
}
let program = self.programs.get(index as usize)?;
// A numeric body calls no other helper, so only the loop's own call
// (depth zero) can reach one; recursion skips the check. It is
// A numeric body runs its own calls on `f64` registers, so only the
// loop's own call (depth zero) enters one from here. It is
// lowered with every parameter a number, so a call that leaves one
// `undefined` -- or passes one past the parameters, which would land
// in a local -- runs on the general path.
Expand All @@ -189,7 +189,7 @@ impl HelperGraph {
&& let Some(Some(numeric)) = self.numeric.get(index as usize)
&& let Some(numbers) = numbers(args)
{
return numeric.run(&numbers[..arity]);
return numeric.run(&self.numeric, &numbers[..arity], 0);
}
// `Typed` is `Copy`, so the whole file is a stack array: a helper call
// allocates nothing and its registers stay in the frame the compiler
Expand Down Expand Up @@ -356,6 +356,7 @@ impl Preparation {
}
preparation.prepare_callee(vm, &callee, site.arity, 0)?;
}
numeric::NumProgram::settle(&mut preparation.graph.numeric);
Some(preparation.graph)
}

Expand Down
Loading
Loading