Commit Graph

62 Commits

Author SHA1 Message Date
Nikolay Nikolov
bc6ab39ea2 * WebAssembly exceptions fix: fixed raise without parameters in except..end
blocks in WebAssembly native and branchful exceptions mode. Fixes #39752
2022-06-21 05:43:35 +03:00
Nikolay Nikolov
12a2c56461 - removed thlcgwasm.incblock, .decblock and br_blocks, as branching is now done
entirely with labels
2021-10-22 17:42:29 +03:00
Nikolay Nikolov
5a0956d805 * use WebAssembly asm labels for the raise branch instruction in branchful
exceptions mode
2021-10-22 13:54:55 +03:00
Nikolay Nikolov
1ce2fb8a4a * use WebAssembly asm labels for generating code for the 'exit' statement 2021-10-20 14:35:51 +03:00
Nikolay Nikolov
dc9090e67f * fixed some more warnings 2021-10-20 10:23:02 +03:00
Nikolay Nikolov
0662a0bd44 + use WebAssembly asm labels for the code generation of 'break' statements as well 2021-10-20 09:59:54 +03:00
Nikolay Nikolov
01dc62b127 + introduced the use of asm labels for WebAssembly. Resolve them in
tcpuprocinfo.postprocess_code. Use them when generating code for the
  'continue' label jumps.
2021-10-20 09:39:44 +03:00
Nikolay Nikolov
0da5d57c1e * replaced the 'if br end_if' sequence with the 'br_if' instruction, when
generating WebAssembly code for try..finally blocks (in all exception modes)
2021-10-14 14:19:13 +03:00
Nikolay Nikolov
3c58f26e83 * thlcgwasm.g_checkexceptions renamed .g_maybe_checkforexceptions, added also as
an empty virtual method in thlcgobj and modified the WebAssembly
  implementation, so that it can be called from any exceptions mode (so it
  emits no code in exception modes that don't require it, instead of generating
  an internal error). This will allow .g_maybe_checkforexceptions to be called
  from the generic parts of the code generator, after calls to systemprocs that
  could raise an exceptions.
