Move target back into wasmer_types

This commit is contained in:
Syrus Akbary
2025-03-06 11:09:51 +01:00
parent bd13db0c48
commit 78eca7958d
41 changed files with 82 additions and 94 deletions

View File

@ -1,5 +1,4 @@
use wasmer_compiler::types::target::Target;
use wasmer_types::Features;
use wasmer_types::{target::Target, Features};
/// The engine for the JavaScript runtime.
#[derive(Clone, Debug)]

View File

@ -1,8 +1,7 @@
use std::sync::Arc;
use rusty_jsc::{JSContext, JSObject};
use wasmer_compiler::types::target::Target;
use wasmer_types::Features;
use wasmer_types::{target::Target, Features};
use crate::{AsEngineRef, AsStoreRef};

View File

@ -4,9 +4,9 @@ use std::{path::Path, sync::Arc};
use shared_buffer::OwnedBuffer;
pub use wasmer_compiler::{
types::target::Target, Artifact, BaseTunables, CompilerConfig, Engine, EngineBuilder, Tunables,
Artifact, BaseTunables, CompilerConfig, Engine, EngineBuilder, Tunables,
};
use wasmer_types::{DeserializeError, Features, HashAlgorithm};
use wasmer_types::{target::Target, DeserializeError, Features, HashAlgorithm};
use crate::{BackendEngine, BackendModule};

View File

@ -14,11 +14,9 @@ pub use wasmer_compiler::{
wasmparser, CompilerConfig, FunctionMiddleware, MiddlewareReaderState, ModuleMiddleware,
};
pub use wasmer_compiler::{
types::target::{Architecture, CpuFeature, OperatingSystem, Target, Triple},
Artifact, EngineBuilder, Features, Tunables,
};
pub use wasmer_compiler::{Artifact, EngineBuilder, Features, Tunables};
pub use wasmer_types::target::{Architecture, CpuFeature, OperatingSystem, Target, Triple};
pub use wasmer_types::MiddlewareError;
#[cfg(feature = "cranelift")]

View File

@ -4,8 +4,7 @@ use crate::{
BackendEngine,
};
use std::sync::Arc;
use wasmer_compiler::types::target::Target;
use wasmer_types::Features;
use wasmer_types::{target::Target, Features};
// A handle to an engine, which we want to unsafely mark as Sync.
struct EngineCapsule(*mut wasm_engine_t);

View File

