mirror of
https://github.com/servo/servo
synced 2026-05-08 16:12:15 +02:00
On recent versions of HarmonyOS the previous JIT detection does not appear to work anymore, since the second `mmap` succeeds. This moves the failure in spidermonkey to a later point, when SM remaps memory to be writable. On recent versions of HOS I observed that the `PROT_WRITE` permission was silently ignored by mprotect, which lead to a crash later on the first attempt to write to the memory region. It's not exactly easy to determine if one can write to a memory location (if mprotect lies to you), but we can use `read` to check if the memory region is writable (without triggering a segfault), since `read` will return an error for invalid addresses (which is possible since the writing is handled in the kernel). Since this solution does add more unsafe code than before, we only use this detection on OpenHarmony, although we could use it on more platforms later if there are other platforms which also may have JIT forbidden. Testing: Removing the explicit `--pref js_disable_jit=true` means the detection is tested in CI. Fixes: #40029 --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Co-authored-by: Sam <16504129+sagudev@users.noreply.github.com>