Nikolay Nikolov
9da276b352
* fixed bug in thlcgwasm.a_op_reg_reg_reg_checkoverflow that used to generate
...
code that fails WebAssembly validation
2024-02-27 11:59:39 +02:00
Nikolay Nikolov
ab65c9889b
+ added the WasmBasicType to TWasmGlobalAsmSymbol. This will help WebAssembly
...
validation and stack tracking.
2024-02-25 08:54:39 +02:00
Nikolay Nikolov
f4b9d51aff
+ introduced TWasmGlobalAsmSymbol subclass of TAsmSymbol. Use it for all
...
AT_WASM_GLOBAL symbols. This allows in the future to add extra data to the
TWasmGlobalAsmSymbol, such as the WebAssembly global type, which will aid in
WebAssembly validation and stack tracking.
2024-02-25 07:29:56 +02:00
Nikolay Nikolov
21cc89f1e3
+ added a second TWasmFuncType parameter to the CALL WebAssembly instruction. It
...
is not part of the WebAssembly syntax and binary encoding, but it helps
WebAssembly stack tracking and validation.
2024-02-25 04:48:17 +02:00
Nikolay Nikolov
3defa34470
+ check whether all br instructions, generated by goto point to a pascal goto label
2023-10-22 05:23:04 +03:00
Nikolay Nikolov
5486182f56
+ introduced thlcgobj.a_jmp_always_pascal_goto - same as .a_jmp_always, but generated by a pascal goto statement
2023-10-22 04:12:59 +03:00
Nikolay Nikolov
064172d65a
* refactored thlcgwasm.a_jmp_always. No functional changes.
2023-10-22 04:03:04 +03:00
Nikolay Nikolov
cf21365a21
* fixed and enabled the is_pascal_goto_target check
2023-10-22 04:01:37 +03:00
Nikolay Nikolov
b3e64d70e7
* temporary workaround for the is_pascal_goto_target check not working properly in a_jmp_always
2023-10-22 01:09:26 +03:00
Nikolay Nikolov
b1cec6de2a
+ allow jumps to goto targets
2023-10-22 00:35:05 +03:00
Nikolay Nikolov
8cd6606970
+ support nil comparison of WebAssembly reference types (externref and funcref)
2023-06-11 07:17:04 +03:00
Nikolay Nikolov
9daabb2123
+ support using nil constants for setting values of WebAssembly reference types (funcref and externref)
2023-06-11 06:23:02 +03:00
Nikolay Nikolov
11712658b0
+ implemented WebAssembly code generator support for funcref and externref data
...
types, using new register types R_FUNCREFREGISTER and R_EXTERNREFREGISTER
2023-06-07 05:25:57 +03:00
Nikolay Nikolov
f32ef29253
* WebAssembly high level code generator: use the global.get and global.set
...
instructions to access references to symbols of type AT_WASM_GLOBAL
2022-07-26 02:13:09 +03:00
Nikolay Nikolov
4db653998b
+ generate proper WebAssembly threadvar access when multithreading is turned on
2022-07-14 02:39:07 +03:00
Nikolay Nikolov
9b16fafc52
+ generate exception checks after calls to fpc_overflow class in WebAssembly
...
branchful exceptions mode, because fpc_overflow can raise an exception in case
unit SysUtils is included.
2022-06-22 03:21:21 +03:00
Nikolay Nikolov
b11434a6f8
+ WebAssembly: use the 64-bit div instruction, instead of an RTL helper for 64-bit division
2022-06-22 01:10:02 +03:00
Nikolay Nikolov
e74797d411
* replaced several internal errors, related to the WebAssembly labels
...
resolution with more meaningful error messages, in order to ease the
debugging of the compiler. Based on patch by Pierre.
2022-05-24 11:44:15 +03:00
Nikolay Nikolov
6e4e3b8580
* fixed WebAssembly code generation in thlcgwasm.g_overflowCheck_loc (patch by Pierre)
2022-05-24 11:06:59 +03:00
Nikolay Nikolov
8bea5dd41e
* WebAssembly code generation fix in thlcgwasm.a_op_reg_reg_reg_checkoverflow, based on patch by Pierre (but simplified, to use a single block)
2022-05-24 11:00:10 +03:00
Pierre Muller
be969205ad
Do not alloc/dealloc NR_DEFAULTFLAGS for wasm32, as it is NR_NO
2022-05-17 22:47:13 +02:00
Nikolay Nikolov
c4f9ec91c9
+ fix support for 8-byte records, held in a register pair on the WebAssembly target. This fixes #39524
2022-01-25 13:03:35 +02:00
J. Gareth "Curious Kit" Moreton
2dc0995067
- Bug fix to new ADD/SUB optimisation where conditions are concerned
...
- Register allocation fixes for overflow checks
2021-11-17 20:18:57 +00: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
3094f75690
* WebAssembly code generation for 'case' nodes changed to use labels
2021-10-22 17:31:04 +03:00
Nikolay Nikolov
6fe647ee3d
* moved the default procedure CurrRaiseLabel to the end of the procedure, not
...
at the exit label. This fixes problems when using units with finalization
code that contain classes with class destructors in branchful WebAssembly
exceptions mode.
2021-10-22 13:54:55 +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
c96e203780
* moved the 'end_block' WebAssembly instruction before the 'exit' label right
...
before the procedure finalization code. This fixes compilation errors in
procedures with implicit finalization code (e.g. for ansistring local vars,
etc).
2021-10-20 14:35:52 +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
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
b91fc3a0d3
* fixed passing of singleton record parameters, containing a float in WebAssembly
2021-10-14 10:53:55 +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
7110d1e48e
* use 'br_if' instead of 'if br end_if' sequence in the code, generated by
...
thlcgwasm.g_checkexceptions
2021-10-05 05:29:10 +03:00
Nikolay Nikolov
7afb665c92
+ insert exception flag check and branch after each function call, when
...
compiling in WebAssembly branchful exceptions mode
2021-10-05 02:26:13 +03:00
Nikolay Nikolov
5be1bfeeca
+ added comment that states that raiseBr is only used in branchful exceptions mode
2021-10-05 01:11:31 +03:00
Nikolay Nikolov
d02921d66b
+ introduced raiseBr, similar to exitBr, but will point to the current
...
innermost exception handler, if there is such a handler in the current
procedure, otherwise it will be the same as exitBr.
2021-10-05 01:07:37 +03:00
Nikolay Nikolov
5adec3ca98
+ workaround for WebAssembly treating the stack parameter of the store and load
...
instructions as unsigned. This caused an 'out of bounds memory access' trap
when accessing arrays with negative offset index, e.g. in test/cg/tvec.pp
2021-10-03 03:16:34 +03:00
Nikolay Nikolov
0a383d8c0f
* fixed WebAssembly method pointer assignment
2021-10-03 02:27:19 +03:00
Nikolay Nikolov
cc2fa67dfa
* fixed OS_S8 to OS_16 conversion for WebAssembly. This fixes test/cg/tcnvint6
2021-10-02 22:10:34 +03:00
Nikolay Nikolov
d2726c2406
* fixed WebAssembly code generation for not(cbool64)
2021-10-01 05:17:12 +03:00
Nikolay Nikolov
4fc763ac50
* fixed WebAssembly cbool support for OP_NOT
2021-10-01 04:54:17 +03:00
Nikolay Nikolov
188a21bbfd
* fixed 'not(boolean64)' for WebAssembly
2021-10-01 03:01:55 +03:00
Nikolay Nikolov
812732cb6a
+ introduced the AT_WASM_GLOBAL asm symbol type
2021-09-27 02:52:29 +03:00
Nikolay Nikolov
d3ec8f0d29
* generate an internalerror if there are values remaining on top of stack
...
at the end of a procedure. If the compiler is compiled with
DEBUG_WASMSTACK, the previous asm comment message is emitted instead of
internal error.
2021-09-18 18:10:57 +03:00
Nikolay Nikolov
f7cc2d560c
+ initialize br_blocks in the thlcgwasm constructor
2021-09-18 16:29:19 +03:00
Nikolay Nikolov
a3610bfea1
+ also added stack underflow check in thlcgwasm.incstack (in case stack
...
height was already negative in the beginning, due to previous underflow)
2021-09-18 16:28:14 +03:00
Nikolay Nikolov
d4bd1f1e9b
* don't halt with an internal error, but add an asm comment instead, when a
...
stack underflow is detected in thlcgwasm.decstack and when the compiler is
compiled with the DEBUG_WASMSTACK define
2021-09-18 16:28:14 +03:00
Nikolay Nikolov
58e4692795
* fixed thlcgwasm.g_adjust_stack_after_call after the removal of discardresult
2021-09-18 16:28:14 +03:00
Nikolay Nikolov
9526b939a2
+ implemented thlcgwasm.g_unreachable, emits the 'unreachable' WebAssembly instruction
2021-09-17 03:41:45 +03:00