Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Send for JITModule #8718

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cranelift/jit/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const READONLY_DATA_ALIGNMENT: u64 = 0x1;
pub struct JITBuilder {
isa: OwnedTargetIsa,
symbols: HashMap<String, *const u8>,
lookup_symbols: Vec<Box<dyn Fn(&str) -> Option<*const u8>>>,
lookup_symbols: Vec<Box<dyn Fn(&str) -> Option<*const u8> + Send>>,
libcall_names: Box<dyn Fn(ir::LibCall) -> String + Send + Sync>,
hotswap_enabled: bool,
}
Expand Down Expand Up @@ -140,7 +140,7 @@ impl JITBuilder {
/// symbol table. Symbol lookup fn's are called in reverse of the order in which they were added.
pub fn symbol_lookup_fn(
&mut self,
symbol_lookup_fn: Box<dyn Fn(&str) -> Option<*const u8>>,
symbol_lookup_fn: Box<dyn Fn(&str) -> Option<*const u8> + Send>,
MolotovCherry marked this conversation as resolved.
Show resolved Hide resolved
) -> &mut Self {
self.lookup_symbols.push(symbol_lookup_fn);
self
Expand Down Expand Up @@ -173,8 +173,8 @@ pub struct JITModule {
isa: OwnedTargetIsa,
hotswap_enabled: bool,
symbols: RefCell<HashMap<String, *const u8>>,
lookup_symbols: Vec<Box<dyn Fn(&str) -> Option<*const u8>>>,
libcall_names: Box<dyn Fn(ir::LibCall) -> String>,
lookup_symbols: Vec<Box<dyn Fn(&str) -> Option<*const u8> + Send>>,
libcall_names: Box<dyn Fn(ir::LibCall) -> String + Send + Sync>,
memory: MemoryHandle,
declarations: ModuleDeclarations,
function_got_entries: SecondaryMap<FuncId, Option<NonNull<AtomicPtr<u8>>>>,
Expand All @@ -191,6 +191,8 @@ pub struct JITModule {
pending_got_updates: Vec<GotUpdate>,
}

unsafe impl Send for JITModule {}
MolotovCherry marked this conversation as resolved.
Show resolved Hide resolved

/// A handle to allow freeing memory allocated by the `Module`.
struct MemoryHandle {
code: Memory,
Expand Down