Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 30, 2024
1 parent a2025f4 commit 7251939
Show file tree
Hide file tree
Showing 41 changed files with 1,036 additions and 1,570 deletions.
297 changes: 64 additions & 233 deletions crates/cranelift/src/func_environ.rs

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions crates/cranelift/src/translate/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ use std::collections::{hash_map, HashMap};
use std::vec::Vec;
use wasmparser::{FuncValidator, MemArg, Operator, WasmModuleResources};
use wasmtime_environ::{
wasm_unsupported, DataIndex, ElemIndex, FuncIndex, GlobalIndex, MemoryIndex, TableIndex,
TypeIndex, WasmRefType, WasmResult,
wasm_unsupported, DataIndex, ElemIndex, FuncIndex, GlobalIndex, MemoryIndex, Signed,
TableIndex, TypeIndex, WasmRefType, WasmResult,
};

/// Given a `Reachability<T>`, unwrap the inner `T` or, when unreachable, set
Expand Down Expand Up @@ -1255,8 +1255,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let effective_addr = if memarg.offset == 0 {
addr
} else {
let index_type = environ.heaps()[heap].index_type;
let offset = builder.ins().iconst(index_type, memarg.offset as i64);
let index_type = environ.heaps()[heap].index_type();
let offset = builder.ins().iconst(index_type, memarg.offset.signed());
environ.uadd_overflow_trap(builder, addr, offset, ir::TrapCode::HEAP_OUT_OF_BOUNDS)
};
// `fn translate_atomic_wait` can inspect the type of `expected` to figure out what
Expand All @@ -1279,8 +1279,8 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
let effective_addr = if memarg.offset == 0 {
addr
} else {
let index_type = environ.heaps()[heap].index_type;
let offset = builder.ins().iconst(index_type, memarg.offset as i64);
let index_type = environ.heaps()[heap].index_type();
let offset = builder.ins().iconst(index_type, memarg.offset.signed());
environ.uadd_overflow_trap(builder, addr, offset, ir::TrapCode::HEAP_OUT_OF_BOUNDS)
};
let res = environ.translate_atomic_notify(
Expand Down Expand Up @@ -3223,7 +3223,9 @@ where
// relatively odd/rare. In the future if needed we can look into
// optimizing this more.
Err(_) => {
let offset = builder.ins().iconst(heap.index_type, memarg.offset as i64);
let offset = builder
.ins()
.iconst(heap.index_type(), memarg.offset.signed());
let adjusted_index = environ.uadd_overflow_trap(
builder,
index,
Expand Down
Loading

0 comments on commit 7251939

Please sign in to comment.