[SimpleJIT] When finalizing multiple functions, make them all executable at the end. (#474)

Add `publish()` function to cranelift-module's `Backend` trait, which
allows `finalize_all()` to defer making memory executable until it
has finished all of the patching it needs to do.
This commit is contained in:
Dan Gohman
2018-08-28 15:27:52 -07:00
committed by GitHub
parent 8e2d01a675
commit 9ada394d11
4 changed files with 23 additions and 4 deletions

View File

@@ -335,8 +335,6 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
}
}
// Now that we're done patching, make the memory executable.
self.code_memory.set_executable();
func.code
}
@@ -397,10 +395,15 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
}
}
self.readonly_memory.set_readonly();
(data.storage, data.size)
}
fn publish(&mut self) {
// Now that we're done patching, prepare the memory for execution!
self.readonly_memory.set_readonly();
self.code_memory.set_executable();
}
/// SimpleJIT emits code and data into memory as it processes them, so it
/// doesn't need to provide anything after the `Module` is complete.
fn finish(self) -> () {}