diff --git a/lib/api/src/externals/table.rs b/lib/api/src/externals/table.rs index 872d6c4da..65f422a98 100644 --- a/lib/api/src/externals/table.rs +++ b/lib/api/src/externals/table.rs @@ -4,7 +4,6 @@ use crate::store::Store; use crate::types::{Val, ValFuncRef}; use crate::RuntimeError; use crate::TableType; -use std::sync::Arc; use wasmer_runtime::{Export, ExportTable, Table as RuntimeTable, VMCallerCheckedAnyfunc}; /// The `Table` struct is an array-like structure representing a WebAssembly Table, diff --git a/lib/api/src/table.rs b/lib/api/src/table.rs index 40d533ee4..daaf0be82 100644 --- a/lib/api/src/table.rs +++ b/lib/api/src/table.rs @@ -1,7 +1,7 @@ use crate::ValType; use std::borrow::{Borrow, BorrowMut}; use std::cell::UnsafeCell; -use std::convert::{TryFrom, TryInto}; +use std::convert::TryFrom; use std::ptr::NonNull; use std::sync::Mutex; use wasmer_runtime::{ @@ -64,8 +64,10 @@ impl Table for LinearTable { /// Returns the number of allocated elements. fn size(&self) -> u32 { - let vec_guard = self.vec.lock().unwrap(); - vec_guard.borrow().len().try_into().unwrap() + unsafe { + let ptr = self.vm_table_definition.get(); + (*ptr).current_elements + } } /// Grow table by the specified amount of elements.