Merge branch 'master' into feature/improve-thread-safety-of-core-types

This commit is contained in:
Mark McCaskey
2020-07-09 13:57:58 -07:00
100 changed files with 1344 additions and 1127 deletions

View File

@@ -44,8 +44,8 @@ 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 table_plans = &compile_info.table_plans;
let memory_styles = &compile_info.memory_styles;
let table_styles = &compile_info.table_styles;
let module = &compile_info.module;
// TODO: merge constants in sections.
@@ -78,8 +78,8 @@ impl Compiler for LLVMCompiler {
i,
input,
self.config(),
&memory_plans,
&table_plans,
memory_styles,
&table_styles,
&func_names,
)
},

View File

@@ -7,7 +7,7 @@ use wasmer_compiler::{
CustomSections, FunctionAddressMap, FunctionBody, InstructionAddressMap, Relocation,
RelocationKind, RelocationTarget, SectionBody, SectionIndex, SourceLoc,
};
use wasmer_runtime::libcalls::LibCall;
use wasmer_vm::libcalls::LibCall;
use wasm_common::entity::entity_impl;
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]

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, TablePlan};
use wasmer_vm::{MemoryStyle, ModuleInfo, TableStyle};
fn to_compile_error(err: impl std::error::Error) -> CompileError {
CompileError::Codegen(format!("{}", err))
@@ -72,8 +72,8 @@ impl FuncTranslator {
local_func_index: &LocalFunctionIndex,
function_body: &FunctionBodyData,
config: &LLVM,
memory_plans: &PrimaryMap<MemoryIndex, MemoryPlan>,
_table_plans: &PrimaryMap<TableIndex, TablePlan>,
memory_styles: &PrimaryMap<MemoryIndex, MemoryStyle>,
_table_styles: &PrimaryMap<TableIndex, TableStyle>,
func_names: &SecondaryMap<FunctionIndex, String>,
) -> Result<CompiledFunction, CompileError> {
// The function type, used for the callbacks.
@@ -198,8 +198,8 @@ impl FuncTranslator {
locals: params_locals,
ctx: CtxType::new(wasm_module, &func, &cache_builder),
unreachable_depth: 0,
memory_plans,
_table_plans,
memory_styles,
_table_styles,
module: &module,
module_translation,
wasm_module,
@@ -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,8 +1264,8 @@ 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>,
_table_plans: &'a PrimaryMap<TableIndex, TablePlan>,
memory_styles: &'a PrimaryMap<MemoryIndex, MemoryStyle>,
_table_styles: &'a PrimaryMap<TableIndex, TableStyle>,
// This is support for stackmaps:
/*

View File

@@ -26,8 +26,8 @@ use wasm_common::{
TableIndex, Type,
};
use wasmer_compiler::CompileError;
use wasmer_runtime::ModuleInfo as WasmerCompilerModule;
use wasmer_runtime::{MemoryPlan, MemoryStyle, TrapCode, VMBuiltinFunctionIndex, VMOffsets};
use wasmer_vm::ModuleInfo as WasmerCompilerModule;
use wasmer_vm::{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 memory_plan.style == MemoryStyle::Dynamic {
if let MemoryStyle::Dynamic { .. } = memory_style {
let current_length_ptr = cache_builder
.build_struct_gep(
memory_definition_ptr,

View File

@@ -2,8 +2,8 @@
use byteorder::{LittleEndian, ReadBytesExt};
use std::io::{self, Cursor};
use wasmer_runtime_core::vm::Ctx;
use wasmer_runtime_core::{
use wasmer_vm_core::vm::Ctx;
use wasmer_vm_core::{
module::Module,
structures::TypedIndex,
types::{GlobalIndex, LocalOrImport, TableIndex},
@@ -65,15 +65,15 @@ impl StackmapEntry {
size_record: &StkSizeRecord,
map_record: &StkMapRecord,
end: Option<(&StackmapEntry, &StkMapRecord)>,
msm: &mut wasmer_runtime_core::state::ModuleStateMap,
msm: &mut wasmer_vm_core::state::ModuleStateMap,
) {
use std::collections::{BTreeMap, HashMap};
use wasmer_runtime_core::state::{
use wasmer_vm_core::state::{
x64::{new_machine_state, X64Register, GPR},
FunctionStateMap, MachineStateDiff, MachineValue, OffsetInfo, RegisterIndex,
SuspendOffset, WasmAbstractValue,
};
use wasmer_runtime_core::vm;
use wasmer_vm_core::vm;
let func_base_addr = (size_record.function_address as usize)
.checked_sub(code_addr)