summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing.h
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-12-05 13:09:21 -0600
committerGitHub <noreply@github.com>2019-12-05 13:09:21 -0600
commita28343a33ed28b4d5c83c37e350aceaf09b5246f (patch)
tree084a487cdf79e8025246d2a85d5578c113c9ad51 /src/tools/fuzzing.h
parentcbf121df96cfce5038f52ed04f9780e19ed3b762 (diff)
downloadbinaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.gz
binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.tar.bz2
binaryen-a28343a33ed28b4d5c83c37e350aceaf09b5246f.zip
Add string parameter to WASM_UNREACHABLE (#2499)
This works more like llvm's unreachable handler in that is preserves information even in release builds.
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r--src/tools/fuzzing.h74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index 733029bd7..8de47900c 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -171,7 +171,7 @@ public:
options.passes.push_back("vacuum");
break;
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected value");
}
}
if (oneIn(2)) {
@@ -984,7 +984,7 @@ private:
case 14:
return makeUnreachable(unreachable);
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected value");
}
// make something with no chance of infinite recursion
@@ -1334,7 +1334,7 @@ private:
return builder.makeLoad(
4, signed_, offset, pick(1, 2, 4), ptr, type);
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected value");
}
case i64: {
bool signed_ = get() & 1;
@@ -1350,7 +1350,7 @@ private:
return builder.makeLoad(
8, signed_, offset, pick(1, 2, 4, 8), ptr, type);
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected value");
}
case f32: {
return builder.makeLoad(4, false, offset, pick(1, 2, 4), ptr, type);
@@ -1369,9 +1369,9 @@ private:
case exnref: // exnref cannot be loaded from memory
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
Expression* makeLoad(Type type) {
@@ -1437,7 +1437,7 @@ private:
return builder.makeStore(
4, offset, pick(1, 2, 4), ptr, value, type);
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case i64: {
switch (upTo(4)) {
@@ -1452,7 +1452,7 @@ private:
return builder.makeStore(
8, offset, pick(1, 2, 4, 8), ptr, value, type);
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case f32: {
return builder.makeStore(4, offset, pick(1, 2, 4), ptr, value, type);
@@ -1471,9 +1471,9 @@ private:
case exnref: // exnref cannot be stored in memory
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
Expression* makeStore(Type type) {
@@ -1546,7 +1546,7 @@ private:
return Literal(
std::array<Literal, 2>{{makeLiteral(f64), makeLiteral(f64)}});
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected value");
}
}
@@ -1567,7 +1567,7 @@ private:
case exnref: // exnref cannot have literals
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
break;
}
@@ -1594,7 +1594,7 @@ private:
small = uint32_t(get32());
break;
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
switch (type) {
case i32:
@@ -1610,7 +1610,7 @@ private:
case exnref: // exnref cannot have literals
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
break;
}
@@ -1676,7 +1676,7 @@ private:
case exnref: // exnref cannot have literals
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
// tweak around special values
if (oneIn(3)) { // +- 1
@@ -1708,7 +1708,7 @@ private:
case exnref: // exnref cannot have literals
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
// maybe negative
if (oneIn(2)) {
@@ -1717,7 +1717,7 @@ private:
return value;
}
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalide value");
}
Literal makeLiteral(Type type) {
@@ -1816,9 +1816,9 @@ private:
case exnref: // there's no unary ops for exnref
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
case i64: {
switch (upTo(4)) {
@@ -1856,7 +1856,7 @@ private:
return buildUnary({op, make(f64)});
}
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case f32: {
switch (upTo(4)) {
@@ -1881,7 +1881,7 @@ private:
case 3:
return makeDeNanOp(buildUnary({DemoteFloat64, make(f64)}));
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case f64: {
switch (upTo(4)) {
@@ -1906,7 +1906,7 @@ private:
case 3:
return makeDeNanOp(buildUnary({PromoteFloat32, make(f32)}));
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case v128: {
assert(wasm.features.hasSIMD());
@@ -1950,15 +1950,15 @@ private:
WidenHighUVecI16x8ToVecI32x4),
make(v128)});
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case anyref: // there's no unary ops for anyref
case exnref: // there's no unary ops for exnref
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
Expression* buildBinary(const BinaryArgs& args) {
@@ -2042,7 +2042,7 @@ private:
make(f64),
make(f64)});
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
case i64: {
return buildBinary({pick(AddInt64,
@@ -2189,9 +2189,9 @@ private:
case exnref: // there's no binary ops for exnref
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid type");
}
Expression* buildSelect(const ThreeArgs& args) {
@@ -2292,7 +2292,7 @@ private:
bytes = pick(1, 2, 4);
break;
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalide value");
}
break;
}
@@ -2311,12 +2311,12 @@ private:
bytes = pick(1, 2, 4, 8);
break;
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalide value");
}
break;
}
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
auto offset = logify(get());
auto* ptr = makePointer();
@@ -2362,7 +2362,7 @@ private:
case 6:
return makeSIMDLoad();
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
Expression* makeSIMDExtract(Type type) {
@@ -2389,7 +2389,7 @@ private:
case exnref:
case none:
case unreachable:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected type");
}
Expression* vec = make(v128);
uint8_t index = 0;
@@ -2450,7 +2450,7 @@ private:
lane_t = f64;
break;
default:
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected op");
}
Expression* value = make(lane_t);
return builder.makeSIMDReplace(op, vec, index, value);
@@ -2551,7 +2551,7 @@ private:
case 3:
return makeMemoryFill();
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("invalid value");
}
Expression* makeMemoryInit() {
@@ -2739,7 +2739,7 @@ private:
} else if (auto* loop = target->dynCast<Loop>()) {
return loop->name;
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected expr type");
}
Type getTargetType(Expression* target) {
@@ -2748,7 +2748,7 @@ private:
} else if (target->is<Loop>()) {
return none;
}
- WASM_UNREACHABLE();
+ WASM_UNREACHABLE("unexpected expr type");
}
};