2021-10-05 17:54:35 +03:00
Nikolay Nikolov
04a41fa5b0 - removed duplicated assignment 2021-10-05 07:43:47 +03:00
Nikolay Nikolov
99ab6bd56d + proper exception object cleanup when using break, continue or exit in try
except blocks in WebAssembly native exceptions mode
2021-10-05 07:41:42 +03:00
Nikolay Nikolov
ddbdc529b1 + proper exception cleanup for try except blocks that use exit, break or
continue in WebAssembly branchful exceptions mode
2021-10-05 07:19:24 +03:00
Nikolay Nikolov
023f08d54b + exception cleanup when break, continue or exit is used inside a
try .. except 'on' block, in WebAssembly native exceptions mode
2021-10-05 06:45:31 +03:00
Nikolay Nikolov
cf7ad98dbf + support exception object cleanup, when 'exit', 'break' or 'continue' is used
in the except 'on' statements, in branchful WebAssembly exceptions mode
2021-10-05 06:25:32 +03:00
Nikolay Nikolov
f7b1ec2435 + call g_checkexceptions after calls to fpc_reraise and fpc_raise_nested in
branchful exceptions mode
2021-10-05 03:38:33 +03:00
Nikolay Nikolov
464b3ebbed + implemented the 'on' node code generation (try except 'on' ...) for the
branchful exceptions mode
2021-10-05 03:25:03 +03:00
Nikolay Nikolov
a5dcd1c44d + initial implementation of try..except in branchful exceptions mode 2021-10-05 03:14:58 +03:00
Nikolay Nikolov
7ce19c1ad7 + implemented try..finally in branchful exceptions mode 2021-10-05 02:47:49 +03:00
Nikolay Nikolov
6599f1d898 - don't generate any WebAssembly native exception handling instructions, nor
relocations, when compiling in branchful exceptions mode. This produces a
  currently not working, but accepted by wasmtime binary (otherwise, it
  complains it doesn't support exceptions and refuses to try to run it).
2021-10-05 01:01:24 +03:00
Nikolay Nikolov
5124ab2521 * cloned the WebAssembly native exceptions code generation and rtl support into
the branchful exceptions (which will be modified later, but we're using this
  as their starting point, because we can get a snapshot built, without compiler
  internal errors)
2021-10-05 00:37:20 +03:00
Nikolay Nikolov
2e5b895d70 * fixed WebAssembly code generation for 'if boolean64 then ... else ...' 2021-10-01 02:47:08 +03:00
Nikolay Nikolov
6e7f0744ca + implemented the 'on' node for WebAssembly in native exceptions mode 2021-09-28 23:55:10 +03:00
Nikolay Nikolov
0e647a073e + override the 'on' node for WebAssembly 2021-09-28 21:23:49 +03:00
Nikolay Nikolov
ef738f01cf * fixed warning 2021-09-28 20:39:47 +03:00
Nikolay Nikolov
f2abce7ea5 + initial implementation of try..except..end in wasm native exceptions mode.
The 'on' statements are not implemented yet.
2021-09-28 20:23:27 +03:00
Nikolay Nikolov
99e449eaa1 * decblock moved after end_try, instead of after catch 2021-09-28 04:11:16 +03:00
Nikolay Nikolov
0c3e179652 - get rid of fpc_PushExceptAddr and fpc_PopAddrStack entirely, when compiling in
wasm native exceptions mode - these helper routines aren't necessary in this
  mode
2021-09-28 03:59:38 +03:00
Nikolay Nikolov
c9fd115ec5 * fixes to the try..finally code generation in wasm native exceptions mode 2021-09-28 03:29:45 +03:00
Nikolay Nikolov
cdf1ceca76 * emit a weak symbol for the exception tag, since that's what the LLVM linker
wants to treat them as shared between .o files
2021-09-28 02:52:40 +03:00
Nikolay Nikolov
82b6450f19 + introduced the AT_WASM_EXCEPTION_TAG asm symbol type, use that for specifying
the parameter to the 'throw' and 'catch' instructions
2021-09-27 17:49:30 +03:00
Nikolay Nikolov
f76e91fb8b * cloned twasmtryexceptnode.pass_generate_code_no_exceptions into twasmtryexceptnode.pass_generate_code_native_exceptions 2021-09-18 02:52:24 +03:00
Nikolay Nikolov
334ea46b44 * cloned twasmraisenode.pass_1_no_exceptions into twasmraisenode.pass_1_native_exceptions 2021-09-18 02:48:51 +03:00
florian
8ad5362b17 * more warnings fixed 2021-09-17 23:44:55 +02:00
Nikolay Nikolov
87702b58c5 + emit a catch instruction in the try/end_try block, generated for
try..finally in native wasm exceptions mode
2021-09-18 00:26:00 +03:00
florian
bee87583de * avoid warnings 2021-09-17 22:27:44 +02:00
Nikolay Nikolov
619a27cbfc + insert try and end_try instructions in the try..finally code in native
WebAssembly exceptions mode
2021-09-17 21:09:17 +03:00
Nikolay Nikolov
45e53ddc16 * cloned the WASM no exceptions mode code generation for try..finally blocks
for the native WASM exceptions mode. Eventually, it is going to be changed
  to support exceptions fully, and it's going to evolve separately, so this
  code is only used as a starting point
2021-09-17 21:01:00 +03:00
Nikolay Nikolov
65a5b299c6 + introduced twasmraisenode.pass_1_no_exceptions 2021-09-17 16:53:35 +03:00
Nikolay Nikolov
6c213137a9 - cleaned up twasmtryexceptnode.pass_generate_code_no_exceptions 2021-09-17 16:21:43 +03:00
Nikolay Nikolov
c992566201 + introduced twasmtryexceptnode.pass_generate_code_no_exceptions,
.pass_generate_code_js_exceptions and .pass_generate_code_native_exceptions
2021-09-17 16:06:39 +03:00
Nikolay Nikolov
848098c63b * improvements to the handling of try..finally in WebAssembly no exceptions
mode - even though exceptions aren't supported in this mode, the finally
  section is now executed in case of exit, break or continue
2021-09-17 15:54:03 +03:00
Nikolay Nikolov
3601d61b81 + introduced twasmtryfinallynode.pass_generate_code_no_exceptions,
.pass_generate_code_js_exceptions and .pass_generate_code_native_exceptions
2021-09-17 13:37:28 +03:00
nickysn
bc42d64348 * workaround for the raise node generating invalid WebAssembly code for
obtaining the current address. Note that exception handling in WebAssembly
  doesn't work. This only fixes the raise node enough to generate valid (but not
  correct) WebAssembly code. This is a temporary fix to allow the SysUtils unit
  to be compiled. Eventually, exception handling for WebAssembly will need to be
  rewritten entirely, in order to make exceptions work properly.

git-svn-id: trunk@49259 -
2021-04-24 14:40:07 +00:00
nickysn
f81dd894aa * override the raise node for WebAssembly and copy the generic pass_1
implementation. No functional changes.

git-svn-id: trunk@49258 -
2021-04-24 14:31:56 +00:00
nickysn
7a15157387 + dummy implementation of the code generator for the try..except node for WebAssembly
git-svn-id: branches/wasm@48216 -
2021-01-19 19:28:27 +00:00
nickysn
28b9d0c6b4 + dummy code generator for the try..finally blocks in WebAssembly
git-svn-id: branches/wasm@48202 -
2021-01-19 16:24:18 +00:00
nickysn
d5caaf792c * update comment about twasmifnode, since the WebAssembly 'if' instruction that
we emit is no longer hardcoded to return a value

git-svn-id: branches/wasm@48201 -
2021-01-19 16:13:45 +00:00
nickysn
0236da1da9 * changed the formatting in nwasmflw.pas to match the style of the rest of the compiler
git-svn-id: branches/wasm@48200 -
2021-01-19 16:11:54 +00:00
nickysn
d1c58ccf4b + override the try finally node for WebAssembly. No functional changes yet.
git-svn-id: branches/wasm@48199 -
2021-01-19 16:06:37 +00:00
nickysn
a478e15836 - removed some commented out code
git-svn-id: branches/wasm@48184 -
2021-01-18 23:11:02 +00:00