From eb4d1bb700b1ac3ef95bb396ea7ea3ef96dc099d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 15 Nov 2020 20:47:17 -0800 Subject: [cost.h] Require all expressions to be define a cost (#3363) Almost NFC, but adds a cost to DataDrop, 5, which tries to reflect that it is costlier than a call (it calls into VM internals) but also not much more, as it actually helps perf in the long term, so it should be preferred where possible. --- src/ir/cost.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ir/cost.h b/src/ir/cost.h index b8a4bf64a..95ef99b65 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -24,7 +24,7 @@ namespace wasm { // Measure the execution cost of an AST. Very handwave-ey -struct CostAnalyzer : public Visitor { +struct CostAnalyzer : public OverriddenVisitor { CostAnalyzer(Expression* ast) { cost = visit(ast); } Index cost; @@ -550,6 +550,21 @@ struct CostAnalyzer : public Visitor { Index visitPop(Pop* curr) { return 0; } 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 visitRefTest(RefTest* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitRefCast(RefCast* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitBrOnCast(BrOnCast* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitRttCanon(RttCanon* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitRttSub(RttSub* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitStructNew(StructNew* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitStructGet(StructGet* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitStructSet(StructSet* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitArrayNew(ArrayNew* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitArrayGet(ArrayGet* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitArraySet(ArraySet* curr) { WASM_UNREACHABLE("TODO: GC"); } + Index visitArrayLen(ArrayLen* curr) { WASM_UNREACHABLE("TODO: GC"); } }; } // namespace wasm -- cgit v1.2.3