Remove unused args from call

This commit is contained in:
Brian Carroll 2023-11-05 23:32:20 +00:00
parent 4b0c5fd0c6
commit 84a230a2e5
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
4 changed files with 13 additions and 18 deletions

View file

@ -351,7 +351,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
self.code_builder.i32_const(0); // argc=0
self.code_builder.i32_const(0); // argv=NULL
self.code_builder.call(main_fn_index, 2, true);
self.code_builder.call(main_fn_index);
self.code_builder.drop_();
self.code_builder.build_fn_header_and_footer(&[], 0, None);
self.reset();
@ -587,8 +587,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
// Call the wrapped inner function
let inner_wasm_fn_index = self.fn_index_offset + inner_lookup_idx as u32;
let has_return_val = ret_type_and_size.is_some();
self.code_builder
.call(inner_wasm_fn_index, n_inner_wasm_args, has_return_val);
self.code_builder.call(inner_wasm_fn_index);
// If the inner function returns a primitive, store it to the address we loaded at the very beginning
if let Some((ty, size)) = ret_type_and_size {
@ -655,8 +654,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
// Call the wrapped inner function
let inner_wasm_fn_index = self.fn_index_offset + inner_lookup_idx as u32;
self.code_builder
.call(inner_wasm_fn_index, n_inner_args, true);
self.code_builder.call(inner_wasm_fn_index);
// Write empty function header (local variables array with zero length)
self.code_builder.build_fn_header_and_footer(&[], 0, None);
@ -1389,8 +1387,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
let wasm_fn_index = self.fn_index_offset + roc_proc_index as u32;
self.code_builder
.call(wasm_fn_index, num_wasm_args, has_return_val);
self.code_builder.call(wasm_fn_index);
}
fn expr_call_low_level(
@ -1428,11 +1425,9 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
self.called_fns.set(*fn_index as usize, true);
if *fn_index < self.import_fn_count {
self.code_builder
.call_import(*fn_index, num_wasm_args, has_return_val);
self.code_builder.call_import(*fn_index);
} else {
self.code_builder
.call(*fn_index, num_wasm_args, has_return_val);
self.code_builder.call(*fn_index);
}
}

View file

@ -342,11 +342,11 @@ impl<'a> CodeBuilder<'a> {
instruction_no_args!(return_, RETURN);
pub fn call(&mut self, function_index: u32, _n_args: usize, _has_return_val: bool) {
pub fn call(&mut self, function_index: u32) {
self.call_impl(function_index, false)
}
pub fn call_import(&mut self, function_index: u32, _n_args: usize, _has_return_val: bool) {
pub fn call_import(&mut self, function_index: u32) {
self.call_impl(function_index, true)
}

View file

@ -345,7 +345,7 @@ impl<'a> LowLevelCall<'a> {
let inc_fn = backend.get_refcount_fn_index(self.ret_layout, HelperOp::Inc);
backend.code_builder.get_local(elem_local);
backend.code_builder.i32_const(1);
backend.code_builder.call(inc_fn, 2, false);
backend.code_builder.call(inc_fn);
}
}
ListReplaceUnsafe => {

View file

@ -122,7 +122,7 @@ macro_rules! build_wrapper_body_primitive {
let frame_size = 8;
code_builder.get_local(frame_pointer_id);
code_builder.call(main_function_index, 0, true);
code_builder.call(main_function_index);
code_builder.$store_instruction($align, 0);
code_builder.get_local(frame_pointer_id);
@ -149,7 +149,7 @@ fn build_wrapper_body_stack_memory(
let frame_pointer = Some(local_id);
code_builder.get_local(local_id);
code_builder.call(main_function_index, 0, true);
code_builder.call(main_function_index);
code_builder.get_local(local_id);
code_builder.build_fn_header_and_footer(local_types, size as i32, frame_pointer);
}
@ -236,7 +236,7 @@ where
impl Wasm32Result for () {
fn build_wrapper_body(code_builder: &mut CodeBuilder, main_function_index: u32) {
code_builder.call(main_function_index, 0, false);
code_builder.call(main_function_index);
code_builder.get_global(0);
code_builder.build_fn_header_and_footer(&[], 0, None);
}
@ -244,7 +244,7 @@ impl Wasm32Result for () {
impl Wasm32Result for std::convert::Infallible {
fn build_wrapper_body(code_builder: &mut CodeBuilder, main_function_index: u32) {
code_builder.call(main_function_index, 0, false);
code_builder.call(main_function_index);
code_builder.get_global(0);
code_builder.build_fn_header_and_footer(&[], 0, None);
}