mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 06:38:22 +00:00
Improve Tunables memory/table creation
This commit is contained in:
@@ -231,7 +231,9 @@ fn set_table_item(
|
|||||||
impl Table {
|
impl Table {
|
||||||
pub fn new(store: &Store, ty: TableType, init: Val) -> Result<Table, RuntimeError> {
|
pub fn new(store: &Store, ty: TableType, init: Val) -> Result<Table, RuntimeError> {
|
||||||
let item = init.into_checked_anyfunc(store)?;
|
let item = init.into_checked_anyfunc(store)?;
|
||||||
let table = store.engine().tunables().create_table(ty);
|
let tunables = store.engine().tunables();
|
||||||
|
let table_plan = tunables.table_plan(ty);
|
||||||
|
let table = tunables.create_table(table_plan);
|
||||||
|
|
||||||
let definition = table.vmtable();
|
let definition = table.vmtable();
|
||||||
for i in 0..definition.current_elements {
|
for i in 0..definition.current_elements {
|
||||||
@@ -345,7 +347,10 @@ pub struct Memory {
|
|||||||
|
|
||||||
impl Memory {
|
impl Memory {
|
||||||
pub fn new(store: &Store, ty: MemoryType) -> Memory {
|
pub fn new(store: &Store, ty: MemoryType) -> Memory {
|
||||||
let memory = store.engine().tunables().create_memory(ty).unwrap();
|
let tunables = store.engine().tunables();
|
||||||
|
let memory_plan = tunables.memory_plan(ty);
|
||||||
|
let memory = tunables.create_memory(memory_plan).unwrap();
|
||||||
|
|
||||||
let definition = memory.vmmemory();
|
let definition = memory.vmmemory();
|
||||||
|
|
||||||
Memory {
|
Memory {
|
||||||
|
|||||||
@@ -92,14 +92,12 @@ impl wasmer_jit::Tunables for Tunables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a memory given a memory type
|
/// Create a memory given a memory type
|
||||||
fn create_memory(&self, memory_type: MemoryType) -> Result<LinearMemory, String> {
|
fn create_memory(&self, plan: MemoryPlan) -> Result<LinearMemory, String> {
|
||||||
let plan = self.memory_plan(memory_type);
|
|
||||||
LinearMemory::new(&plan)
|
LinearMemory::new(&plan)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a memory given a memory type
|
/// Create a memory given a memory type
|
||||||
fn create_table(&self, table_type: TableType) -> Table {
|
fn create_table(&self, plan: TablePlan) -> Table {
|
||||||
let plan = self.table_plan(table_type);
|
|
||||||
Table::new(&plan)
|
Table::new(&plan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ pub trait Tunables {
|
|||||||
fn table_plan(&self, table: TableType) -> TablePlan;
|
fn table_plan(&self, table: TableType) -> TablePlan;
|
||||||
|
|
||||||
/// Create a memory given a memory type
|
/// Create a memory given a memory type
|
||||||
fn create_memory(&self, memory_type: MemoryType) -> Result<LinearMemory, String>;
|
fn create_memory(&self, memory_type: MemoryPlan) -> Result<LinearMemory, String>;
|
||||||
|
|
||||||
/// Create a memory given a memory type
|
/// Create a memory given a memory type
|
||||||
fn create_table(&self, table_type: TableType) -> Table;
|
fn create_table(&self, table_type: TablePlan) -> Table;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user