Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
cleanup & remove guestptr DerefMut
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Mar 8, 2024
1 parent 134b103 commit 8cfb8c4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
8 changes: 1 addition & 7 deletions arbitrator/caller-env/src/guest_ptr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE

use core::ops::{Add, AddAssign, Deref, DerefMut};
use core::ops::{Add, AddAssign, Deref};

/// Represents a pointer to a Guest WASM's memory.
#[derive(Clone, Copy, Eq, PartialEq)]
Expand Down Expand Up @@ -41,9 +41,3 @@ impl Deref for GuestPtr {
&self.0
}
}

impl DerefMut for GuestPtr {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
6 changes: 3 additions & 3 deletions arbitrator/jit/src/arbcompress.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022-2024, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE

use crate::caller_env::jit_env;
use crate::caller_env::{JitEnv, JitExecEnv};
use crate::machine::Escape;
use crate::machine::WasmEnvMut;
use caller_env::brotli::BrotliStatus;
Expand All @@ -11,9 +11,9 @@ macro_rules! wrap {
($(fn $func_name:ident ($($arg_name:ident : $arg_type:ty),* ) -> $return_type:ty);*) => {
$(
pub fn $func_name(mut src: WasmEnvMut, $($arg_name : $arg_type),*) -> Result<$return_type, Escape> {
let (mut mem, mut env) = jit_env(&mut src);
let (mut mem, wenv) = src.jit_env();

Ok(caller_env::brotli::$func_name(&mut mem, &mut env, $($arg_name),*))
Ok(caller_env::brotli::$func_name(&mut mem, &mut JitExecEnv { wenv }, $($arg_name),*))
}
)*
};
Expand Down
6 changes: 0 additions & 6 deletions arbitrator/jit/src/caller_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ impl<'a> JitEnv<'a> for WasmEnvMut<'a> {
}
}

pub fn jit_env<'s>(env: &'s mut WasmEnvMut) -> (JitMemAccess<'s>, JitExecEnv<'s>) {
let memory = env.data().memory.clone().unwrap();
let (wenv, store) = env.data_and_store_mut();
(JitMemAccess { memory, store }, JitExecEnv { wenv })
}

impl<'s> JitMemAccess<'s> {
fn view(&self) -> MemoryView {
self.memory.view(&self.store)
Expand Down
6 changes: 3 additions & 3 deletions arbitrator/jit/src/wasip1_stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(clippy::too_many_arguments)]

use crate::caller_env::jit_env;
use crate::caller_env::{JitEnv, JitExecEnv};
use crate::machine::{Escape, WasmEnvMut};
use caller_env::{self, wasip1_stub::Errno, GuestPtr};

Expand All @@ -15,9 +15,9 @@ macro_rules! wrap {
($(fn $func_name:ident ($($arg_name:ident : $arg_type:ty),* ) -> $return_type:ty);*) => {
$(
pub fn $func_name(mut src: WasmEnvMut, $($arg_name : $arg_type),*) -> Result<$return_type, Escape> {
let (mut mem, mut env) = jit_env(&mut src);
let (mut mem, wenv) = src.jit_env();

Ok(caller_env::wasip1_stub::$func_name(&mut mem, &mut env, $($arg_name),*))
Ok(caller_env::wasip1_stub::$func_name(&mut mem, &mut JitExecEnv { wenv }, $($arg_name),*))
}
)*
};
Expand Down

0 comments on commit 8cfb8c4

Please sign in to comment.