Commit Graph

696 Commits

Author SHA1 Message Date
Nikolay Nikolov
c515d45026 + added new target to the compiler: wasm32-wasip2. Not working, yet. 2025-03-10 21:53:40 +02:00
Nikolay Nikolov
d1dbbc0a35 + also handle system_wasm32_wasip1threads in the compiler anywhere system_wasm32_wasip1 is handled 2025-02-28 15:12:21 +02:00
Nikolay Nikolov
e20466ffd1 * system_wasm32_wasi renamed system_wasm32_wasip1 2025-02-28 15:12:19 +02:00
Nikolay Nikolov
0c939ac6c6 + WebAssembly: added support for using saturating (non-trapping) float-to-int conversion instructions via the new target switch SATURATINGFLOATINGTOINT 2025-02-25 09:08:55 +02:00
Nikolay Nikolov
671a36c823 * fixed WebAssembly goto in case statement crash with internal error 2021011801 2025-02-25 08:22:26 +02:00
Nikolay Nikolov
4b757dd360 * On WebAssembly, when calling a function, first generate code for evaluating
all the parameters, and only after that, push them on the stack. This avoids
  problems with our 'goto' support.
2025-02-25 07:29:36 +02:00
Nikolay Nikolov
79b240ec81 * WebAssembly goto support: skip unused labels in resolve_labels_via_state_machine. Fixes #41093 2025-02-24 16:57:26 +02:00
Nikolay Nikolov
7c44300136 * WebAssembly: fixed type conversion from pointer to qword (fixes bug #41092) 2025-02-24 10:48:18 +02:00
Nikolay Nikolov
39fb7618e4 * WebAssembly internal linker: refactored the writing of the memory section and
the memory import section: introduced a TWasmMemoryType record, and structures
  for holding the memory entries in the import and memory sections, instead of
  writing them in an ad hoc manner. The memory information in the linker map
  file is now also a little more detailed.
2025-02-16 03:22:20 +02:00
Nikolay Nikolov
c005544f3d + WebAssembly internal linker: write the global section in the linker map file 2025-02-16 02:11:52 +02:00
florian
b2f6214b33 + a_bit_scan_reg_reg gets a flag if src cannot be zero: this simplifies the generated code 2025-02-08 14:27:48 +01:00
Nikolay Nikolov
ba8554fcf5 * override tcpuparamanager.has_strict_proc_signature and return true for WebAssembly 2025-02-02 19:11:14 +02:00
Nikolay Nikolov
9a77a855e4 * WebAssembly codegen: enable -CN nil pointer checks in more places: a_cmp_const_ref_stack, a_cmp_ref_reg_stack and a_cmp_reg_ref_stack 2025-02-02 17:17:42 +02:00
Nikolay Nikolov
bd1a6a60e8 + added ref2string debug helper function to the WebAssembly code generator 2025-02-02 17:05:40 +02:00
Nikolay Nikolov
6ce57a1625 * WebAssembly: also handle dup=true in thlcgwasm.prepare_stack_for_ref for absolute address refs 2025-02-02 16:46:44 +02:00
Nikolay Nikolov
2e77e1a471 * WebAssembly codegen: fixed access to absolute variables, pointing to just a constant address, e.g. var a: longint absolute 5; 2025-02-02 16:26:42 +02:00
Nikolay Nikolov
5f9ea00b38 * fixed WebAssembly code generator internal error when passing real constants as
constref parameters. Also fixes test webtbs/tw41011
2025-01-28 10:52:21 +02:00
Nikolay Nikolov
3ae64e5e17 + include unit aoptcpu in wasm32/cputarg.pas 2024-09-21 15:41:26 +03:00
Nikolay Nikolov
a7be888255 + add optimizer units (empty for now) for the WebAssembly target 2024-09-21 14:50:16 +03:00
Nikolay Nikolov
29ee863e8f - WebAssembly code generator: removed the g_fingerprint hack, that added 4
useless i64 constants on the stack with random numbers and then drop them. It
  was used for primitive debugging, since previously it wasn't possible to
  identify the function name. Now we can produce DWARF debug info, as well as a
  "names" custom section to give each function a name and most WebAssembly
  environments support at least one of the two mechanisms. Therefore the
  g_fingerprint hack is no longer necessary.
2024-09-17 06:14:03 +03:00
Nikolay Nikolov
1a08d76ccb + WebAssembly: insert a tai_local directive also for assembler functions 2024-09-15 02:12:48 +03:00
Nikolay Nikolov
b9ca30165c * WebAssembly: refactored tai_local, so that it is a single directive,
containing multiple locals, instead of creating multiple tai_local directives,
  each containing a single local. No functional changes.
2024-09-15 00:49:05 +03:00
Nikolay Nikolov
05b67c7408 - WebAssembly: removed tai_local.name, because we don't use it 2024-09-15 00:09:39 +03:00
Nikolay Nikolov
99943610cb * 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.
2024-09-11 07:46:23 +03:00
Nikolay Nikolov
c8e4a52428 + WebAssembly internal object writer: added safety check for catching bugs,
caused by instruction size changes between Pass1 and Pass2
2024-09-11 04:44:50 +03:00
Nikolay Nikolov
d41d98b70b * WebAssembly internal object writer: fixed helper function SlebSize() 2024-09-11 04:44:05 +03:00
Nikolay Nikolov
964aa8b71b + added an optional nil pointer checking for WebAssembly (similar to
PowerPC-AIX), that can be activated via the -CN option
2024-09-03 18:05:52 +03:00
Nikolay Nikolov
6149fe394e * unit agwat renamed agwasa 2024-09-02 02:09:34 +03:00
Nikolay Nikolov
3d204dd0da * TWabtTextAssembler class renamed TWasaTextAssembler 2024-09-02 02:07:48 +03:00
Nikolay Nikolov
75e061e06f * as_wasm_wabt_info renamed as_wasm_wasa_info 2024-09-02 02:07:09 +03:00
Nikolay Nikolov
3e036e4ff8 * WebAssembly WABT assembler ID changed to WASA 2024-09-02 02:06:40 +03:00
Nikolay Nikolov
d786b639c0 * WebAssembly wabt assembler id as_wasm32_wabt renamed as_wasm32_wasa 2024-09-02 02:06:16 +03:00
Nikolay Nikolov
293ddffebd + disable the WebAssembly type checker for all LLVM-MC versions since version 13 2024-09-01 21:20:43 +03:00
Nikolay Nikolov
342ede81ee * WebAssembly code generator: don't emit a return instruction at the end of the
function, because it's redundant
2024-09-01 20:28:42 +03:00
Nikolay Nikolov
6ab6d613e0 + add explicit support for LLVM-MC versions 15..18 2024-09-01 20:10:54 +03:00
Nikolay Nikolov
a76ca8f60e + pass '--no-type-check' to llvm-mc-13, because its type checking is broken 2024-09-01 20:03:29 +03:00
Nikolay Nikolov
5e327453a8 + WebAssembly external asm writer: workaround for the 'missing functype' error,
produced by LLVM-MC versions 13 and above
2024-09-01 19:52:50 +03:00
Nikolay Nikolov
54d65ff75c * WebAssembly: fixed crash when attempting to generate a functype directive for
a generic function
2024-08-25 20:49:55 +03:00
Nikolay Nikolov
b6527c6c03 + WebAssembly: check for exceptions after call of fpc_rangeerror in branchful
exceptions mode. This fixes catching of ERangeError exceptions when using
  SysUtils and runtime errors are converted to exceptions.
2024-08-25 13:43:50 +03:00
Nikolay Nikolov
58a3f2ef64 * WebAssembly: changed the generated code in a_op_reg_reg_reg_checkoverflow to
avoid using a label
2024-08-25 13:23:45 +03:00
Nikolay Nikolov
7a1c50ff87 * fix warning 2024-08-25 12:20:55 +03:00
Nikolay Nikolov
d2785117df * WebAssembly: fixed overflow checking for unsigned subtraction 2024-08-25 11:48:53 +03:00
Nikolay Nikolov
4f42553cb3 * fix bug in thlcgwasm.a_op_reg_reg_reg_checkoverflow when either src1 or src2
is the same as dst
2024-08-25 11:33:33 +03:00
Nikolay Nikolov
8bbb28ace8 + WASI: enable the generic stack checking 2024-08-06 05:00:14 +03:00
Nikolay Nikolov
ee3ff19312 + allow referencing TLS_SIZE_SYM, TLS_ALIGN_SYM and TLS_BASE_SYM from WebAssembly inline asm 2024-07-22 16:45:26 +03:00
Nikolay Nikolov
43229cdf2e + support the atomic instructions in the WebAssembly inline asm reader 2024-07-22 02:02:25 +03:00
Nikolay Nikolov
fcfcdc2ccd - removed debug printing from the WebAssembly inline assembler reader 2024-07-21 21:05:53 +03:00
Nikolay Nikolov
5cfd214b68 * fixed WebAssembly inline asm parsing bug for the global.get/global.set ID instruction 2024-07-21 18:13:42 +03:00
Nikolay Nikolov
b08b5bf136 * fixed the WebAssembly inline asm call instruction with the internal assembler writer 2024-07-20 21:53:24 +03:00
Nikolay Nikolov
d8340641cc + support the call instruction in the WebAssembly inline asm 2024-07-20 21:30:00 +03:00