summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-11-17 08:31:13 -0800
committerGitHub <noreply@github.com>2020-11-17 08:31:13 -0800
commita3d2a4d7854b8c14c7c7d222307b2af0c48b1275 (patch)
treef219335588c77751d7f55cd8bd81509831214929
parent8046ebaa848617588f945a007adb2ba8489a6399 (diff)
downloadbinaryen-a3d2a4d7854b8c14c7c7d222307b2af0c48b1275.tar.gz
binaryen-a3d2a4d7854b8c14c7c7d222307b2af0c48b1275.tar.bz2
binaryen-a3d2a4d7854b8c14c7c7d222307b2af0c48b1275.zip
[cost.h] Define costs for I31New and I31Get which the fuzzer emits (#3373)
cost.h now requires costs be defined, or it halts at runtime. But the fuzzer already emits those two, so define them to unbreak the fuzzer. Both access a reference, so they should be at least as costly as a load. I31New also allocates, which is very cheap on a generational GC, so do not add much for that.
-rw-r--r--src/ir/cost.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ir/cost.h b/src/ir/cost.h
index 95ef99b65..c0845f7e2 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -551,8 +551,8 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, Index> {
Index visitNop(Nop* curr) { return 0; }
Index visitUnreachable(Unreachable* curr) { return 0; }
Index visitDataDrop(DataDrop* curr) { return 5; }
- Index visitI31New(I31New* curr) { WASM_UNREACHABLE("TODO: GC"); }
- Index visitI31Get(I31Get* curr) { WASM_UNREACHABLE("TODO: GC"); }
+ Index visitI31New(I31New* curr) { return 3 + visit(curr->value); }
+ Index visitI31Get(I31Get* curr) { return 2 + visit(curr->i31); }
Index visitRefTest(RefTest* curr) { WASM_UNREACHABLE("TODO: GC"); }
Index visitRefCast(RefCast* curr) { WASM_UNREACHABLE("TODO: GC"); }
Index visitBrOnCast(BrOnCast* curr) { WASM_UNREACHABLE("TODO: GC"); }