summaryrefslogtreecommitdiff
path: root/src/tools/execution-results.h
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-12-30 17:55:20 -0800
committerGitHub <noreply@github.com>2019-12-30 17:55:20 -0800
commitbcc76146fed433cbc8ba01a9f568d979c145110b (patch)
treeab70ad24afc257b73513c3e62f3aab9938d05944 /src/tools/execution-results.h
parenta30f1df5696ccb3490e2eaa3a9ed5e7e487c7b0e (diff)
downloadbinaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.gz
binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.tar.bz2
binaryen-bcc76146fed433cbc8ba01a9f568d979c145110b.zip
Add support for reference types proposal (#2451)
This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447.
Diffstat (limited to 'src/tools/execution-results.h')
-rw-r--r--src/tools/execution-results.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h
index c0c7428cc..7787dba25 100644
--- a/src/tools/execution-results.h
+++ b/src/tools/execution-results.h
@@ -69,11 +69,17 @@ struct ExecutionResults {
auto* func = wasm.getFunction(exp->value);
if (func->sig.results != Type::none) {
// this has a result
- results[exp->name] = run(func, wasm, instance);
- // ignore the result if we hit an unreachable and returned no value
- if (results[exp->name].type.isConcrete()) {
- std::cout << "[fuzz-exec] note result: " << exp->name << " => "
- << results[exp->name] << '\n';
+ Literal ret = run(func, wasm, instance);
+ // We cannot compare funcrefs by name because function names can
+ // change (after duplicate function elimination or roundtripping)
+ // while the function contents are still the same
+ if (ret.type != Type::funcref) {
+ results[exp->name] = ret;
+ // ignore the result if we hit an unreachable and returned no value
+ if (results[exp->name].type.isConcrete()) {
+ std::cout << "[fuzz-exec] note result: " << exp->name << " => "
+ << results[exp->name] << '\n';
+ }
}
} else {
// no result, run it anyhow (it might modify memory etc.)
@@ -100,17 +106,17 @@ struct ExecutionResults {
auto name = iter.first;
if (results.find(name) == results.end()) {
std::cout << "[fuzz-exec] missing " << name << '\n';
- abort();
+ return false;
}
std::cout << "[fuzz-exec] comparing " << name << '\n';
if (results[name] != other.results[name]) {
std::cout << "not identical!\n";
- abort();
+ return false;
}
}
if (loggings != other.loggings) {
std::cout << "logging not identical!\n";
- abort();
+ return false;
}
return true;
}
@@ -138,7 +144,7 @@ struct ExecutionResults {
// call the method
for (Type param : func->sig.params.expand()) {
// zeros in arguments TODO: more?
- arguments.push_back(Literal(param));
+ arguments.push_back(Literal::makeZero(param));
}
return instance.callFunction(func->name, arguments);
} catch (const TrapException&) {