Project

General

Profile

« Previous | Next » 

Revision 157095b3

Added by tenderlovemaking (Aaron Patterson) over 3 years ago

Mark JIT code as writeable / executable depending on the situation

Some platforms don't want memory to be marked as writeable and
executable at the same time. When we write to the code block, we
calculate the OS page that the buffer position maps to. Then we call
mprotect to allow writes on that particular page. As an optimization,
we cache the "last written" aligned page which allows us to amortize the
cost of the mprotect call. In other words, sequential writes to the
same page will only call mprotect on the page once.

When we're done writing, we call mprotect on the entire JIT buffer.
This means we don't need to keep track of which pages were marked as
writeable, we let the OS take care of that.

Co-authored-by: John Hawthorn