Removed Memory plans in favor of direct styles

This commit is contained in:
Syrus
2020-07-07 16:50:08 -07:00
parent d94bf1c022
commit b57a28edc7
22 changed files with 116 additions and 135 deletions

View File

@@ -44,7 +44,7 @@ impl Compiler for LLVMCompiler {
) -> Result<Compilation, CompileError> {
//let data = Arc::new(Mutex::new(0));
let mut func_names = SecondaryMap::new();
let memory_plans = &compile_info.memory_plans;
let memory_styles = &compile_info.memory_styles;
let table_styles = &compile_info.table_styles;
let module = &compile_info.module;
@@ -78,7 +78,7 @@ impl Compiler for LLVMCompiler {
i,
input,
self.config(),
&memory_plans,
memory_styles,
&table_styles,
&func_names,
)

View File

@@ -34,7 +34,7 @@ use wasmer_compiler::{
to_wasm_error, wptype_to_type, CompileError, FunctionBodyData, GenerateMiddlewareChain,
MiddlewareBinaryReader, ModuleTranslationState, RelocationTarget,
};
use wasmer_runtime::{MemoryPlan, ModuleInfo, TableStyle};
use wasmer_runtime::{MemoryStyle, ModuleInfo, TableStyle};
fn to_compile_error(err: impl std::error::Error) -> CompileError {
CompileError::Codegen(format!("{}", err))
@@ -72,7 +72,7 @@ impl FuncTranslator {
local_func_index: &LocalFunctionIndex,
function_body: &FunctionBodyData,
config: &LLVM,
memory_plans: &PrimaryMap<MemoryIndex, MemoryPlan>,
memory_styles: &PrimaryMap<MemoryIndex, MemoryStyle>,
_table_styles: &PrimaryMap<TableIndex, TableStyle>,
func_names: &SecondaryMap<FunctionIndex, String>,
) -> Result<CompiledFunction, CompileError> {
@@ -198,7 +198,7 @@ impl FuncTranslator {
locals: params_locals,
ctx: CtxType::new(wasm_module, &func, &cache_builder),
unreachable_depth: 0,
memory_plans,
memory_styles,
_table_styles,
module: &module,
module_translation,
@@ -908,7 +908,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
memory_index,
self.intrinsics,
self.module,
self.memory_plans,
self.memory_styles,
) {
// The best we've got is `volatile`.
// TODO: convert unwrap fail to CompileError
@@ -962,14 +962,14 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> {
let base_ptr =
match self
.ctx
.memory(memory_index, intrinsics, self.module, self.memory_plans)
.memory(memory_index, intrinsics, self.module, self.memory_styles)
{
MemoryCache::Dynamic {
ptr_to_base_ptr,
current_length_ptr,
} => {
// Bounds check it.
let minimum = self.memory_plans[memory_index].memory.minimum;
let minimum = self.wasm_module.memories[memory_index].minimum;
let value_size_v = intrinsics.i64_ty.const_int(value_size as u64, false);
let ptr_in_bounds = if offset.is_const() {
// When the offset is constant, if it's below the minimum
@@ -1264,7 +1264,7 @@ pub struct LLVMFunctionCodeGenerator<'ctx, 'a> {
locals: Vec<PointerValue<'ctx>>, // Contains params and locals
ctx: CtxType<'ctx, 'a>,
unreachable_depth: usize,
memory_plans: &'a PrimaryMap<MemoryIndex, MemoryPlan>,
memory_styles: &'a PrimaryMap<MemoryIndex, MemoryStyle>,
_table_styles: &'a PrimaryMap<TableIndex, TableStyle>,
// This is support for stackmaps:

View File

@@ -27,7 +27,7 @@ use wasm_common::{
};
use wasmer_compiler::CompileError;
use wasmer_runtime::ModuleInfo as WasmerCompilerModule;
use wasmer_runtime::{MemoryPlan, MemoryStyle, TrapCode, VMBuiltinFunctionIndex, VMOffsets};
use wasmer_runtime::{MemoryStyle, TrapCode, VMBuiltinFunctionIndex, VMOffsets};
pub fn type_to_llvm_ptr<'ctx>(
intrinsics: &Intrinsics<'ctx>,
@@ -569,7 +569,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
index: MemoryIndex,
intrinsics: &Intrinsics<'ctx>,
module: &Module<'ctx>,
memory_plans: &PrimaryMap<MemoryIndex, MemoryPlan>,
memory_styles: &PrimaryMap<MemoryIndex, MemoryStyle>,
) -> MemoryCache<'ctx> {
let (cached_memories, wasm_module, ctx_ptr_value, cache_builder, offsets) = (
&mut self.cached_memories,
@@ -578,7 +578,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
&self.cache_builder,
&self.offsets,
);
let memory_plan = &memory_plans[index];
let memory_style = &memory_styles[index];
*cached_memories.entry(index).or_insert_with(|| {
let memory_definition_ptr =
if let Some(local_memory_index) = wasm_module.local_memory_index(index) {
@@ -622,7 +622,7 @@ impl<'ctx, 'a> CtxType<'ctx, 'a> {
"",
)
.unwrap();
if matches!(memory_plan.style, MemoryStyle::Dynamic { .. }) {
if matches!(memory_style, MemoryStyle::Dynamic { .. }) {
let current_length_ptr = cache_builder
.build_struct_gep(
memory_definition_ptr,