@@ -37,15 +37,16 @@ random_gen_val(wasm_valkind_t kind)
37
37
return wasm_val_t { .kind = WASM_F64, .of = { .f64 = dis (gen) } };
38
38
}
39
39
else if (kind == WASM_EXTERNREF) {
40
- // TODO:
41
- return wasm_val_t { .kind = WASM_EXTERNREF, .of = { .foreign = 0 } };
40
+ std::uniform_int_distribution<uintptr_t > dis;
41
+ return wasm_val_t { .kind = WASM_EXTERNREF,
42
+ .of = { .foreign = dis (gen) } };
42
43
}
43
44
else if (kind == WASM_FUNCREF) {
44
- // TODO:
45
45
return wasm_val_t { .kind = WASM_FUNCREF, .of = { .ref = nullptr } };
46
46
}
47
+ // TODO:v128
47
48
else {
48
- assert (0 );
49
+ assert (0 && " unsupported value kind " );
49
50
}
50
51
}
51
52
@@ -88,18 +89,53 @@ execute_export_functions(wasm_module_t module, wasm_module_inst_t inst)
88
89
89
90
/* execute the function */
90
91
wasm_exec_env_t exec_env = wasm_runtime_get_exec_env_singleton (inst);
92
+
93
+ {
94
+ std::cout << " [EXECUTION] " << export_type.name << " (" ;
95
+ for (unsigned p_i = 0 ; p_i < param_count; p_i++) {
96
+ if (p_i != 0 ) {
97
+ std::cout << " , " ;
98
+ }
99
+
100
+ if (args[p_i].kind == WASM_I32) {
101
+ std::cout << " i32:" << args[p_i].of .i32 ;
102
+ }
103
+ else if (args[p_i].kind == WASM_I64) {
104
+ std::cout << " i64:" << args[p_i].of .i64 ;
105
+ }
106
+ else if (args[p_i].kind == WASM_F32) {
107
+ std::cout << " f32:" << args[p_i].of .f32 ;
108
+ }
109
+ else if (args[p_i].kind == WASM_F64) {
110
+ std::cout << " f64:" << args[p_i].of .f64 ;
111
+ }
112
+ else if (args[p_i].kind == WASM_EXTERNREF) {
113
+ std::cout << " externref:" << args[p_i].of .foreign ;
114
+ }
115
+ else if (args[p_i].kind == WASM_FUNCREF) {
116
+ std::cout << " funcref:" << args[p_i].of .ref ;
117
+ }
118
+ // TODO:v128
119
+ else {
120
+ assert (0 && " unsupported value kind" );
121
+ }
122
+ }
123
+
124
+ std::cout << " )" ;
125
+ }
126
+
91
127
bool ret =
92
128
wasm_runtime_call_wasm_a (exec_env, func, result_count,
93
129
results.data (), param_count, args.data ());
94
130
if (!ret) {
95
131
const char *exception = wasm_runtime_get_exception (inst);
96
132
if (!exception ) {
97
- std::cout << " Failed to execute function: " << export_type.name
98
- << " . No exception info." << std::endl;
133
+ std::cout << " [EXECUTION] " << export_type.name
134
+ << " () failed . No exception info." << std::endl;
99
135
}
100
136
else {
101
- std::cout << " Failed to execute function: " << export_type.name
102
- << " . " << exception << std::endl;
137
+ std::cout << " [EXECUTION] " << export_type.name << " () failed. "
138
+ << exception << std::endl;
103
139
}
104
140
}
105
141
@@ -141,8 +177,6 @@ LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
141
177
142
178
execute_export_functions (module, inst);
143
179
144
- std::cout << " PASS" << std::endl;
145
-
146
180
wasm_runtime_deinstantiate (inst);
147
181
wasm_runtime_unload (module);
148
182
wasm_runtime_destroy ();
0 commit comments