Make FunctionBodyPtr a thin pointer.

This requires keeping the length around and passing it around in a few places that need it.
This commit is contained in:
Nick Lewycky
2020-11-02 12:56:54 -08:00
parent 0ca87b8a83
commit 22187a8dc4
8 changed files with 51 additions and 69 deletions

View File

@@ -58,13 +58,13 @@ pub use crate::vmoffsets::{TargetSharedSignatureIndex, VMOffsets};
/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// A safe wrapper around `VMFunctionBody`
/// A safe wrapper around `VMFunctionBody`.
#[derive(Clone, Copy, Debug)]
#[repr(transparent)]
pub struct FunctionBodyPtr(pub *const [VMFunctionBody]);
pub struct FunctionBodyPtr(pub *const VMFunctionBody);
impl std::ops::Deref for FunctionBodyPtr {
type Target = *const [VMFunctionBody];
type Target = *const VMFunctionBody;
fn deref(&self) -> &Self::Target {
&self.0