Browse Source

* WebAssembly: generate the final bashB opcode of a function via the
end_function instruction, instead of adding it magically in the object writer.
This makes the WebAssembly debug line info more accurate, covering the
end_function instruction as well.

Nikolay Nikolov 11 months ago
parent
commit
99943610cb
2 changed files with 4 additions and 7 deletions
  1. 1 2
      compiler/ogwasm.pas
  2. 3 5
      compiler/wasm32/aasmcpu.pas

+ 1 - 2
compiler/ogwasm.pas

@@ -1322,14 +1322,13 @@ implementation
 
         encoded_locals:=tdynamicarray.Create(64);
         WriteFunctionLocals(encoded_locals,ObjSymExtraData);
-        codelen:=encoded_locals.size+codeexprlen+1;
+        codelen:=encoded_locals.size+codeexprlen;
         WriteUleb(dest,codelen);
         encoded_locals.seek(0);
         CopyDynamicArray(encoded_locals,dest,encoded_locals.size);
         ObjSection.FileSectionOfs:=dest.size-objsym.offset;
         ObjSection.EncodedLocalsSize:=encoded_locals.size;
         CopyDynamicArray(ObjSection.Data,dest,codeexprlen);
-        WriteByte(dest,$0B);
         encoded_locals.Free;
       end;
 

+ 3 - 5
compiler/wasm32/aasmcpu.pas

@@ -2236,6 +2236,7 @@ uses
           a_end_if,
           a_end_loop,
           a_end_try,
+          a_end_function,
           a_catch_all,
           a_ref_is_null:
             result:=1;
@@ -2350,8 +2351,6 @@ uses
                     internalerror(2021092011);
                 end;
             end;
-          a_end_function:
-            result:=0;
           a_block,
           a_loop,
           a_if,
@@ -2993,7 +2992,8 @@ uses
           a_end_block,
           a_end_if,
           a_end_loop,
-          a_end_try:
+          a_end_try,
+          a_end_function:
             WriteByte($0B);
           a_catch_all:
             WriteByte($19);
@@ -3132,8 +3132,6 @@ uses
                     internalerror(2021092011);
                 end;
             end;
-          a_end_function:
-            ;
           a_block,
           a_loop,
           a_if,