summaryrefslogtreecommitdiff
path: root/zjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2025-02-06 12:23:31 -0500
committerTakashi Kokubun <[email protected]>2025-04-18 21:52:56 +0900
commitcf2e305d737c2d217f0509079b86f246aefdae68 (patch)
tree664764835688f2fc2971079b1d7e6bb52c5a5518 /zjit.c
parentf9b03b237c29993f293c0d17a26cbb2246d489bd (diff)
Initialize VirtualMem
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13131
Diffstat (limited to 'zjit.c')
-rw-r--r--zjit.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/zjit.c b/zjit.c
index 69b8fc6b67..d0034e7bf1 100644
--- a/zjit.c
+++ b/zjit.c
@@ -31,6 +31,24 @@
#include <errno.h>
+uint32_t
+rb_zjit_get_page_size(void)
+{
+#if defined(_SC_PAGESIZE)
+ long page_size = sysconf(_SC_PAGESIZE);
+ if (page_size <= 0) rb_bug("zjit: failed to get page size");
+
+ // 1 GiB limit. x86 CPUs with PDPE1GB can do this and anything larger is unexpected.
+ // Though our design sort of assume we have fine grained control over memory protection
+ // which require small page sizes.
+ if (page_size > 0x40000000l) rb_bug("zjit page size too large");
+
+ return (uint32_t)page_size;
+#else
+#error "YJIT supports POSIX only for now"
+#endif
+}
+
// Address space reservation. Memory pages are mapped on an as needed basis.
// See the Rust mm module for details.
uint8_t *