[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:
@@ -600,6 +600,7 @@ where
|
||||
)
|
||||
};
|
||||
self.contents.functions[func].finalized = true;
|
||||
self.backend.publish();
|
||||
output
|
||||
}
|
||||
|
||||
@@ -627,6 +628,7 @@ where
|
||||
)
|
||||
};
|
||||
self.contents.data_objects[data].finalized = true;
|
||||
self.backend.publish();
|
||||
output
|
||||
}
|
||||
|
||||
@@ -646,6 +648,9 @@ where
|
||||
);
|
||||
}
|
||||
}
|
||||
for info in self.contents.functions.values_mut() {
|
||||
info.finalized = true;
|
||||
}
|
||||
for info in self.contents.data_objects.values() {
|
||||
if info.decl.linkage.is_definable() && !info.finalized {
|
||||
self.backend.finalize_data(
|
||||
@@ -658,12 +663,16 @@ where
|
||||
);
|
||||
}
|
||||
}
|
||||
for info in self.contents.data_objects.values_mut() {
|
||||
info.finalized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Consume the module and return the resulting `Product`. Some `Backend`
|
||||
/// implementations may provide additional functionality available after
|
||||
/// a `Module` is complete.
|
||||
pub fn finish(self) -> B::Product {
|
||||
pub fn finish(mut self) -> B::Product {
|
||||
self.backend.publish();
|
||||
self.backend.finish()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user