Skip to content

Remove dependency on more-asserts #4408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ rustix = { version = "0.35.6", features = ["mm", "param"] }
wasmtime = { path = "crates/wasmtime", version = "0.40.0" }
env_logger = "0.9.0"
filecheck = "0.5.0"
more-asserts = "0.2.1"
tempfile = "3.1.0"
test-programs = { path = "crates/test-programs" }
wasmtime-runtime = { path = "crates/runtime" }
Expand Down
1 change: 0 additions & 1 deletion crates/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ rustix = { version = "0.35.6", features = ["process"] }
[dev-dependencies]
filetime = "0.2.7"
once_cell = "1.12.0"
more-asserts = "0.2.1"
pretty_env_logger = "0.4.0"
tempfile = "3"
18 changes: 4 additions & 14 deletions crates/cache/src/worker/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;
use crate::config::tests::test_prolog;
use more_asserts::{assert_ge, assert_gt, assert_lt};
use std::iter::repeat;
use std::process;
// load_config! comes from crate::cache(::config::tests);
Expand Down Expand Up @@ -150,10 +149,7 @@ fn test_on_get_recompress_with_mod_file() {
let scenarios = [(4, false), (7, true), (2, false)];

let mut usages = start_stats.usages;
assert_lt!(
usages,
cache_config.optimized_compression_usage_counter_threshold()
);
assert!(usages < cache_config.optimized_compression_usage_counter_threshold());
let mut tested_higher_opt_compr_lvl = false;
for (times_used, lower_compr_lvl) in &scenarios {
for _ in 0..*times_used {
Expand All @@ -180,19 +176,13 @@ fn test_on_get_recompress_with_mod_file() {
assert_eq!(decoded_data, mod_data.as_bytes());

if *lower_compr_lvl {
assert_ge!(
usages,
cache_config.optimized_compression_usage_counter_threshold()
);
assert!(usages >= cache_config.optimized_compression_usage_counter_threshold());
tested_higher_opt_compr_lvl = true;
stats.compression_level -= 1;
assert!(write_stats_file(&stats_file, &stats));
}
}
assert_ge!(
usages,
cache_config.optimized_compression_usage_counter_threshold()
);
assert!(usages >= cache_config.optimized_compression_usage_counter_threshold());
assert!(tested_higher_opt_compr_lvl);
}

Expand Down Expand Up @@ -428,7 +418,7 @@ fn test_on_update_cleanup_limits_trash_locks() {
"past",
&Duration::from_secs(secs_ago),
);
assert_gt!(secs_ago, 0);
assert!(secs_ago > 0);
secs_ago -= 1;
}

Expand Down
1 change: 0 additions & 1 deletion crates/cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ wasmparser = "0.87.0"
target-lexicon = "0.12"
gimli = { version = "0.26.0", default-features = false, features = ['read', 'std'] }
object = { version = "0.29.0", default-features = false, features = ['write'] }
more-asserts = "0.2.1"
thiserror = "1.0.4"

[features]
Expand Down
14 changes: 5 additions & 9 deletions crates/cranelift/src/debug/transform/address_transform.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{CompiledFunctions, FunctionAddressMap};
use gimli::write;
use more_asserts::assert_le;
use std::collections::BTreeMap;
use std::iter::FromIterator;
use wasmtime_environ::{DefinedFuncIndex, EntityRef, FilePos, PrimaryMap, WasmFileInfo};
Expand Down Expand Up @@ -87,13 +86,10 @@ fn build_function_lookup(
ft: &FunctionAddressMap,
code_section_offset: u64,
) -> (WasmAddress, WasmAddress, FuncLookup) {
assert_le!(
code_section_offset,
ft.start_srcloc.file_offset().unwrap().into()
);
assert!(code_section_offset <= ft.start_srcloc.file_offset().unwrap().into());
let fn_start = get_wasm_code_offset(ft.start_srcloc, code_section_offset);
let fn_end = get_wasm_code_offset(ft.end_srcloc, code_section_offset);
assert_le!(fn_start, fn_end);
assert!(fn_start <= fn_end);

// Build ranges of continuous source locations. The new ranges starts when
// non-descending order is interrupted. Assuming the same origin location can
Expand All @@ -111,8 +107,8 @@ fn build_function_lookup(
}

let offset = get_wasm_code_offset(t.srcloc, code_section_offset);
assert_le!(fn_start, offset);
assert_le!(offset, fn_end);
assert!(fn_start <= offset);
assert!(offset <= fn_end);

let inst_gen_start = t.code_offset as usize;
let inst_gen_end = match ft.instructions.get(i + 1) {
Expand Down Expand Up @@ -213,7 +209,7 @@ fn build_function_addr_map(
if cfg!(debug_assertions) {
// fn_map is sorted by the generated field -- see FunctionAddressMap::instructions.
for i in 1..fn_map.len() {
assert_le!(fn_map[i - 1].generated, fn_map[i].generated);
assert!(fn_map[i - 1].generated <= fn_map[i].generated);
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/cranelift/src/debug/transform/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::ValueLabelsRanges;
use cranelift_wasm::get_vmctx_value_label;
use gimli::{self, write, Expression, Operation, Reader, ReaderOffset, X86_64};
use more_asserts::{assert_le, assert_lt};
use std::cmp::PartialEq;
use std::collections::{HashMap, HashSet};
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -687,7 +686,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
if range_start == range_end {
continue;
}
assert_lt!(range_start, range_end);
assert!(range_start < range_end);

// Find acceptable scope of ranges to intersect with.
let i = match ranges.binary_search_by(|s| s.start.cmp(&range_start)) {
Expand Down Expand Up @@ -716,7 +715,7 @@ impl<'a, 'b> ValueLabelRangesBuilder<'a, 'b> {
tail.start = range_end;
ranges.insert(i + 1, tail);
}
assert_le!(ranges[i].end, range_end);
assert!(ranges[i].end <= range_end);
if range_start <= ranges[i].start {
ranges[i].label_location.insert(label, loc);
continue;
Expand Down
3 changes: 1 addition & 2 deletions crates/cranelift/src/debug/transform/line_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use gimli::{
write, DebugLine, DebugLineOffset, DebugLineStr, DebugStr, DebugStrOffsets,
DebuggingInformationEntry, LineEncoding, Unit,
};
use more_asserts::assert_le;
use wasmtime_environ::{DefinedFuncIndex, EntityRef};

#[derive(Debug)]
Expand Down Expand Up @@ -93,7 +92,7 @@ where
if let Ok(program) = program {
let header = program.header();
let file_index_base = if header.version() < 5 { 1 } else { 0 };
assert_le!(header.version(), 5, "not supported 6");
assert!(header.version() <= 5, "not supported 6");
let line_encoding = LineEncoding {
minimum_instruction_length: header.minimum_instruction_length(),
maximum_operations_per_instruction: header.maximum_operations_per_instruction(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::address_transform::AddressTransform;
use super::{DebugInputContext, Reader};
use anyhow::Error;
use gimli::{write, AttributeValue, DebuggingInformationEntry, RangeListsOffset, Unit};
use more_asserts::assert_lt;
use wasmtime_environ::{DefinedFuncIndex, EntityRef};

pub(crate) enum RangeInfoBuilder {
Expand Down Expand Up @@ -206,7 +205,7 @@ impl RangeInfoBuilder {
if let RangeInfoBuilder::Ranges(ranges) = self {
let mut range_list = Vec::new();
for (begin, end) in ranges {
assert_lt!(begin, end);
assert!(begin < end);
range_list.extend(addr_tr.translate_ranges(*begin, *end).map(|tr| {
write::Range::StartLength {
begin: tr.0,
Expand Down
1 change: 0 additions & 1 deletion crates/environ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ indexmap = { version = "1.0.2", features = ["serde-1"] }
thiserror = "1.0.4"
serde = { version = "1.0.94", features = ["derive"] }
log = { version = "0.4.8", default-features = false }
more-asserts = "0.2.1"
gimli = { version = "0.26.0", default-features = false, features = ['read'] }
object = { version = "0.29.0", default-features = false, features = ['read_core', 'write_core', 'elf'] }
target-lexicon = "0.12"
Expand Down
19 changes: 9 additions & 10 deletions crates/environ/src/vmoffsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::{
GlobalIndex, MemoryIndex, Module, TableIndex,
};
use cranelift_entity::packed_option::ReservedValue;
use more_asserts::assert_lt;
use std::convert::TryFrom;
use wasmtime_types::OwnedMemoryIndex;

Expand Down Expand Up @@ -671,61 +670,61 @@ impl<P: PtrSize> VMOffsets<P> {
/// Return the offset to `VMFunctionImport` index `index`.
#[inline]
pub fn vmctx_vmfunction_import(&self, index: FuncIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_imported_functions);
assert!(index.as_u32() < self.num_imported_functions);
self.vmctx_imported_functions_begin()
+ index.as_u32() * u32::from(self.size_of_vmfunction_import())
}

/// Return the offset to `VMTableImport` index `index`.
#[inline]
pub fn vmctx_vmtable_import(&self, index: TableIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_imported_tables);
assert!(index.as_u32() < self.num_imported_tables);
self.vmctx_imported_tables_begin()
+ index.as_u32() * u32::from(self.size_of_vmtable_import())
}

/// Return the offset to `VMMemoryImport` index `index`.
#[inline]
pub fn vmctx_vmmemory_import(&self, index: MemoryIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_imported_memories);
assert!(index.as_u32() < self.num_imported_memories);
self.vmctx_imported_memories_begin()
+ index.as_u32() * u32::from(self.size_of_vmmemory_import())
}

/// Return the offset to `VMGlobalImport` index `index`.
#[inline]
pub fn vmctx_vmglobal_import(&self, index: GlobalIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_imported_globals);
assert!(index.as_u32() < self.num_imported_globals);
self.vmctx_imported_globals_begin()
+ index.as_u32() * u32::from(self.size_of_vmglobal_import())
}

/// Return the offset to `VMTableDefinition` index `index`.
#[inline]
pub fn vmctx_vmtable_definition(&self, index: DefinedTableIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_defined_tables);
assert!(index.as_u32() < self.num_defined_tables);
self.vmctx_tables_begin() + index.as_u32() * u32::from(self.size_of_vmtable_definition())
}

/// Return the offset to the `*mut VMMemoryDefinition` at index `index`.
#[inline]
pub fn vmctx_vmmemory_pointer(&self, index: DefinedMemoryIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_defined_memories);
assert!(index.as_u32() < self.num_defined_memories);
self.vmctx_memories_begin() + index.as_u32() * u32::from(self.size_of_vmmemory_pointer())
}

/// Return the offset to the owned `VMMemoryDefinition` at index `index`.
#[inline]
pub fn vmctx_vmmemory_definition(&self, index: OwnedMemoryIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_owned_memories);
assert!(index.as_u32() < self.num_owned_memories);
self.vmctx_owned_memories_begin()
+ index.as_u32() * u32::from(self.size_of_vmmemory_definition())
}

/// Return the offset to the `VMGlobalDefinition` index `index`.
#[inline]
pub fn vmctx_vmglobal_definition(&self, index: DefinedGlobalIndex) -> u32 {
assert_lt!(index.as_u32(), self.num_defined_globals);
assert!(index.as_u32() < self.num_defined_globals);
self.vmctx_globals_begin()
+ index.as_u32() * u32::from(self.ptr.size_of_vmglobal_definition())
}
Expand All @@ -735,7 +734,7 @@ impl<P: PtrSize> VMOffsets<P> {
#[inline]
pub fn vmctx_anyfunc(&self, index: AnyfuncIndex) -> u32 {
assert!(!index.is_reserved_value());
assert_lt!(index.as_u32(), self.num_escaped_funcs);
assert!(index.as_u32() < self.num_escaped_funcs);
self.vmctx_anyfuncs_begin()
+ index.as_u32() * u32::from(self.ptr.size_of_vmcaller_checked_anyfunc())
}
Expand Down
1 change: 0 additions & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ log = "0.4.8"
memoffset = "0.6.0"
indexmap = "1.0.2"
thiserror = "1.0.4"
more-asserts = "0.2.1"
cfg-if = "1.0"
backtrace = { version = "0.3.61" }
rand = "0.8.3"
Expand Down
3 changes: 1 addition & 2 deletions crates/runtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{
};
use anyhow::Error;
use memoffset::offset_of;
use more_asserts::assert_lt;
use std::alloc::Layout;
use std::any::Any;
use std::convert::TryFrom;
Expand Down Expand Up @@ -364,7 +363,7 @@ impl Instance {
)
.unwrap(),
);
assert_lt!(index.index(), self.tables.len());
assert!(index.index() < self.tables.len());
index
}

Expand Down
5 changes: 2 additions & 3 deletions crates/runtime/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::MemoryImageSlot;
use crate::Store;
use anyhow::Error;
use anyhow::{bail, format_err, Result};
use more_asserts::{assert_ge, assert_le};
use std::convert::TryFrom;
use std::sync::atomic::Ordering;
use std::sync::{Arc, RwLock};
Expand Down Expand Up @@ -214,7 +213,7 @@ impl MmapMemory {
// of the two is, the `maximum` given or the `bound` specified for
// this memory.
MemoryStyle::Static { bound } => {
assert_ge!(bound, plan.memory.minimum);
assert!(bound >= plan.memory.minimum);
let bound_bytes =
usize::try_from(bound.checked_mul(WASM_PAGE_SIZE_U64).unwrap()).unwrap();
maximum = Some(bound_bytes.min(maximum.unwrap_or(usize::MAX)));
Expand Down Expand Up @@ -662,7 +661,7 @@ impl Memory {
} else {
WASM32_MAX_PAGES
};
assert_le!(plan.memory.minimum, absolute_max);
assert!(plan.memory.minimum <= absolute_max);
assert!(plan.memory.maximum.is_none() || plan.memory.maximum.unwrap() <= absolute_max);

// This is the absolute possible maximum that the module can try to
Expand Down
Loading