578 Commits

Author SHA1 Message Date
kobalicek
b2a01018ad [Bug] Fixed ASMJIT_NO_STDCXX option broken by previous commit 2023-11-12 19:04:50 +01:00
kobalicek
10ae662219 Removed the dependency on a <new> header 2023-11-12 13:20:50 +01:00
kobalicek
30b83beda7 [Doc] Minor fix in x86::Assembler documentation 2023-11-06 14:13:33 +01:00
kobalicek
7e64eabca4 [CI] Updated BSD versions on CI 2023-10-07 11:37:07 +02:00
kobalicek
6e71f6be0c Use override instead of virtual on destructors
In addition, fixed a potential fall-through in x86:Assembler.
2023-10-06 23:04:56 +02:00
kobalicek
4413d78c98 [CI] Removed NetBSD builds because the VM doesn't work 2023-10-06 12:06:47 +02:00
Xing Guo
c1e02dc558 [Doc] Fixed documentation of SystemV X86_64 calling convention. (#417)
The first 6 arguments passed on UNIX64 platform is by RDI, RSI, RDX, RCX, R8, R9.
2023-10-06 11:06:48 +02:00
kobalicek
917f19d940 Added NodeList to abstract double linked list of nodes 2023-09-14 17:59:54 +02:00
kobalicek
87bec89b10 [API] Deprecated the use of Operand::size()
From this moment, the use of Operand::size() is discouraged:

  - Use BaseReg::size() to get a size of a register
  - Use x86::Mem::size() to get a size of a x88 memory operand
  - Use Operand::x86RmSize() to get a size of a register or
    x86 memory operand (convenience)

The problem with size occupying bits of each operand is problematic
as we want to pack more information to architecture specific operands.
For example AArch32 and AArch64 memory operands need more payload,
which can use the bits that were used by size in the past.
2023-09-14 16:47:52 +02:00
kobalicek
46bdb67262 Fixed -fno-semantic-interposition warning with apple-clang 2023-09-11 10:47:10 +02:00
kobalicek
8c9b0073a7 Fixed implicit long to int conversion (VirtMem) 2023-09-11 10:20:58 +02:00
kobalicek
cfc0b8ffb0 Updated docs, added back deprecated CpuFeature getters
* Updated documentation regarding recent breaking changes.
  * Added back 3 CPU feature getters, which were deprecated.
2023-09-10 19:29:30 +02:00
kobalicek
2fa0b3f8fb [ABI] Added implementation of all pure virtual functions
This changes virtually nothing from API perspective, however, it
allows to embed asmjit well in C projects that do not link to C++
standard library.

In normal circumstances, when a pure virtual function is declared,
but not implemented, the compiler would replace it with it's
default version, which would print a message and terminate the
program. However, this function is part of a C++ standard library,
so we don't want to use it.
2023-09-10 17:12:15 +02:00
kobalicek
f6a9c86b26 Use ASMJIT_INLINE_NODEBUG to make debugging easier
Having 'inline' is fine, however, when debugging a class that has
abstractions then sometimes to step over all of them can be very
frustrating. This is solved by ASMJIT_INLINE_NODEBUG, which tells
compiler that the body of a function doesn't have to be debuggable.

This mostly applies to getters, setters, and wrappers around API
functions.

In addition - some assembler tests were split to make the compilation
a little bit faster, especially when compiling with UBSAN.
2023-09-10 15:04:39 +02:00
kobalicek
e4e61c4f15 [ABI] Completely reworked instruction DB and generators
* Instruction database is now part of asmjit to keep it in sync
  * X86/X64 ISA data has been reworked, now in a proper JSON format
  * ARM32 ISA data has been added (currently only DB, support later)
  * ARM64 ISA data has been added
  * ARM features detection has been updated
2023-09-10 09:55:17 +02:00
kobalicek
8e2f4de484 [ABI] Reworked JitAllocator to alloc spans and to use explicit write API 2023-09-10 09:55:00 +02:00
kobalicek
bb47dc3ede Added a workaround to JitAllocator to work well with clang-17 UBSAN
LLVM's UBSAN (version 17) started using bytes below a function as
metadata for the sanitizer. It adds code to read this metadata when
performing an indirect function call, which means that if the function
itself is placed at a beginning of a mapped page, the application would
crash, because the previous page doesn't have to be accessible.

Unfortunately, LLVM exposes users to this implementation detail now,
and to make it possible to instrument software that links to asmjit,
a workaround had to be added. In addition, it's not just possible to
add this workaround to UBSAN builds, because asmjit can be installed
via a package and third party code that uses UBSAN can just link to
it. This means that we have to add padding to each block that provides
consecutive memory.

This behavior is now the default, however, an option exist:

  asmjit::JitAllocatorOptions::kDisableInitialPadding

With this option it's possible to control the behavior and to disable
the artificial padding used as a workaround.
2023-09-08 16:04:19 +02:00
kobalicek
15919150fb Fixed asmjit_test_perf to use something else than mips() name
The problem is that mips is also defined as a macro when compiling
for MIPS target, which then causes a compilation error when used as
a function.
2023-08-18 10:03:43 +02:00
kobalicek
63fdb762f0 [Bug] Fixed constpool tests to not fail on big-endian machines 2023-08-07 15:33:44 +02:00
ZeeWanderer
3577608cab [MSVC] workaround mvn macro and detect ARM64 (#407)
Fixed MSVC AArch64 build

* Detect AArch64 target properly when compiling by MSVC
* Workaround the issue caused by MSVC defining a mvn macro

---------

Co-authored-by: Petr Kobalicek <kobalicek.petr@gmail.com>
2023-04-28 01:14:41 +02:00
kobalicek
5635cf463a Added a unique register metadata to asmjit's instruction database 2023-04-26 22:00:56 +02:00
kobalicek
4163483b36 [Bug] Properly detect MMX2 on Intel CPUs via CPUID.SSE flag 2023-04-26 11:07:20 +02:00
kobalicek
42894f67e5 [Bug] Fixed VPTERNLOG[D|Q] RW info when the predicate doesn't influence DST 2023-04-26 10:58:08 +02:00
kobalicek
ff6775f424 [Bug] Fixed x86::Compiler to not rewrite reg->mem when embedded rounding is used 2023-04-25 19:58:18 +02:00
kobalicek
51b10b19b6 [Bug] Fixed build having ASMJIT_NO_TEXT enabled (AArch64) 2023-03-25 00:09:15 +01:00
Adrian Vogelsgesang
f1ea8a46c3 [Bug] Fixed ASMJIT_NO_INTROSPECTION build (#403)
The helper functions for the tests were referencing functions which do not exist if AsmJit is built using `ASMJIT_NO_INTROSPECTION`. This commit fixes the issue by moving the helper function inside the preprocessor `if` used for the test cases.
2023-03-22 08:48:33 +01:00
kobalicek
0cd18daa5d [Bug] Properly report AVX512 when querying GATHER instructions without {k} 2023-03-11 13:21:26 +01:00
kobalicek
c1019f1642 Improved testing
* Refactored workflows to use a single workflow for both VM and non-VM builds
  * Compiler tests are now able to test compilation of different architectures
2023-03-11 00:31:03 +01:00
kobalicek
d7edac813a [Bug] Don't crash when formatting label without having an emitter 2023-03-10 20:20:20 +01:00
John Högberg
1098b7d887 [Bug] Don't enable both MAP_JIT and MAP_SHARED (#402) 2023-03-06 10:51:53 +01:00
kobalicek
d38b12a2b5 Switched to a newer testing framework, fixed warnings on AArch64 2023-03-05 15:28:27 +01:00
kobalicek
76520a513d Use MFD_CLOEXEC when using memfd_create, documentation update 2023-03-05 13:23:53 +01:00
kobalicek
915186f6c5 [Bug] Virtual memory changes - addressing remaining issues on NetBSD
Changes related to VirtMem
  * Moved memory mapping code to mapMemory() and unmapMemory() helper functions
  * Added MemoryFlags::kMapShared to optionally allow MAP_SHARED when necessary
  * Clarified that MAP_SHARED is used by dual mapping by default
  * Extends MemoryFlags::kMMapMax... to use PROT_MPROTECT on NetBSD
  * Changed NetBSD dual mapping code to use MAP_SHARED to avoid COW

Changes related to JitAllocator
  * Propagate error from VirtMem (not just OOM) when VirtMem allocation failed
  * Added more tests to verify that RW + RX regions share the same content
2023-03-02 15:53:45 +01:00
Nicolas Roussel
d4dfd8e865 [Bug] Don't compile formatter API of disabled backends (#400) 2023-02-28 18:34:59 +01:00
kobalicek
c87476dd5d [Bug] Use ReadWrite scope to fill memory in JitAllocator::shrink() (MAP_JIT) 2023-02-27 20:41:08 +01:00
kobalicek
965d19506f [CI] Updated build matrix, updated docs regarding CI 2023-02-25 00:46:33 +01:00
kobalicek
8552e286c2 [CI] Updated to use build-actions new prepare-environment 2023-02-23 16:18:07 +01:00
kobalicek
d5b2cd2ba8 [Bug] Don't check for TARGET_OS_XXX before checking for __APPLE__ (VirtMem) 2023-02-23 08:43:42 +01:00
kobalicek
9d33c892f7 [Bug] Use mremap() to allocate a dual mapped region on NetBSD
In addition, always enable DualMapping when RWX pages are not
possible to allocate in JitAllocator, because otherwise the
allocator would not be able to allocate memory for JIT code
execution.

New CI runners to test FreeBSD, NetBSD, and OpenBSD are also
provided.
2023-02-23 00:40:20 +01:00
uvxwx
8c31a8f34f JitRuntime: removed duplicate code (#397) 2023-02-18 19:48:58 +01:00
kobalicek
e136425673 [Bug] Added unsigned case to imul with 16-bit and 32-bit immediate 2023-01-18 16:49:19 +01:00
kobalicek
f97475e5ab Fixed a signed/unsigned conversion warning when compiling for OSX target 2023-01-17 13:08:22 +01:00
kobalicek
3ee3846283 [ABI] Raised ABI version due to recent changes 2023-01-16 14:55:03 +01:00
kobalicek
0186d3022d [ABI] Optimized size of instruction name data (X86, AArch64) 2023-01-16 00:25:48 +01:00
kobalicek
001c5231e6 [ABI] Added more CPU feature identifiers and detection (X86) 2023-01-16 00:16:56 +01:00
kobalicek
1ed8b77f5b [ABI] Added CpuFeatures to Target and CodeHolder, improved test_perf 2023-01-16 00:10:56 +01:00
kobalicek
a9ac13536e [Bug] Removed a debugging printf() 2023-01-08 21:49:01 +01:00
kobalicek
8a33b814d6 [Bug] Assign inline comments to Invoke/Func nodes, annotate without Logger 2023-01-08 14:34:36 +01:00
kobalicek
6a414ea141 Added a possibility to reset a red zone in FuncFrame 2023-01-08 14:34:07 +01:00
kobalicek
9f6d677615 [Bug] Fixed push/pop RW instruction data (segment and GP interfering each other) 2023-01-08 13:54:47 +01:00