upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
authorrobot00f <robot00f@users.noreply.github.com>2026-11-26 20:57:13 -0300
committerrobot00f <robot00f@users.noreply.github.com>2026-11-27 18:49:17 -0300
commit8b14930b3d072ee270c294a687b6262f270439ad (patch)
tree2aaae132f32fbf4a1b24ca9f12079abef825c5f6 /runtime/src/pe_loader.cpp
parentb6e51b737674beebef48d4945a474aa38c862eed (diff)
runtime(cpu): add ahead-of-time AVX1/SSE4.2 stub compiler for pre-Haswell hosts
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index f87531063..51f395ddb 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -22,6 +22,7 @@
22#include "bmi_emulation.h" 22#include "bmi_emulation.h"
23#include "clzero_patch.h" 23#include "clzero_patch.h"
24#include "cpu_emulation.h" 24#include "cpu_emulation.h"
25#include "isa_jit_patch.h"
25 26
26namespace rt { 27namespace rt {
27 28
@@ -2216,6 +2217,21 @@ void Loader::protect_sections(Module& m) {
2216 "[rt] loader: %s: %zu CLZERO loops run from stubs at %p (%zu bytes), not as a #UD per line\n", 2217 "[rt] loader: %s: %zu CLZERO loops run from stubs at %p (%zu bytes), not as a #UD per line\n",
2217 m.name.c_str(), patched.sites, static_cast<void*>(patched.stubs), patched.stub_bytes); 2218 m.name.c_str(), patched.sites, static_cast<void*>(patched.stubs), patched.stub_bytes);
2218 } 2219 }
2220 {
2221 const auto isa = rt::isa_jit_patch::patch_image(m.base, m.size);
2222 if (isa.stubs && isa.stub_bytes) {
2223 std::unique_lock lock(ranges_mutex_);
2224 ranges_.push_back({reinterpret_cast<uint64_t>(isa.stubs),
2225 static_cast<uint32_t>(isa.stub_bytes), m.name + "[isa-stubs]"});
2226 }
2227 if (isa.inplace_sites || isa.bmi_stubs || isa.avx2_stubs || isa.fma3_stubs) {
2228 std::fprintf(stderr,
2229 "[rt] loader: %s: native AVX1/x64 acceleration: %zu in-place, %zu BMI, %zu AVX2 (%zu fused 4B), "
2230 "%zu FMA3 stubs at %p (%zu KiB)\n",
2231 m.name.c_str(), isa.inplace_sites, isa.bmi_stubs, isa.avx2_stubs, isa.avx2_fused_4b,
2232 isa.fma3_stubs, static_cast<void*>(isa.stubs), (isa.stub_bytes + 1023u) / 1024u);
2233 }
2234 }
2219 static const auto bmi_host = rt::bmi_emulation::detect_host(); 2235 static const auto bmi_host = rt::bmi_emulation::detect_host();
2220 if ((!bmi_host.bmi1 || !bmi_host.lzcnt) && rt::bmi_emulation::lzcnt_patch_enabled()) { 2236 if ((!bmi_host.bmi1 || !bmi_host.lzcnt) && rt::bmi_emulation::lzcnt_patch_enabled()) {
2221 std::vector<std::pair<uint32_t, uint32_t>> exec_ranges; 2237 std::vector<std::pair<uint32_t, uint32_t>> exec_ranges;