Skip to content

Commit c7cab27

Browse files
authored
wasmtime-cranelift: Use wasmtime_environ::error instead of anyhow (#12204)
1 parent b7ee9a4 commit c7cab27

File tree

16 files changed

+21
-23
lines changed

16 files changed

+21
-23
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cranelift/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rust-version.workspace = true
1515
workspace = true
1616

1717
[dependencies]
18-
anyhow = { workspace = true }
1918
log = { workspace = true }
2019
wasmtime-environ = { workspace = true, features = ['compile'] }
2120
cranelift-codegen = { workspace = true, features = ["host-arch", "timing"] }

crates/cranelift/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! well as providing a function to return the default configuration to build.
55
66
use crate::isa_builder::IsaBuilder;
7-
use anyhow::Result;
87
use cranelift_codegen::{
98
CodegenResult,
109
isa::{self, OwnedTargetIsa},
@@ -13,6 +12,7 @@ use std::fmt;
1312
use std::path;
1413
use std::sync::Arc;
1514
use target_lexicon::Triple;
15+
use wasmtime_environ::error::Result;
1616
use wasmtime_environ::{CacheStore, CompilerBuilder, Setting, Tunables};
1717

1818
struct Builder {

crates/cranelift/src/compiler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::func_environ::FuncEnvironment;
44
use crate::translate::FuncTranslator;
55
use crate::{BuiltinFunctionSignatures, builder::LinkOptions, wasm_call_signature};
66
use crate::{CompiledFunction, ModuleTextBuilder, array_call_signature};
7-
use anyhow::{Context as _, Result};
87
use cranelift_codegen::binemit::CodeOffset;
98
use cranelift_codegen::inline::InlineCommand;
109
use cranelift_codegen::ir::condcodes::IntCC;
@@ -32,6 +31,7 @@ use std::ops::Range;
3231
use std::path;
3332
use std::sync::{Arc, Mutex};
3433
use wasmparser::{FuncValidatorAllocations, FunctionBody};
34+
use wasmtime_environ::error::{Context as _, Result};
3535
use wasmtime_environ::obj::{ELF_WASMTIME_EXCEPTIONS, ELF_WASMTIME_FRAMES};
3636
use wasmtime_environ::{
3737
Abi, AddressMapSection, BuiltinFunctionIndex, CacheStore, CompileError, CompiledFunctionBody,
@@ -1579,7 +1579,7 @@ fn clif_to_env_exception_tables<'a>(
15791579
builder: &mut ExceptionTableBuilder,
15801580
range: Range<u64>,
15811581
call_sites: impl Iterator<Item = FinalizedMachCallSite<'a>>,
1582-
) -> anyhow::Result<()> {
1582+
) -> wasmtime_environ::error::Result<()> {
15831583
builder.add_func(CodeOffset::try_from(range.start).unwrap(), call_sites)
15841584
}
15851585

@@ -1591,7 +1591,7 @@ fn clif_to_env_frame_tables<'a>(
15911591
tag_sites: impl Iterator<Item = MachBufferDebugTagList<'a>>,
15921592
frame_layout: &MachBufferFrameLayout,
15931593
frame_descriptors: &HashMap<FuncKey, Vec<u8>>,
1594-
) -> anyhow::Result<()> {
1594+
) -> wasmtime_environ::error::Result<()> {
15951595
let mut frame_descriptor_indices = HashMap::new();
15961596
for tag_site in tag_sites {
15971597
// Split into frames; each has three debug tags.
@@ -1647,7 +1647,7 @@ fn clif_to_env_breakpoints(
16471647
range: Range<u64>,
16481648
breakpoint_patches: impl Iterator<Item = (u32, Range<u32>)>,
16491649
patch_table: &mut Vec<(u32, Range<u32>)>,
1650-
) -> anyhow::Result<()> {
1650+
) -> wasmtime_environ::error::Result<()> {
16511651
patch_table.extend(breakpoint_patches.map(|(wasm_pc, offset_range)| {
16521652
let start = offset_range.start + u32::try_from(range.start).unwrap();
16531653
let end = offset_range.end + u32::try_from(range.start).unwrap();

crates/cranelift/src/compiler/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Compilation support for the component model.
22
33
use crate::{TRAP_ALWAYS, TRAP_CANNOT_ENTER, TRAP_INTERNAL_ASSERT, compiler::Compiler};
4-
use anyhow::{Result, bail};
54
use cranelift_codegen::ir::condcodes::IntCC;
65
use cranelift_codegen::ir::{self, InstBuilder, MemFlags, Value};
76
use cranelift_codegen::isa::{CallConv, TargetIsa};
87
use cranelift_frontend::FunctionBuilder;
8+
use wasmtime_environ::error::{Result, bail};
99
use wasmtime_environ::{
1010
Abi, CompiledFunctionBody, EntityRef, FuncKey, HostCall, PtrSize, TrapSentinel, Tunables,
1111
WasmFuncType, WasmValType, component::*, fact::PREPARE_CALL_FIXED_PARAMS,

crates/cranelift/src/debug/transform/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use super::range_info_builder::RangeInfoBuilder;
77
use super::refs::{PendingDebugInfoRefs, PendingUnitRefs};
88
use super::unit::InheritedAttr;
99
use super::{TransformError, dbi_log};
10-
use anyhow::{Error, bail};
1110
use cranelift_codegen::isa::TargetIsa;
1211
use gimli::{
1312
AttributeValue, DebugLineOffset, DebuggingInformationEntry, UnitOffset, UnitRef, write,
1413
};
14+
use wasmtime_environ::error::{Error, bail};
1515

1616
#[derive(Debug)]
1717
pub(crate) enum EntryAttributesContext<'a> {

crates/cranelift/src/debug/transform/expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::debug::transform::debug_transform_logging::{
55
dbi_log_enabled, log_get_value_loc, log_get_value_name, log_get_value_ranges,
66
};
77
use crate::translate::get_vmctx_value_label;
8-
use anyhow::{Context, Error, Result};
98
use core::fmt;
109
use cranelift_codegen::LabelValueLoc;
1110
use cranelift_codegen::ValueLabelsRanges;
@@ -17,6 +16,7 @@ use std::cmp::PartialEq;
1716
use std::collections::{HashMap, HashSet};
1817
use std::hash::{Hash, Hasher};
1918
use std::rc::Rc;
19+
use wasmtime_environ::error::{Context, Error, Result};
2020

2121
#[derive(Debug)]
2222
pub struct FunctionFrameInfo<'a> {

crates/cranelift/src/debug/transform/line_program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::TransformError;
22
use super::address_transform::AddressTransform;
33
use crate::debug::Reader;
4-
use anyhow::{Error, bail};
54
use gimli::{DebugLineOffset, LineEncoding, UnitRef, write};
65
use wasmtime_environ::DefinedFuncIndex;
6+
use wasmtime_environ::error::{Error, bail};
77

88
#[derive(Debug)]
99
enum SavedLineProgramRow {

crates/cranelift/src/debug/transform/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use self::simulate::generate_simulated_dwarf;
44
use self::unit::clone_unit;
55
use crate::debug::gc::build_dependencies;
66
use crate::debug::{Compilation, Reader};
7-
use anyhow::Error;
87
use cranelift_codegen::isa::TargetIsa;
98
use gimli::{Dwarf, DwarfPackage, LittleEndian, Section, Unit, UnitRef, UnitSectionOffset, write};
109
use std::{collections::HashSet, fmt::Debug};
1110
use synthetic::ModuleSyntheticUnit;
1211
use thiserror::Error;
12+
use wasmtime_environ::error::Error;
1313
use wasmtime_environ::{
1414
DefinedFuncIndex, ModuleTranslation, PrimaryMap, StaticModuleIndex, Tunables,
1515
};
@@ -54,11 +54,11 @@ pub(crate) struct DebugInputContext<'a> {
5454
fn load_dwp<'data>(
5555
translation: ModuleTranslation<'data>,
5656
buffer: &'data [u8],
57-
) -> anyhow::Result<DwarfPackage<gimli::EndianSlice<'data, gimli::LittleEndian>>> {
57+
) -> wasmtime_environ::error::Result<DwarfPackage<gimli::EndianSlice<'data, gimli::LittleEndian>>> {
5858
let endian_slice = gimli::EndianSlice::new(buffer, LittleEndian);
5959

6060
let dwarf_package = DwarfPackage::load(
61-
|id| -> anyhow::Result<_> {
61+
|id| -> wasmtime_environ::error::Result<_> {
6262
let slice = match id {
6363
gimli::SectionId::DebugAbbrev => {
6464
translation.debuginfo.dwarf.debug_abbrev.reader().slice()

crates/cranelift/src/debug/transform/range_info_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::address_transform::AddressTransform;
22
use crate::debug::Reader;
3-
use anyhow::Error;
43
use gimli::{AttributeValue, DebuggingInformationEntry, RangeListsOffset, UnitRef, write};
54
use wasmtime_environ::DefinedFuncIndex;
5+
use wasmtime_environ::error::Error;
66

77
pub(crate) enum RangeInfoBuilder {
88
Undefined,

0 commit comments

Comments
 (0)