From 4e3a6aa5a812fbd1aee6394f98cc4c2425032735 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 20 Oct 2021 14:29:08 +0300 Subject: [PATCH] * match the label to the wider block, if it is adjacent to both the brevious and the next instruction --- compiler/wasm32/cpupi.pas | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/compiler/wasm32/cpupi.pas b/compiler/wasm32/cpupi.pas index c3e48a4c72..c0d5dc7c65 100644 --- a/compiler/wasm32/cpupi.pas +++ b/compiler/wasm32/cpupi.pas @@ -440,23 +440,16 @@ implementation begin lbl:=tai_label(hp); lbl.labsym.nestingdepth:=-1; - { first, try to match label to the previous instruction } - if assigned(lastinstr) then - begin - if lastinstr.opcode=a_loop then - lbl.labsym.nestingdepth:=cur_nesting_depth - else if lastinstr.opcode in [a_end_block,a_end_try,a_end_if] then - lbl.labsym.nestingdepth:=cur_nesting_depth+1; - end; - { if not matched, try to match it to the next instruction } - if lbl.labsym.nestingdepth=-1 then - begin - nextinstr:=FindNextInstruction(hp); - if nextinstr.opcode=a_loop then - lbl.labsym.nestingdepth:=cur_nesting_depth+1 - else if nextinstr.opcode in [a_end_block,a_end_try,a_end_if] then - lbl.labsym.nestingdepth:=cur_nesting_depth; - end; + nextinstr:=FindNextInstruction(hp); + + if assigned(nextinstr) and (nextinstr.opcode in [a_end_block,a_end_try,a_end_if]) then + lbl.labsym.nestingdepth:=cur_nesting_depth + else if assigned(lastinstr) and (lastinstr.opcode=a_loop) then + lbl.labsym.nestingdepth:=cur_nesting_depth + else if assigned(lastinstr) and (lastinstr.opcode in [a_end_block,a_end_try,a_end_if]) then + lbl.labsym.nestingdepth:=cur_nesting_depth+1 + else if assigned(nextinstr) and (nextinstr.opcode=a_loop) then + lbl.labsym.nestingdepth:=cur_nesting_depth+1; end; else ;