why do we need to JIT the munmap code? Can we not just call munmap(2)
The program gets a list of all the allocated pages first, then creates one more for the JIT code (and a copy of the list) which is unmapped as the last thing it does. There really is no other way of doing it.