Skip to content

Commit

Permalink
Fixed duplicate in store duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Apr 27, 2023
1 parent d9998bd commit de8cdf7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 31 deletions.
5 changes: 4 additions & 1 deletion lib/api/src/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ impl Memory {
// We should only be able to duplicate in a new store if the memory is shared
return None;
}
self.0.duplicate_in_store(store, new_store).map(Self)
self.0
.try_clone(&store)
.and_then(|mut memory| memory.duplicate().ok())
.map(|new_memory| Self::new_from_existing(new_store, new_memory.into()))
}

/// To `VMExtern`.
Expand Down
10 changes: 0 additions & 10 deletions lib/api/src/js/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ impl Memory {
true
}

pub fn duplicate_in_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Option<Self> {
self.try_clone(&store)
.and_then(|mut memory| memory.duplicate().ok())
.map(|new_memory| Self::new_from_existing(new_store, new_memory.into()))
}

#[allow(unused)]
pub fn duplicate(&mut self, _store: &impl AsStoreRef) -> Result<VMMemory, MemoryError> {
self.handle.duplicate()
Expand Down
10 changes: 0 additions & 10 deletions lib/api/src/jsc/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,6 @@ impl Memory {
self.handle.try_clone()
}

pub fn duplicate_in_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Option<Self> {
self.try_clone(&store)
.and_then(|mut memory| memory.duplicate(&store).ok())
.map(|new_memory| Self::new_from_existing(new_store, new_memory.into()))
}

pub fn is_from_store(&self, _store: &impl AsStoreRef) -> bool {
true
}
Expand Down
10 changes: 0 additions & 10 deletions lib/api/src/sys/externals/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ impl Memory {
mem.try_clone().map(|mem| mem.into())
}

pub fn duplicate_in_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Option<Self> {
self.try_clone(&store)
.and_then(|mut memory| memory.duplicate().ok())
.map(|new_memory| Self::new_from_existing(new_store, new_memory.into()))
}

/// To `VMExtern`.
pub(crate) fn to_vm_extern(&self) -> VMExtern {
VMExtern::Memory(self.handle.internal_handle())
Expand Down

0 comments on commit de8cdf7

Please sign in to comment.