Only check memory bounds for dynamic memory plans.

This commit is contained in:
losfair
2020-05-20 14:28:49 +08:00
parent 13f842cd6a
commit b34ef92b24

View File

@@ -22,7 +22,7 @@ use wasmer_compiler::{
TrapInformation, TrapInformation,
}; };
use wasmer_runtime::{ use wasmer_runtime::{
MemoryPlan, ModuleInfo, TablePlan, TrapCode, VMBuiltinFunctionIndex, VMOffsets, MemoryPlan, MemoryStyle, ModuleInfo, TablePlan, TrapCode, VMBuiltinFunctionIndex, VMOffsets,
}; };
/// The singlepass per-function code generator. /// The singlepass per-function code generator.
@@ -38,7 +38,7 @@ pub struct FuncGen<'a> {
vmoffsets: &'a VMOffsets, vmoffsets: &'a VMOffsets,
// // Memory plans. // // Memory plans.
// memory_plans: &'a PrimaryMap<MemoryIndex, MemoryPlan>, memory_plans: &'a PrimaryMap<MemoryIndex, MemoryPlan>,
// // Table plans. // // Table plans.
// table_plans: &'a PrimaryMap<TableIndex, TablePlan>, // table_plans: &'a PrimaryMap<TableIndex, TablePlan>,
@@ -1214,7 +1214,10 @@ impl<'a> FuncGen<'a> {
value_size: usize, value_size: usize,
cb: F, cb: F,
) -> Result<(), CodegenError> { ) -> Result<(), CodegenError> {
let need_check = true; let need_check = match self.memory_plans[MemoryIndex::new(0)].style {
MemoryStyle::Static { .. } => false,
MemoryStyle::Dynamic => true,
};
let tmp_addr = self.machine.acquire_temp_gpr().unwrap(); let tmp_addr = self.machine.acquire_temp_gpr().unwrap();
let tmp_base = self.machine.acquire_temp_gpr().unwrap(); let tmp_base = self.machine.acquire_temp_gpr().unwrap();
@@ -1769,7 +1772,7 @@ impl<'a> FuncGen<'a> {
module: &'a ModuleInfo, module: &'a ModuleInfo,
config: &'a SinglepassConfig, config: &'a SinglepassConfig,
vmoffsets: &'a VMOffsets, vmoffsets: &'a VMOffsets,
_memory_plans: &'a PrimaryMap<MemoryIndex, MemoryPlan>, memory_plans: &'a PrimaryMap<MemoryIndex, MemoryPlan>,
_table_plans: &'a PrimaryMap<TableIndex, TablePlan>, _table_plans: &'a PrimaryMap<TableIndex, TablePlan>,
local_func_index: LocalFunctionIndex, local_func_index: LocalFunctionIndex,
local_types_excluding_arguments: &[WpType], local_types_excluding_arguments: &[WpType],
@@ -1798,7 +1801,7 @@ impl<'a> FuncGen<'a> {
module, module,
config, config,
vmoffsets, vmoffsets,
// memory_plans, memory_plans,
// table_plans, // table_plans,
signature, signature,
assembler: Assembler::new().unwrap(), assembler: Assembler::new().unwrap(),