Skip to content

Commit

Permalink
Remove TrapCode::TableSetterOutOfBounds
Browse files Browse the repository at this point in the history
This trap code is also now unused due to Wasm spec changes
  • Loading branch information
Mark McCaskey committed May 6, 2021
1 parent 657a6cd commit c45b5f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
- [#2135](https://github.com/wasmerio/wasmer/pull/2135) [Documentation](./PACKAGING.md) for linux distribution maintainers

### Changed
- [#2299](https://github.com/wasmerio/wasmer/pull/2299) Unused trap codes (due to Wasm spec changes), `HeapSetterOutOfBounds` and `TableSetterOutOfBounds` were removed from `wasmer_vm::TrapCode` and the numbering of the remaining variants has been adjusted.
- [#2293](https://github.com/wasmerio/wasmer/pull/2293) The `Memory::ty` trait method now returns `MemoryType` by value. `wasmer_vm::LinearMemory` now recomputes `MemoryType`'s `minimum` field when accessing its type. This behavior is what's expected by the latest spectests. `wasmer::Memory::ty` has also been updated to follow suit, it now returns `MemoryType` by value.
- [#2251](https://github.com/wasmerio/wasmer/pull/2251) Wasmer CLI will now execute WASI modules with multiple WASI namespaces in them by default. Use `--allow-multiple-wasi-versions` to suppress the warning and use `--deny-multiple-wasi-versions` to make it an error.
- [#2201](https://github.com/wasmerio/wasmer/pull/2201) Implement `loupe::MemoryUsage` for `wasmer::Instance`.
Expand Down
2 changes: 1 addition & 1 deletion lib/vm/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub trait Table: fmt::Debug + Send + Sync + MemoryUsage {
}

if dst_index.checked_add(len).map_or(true, |m| m > self.size()) {
return Err(Trap::new_from_runtime(TrapCode::TableSetterOutOfBounds));
return Err(Trap::new_from_runtime(TrapCode::TableAccessOutOfBounds));
}

let srcs = src_index..src_index + len;
Expand Down
35 changes: 12 additions & 23 deletions lib/vm/src/trap/trapcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,39 @@ pub enum TrapCode {
/// A `heap_addr` instruction was misaligned.
HeapMisaligned = 2,

/// Table Elements doesn't fit the table size.
///
/// This only can happen during instantiation.
TableSetterOutOfBounds = 3,

/// A `table_addr` instruction detected an out-of-bounds error.
TableAccessOutOfBounds = 4,
TableAccessOutOfBounds = 3,

/// Other bounds checking error.
OutOfBounds = 5,
OutOfBounds = 4,

/// Indirect call to a null table entry.
IndirectCallToNull = 6,
IndirectCallToNull = 5,

/// Signature mismatch on indirect call.
BadSignature = 7,
BadSignature = 6,

/// An integer arithmetic operation caused an overflow.
IntegerOverflow = 8,
IntegerOverflow = 7,

/// An integer division by zero.
IntegerDivisionByZero = 9,
IntegerDivisionByZero = 8,

/// Failed float-to-int conversion.
BadConversionToInteger = 10,
BadConversionToInteger = 9,

/// Code that was supposed to have been unreachable was reached.
UnreachableCodeReached = 11,
UnreachableCodeReached = 10,

/// Execution has potentially run too long and may be interrupted.
/// This trap is resumable.
Interrupt = 12,
Interrupt = 11,

/// An atomic memory access was attempted with an unaligned pointer.
UnalignedAtomic = 13,
UnalignedAtomic = 12,

/// A trap indicating that the runtime was unable to allocate sufficient memory.
VMOutOfMemory = 14,
VMOutOfMemory = 13,
// /// A user-defined trap code.
// User(u16),
}
Expand All @@ -86,9 +81,6 @@ impl TrapCode {
Self::StackOverflow => "call stack exhausted",
Self::HeapAccessOutOfBounds => "out of bounds memory access",
Self::HeapMisaligned => "misaligned heap",
Self::TableSetterOutOfBounds => {
"out of bounds table access: elements segment does not fit"
}
Self::TableAccessOutOfBounds => "undefined element: out of bounds table access",
Self::OutOfBounds => "out of bounds",
Self::IndirectCallToNull => "uninitialized element",
Expand All @@ -111,7 +103,6 @@ impl Display for TrapCode {
Self::StackOverflow => "stk_ovf",
Self::HeapAccessOutOfBounds => "heap_get_oob",
Self::HeapMisaligned => "heap_misaligned",
Self::TableSetterOutOfBounds => "table_set_oob",
Self::TableAccessOutOfBounds => "table_get_oob",
Self::OutOfBounds => "oob",
Self::IndirectCallToNull => "icall_null",
Expand All @@ -138,7 +129,6 @@ impl FromStr for TrapCode {
"stk_ovf" => Ok(StackOverflow),
"heap_get_oob" => Ok(HeapAccessOutOfBounds),
"heap_misaligned" => Ok(HeapMisaligned),
"table_set_oob" => Ok(TableSetterOutOfBounds),
"table_get_oob" => Ok(TableAccessOutOfBounds),
"oob" => Ok(OutOfBounds),
"icall_null" => Ok(IndirectCallToNull),
Expand All @@ -161,11 +151,10 @@ mod tests {
use super::*;

// Everything but user-defined codes.
const CODES: [TrapCode; 15] = [
const CODES: [TrapCode; 13] = [
TrapCode::StackOverflow,
TrapCode::HeapAccessOutOfBounds,
TrapCode::HeapMisaligned,
TrapCode::TableSetterOutOfBounds,
TrapCode::TableAccessOutOfBounds,
TrapCode::OutOfBounds,
TrapCode::IndirectCallToNull,
Expand Down

0 comments on commit c45b5f8

Please sign in to comment.