summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asmjit/test/asmjit_test_x86_sections.cpp
diff options
context:
space:
mode:
author Patrick Mackinlay <pmackinlay@hotmail.com>2024-04-11 00:16:51 +0700
committer GitHub <noreply@github.com>2024-04-11 03:16:51 +1000
commit2c566627a1fc0ab21cc0399e8ad0ce134e36b53f (patch)
tree8eb19fad727675c673de8e59a7fd6137e14f2cfd /3rdparty/asmjit/test/asmjit_test_x86_sections.cpp
parent4bcbfac11f352eabcae33b203c026ce02b3fd4ba (diff)
3rdparty/asmjit: Updated to upstream version 1.13.0. (#12228)
From revision asmjit/asmjit@e5d7c0bd5d9aec44d68830187138149e6a8c4e32
Diffstat (limited to '3rdparty/asmjit/test/asmjit_test_x86_sections.cpp')
-rw-r--r--3rdparty/asmjit/test/asmjit_test_x86_sections.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/3rdparty/asmjit/test/asmjit_test_x86_sections.cpp b/3rdparty/asmjit/test/asmjit_test_x86_sections.cpp
index 353b5e4fa1b..df763224d9b 100644
--- a/3rdparty/asmjit/test/asmjit_test_x86_sections.cpp
+++ b/3rdparty/asmjit/test/asmjit_test_x86_sections.cpp
@@ -17,7 +17,7 @@
// ----------------------------------------------------------------------------
#include <asmjit/core.h>
-#if !defined(ASMJIT_NO_X86) && ASMJIT_ARCH_X86
+#if ASMJIT_ARCH_X86 && !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_JIT)
#include <asmjit/x86.h>
#include <stdio.h>
@@ -70,7 +70,7 @@ int main() {
Label data = a.newLabel();
FuncDetail func;
- func.init(FuncSignatureT<size_t, size_t>(CallConvId::kHost), code.environment());
+ func.init(FuncSignature::build<size_t, size_t>(), code.environment());
FuncFrame frame;
frame.init(func);
@@ -127,29 +127,26 @@ int main() {
}
// Allocate memory for the function and relocate it there.
- void* rxPtr;
- void* rwPtr;
- err = allocator.alloc(&rxPtr, &rwPtr, codeSize);
+ JitAllocator::Span span;
+ err = allocator.alloc(span, codeSize);
if (err)
fail("Failed to allocate executable memory", err);
// Relocate to the base-address of the allocated memory.
- code.relocateToBase(uint64_t(uintptr_t(rxPtr)));
+ code.relocateToBase(uint64_t(uintptr_t(span.rx())));
- VirtMem::protectJitMemory(VirtMem::ProtectJitAccess::kReadWrite);
-
- // Copy the flattened code into `mem.rw`. There are two ways. You can either copy
- // everything manually by iterating over all sections or use `copyFlattenedData`.
- // This code is similar to what `copyFlattenedData(p, codeSize, 0)` would do:
- for (Section* section : code.sectionsByOrder())
- memcpy(static_cast<uint8_t*>(rwPtr) + size_t(section->offset()), section->data(), section->bufferSize());
-
- VirtMem::protectJitMemory(VirtMem::ProtectJitAccess::kReadExecute);
- VirtMem::flushInstructionCache(rwPtr, code.codeSize());
+ allocator.write(span, [&](JitAllocator::Span& span) noexcept -> Error {
+ // Copy the flattened code into `mem.rw`. There are two ways. You can either copy
+ // everything manually by iterating over all sections or use `copyFlattenedData`.
+ // This code is similar to what `copyFlattenedData(p, codeSize, 0)` would do:
+ for (Section* section : code.sectionsByOrder())
+ memcpy(static_cast<uint8_t*>(span.rw()) + size_t(section->offset()), section->data(), section->bufferSize());
+ return kErrorOk;
+ });
// Execute the function and test whether it works.
typedef size_t (*Func)(size_t idx);
- Func fn = (Func)rxPtr;
+ Func fn = (Func)span.rx();
printf("\n");
if (fn(0) != dataArray[0] ||
@@ -166,7 +163,7 @@ int main() {
#else
int main() {
- printf("AsmJit X86 Sections Test is disabled on non-x86 host\n\n");
+ printf("AsmJit X86 Sections Test is disabled on non-x86 host or when compiled with ASMJIT_NO_JIT\n\n");
return 0;
}
-#endif // !ASMJIT_NO_X86 && ASMJIT_ARCH_X86
+#endif // ASMJIT_ARCH_X86 && !ASMJIT_NO_X86 && !ASMJIT_NO_JIT