@@ -43,20 +43,23 @@ class X86Visitor : public BaseWASMVisitor<X86Visitor> {
43
43
if (func_index == 0 ) {
44
44
m_a.asm_call_label (" print_i32" );
45
45
} else if (func_index == 5 ) {
46
- // currently ignoring print_buf
46
+ // currently ignoring flush_buf
47
47
} else if (func_index == 6 ) {
48
48
m_a.asm_call_label (" exit" );
49
49
} else {
50
50
std::cerr << " Call to imported function with index " +
51
51
std::to_string (func_index) +
52
52
" not yet supported" ;
53
53
}
54
- } else {
55
- m_a.asm_call_label (exports[func_index - 7 ].name );
54
+ return ;
56
55
}
57
56
57
+ uint32_t imports_adjusted_func_index = func_index - 7U ;
58
+ m_a.asm_call_label (exports[imports_adjusted_func_index].name );
59
+
60
+
58
61
// Pop the passed function arguments
59
- wasm::FuncType func_type = func_types[type_indices[func_index ]];
62
+ wasm::FuncType func_type = func_types[type_indices[imports_adjusted_func_index ]];
60
63
for (uint32_t i = 0 ; i < func_type.param_types .size (); i++) {
61
64
m_a.asm_pop_r32 (X86Reg::eax);
62
65
}
@@ -68,7 +71,7 @@ class X86Visitor : public BaseWASMVisitor<X86Visitor> {
68
71
m_a.asm_mov_r32_m32 (
69
72
X86Reg::eax, &base, nullptr , 1 ,
70
73
-(4 * (func_type.param_types .size () + 2 +
71
- func_codes[func_index ].locals .size () + 1 )));
74
+ func_codes[imports_adjusted_func_index ].locals .size () + 1 )));
72
75
73
76
// push eax value onto stack
74
77
m_a.asm_push_r32 (X86Reg::eax);
0 commit comments