From 55aa5ac129fb44d38a1164f4917dcb3182fb8256 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Sun, 9 Feb 2025 20:12:57 +0200 Subject: [PATCH] * WebAssembly: micro optimization in the invoke helper - omit the last 'return' instruction --- compiler/ogwasm.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/ogwasm.pas b/compiler/ogwasm.pas index f87d7a269d..b205feed58 100644 --- a/compiler/ogwasm.pas +++ b/compiler/ogwasm.pas @@ -6001,7 +6001,7 @@ implementation Sec: TObjSection; IndirectFunctionTableMap: array of Integer; - procedure InvokeFuncType(typidx: Integer); + procedure InvokeFuncType(typidx: Integer; islast: Boolean); var ft: TWasmFuncType; i, nextofs: Integer; @@ -6118,8 +6118,9 @@ implementation internalerror(2025012501); end; end; - { return } - Sec.writeUInt8($0F); + if not islast then + { return } + Sec.writeUInt8($0F); end; function FuncIdx2TypeIdx(fi: Integer): Integer; @@ -6252,7 +6253,7 @@ implementation begin { end } Sec.writeUInt8($0B); - InvokeFuncType(InvokableTypeIndices[i]); + InvokeFuncType(InvokableTypeIndices[i],i=(Length(InvokableTypeIndices)-1)); end; { end }