mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 14:41:32 +00:00
Get caching working again
This commit is contained in:
@ -10,7 +10,6 @@ pub use self::unix::*;
|
||||
#[cfg(windows)]
|
||||
pub use self::windows::*;
|
||||
|
||||
|
||||
use serde::{
|
||||
de::{self, SeqAccess, Visitor},
|
||||
ser::SerializeStruct,
|
||||
@ -21,7 +20,6 @@ use serde_bytes::Bytes;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
||||
impl Serialize for Memory {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
@ -36,7 +34,6 @@ impl Serialize for Memory {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<'de> Deserialize<'de> for Memory {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
@ -207,16 +207,26 @@ impl Drop for Memory {
|
||||
|
||||
impl Clone for Memory {
|
||||
fn clone(&self) -> Self {
|
||||
let mut new = Memory::with_size_protect(self.size, self.protection).unwrap();
|
||||
let temp_protection = if self.protection.is_writable() {
|
||||
self.protection
|
||||
} else {
|
||||
Protect::ReadWrite
|
||||
};
|
||||
|
||||
let mut new = Memory::with_size_protect(self.size, temp_protection).unwrap();
|
||||
unsafe {
|
||||
new.as_slice_mut().copy_from_slice(self.as_slice());
|
||||
|
||||
if temp_protection != self.protection {
|
||||
new.protect(.., self.protection).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
new
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[allow(dead_code)]
|
||||
pub enum Protect {
|
||||
None,
|
||||
|
@ -158,16 +158,26 @@ impl Drop for Memory {
|
||||
|
||||
impl Clone for Memory {
|
||||
fn clone(&self) -> Self {
|
||||
let mut new = Memory::with_size_protect(self.size, self.protection).unwrap();
|
||||
let temp_protection = if self.protection.is_writable() {
|
||||
self.protection
|
||||
} else {
|
||||
Protect::ReadWrite
|
||||
};
|
||||
|
||||
let mut new = Memory::with_size_protect(self.size, temp_protection).unwrap();
|
||||
unsafe {
|
||||
new.as_slice_mut().copy_from_slice(self.as_slice());
|
||||
|
||||
if temp_protection != self.protection {
|
||||
new.protect(.., self.protection).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
new
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[allow(dead_code)]
|
||||
pub enum Protect {
|
||||
None,
|
||||
|
Reference in New Issue
Block a user