From 56ce1eaba7f500b572bcfe06e3248372e9672322 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 14 Sep 2023 16:15:26 -0700 Subject: Optimize tuple.extract of gets in BinaryInstWriter (#5941) In general, the binary lowering of tuple.extract expects that all the tuple values are on top of the stack, so it inserts drops and possibly uses a scratch local to ensure only the extracted value is left. However, when the extracted tuple expression is a local.get, local.tee, or global.get, it's much more efficient to change the lowering of the get or tee to ensure that only the extracted value is on the stack to begin with. Implement that optimization in the binary writer. --- test/exception-handling.wast.fromBinary.noDebugInfo | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'test/exception-handling.wast.fromBinary.noDebugInfo') diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo index 5c527119e..27202e8a6 100644 --- a/test/exception-handling.wast.fromBinary.noDebugInfo +++ b/test/exception-handling.wast.fromBinary.noDebugInfo @@ -20,7 +20,6 @@ (local $1 i64) (local $2 (i32 i64)) (local $3 i32) - (local $4 i32) (try $label$3 (do (throw $tag$0 @@ -60,15 +59,7 @@ ) ) (drop - (block (result i32) - (local.set $4 - (local.get $0) - ) - (drop - (local.get $1) - ) - (local.get $4) - ) + (local.get $0) ) ) ) -- cgit v1.2.3