@ -4,8 +4,7 @@ use crate::{
BackendEngine,
};
use std::sync::Arc;
use wasmer_compiler::types::target::Target;
use wasmer_types::Features;
use wasmer_types::{target::Target, Features};
#[derive(Debug)]
pub(crate) struct CApiEngine {

View File

@ -4,8 +4,7 @@ use crate::{
BackendEngine,
};
use std::sync::Arc;
use wasmer_compiler::types::target::Target;
use wasmer_types::Features;
use wasmer_types::{target::Target, Features};
#[derive(Debug)]
pub(crate) struct CApiEngine {

View File

@ -1,7 +1,6 @@
use bytes::Bytes;
use std::{path::Path, sync::Arc};
use wasmer_compiler::types::target::Target;
use wasmer_types::{DeserializeError, Features};
use wasmer_types::{target::Target, DeserializeError, Features};
#[cfg(feature = "sys")]
use wasmer_compiler::{Artifact, CompilerConfig};

View File

@ -2,12 +2,12 @@
use bytes::Bytes;
use std::{path::Path, sync::Arc};
use wasmer_types::{DeserializeError, Features};
use wasmer_types::{target::Target, DeserializeError, Features};
#[cfg(feature = "sys")]
use wasmer_compiler::Artifact;
use wasmer_compiler::types::target::Target;
#[cfg(feature = "compiler")]
use wasmer_compiler::CompilerConfig;
use crate::{BackendKind, IntoBytes, Store};

View File

@ -1595,7 +1595,7 @@ pub(super) mod utils {
use anyhow::{anyhow, Context};
use target_lexicon::{Architecture, Environment, OperatingSystem, Triple};
use wasmer_compiler::types::target::{self as wasmer_types, CpuFeature, Target};
use wasmer_types::target::{CpuFeature, Target};
use crate::config::WasmerEnv;
@ -1848,7 +1848,9 @@ pub(super) mod utils {
pub(super) fn triple_to_zig_triple(target_triple: &Triple) -> String {
let arch = match target_triple.architecture {
Architecture::X86_64 => "x86_64".into(),
Architecture::Aarch64(wasmer_types::Aarch64Architecture::Aarch64) => "aarch64".into(),
Architecture::Aarch64(wasmer_types::target::Aarch64Architecture::Aarch64) => {
"aarch64".into()
}
v => v.to_string(),
};
let os = match target_triple.operating_system {

View File

@ -3,15 +3,12 @@ use std::path::PathBuf;
use anyhow::{Context, Error};
use bytes::Bytes;
use clap::Parser;
use wasmer_compiler::{
types::{
symbols::ModuleMetadataSymbolRegistry,
target::{CpuFeature, Triple},
},
Artifact,
};
use wasmer_compiler::{types::symbols::ModuleMetadataSymbolRegistry, Artifact};
use wasmer_package::{package::WasmerPackageError, utils::from_bytes};
use wasmer_types::MetadataHeader;
use wasmer_types::{
target::{CpuFeature, Triple},
MetadataHeader,
};
use webc::{compat::SharedBytes, Container, ContainerError, DetectError};
use crate::backend::RuntimeOptions;

View File

@ -35,13 +35,13 @@ use wasmer_compiler::{
module::CompileModuleInfo,
relocation::{Relocation, RelocationTarget},
section::SectionIndex,
target::{CallingConvention, Target},
unwind::CompiledFunctionUnwindInfo,
},
Compiler, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader, ModuleMiddleware,
ModuleMiddlewareChain, ModuleTranslationState,
};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::target::{CallingConvention, Target};
use wasmer_types::{
CompileError, FunctionIndex, LocalFunctionIndex, ModuleInfo, SignatureIndex, TrapCode,
TrapInformation,

View File

@ -5,10 +5,8 @@ use cranelift_codegen::{
CodegenResult,
};
use std::sync::Arc;
use wasmer_compiler::{
types::target::{Architecture, CpuFeature, Target},
Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware,
};
use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::target::{Architecture, CpuFeature, Target};
// Runtime Environment

View File

@ -3,9 +3,8 @@ use gimli::{RunTimeEndian, SectionId};
use wasmer_compiler::types::{
relocation::{Relocation, RelocationKind, RelocationTarget},
section::{CustomSection, CustomSectionProtection, SectionBody},
target::Endianness,
};
use wasmer_types::{entity::EntityRef, LocalFunctionIndex};
use wasmer_types::{entity::EntityRef, target::Endianness, LocalFunctionIndex};
#[derive(Clone, Debug)]
pub struct WriterRelocate {

View File

@ -19,11 +19,11 @@ use wasmer_compiler::{
relocation::RelocationTarget,
section::{CustomSection, CustomSectionProtection, SectionBody, SectionIndex},
symbols::{Symbol, SymbolRegistry},
target::Target,
},
Compiler, FunctionBodyData, ModuleMiddleware, ModuleTranslationState,
};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::target::Target;
use wasmer_types::{CompileError, FunctionIndex, LocalFunctionIndex, SignatureIndex};
use wasmer_vm::LibCall;

View File

@ -8,11 +8,11 @@ use itertools::Itertools;
use std::fmt::Debug;
use std::sync::Arc;
use target_lexicon::BinaryFormat;
use wasmer_compiler::{
types::target::{Architecture, OperatingSystem, Target, Triple},
Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware,
use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::{
target::{Architecture, OperatingSystem, Target, Triple},
Features, FunctionType, LocalFunctionIndex,
};
use wasmer_types::{Features, FunctionType, LocalFunctionIndex};
/// The InkWell ModuleInfo type
pub type InkwellModule<'ctx> = inkwell::module::Module<'ctx>;

View File

@ -6,7 +6,7 @@ use crate::{
};
use std::collections::BTreeMap;
use std::slice::Iter;
use wasmer_compiler::types::target::CallingConvention;
use wasmer_types::target::CallingConvention;
use wasmer_types::{CompileError, Type};
/// General-purpose registers.

View File

@ -20,7 +20,6 @@ use wasmer_compiler::{
function::{CompiledFunction, CompiledFunctionFrameInfo, FunctionBody},
relocation::{Relocation, RelocationTarget},
section::SectionIndex,
target::CallingConvention,
},
wasmparser::{
BlockType as WpTypeOrFuncType, HeapType as WpHeapType, Operator, RefType as WpRefType,
@ -32,13 +31,13 @@ use wasmer_compiler::{
#[cfg(feature = "unwind")]
use wasmer_compiler::types::unwind::CompiledFunctionUnwindInfo;
use wasmer_types::target::CallingConvention;
use wasmer_types::{
entity::{EntityRef, PrimaryMap},
CompileError, FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, LocalMemoryIndex,
MemoryIndex, MemoryStyle, ModuleInfo, SignatureIndex, TableIndex, TableStyle, TrapCode, Type,
VMBuiltinFunctionIndex, VMOffsets,
};
/// The singlepass per-function code generator.
pub struct FuncGen<'a, M: Machine> {
// Immutable properties assigned at creation time.

View File

@ -25,12 +25,12 @@ use wasmer_compiler::{
function::{Compilation, CompiledFunction, FunctionBody, UnwindInfo},
module::CompileModuleInfo,
section::SectionIndex,
target::{Architecture, CallingConvention, CpuFeature, OperatingSystem, Target},
},
Compiler, CompilerConfig, FunctionBinaryReader, FunctionBodyData, MiddlewareBinaryReader,
ModuleMiddleware, ModuleMiddlewareChain, ModuleTranslationState,
};
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::target::{Architecture, CallingConvention, CpuFeature, Target};
use wasmer_types::{
CompileError, FunctionIndex, FunctionType, LocalFunctionIndex, MemoryIndex, ModuleInfo,
TableIndex, TrapCode, TrapInformation, VMOffsets,

View File

@ -3,11 +3,11 @@
use crate::compiler::SinglepassCompiler;
use std::sync::Arc;
use wasmer_compiler::{
types::target::{CpuFeature, Target},
Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware,
use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::{
target::{CpuFeature, Target},
Features,
};
use wasmer_types::Features;
#[derive(Debug, Clone)]
pub struct Singlepass {

View File

@ -5,9 +5,8 @@ use gimli::{
use wasmer_compiler::types::{
relocation::{Relocation, RelocationKind, RelocationTarget},
section::{CustomSection, CustomSectionProtection, SectionBody},
target::Endianness,
};
use wasmer_types::{entity::EntityRef, LocalFunctionIndex};
use wasmer_types::{entity::EntityRef, target::Endianness, LocalFunctionIndex};
#[derive(Clone, Debug)]
pub struct WriterRelocate {

View File

@ -13,9 +13,10 @@ use dynasmrt::{
use wasmer_compiler::types::{
function::FunctionBody,
section::{CustomSection, CustomSectionProtection, SectionBody},
target::CallingConvention,
};
use wasmer_types::{CompileError, FunctionIndex, FunctionType, Type, VMOffsets};
use wasmer_types::{
target::CallingConvention, CompileError, FunctionIndex, FunctionType, Type, VMOffsets,
};
type Assembler = VecAssembler<Aarch64Relocation>;

View File

@ -9,8 +9,7 @@ pub use crate::{
};
use dynasm::dynasm;
use dynasmrt::{AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
use wasmer_compiler::types::target::CpuFeature;
use wasmer_types::CompileError;
use wasmer_types::{target::CpuFeature, CompileError};
/// Force `dynasm!` to use the correct arch (x64) when cross-compiling.
/// `dynasm!` proc-macro tries to auto-detect it by default by looking at the

View File

@ -13,11 +13,11 @@ use wasmer_compiler::{
function::FunctionBody,
relocation::{Relocation, RelocationTarget},
section::CustomSection,
target::{Architecture, CallingConvention, Target},
},
wasmparser::{MemArg, ValType as WpType},
};
use wasmer_types::{
target::{Architecture, CallingConvention, Target},
CompileError, FunctionIndex, FunctionType, TrapCode, TrapInformation, VMOffsets,
};
pub type Label = DynamicLabel;

View File

@ -8,11 +8,11 @@ use wasmer_compiler::{
function::FunctionBody,
relocation::{Relocation, RelocationKind, RelocationTarget},
section::CustomSection,
target::{CallingConvention, CpuFeature, Target},
},
wasmparser::{MemArg, ValType as WpType},
};
use wasmer_types::{
target::{CallingConvention, CpuFeature, Target},
CompileError, FunctionIndex, FunctionType, SourceLoc, TrapCode, TrapInformation, VMOffsets,
};

View File

@ -19,11 +19,11 @@ use wasmer_compiler::{
function::FunctionBody,
relocation::{Relocation, RelocationKind, RelocationTarget},
section::{CustomSection, CustomSectionProtection, SectionBody},
target::{CallingConvention, CpuFeature, Target},
},
wasmparser::{MemArg, ValType as WpType},
};
use wasmer_types::{
target::{CallingConvention, CpuFeature, Target},
CompileError, FunctionIndex, FunctionType, SourceLoc, TrapCode, TrapInformation, Type,
VMOffsets,
};
@ -8302,7 +8302,7 @@ mod test {
use super::*;
use enumset::enum_set;
use std::str::FromStr;
use wasmer_compiler::types::target::{CpuFeature, Target, Triple};
use wasmer_types::target::{CpuFeature, Target, Triple};
fn test_move_location(machine: &mut MachineX86_64) -> Result<(), CompileError> {
machine.move_location_for_native(

View File

@ -4,7 +4,7 @@ use gimli::write::{Address, CallFrameInstruction, CommonInformationEntry, FrameD
use gimli::{AArch64, Encoding, Format, X86_64};
use std::fmt::Debug;
#[cfg(feature = "unwind")]
use wasmer_compiler::types::target::Architecture;
use wasmer_types::target::Architecture;
#[derive(Clone, Debug)]
pub enum UnwindOps {

View File

@ -6,8 +6,7 @@ use crate::location::CombinedRegister;
use crate::location::Reg as AbstractReg;
use std::collections::BTreeMap;
use std::slice::Iter;
use wasmer_compiler::types::target::CallingConvention;
use wasmer_types::{CompileError, Type};
use wasmer_types::{target::CallingConvention, CompileError, Type};
/// General-purpose registers.
#[repr(u8)]

View File

@ -6,8 +6,7 @@ use super::trampoline::{libcall_trampoline_len, make_libcall_trampolines};
#[cfg(feature = "compiler")]
use crate::{
serialize::SerializableCompilation, types::target::Target, EngineInner, ModuleEnvironment,
ModuleMiddlewareChain,
serialize::SerializableCompilation, EngineInner, ModuleEnvironment, ModuleMiddlewareChain,
};
use crate::{
serialize::{
@ -19,10 +18,12 @@ use crate::{
module::CompileModuleInfo,
relocation::Relocation,
section::{CustomSection, SectionIndex},
target::CpuFeature,
},
ArtifactCreate, Features,
};
#[cfg(feature = "compiler")]
use wasmer_types::target::Target;
use core::mem::MaybeUninit;
use enumset::EnumSet;
use rkyv::rancor::Error as RkyvError;
@ -31,6 +32,7 @@ use shared_buffer::OwnedBuffer;
use std::sync::Arc;
use wasmer_types::{
entity::{ArchivedPrimaryMap, PrimaryMap},
target::CpuFeature,
DeserializeError,
};

View File

@ -4,13 +4,12 @@
//! through normal branch instructions.
use enum_iterator::IntoEnumIterator;
use target_lexicon::Architecture;
use wasmer_types::target::{Architecture, Target};
use wasmer_types::LibCall;
use crate::types::{
relocation::{Relocation, RelocationKind, RelocationTarget},
section::{CustomSection, CustomSectionProtection, SectionBody},
target::Target,
};
// SystemV says that both x16 and x17 are available as intra-procedural scratch

View File

@ -1,15 +1,20 @@
//! This module mainly outputs the `Compiler` trait that custom
//! compilers will need to implement.
use crate::types::{module::CompileModuleInfo, symbols::SymbolRegistry, target::Target};
use crate::types::{module::CompileModuleInfo, symbols::SymbolRegistry};
use crate::{
lib::std::{boxed::Box, sync::Arc},
translator::ModuleMiddleware,
types::{function::Compilation, target::CpuFeature},
types::function::Compilation,
FunctionBodyData, ModuleTranslationState,
};
use enumset::EnumSet;
use wasmer_types::{entity::PrimaryMap, error::CompileError, Features, LocalFunctionIndex};
use wasmer_types::{
entity::PrimaryMap,
error::CompileError,
target::{CpuFeature, Target},
Features, LocalFunctionIndex,
};
use wasmparser::{Validator, WasmFeatures};
/// The compiler configuration options.

View File

@ -11,10 +11,7 @@ use crate::{
lib::std::vec::IntoIter,
register_frame_info, resolve_imports,
serialize::{MetadataHeader, SerializableModule},
types::{
relocation::{RelocationLike, RelocationTarget},
target::{CpuFeature, Target},
},
types::relocation::{RelocationLike, RelocationTarget},
ArtifactBuild, ArtifactBuildFromArchive, ArtifactCreate, Engine, EngineInner, Features,
FrameInfosVariant, FunctionExtent, GlobalFrameInfoRegistration, InstantiationError,
ModuleEnvironment, Tunables,
@ -35,6 +32,7 @@ use crate::object::{emit_compilation, emit_data, get_object_for_target, Object};
use wasmer_types::{
entity::{BoxedSlice, PrimaryMap},
target::{CpuFeature, Target},
ArchivedDataInitializerLocation, ArchivedOwnedDataInitializer, CompileError, DataInitializer,
DataInitializerLike, DataInitializerLocation, DataInitializerLocationLike, DeserializeError,
FunctionIndex, HashAlgorithm, LocalFunctionIndex, MemoryIndex, ModuleInfo,

View File

@ -1,6 +1,6 @@
use super::Engine;
use crate::{types::target::Target, CompilerConfig};
use wasmer_types::{Features, HashAlgorithm};
use crate::CompilerConfig;
use wasmer_types::{target::Target, Features, HashAlgorithm};
/// The Builder contents of `Engine`
pub struct EngineBuilder {

View File

@ -1,6 +1,6 @@
//! Universal compilation.
use crate::{engine::builder::EngineBuilder, types::target::Target};
use crate::engine::builder::EngineBuilder;
#[cfg(not(target_arch = "wasm32"))]
use crate::{
types::{
@ -22,8 +22,8 @@ use std::sync::{Arc, Mutex};
#[cfg(not(target_arch = "wasm32"))]
use wasmer_types::{
entity::PrimaryMap, DeserializeError, FunctionIndex, FunctionType, LocalFunctionIndex,
SignatureIndex,
entity::PrimaryMap, target::Target, DeserializeError, FunctionIndex, FunctionType,
LocalFunctionIndex, SignatureIndex,
};
use wasmer_types::{CompileError, Features, HashAlgorithm};

View File

@ -1,8 +1,8 @@
use crate::engine::error::LinkError;
use crate::types::target::{PointerWidth, Target};
use std::ptr::NonNull;
use wasmer_types::entity::{EntityRef, PrimaryMap};
use wasmer_types::{
target::{PointerWidth, Target},
FunctionType, GlobalType, LocalGlobalIndex, LocalMemoryIndex, LocalTableIndex, LocalTagIndex,
MemoryIndex, MemoryType, ModuleInfo, Pages, TableIndex, TableType, TagKind,
};

View File

@ -4,7 +4,6 @@ use crate::types::{
relocation::{RelocationKind as Reloc, RelocationTarget},
section::{CustomSectionProtection, SectionIndex},
symbols::{Symbol, SymbolRegistry},
target::{Architecture, BinaryFormat, Endianness, Triple},
};
use object::{
elf, macho,
@ -15,6 +14,7 @@ use object::{
SymbolScope,
};
use wasmer_types::entity::PrimaryMap;
use wasmer_types::target::{Architecture, BinaryFormat, Endianness, Triple};
use wasmer_types::LocalFunctionIndex;
const DWARF_SECTION_NAME: &[u8] = b".eh_frame";

View File

@ -9,14 +9,13 @@ use crate::types::{
module::CompileModuleInfo,
relocation::Relocation,
section::{CustomSection, SectionIndex},
target::CpuFeature,
};
use enumset::EnumSet;
use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
use wasmer_types::{
entity::PrimaryMap, DeserializeError, Features, FunctionIndex, LocalFunctionIndex, MemoryIndex,
MemoryStyle, ModuleInfo, OwnedDataInitializer, SerializeError, SignatureIndex, TableIndex,
TableStyle,
entity::PrimaryMap, target::CpuFeature, DeserializeError, Features, FunctionIndex,
LocalFunctionIndex, MemoryIndex, MemoryStyle, ModuleInfo, OwnedDataInitializer, SerializeError,
SignatureIndex, TableIndex, TableStyle,
};
pub use wasmer_types::MetadataHeader;

View File

@ -1,6 +1,5 @@
//! Generic Artifact abstraction for Wasmer Engines.
use crate::types::target::CpuFeature;
use crate::Features;
use enumset::EnumSet;
use std::any::Any;
@ -8,7 +7,8 @@ use std::sync::Arc;
use wasmer_types::entity::PrimaryMap;
use wasmer_types::SerializeError;
use wasmer_types::{
DataInitializerLike, MemoryIndex, MemoryStyle, ModuleInfo, TableIndex, TableStyle,
target::CpuFeature, DataInitializerLike, MemoryIndex, MemoryStyle, ModuleInfo, TableIndex,
TableStyle,
};
/// An `Artifact` is the product that the `Engine`

View File

@ -6,5 +6,4 @@ pub mod module;
pub mod relocation;
pub mod section;
pub mod symbols;
pub mod target;
pub mod unwind;

View File

@ -62,6 +62,7 @@ mod serialize;
mod stack;
mod store_id;
mod table;
pub mod target;
mod trapcode;
mod types;
mod units;
@ -90,13 +91,13 @@ pub use crate::initializers::{
pub use crate::memory::{Memory32, Memory64, MemorySize};
pub use crate::module::{ExportsIterator, ImportKey, ImportsIterator, ModuleInfo};
pub use crate::module_hash::{HashAlgorithm, ModuleHash};
pub use crate::units::{
Bytes, PageCountOutOfRange, Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
};
pub use types::{
pub use crate::types::{
ExportType, ExternType, FunctionType, GlobalInit, GlobalType, ImportType, MemoryType,
Mutability, TableType, TagKind, TagType, Type, V128,
};
pub use crate::units::{
Bytes, PageCountOutOfRange, Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE,
};
pub use value::{RawValue, ValueType};
pub use crate::libcalls::LibCall;

View File

@ -8,13 +8,13 @@
// Same things is now happening with unused-unit for the EnumSetType derivative
#![allow(clippy::unused_unit, clippy::use_self)]
use crate::error::ParseCpuFeatureError;
use enumset::{EnumSet, EnumSetType};
use std::str::FromStr;
pub use target_lexicon::{
Aarch64Architecture, Architecture, BinaryFormat, CallingConvention, Endianness, Environment,
OperatingSystem, PointerWidth, Triple, Vendor,
};
use wasmer_types::error::ParseCpuFeatureError;
/// The nomenclature is inspired by the [`cpuid` crate].
/// The list of supported features was initially retrieved from