From 35c6d869f55e9ea263498ef56d1f68b36d3388cb Mon Sep 17 00:00:00 2001 From: Wander Lairson Costa Date: Tue, 10 Sep 2019 19:11:20 -0300 Subject: [PATCH] Replace region::protect by make_exec in cranelift-filetests --- cranelift/filetests/src/function_runner.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rs index 8837596ed9..6f2cd4a83a 100644 --- a/cranelift/filetests/src/function_runner.rs +++ b/cranelift/filetests/src/function_runner.rs @@ -5,8 +5,6 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::{settings, Context}; use cranelift_native::builder as host_isa_builder; use memmap::MmapMut; -use region; -use region::Protection; /// Run a function on a host pub struct FunctionRunner { @@ -66,7 +64,8 @@ impl FunctionRunner { .map_err(|e| e.to_string())?; let mut code_page = MmapMut::map_anon(code_info.total_size as usize).map_err(|e| e.to_string())?; - let callable_fn: fn() -> bool = unsafe { + + unsafe { context.emit_to_memory( self.isa.as_ref(), code_page.as_mut_ptr(), @@ -74,15 +73,11 @@ impl FunctionRunner { traps, stackmaps, ); - region::protect( - code_page.as_mut_ptr(), - code_page.len(), - Protection::ReadExecute, - ) - .map_err(|e| e.to_string())?; - mem::transmute(code_page.as_mut_ptr()) }; + let code_page = code_page.make_exec().map_err(|e| e.to_string())?; + let callable_fn: fn() -> bool = unsafe { mem::transmute(code_page.as_ptr()) }; + // execute match callable_fn() { true => Ok(()),