MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / process_function_job

Function process_function_job

crates/parser/src/parallel.rs:61–88  ·  view source on GitHub ↗
(
    job: PendingFunction<'_>,
    options: &ParserOptions,
    func_types: &[Arc<FuncType>],
    imported_func_count: usize,
    imported_memory_count: u32,
)

Source from the content-addressed store, hash-verified

59}
60
61fn process_function_job(
62 job: PendingFunction<'_>,
63 options: &ParserOptions,
64 func_types: &[Arc<FuncType>],
65 imported_func_count: usize,
66 imported_memory_count: u32,
67) -> Result<(usize, FunctionCode)> {
68 let validator = job.func_to_validate.into_validator(FuncValidatorAllocations::default());
69 let (code, _, _) = match job.body {
70 FunctionBodyInput::Borrowed(func) => conversion::convert_module_code(func, validator, Default::default())?,
71 FunctionBodyInput::Owned(body) => {
72 let reader = wasmparser::BinaryReader::new(&body.section_bytes[body.body_range], body.body_offset);
73 let func = wasmparser::FunctionBody::new(reader);
74 conversion::convert_module_code(func, validator, Default::default())?
75 }
76 };
77
78 let ty = func_types.get(job.ty_idx as usize).expect("No func type for func, this is a bug");
79 let code = optimize_function_code(
80 code,
81 options,
82 ValueCounts::from_iter(ty.results()),
83 (imported_func_count + job.ordinal) as u32,
84 imported_memory_count,
85 );
86
87 Ok((job.ordinal, code))
88}
89
90pub(crate) fn process_pending(
91 pending: Vec<PendingFunction<'_>>,

Callers 1

process_pendingFunction · 0.85

Calls 4

convert_module_codeFunction · 0.85
optimize_function_codeFunction · 0.85
resultsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected