Nikolay Nikolov
b821b9d502
+ WebAssembly multithreading: also declare threadvar sections as TLS and prefix their name with '.tbss' when using the external assembler
2022-07-13 23:50:48 +03:00
Nikolay Nikolov
b923613ead
+ make use of the unsigned remainder instructions in WebAssembly (i32.rem_s, i64.rem_u)
2022-06-22 03:37:36 +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
b2350d90ea
* fixed typo in comment
2022-06-22 02:09:05 +03:00
Nikolay Nikolov
90e43e055b
* fixed WebAssembly code generation for integer unary minus with overflow checking
2022-06-22 01:47:07 +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
4d6e3b4e1a
* Don't call secondpass(left) in twasmtypeconvnode.second_int_to_real, this fixes bug #39735 .
2022-06-21 23:59:25 +03:00
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
Pierre Muller
2307dc8f26
Try to fix real constant problems for llvm compiler
2022-06-07 23:51:27 +02:00
Nikolay Nikolov
d378240134
+ added the WebAssembly saturating truncation instructions to the internal assembler
2022-05-28 17:41:28 +03:00
Nikolay Nikolov
0ba7ef98b3
+ support the memory.init and the data.drop instructions in the internal asm writer for WebAssembly
2022-05-28 16:00:43 +03:00
Nikolay Nikolov
3a095f5ed5
+ support all the new types in encode_wasm_basic_type
2022-05-28 00:30:43 +03:00
Nikolay Nikolov
907e8402ab
+ added the WebAssembly reference and vector types to TWasmBasicType
2022-05-28 00:16:51 +03:00
Nikolay Nikolov
2888710594
+ added the WebAssembly table instructions
2022-05-28 00:02:27 +03:00
Nikolay Nikolov
534383f686
+ added the WebAssembly reference instructions ref.null, ref.is_null and ref.func
2022-05-27 23:58:27 +03:00
Nikolay Nikolov
e2eadc51a3
+ added the memory.init and data.drop instructions
2022-05-27 23:38:49 +03:00
Nikolay Nikolov
dbba2d2746
+ implemented popcnt via the popcnt instruction in WebAssembly
2022-05-27 23:23:27 +03:00
Nikolay Nikolov
66b471e516
+ support different versions of llvm-mc (version 10 seems to be the earliest that works)
2022-05-26 15:06:35 +03:00
Nikolay Nikolov
16f5863847
+ added WebAssembly atomic store intrinsics
2022-05-25 19:22:45 +03:00
Nikolay Nikolov
0103964250
+ implemented WebAssembly atomic load intrinsics
2022-05-25 18:55:41 +03:00
Nikolay Nikolov
9274f17c52
+ reserved inline numbers for the WebAssembly atomic loads and stores
2022-05-24 16:06:05 +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
Nikolay Nikolov
283c213a0c
* patch by Pierre, which fixes WebAssembly code generation for signed div/mod with overflow checking
2022-05-24 10:47:38 +03:00
Nikolay Nikolov
f1cb5d8f71
+ support intrinsic for the memory.atomic.notify WebAssembly instruction
2022-05-21 18:03:14 +03:00
Nikolay Nikolov
86643710c4
+ support intrinsics for the WebAssembly memory.atomic.wait32 and memory.atomic.wait64 instructions
2022-05-21 17:53:38 +03:00
Nikolay Nikolov
3cfdf000a2
+ support the new WebAssembly threads and atomics instructions in the internal assembler
2022-05-21 17:24:21 +03:00
Nikolay Nikolov
e03b920520
+ added intrinsic support for the WebAssembly cmpxchg atomic operations as well
2022-05-21 02:52:31 +03:00
Nikolay Nikolov
d8f06aa4f1
+ added instrinsic support for the all the 2-parameter read-modify-write
...
WebAssembly atomic operations (add, sub, and, or, xor, xchg). Note that they
are not implemented in the internal assembler, yet.
2022-05-20 17:36:37 +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
812736bd41
+ support the atomic.fence instruction in the WebAssembly internal object writer
2022-05-13 22:56:36 +03:00
Nikolay Nikolov
1d70437017
+ added intrinsic (for RTL internal use) that emits the WebAssembly atomic.fence instruction
2022-05-13 22:46:27 +03:00
Nikolay Nikolov
ddab39dbdc
+ enable the atomics extension on the llvm-mc command line (extension appears
...
to be recognized since LLVM 8.0, so it should be safe to always enable this
from the llvm-mc command line)
2022-05-13 21:15:54 +03:00
Nikolay Nikolov
5198e47e36
+ added the atomic memory access WebAssembly instructions from the threading proposal for WebAssembly
2022-05-13 20:55:12 +03:00
florian
27fb9086aa
* cleanup: cs_opt_loopunroll is a generic optimization for a long time already
2022-03-08 23:03:18 +01:00
Nikolay Nikolov
2c0f10d988
* when adding WebAssembly object info, traverse through current_module.used_units,
...
as well as the usedunits global. This resolves #39543
2022-02-12 08:32:48 +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
florian
6404478ea4
* cleanup of VER3_0 defines
2021-11-17 22:19:57 +01: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
Yuriy Sydorov
b78761efd3
* Removed obsolete OLDREGVARS ifdefs.
2021-11-02 17:08:08 +02:00
florian
ff3acfb8cd
* cleanup of 2.7.0 defines
2021-10-31 13:20:28 +01:00
Nikolay Nikolov
7f1050464a
+ added 'else' tracking for the if..end_if blocks
2021-10-23 11:56:25 +03:00
Nikolay Nikolov
7bef4d827d
* keep track of the block stack, when resolving labels and check whether the
...
blocks match (i.e. block..end_block, if..end_if, loop..end_loop, try..end_try)
2021-10-23 11:25:44 +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
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
470e77a572
+ added sanity check when resolving labels to ensure we don't get any jumps with
...
negative nesting depth
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
4e3a6aa5a8
* match the label to the wider block, if it is adjacent to both the brevious
...
and the next instruction
2021-10-20 14:35:52 +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
bb30958665
+ wrap block nodes with exit in a_block..a_end_block instructions. This fixes
...
'exit' in inlined procedures on the WebAssembly target.
2021-10-20 14:35:51 +03:00
Nikolay Nikolov
703ae75ba6
* if a label cannot be associated with the previous block instruction, try
...
matching it with the next instruction
2021-10-20 14:35:51 +03:00
Nikolay Nikolov
9f077d4ac0
* leave unresolved branches in the asm output, when the compiler is compiled with -dEXTDEBUG
2021-10-20 14:35:51 +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
b3a9c36cbb
* fixed some warnings
2021-10-20 10:03:14 +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
dcae87bd52
+ support cdecl and stdcall on the WebAssembly target. They are essentially the
...
same, the only difference is that cdecl creates an unmangled alias
2021-10-14 12:29:59 +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
df92d88f39
+ added support for the handling of singleton record and array types in
...
defToWasmBasic
2021-10-14 10:53:55 +03:00
Nikolay Nikolov
3511b80972
* fixed formatting in defToWasmBasic
2021-10-14 10:53:55 +03:00
Nikolay Nikolov
ee387f7c66
* C ABI fixes for the passing of records in WebAssembly
2021-10-14 10:53:55 +03:00
Nikolay Nikolov
236e10d03a
+ pass 64-bit structures by address in WebAssembly for compatibility with LLVM's C ABI
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
fab4ca449b
* twasmexceptionstatehandler_nativeexceptions.handle_nested_exception and
...
twasmexceptionstatehandler_bfexceptions.handle_nested_exception should not be
called, so now they cause an internal error
2021-10-05 07:54:57 +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
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
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
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
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
41db71c21c
+ implemented the <= operator for smallsets for WebAssembly
2021-10-03 04:37:13 +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
6f88919f37
- don't set casmdata in wasm32/aasmcpu.pas, so that the aasmdef unit can override it
2021-10-03 00:59:11 +03:00
Nikolay Nikolov
c1eeb8beda
+ use the aasmdef unit in wasm32/cpunode.pas
2021-10-03 00:49:53 +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
3258937d97
+ implemented move() for WebAssembly via the memory.copy instruction
2021-10-02 21:33:28 +03:00
Nikolay Nikolov
2e3e3edb5f
+ implemented FillChar for WebAssembly via the memory.fill instruction
2021-10-02 20:31:37 +03:00
Nikolay Nikolov
85207e94f8
+ added inline numbers for a memory.copy and a memory.fill intrinsic
2021-10-02 19:40:36 +03:00
Nikolay Nikolov
026d23632a
+ added the memory.copy and memory.fill WebAssembly instructions
2021-10-02 19:35:26 +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
baf5ff4e05
* another WebAssembly cbool fix in twasmtypeconvnode.second_int_to_bool
2021-10-01 04:40:50 +03:00
Nikolay Nikolov
968e23546c
* fixed second_int_to_bool for cbool types for WebAssembly
2021-10-01 04:20:02 +03:00
Nikolay Nikolov
188a21bbfd
* fixed 'not(boolean64)' for WebAssembly
2021-10-01 03:01:55 +03:00
Nikolay Nikolov
c6a549eb48
* int64/boolean64 fix in twasmtypeconvnode.second_int_to_bool
2021-10-01 02:57:04 +03:00
Nikolay Nikolov
2e5b895d70
* fixed WebAssembly code generation for 'if boolean64 then ... else ...'
2021-10-01 02:47:08 +03:00
Nikolay Nikolov
4d571a1928
* fixed code generation for 'boolean64 and/or boolean64' for WebAssembly
2021-10-01 02:43:55 +03:00
Nikolay Nikolov
91d8009b53
+ implemented round(real) for WebAssembly via the fXX.nearest and i64.trunc_fXX_s instructions
2021-09-29 05:27:27 +03:00
Nikolay Nikolov
835bc62e2a
+ implemented trunc(real) for WebAssembly via the i64.trunc_f32_s and i64.trunc_f64_s instructions
2021-09-29 05:07:43 +03:00
Nikolay Nikolov
f6b4a54f7d
* fixed output of 32-bit floating point constants in the llvm-mc asm output
2021-09-29 04:57:19 +03:00
Nikolay Nikolov
d84a7d1bde
+ implemented int(real) for WebAssembly via the f32.trunc and f64.trunc instructions
2021-09-29 04:19:10 +03:00
Nikolay Nikolov
8822be8a1f
+ implemented abs(real) for WebAssembly via the f32.abs and f64.abs instructions
2021-09-29 04:04:03 +03:00
Nikolay Nikolov
f42817d1a2
* fixed opcode generation for the f32.const in the WebAssembly internal asm
2021-09-29 03:56:13 +03:00
Nikolay Nikolov
95243ed6ed
+ implemented sqrt via the f32.sqrt and f64.sqrt instructions
2021-09-29 03:48:31 +03:00
Nikolay Nikolov
6e6c946e0f
* the fpc_Catches result test code was inverted
2021-09-29 00:17:17 +03:00
Nikolay Nikolov
99dbbcadcd
+ generate functype directives for all functions in all used units, regardless
...
of whether they have paraloc info created. This fixes linking of WebAssembly
programs that declare their own classes, because that causes the compiler to
generate a VMT, containing references to virtual methods, and these don't
necessarily have paraloc info (if they're not called from within the program)
2021-09-29 00:04:23 +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
f701d2f294
+ support in_wasm32_throw_fpcexception in twasminlinenode.pass_typecheck_cpu
2021-09-28 01:11:01 +03:00
Nikolay Nikolov
ec0bdfbdd9
* fill exceptstate variables and update flowcontrol in
...
twasmexceptionstatehandler_nativeexceptions.new_exception
- removed the TODO comment, generated in the asm output by
twasmexceptionstatehandler_nativeexceptions.free_exception
2021-09-28 00:19:13 +03:00
Nikolay Nikolov
b463f2a141
+ added support for exception tags and for the 'throw' and 'catch' instructions
...
in the wasm internal assembler and object writer
2021-09-27 21:44:09 +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
e0ad427b6c
+ introduced the FPC_EXCEPTION_TAG_SYM string constant
2021-09-27 17:38:28 +03:00
Nikolay Nikolov
b46c010f82
+ also support immutable wasm globals in the wasm assembler writer (both internal and external)
2021-09-27 05:40:26 +03:00
Nikolay Nikolov
2bce4d36db
+ proper support for WASM globals in the internal object writer - emit
...
relocations, generate a Global section, if they are declared in the object
file, etc.
2021-09-27 04:24:49 +03:00
Nikolay Nikolov
812732cb6a
+ introduced the AT_WASM_GLOBAL asm symbol type
2021-09-27 02:52:29 +03:00
Nikolay Nikolov
8226233aa3
* introduced the tai_globaltype asm directive, use that to declare the stack
...
pointer global symbol
2021-09-27 02:39:43 +03:00
Nikolay Nikolov
a1c8e92904
* emit a tai_tagtype for __FPC_exception instead of hardcoding the asm output
...
directly when wasm native exceptions are enabled
2021-09-27 00:33:57 +03:00
Nikolay Nikolov
10db5ea5dc
+ implemented the 'delegate' and the 'rethrow' instructions in the wasm internal assembler
2021-09-26 23:58:21 +03:00
Nikolay Nikolov
6fb4b9b7dd
+ support the 'try' instruction in the wasm internal assembler
2021-09-26 23:50:02 +03:00
Nikolay Nikolov
db843287a2
+ generate funcdef for external procs, that don't have an import dll
2021-09-26 20:37:34 +03:00
Nikolay Nikolov
346b57e238
* tai_impexp renamed tai_export_name
...
* ait_importexport renamed ait_export_name
2021-09-26 18:35:10 +03:00
Nikolay Nikolov
2940d0f45f
- removed unused constructor of tai_impexp, as well as unused member variable extmodule
2021-09-26 18:29:28 +03:00
Nikolay Nikolov
cb3ac37fb3
* fixed i32.const with large unsigned 32-bit const parameter (>2GB)
2021-09-26 09:50:35 +03:00
Nikolay Nikolov
92fb1d2564
* fixed warning
2021-09-26 08:25:22 +03:00
Nikolay Nikolov
9e0c028142
+ support load/store with op_const
2021-09-26 08:15:04 +03:00
Nikolay Nikolov
7e9607a62c
* fixed warning
2021-09-26 08:07:21 +03:00
Nikolay Nikolov
2e491d1ffa
+ implemented the br and br_if instructions in the wasm internal asm
2021-09-26 07:58:59 +03:00
Nikolay Nikolov
ca70cb05a7
* fixed warning
2021-09-26 07:54:20 +03:00
Nikolay Nikolov
07b71ac6ce
* generate an internal error instead of warning for unsupported opcodes
...
in the internal asm writer for wasm
2021-09-26 07:48:31 +03:00
Nikolay Nikolov
d7b141d70e
+ implemented the if, loop and else instructions
2021-09-26 07:45:14 +03:00
Nikolay Nikolov
6133affad6
+ implemented the f32.const and f64.const instructions in the wasm
...
internal asm
2021-09-26 07:19:36 +03:00
Nikolay Nikolov
0486caeb91
* generate an internal error, instead of warning for i32.const and
...
i64.const instructions with an unknown parameter
2021-09-26 06:58:46 +03:00
Nikolay Nikolov
81b8574bfd
+ implemented all the load/store instructions in the wasm internal asm
...
writer (previously, only i32.load and i32.store were implemented)
2021-09-26 06:49:51 +03:00
Nikolay Nikolov
7f5250bf46
+ implemented support for R_WASM_TABLE_INDEX_SLEB relocations
2021-09-26 06:22:41 +03:00
Nikolay Nikolov
9fa2e2934b
+ support the call_indirect instruction and the R_WASM_TYPE_INDEX_LEB
...
relocation that it requires in the internal wasm object writer
2021-09-26 06:03:18 +03:00
Nikolay Nikolov
b913133152
+ implemented leb and sleb relocations to data symbols
2021-09-26 02:23:31 +03:00
Nikolay Nikolov
54481d7218
* moved the imports/funcdef writing from the llvm-mc assembler writer to
...
twasmnodeutils.InsertObjectInfo. This way, the info it produces will be
shared with the internal wasm object writer as well.
2021-09-25 00:16:53 +03:00
Nikolay Nikolov
d19919aa13
* TLLVMMachineCodePlaygroundAssembler.WriteImports now uses just a single TAsmList
2021-09-25 00:02:14 +03:00
Nikolay Nikolov
a6e75d52f7
+ introduced tai_import_module and tai_import_name that represent the
...
.import_module and .import_name assembler directives
2021-09-24 22:14:32 +03:00
Nikolay Nikolov
459bb0fa18
* override twasmnodeutils.InsertObjectInfo
2021-09-24 21:52:57 +03:00
Nikolay Nikolov
860e4487c3
+ added WebAssembly node utils
2021-09-24 16:44:33 +03:00
Nikolay Nikolov
4ca39cf07d
+ write the import functions in the wasm binary writer
2021-09-23 17:11:24 +03:00
Nikolay Nikolov
a58368d20d
+ avoid duplicate functypes in the types section of the wasm module we produce
2021-09-20 19:33:48 +03:00
Nikolay Nikolov
3e2a9b6ceb
+ handle the call instruction in the wasm binary writer
2021-09-20 05:03:38 +03:00
Nikolay Nikolov
628fcb9b1c
+ create the Type wasm section
2021-09-20 03:43:23 +03:00
Nikolay Nikolov
fced051f5f
+ implemented binary encoding of a_i32_load and a_i32_store without symbol
2021-09-20 03:00:37 +03:00
Nikolay Nikolov
b975317c51
+ implemented the encoding of the block instruction without operands
2021-09-20 02:37:40 +03:00
Nikolay Nikolov
079e5ae151
+ encode the end_function dummy instruction
2021-09-20 02:24:28 +03:00
Nikolay Nikolov
b7c638a717
+ implemented binary encoding of the global.get and global.set instructions
2021-09-20 02:19:18 +03:00
Nikolay Nikolov
4a886e2019
* simplified operand access via the 'with' operator
2021-09-20 02:09:42 +03:00
Nikolay Nikolov
4dd44427c0
+ implemented instruction encoding for local.get, local.set and local.tee
2021-09-20 02:03:47 +03:00
Nikolay Nikolov
2954588e4d
+ implemented binary output for the i32.const and i64.const with top_const parameter
2021-09-20 01:46:07 +03:00
Nikolay Nikolov
5b3efc4b38
+ implemented encoding of the most simple wasm instructions
2021-09-20 01:24:39 +03:00
Nikolay Nikolov
cc314e61a2
+ started working on the WebAssembly internal assembler
2021-09-19 16:17:09 +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
324382d3a5
* use create_functype to determine accurately the number of parameters to
...
discard in twasmcallnode.do_release_unused_return_value. This fixes
various stack tracking bugs when a constructor is invoking another
constructor, etc.
2021-09-18 17:59:50 +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
fa36141649
* fixed the stack tracking in twasmcallnode.do_release_unused_return_value for
...
ret_in_param function calls
2021-09-18 16:28:14 +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
Nikolay Nikolov
c2754eac3f
+ introduced the wasm32_throw_fpcexception inline function, that emits a
...
'throw' instruction. This way we'll be able to emit this instruction from
RTL code (i.e. from fpc_raiseexception, when that is implemented for
WebAssembly)
2021-09-18 02:39:16 +03:00
Nikolay Nikolov
ac2f299d04
+ declare __FPC_exception as a label, otherwise wasm-ld crashes
2021-09-18 01:47:28 +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
Nikolay Nikolov
288f79cb3b
+ declare the __FPC_exception tag, when compiling with native WebAssembly
...
exceptions
2021-09-17 23:46:38 +03:00
Nikolay Nikolov
d8665f8a51
* write the .globaltype directive and the imports in the beginning of the
...
assembly file, because that appears to be required by llvm-mc from git
2021-09-17 23:46:38 +03:00
florian
bee87583de
* avoid warnings
2021-09-17 22:27:44 +02:00
Nikolay Nikolov
d36e239f45
+ enabled the exception handling instructions in the llvm-mc command line
2021-09-17 21:20:14 +03: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
Nikolay Nikolov
2bcc8d65ff
+ introduced twasmexceptionstatehandler_nativeexceptions and
...
twasmexceptionstatehandler_jsexceptions
2021-09-17 13:12:34 +03:00
Nikolay Nikolov
3ca9475bde
* twasmexceptionstatehandler renamed twasmexceptionstatehandler_noexceptions
2021-09-17 12:33:34 +03:00
Nikolay Nikolov
9526b939a2
+ implemented thlcgwasm.g_unreachable, emits the 'unreachable' WebAssembly instruction
2021-09-17 03:41:45 +03:00
Nikolay Nikolov
3022f59ff4
+ introduced ait_tagtype and tai_tagtype
2021-09-17 02:05:24 +03:00
Nikolay Nikolov
10d8332563
+ added the new WebAssembly instructions, added by the exception handling proposal
2021-09-16 23:45:03 +03:00
Nikolay Nikolov
3bf5b0c395
- avoid useless typecasts for accessing members in self in thlcgwasm.a_load_subsetref_regs_index
2021-09-16 15:15:39 +03:00
Nikolay Nikolov
4120825f50
+ implemented thlcgwasm.a_load_regconst_subsetref_intern
2021-09-16 15:14:51 +03:00
Nikolay Nikolov
7af6e628c8
+ implemented thlcgwasm.a_load_subsetref_regs_index
2021-09-16 14:30:29 +03:00
Nikolay Nikolov
c41516399b
+ implemented thlcgwasm.a_load_subsetref_stack
2021-09-16 12:10:43 +03:00
Nikolay Nikolov
ba9a8ab069
+ added thlcgwasm.a_load_subsetref_stack, not implemented yet
2021-09-09 14:11:20 +03:00
nickysn
715de4547a
* fixed WASI dll imports that are declared in a different unit
...
git-svn-id: trunk@49537 -
2021-06-23 20:36:52 +00:00
nickysn
b527ab694c
+ implemented twasmtypeconvnode.second_class_to_intf
...
git-svn-id: trunk@49451 -
2021-06-01 22:15:57 +00:00
nickysn
74bac86711
+ support loading a function result (on the evaluation stack) to a register in
...
thlcgwasm.gen_load_cgpara_loc
git-svn-id: trunk@49449 -
2021-06-01 21:52:51 +00:00
nickysn
08f9a68798
- removed unused local variables from twasmaddnode.second_generic_compare
...
git-svn-id: trunk@49435 -
2021-06-01 19:11:21 +00:00
nickysn
8dd591e838
+ implemented twasmaddnode.second_cmpsmallset for equaln and unequaln
...
git-svn-id: trunk@49434 -
2021-06-01 19:10:20 +00:00
nickysn
c42e297bc6
+ implemented sqr(real) for the WebAssembly target
...
git-svn-id: trunk@49430 -
2021-06-01 16:41:39 +00:00
pierre
570af33fa9
Add a second handling of NIL entries in deflist
...
git-svn-id: trunk@49270 -
2021-04-26 21:12:02 +00: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
pierre
e6045673ee
Handle NIL entries in deflist after commit 48986
...
git-svn-id: trunk@49230 -
2021-04-18 15:44:07 +00:00
nickysn
dbecb67d45
* fixed the value passing of record parameters with non-scalar value size on the
...
WebAssembly target
git-svn-id: trunk@49218 -
2021-04-17 14:25:54 +00:00
nickysn
947f9af0e5
+ fixed code generation for high(dynarray) for the WebAssembly target
...
git-svn-id: trunk@49217 -
2021-04-17 13:58:55 +00:00
nickysn
4f828929a3
* fixed the support for infinity and nan float literal values in the webassembly
...
llvm-mc asm writer
git-svn-id: trunk@49213 -
2021-04-16 23:40:11 +00:00
nickysn
340a71d2bc
* always keep the WebAssembly stack frame aligned on 16 bytes
...
git-svn-id: trunk@49179 -
2021-04-11 14:02:40 +00:00
nickysn
9fa61a6c9f
- removed the discardresult proc directive
...
git-svn-id: trunk@49017 -
2021-03-20 01:22:43 +00:00
nickysn
ecad5e9a6c
+ WebAssembly implementation of g_rangecheck that uses if/endif instead of
...
jumps to labels (which causes internal compiler error, because they're not
supported in WebAssembly)
git-svn-id: trunk@49000 -
2021-03-18 16:45:40 +00:00
nickysn
d090af4abe
* skip nil values in current_module.deflist in TLLVMMachineCodePlaygroundAssembler.WriteImports
...
git-svn-id: trunk@48985 -
2021-03-15 18:12:36 +00:00
nickysn
76c61c3aac
* call inherited inside twasminnode.checkgenjumps in order to initialize use_small
...
git-svn-id: trunk@48971 -
2021-03-14 16:56:16 +00:00
nickysn
f0aed5d355
* fixed another WebAssembly compilation error with -CR
...
git-svn-id: trunk@48966 -
2021-03-14 15:06:13 +00:00
nickysn
74854eee58
* fixed WebAssembly compilation error with -CR
...
git-svn-id: trunk@48964 -
2021-03-14 15:03:58 +00:00
nickysn
e2e0756eaf
* fixed compilation with -Sew
...
git-svn-id: branches/wasm@48446 -
2021-01-28 16:25:03 +00:00
nickysn
0ceefa4d22
+ enabled DWARF debug info writing on the WebAssembly target. Note that it
...
doesn't work yet (produces internal errors).
git-svn-id: branches/wasm@48445 -
2021-01-28 16:16:32 +00:00
nickysn
4ef1367019
+ added wasm32 inline procedure for generating the 'unreachable' instruction
...
git-svn-id: branches/wasm@48442 -
2021-01-28 12:48:56 +00:00
nickysn
eb7db76a31
* fixed compiler internal error, when compiling a unit that has an external function in its interface section
...
git-svn-id: branches/wasm@48421 -
2021-01-25 20:53:01 +00:00
nickysn
f77ae51751
* the wasm target (now 'embedded') moved to the i_embed/t_embed units
...
git-svn-id: branches/wasm@48365 -
2021-01-24 01:45:35 +00:00
nickysn
807c743e35
* system identifier system_wasm32_wasm renamed system_wasm32_embedded
...
git-svn-id: branches/wasm@48362 -
2021-01-24 01:01:39 +00:00
nickysn
594be1be04
* properly handle reference with negative offsets
...
git-svn-id: branches/wasm@48340 -
2021-01-23 05:27:32 +00:00
nickysn
b35d3c5f3a
* don't override inittempvariables for WebAssembly, because things like
...
ansistrings actually need to be initialized to zero on proc entry
git-svn-id: branches/wasm@48338 -
2021-01-23 04:42:52 +00:00
nickysn
f891c52dd1
- removed tarrayreftype, because it's not used on the wasm target
...
git-svn-id: branches/wasm@48336 -
2021-01-22 21:47:08 +00:00
nickysn
f294ea5028
- removed commented out code from aasmcpu.pas
...
git-svn-id: branches/wasm@48335 -
2021-01-22 18:23:15 +00:00
nickysn
1003d6499f
* formatting
...
git-svn-id: branches/wasm@48333 -
2021-01-22 16:35:32 +00:00
nickysn
9e95895a9b
* get rid of the internal error in thlcgwasm.a_cmp_ref_reg_stack by using swap_opcmp
...
git-svn-id: branches/wasm@48332 -
2021-01-22 16:31:31 +00:00
nickysn
5a84c4db61
- get rid of FRAME_POINTER_SYM and BASE_POINTER_SYM - they should not be used anymore
...
git-svn-id: branches/wasm@48331 -
2021-01-22 16:24:56 +00:00
nickysn
4d99fb3352
* allocate locals in a better way, so that we don't get 2 extra wasted locals per function
...
git-svn-id: branches/wasm@48330 -
2021-01-22 16:22:49 +00:00
nickysn
e0dffb1c2c
* fixes to the type conversions in thlcgwasm.resize_stack_int_val
...
git-svn-id: branches/wasm@48329 -
2021-01-22 16:05:03 +00:00
nickysn
f03245e05c
- get rid of maybe_adjust_cmp_stackval - it is unnecessary for WebAssembly,
...
because it has unsigned comparison instructions, unlike the JVM, and using it
with the unsigned instructions even produced incorrect code
git-svn-id: branches/wasm@48328 -
2021-01-22 15:41:50 +00:00
nickysn
a9264cc608
- removed commented out method g_copyvalueparas
...
git-svn-id: branches/wasm@48327 -
2021-01-22 15:29:34 +00:00
nickysn
3a0d84fde2
- removed outdated comment from thlcgwasm.a_cmp_stack_stack
...
git-svn-id: branches/wasm@48326 -
2021-01-22 15:26:30 +00:00
nickysn
f3482acbf9
- removed commented out code from thlcgwasm.g_proc_entry
...
git-svn-id: branches/wasm@48325 -
2021-01-22 15:24:11 +00:00
nickysn
83f88e515b
* renamed the a_get/set/tee_local/global asm ops a_local/global_set/get/tee
...
git-svn-id: branches/wasm@48324 -
2021-01-22 15:21:40 +00:00
nickysn
d8f55ebb48
* renamed the a_iXX_extendYYYY family of asm ops to their modern versions
...
git-svn-id: branches/wasm@48323 -
2021-01-22 15:08:43 +00:00
nickysn
116366a8e3
* updated the a_iXX_trunc_su_fYY asm ops to their modern format a_iXX_trunc_fYY_su
...
git-svn-id: branches/wasm@48322 -
2021-01-22 15:05:35 +00:00
nickysn
60242ca0fd
* updated the a_fXX_convert_su_iYY asm ops to their modern format a_fXX_convert_iYY_su
...
git-svn-id: branches/wasm@48321 -
2021-01-22 15:03:04 +00:00
nickysn
9acfdc8cdd
* the a_f64_reinterpret_f64 asm op renamed a_f64_reinterpret_i64
...
git-svn-id: branches/wasm@48320 -
2021-01-22 14:58:50 +00:00
nickysn
699626ee5c
* a_grow_memory asm op renamed a_memory_grow
...
git-svn-id: branches/wasm@48319 -
2021-01-22 14:52:46 +00:00
nickysn
d0fe45a595
* a_current_memory asm op renamed a_memory_size
...
git-svn-id: branches/wasm@48318 -
2021-01-22 14:51:55 +00:00
nickysn
910bbc6b37
* override is_pushleftright for WebAssembly and make it return true
...
git-svn-id: branches/wasm@48312 -
2021-01-22 02:59:13 +00:00
nickysn
61ba4869ae
* quick and dirty fix for the move parameter order passing in g_concatcopy
...
git-svn-id: branches/wasm@48295 -
2021-01-22 00:02:12 +00:00
nickysn
54299874d3
+ implemented memory.grow and memory.size intrinsics and implemented SysOSAlloc
...
git-svn-id: branches/wasm@48290 -
2021-01-21 23:13:49 +00:00
nickysn
4d933d74b9
+ call the inherited methods for generating the standard entry/exit code, so that units are initialized/finalized
...
git-svn-id: branches/wasm@48286 -
2021-01-21 22:15:50 +00:00
nickysn
9908a9d82a
+ add functypes for the unit init and finalization code procedures
...
git-svn-id: branches/wasm@48285 -
2021-01-21 22:12:15 +00:00