Skip to content

Commit

Permalink
Annotate some FIXMEs with issue numbers (bytecodealliance#9951)
Browse files Browse the repository at this point in the history
Fill out bytecodealliance#4311 throughout the codebase where I know of that it needs to
be handled.
  • Loading branch information
alexcrichton committed Jan 8, 2025
1 parent 4ad53fa commit 6079e29
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 149 deletions.
159 changes: 80 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ wit-bindgen = { version = "0.35.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.35.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.221.2", default-features = false, features = ['simd'] }
wat = "1.221.2"
wast = "221.0.2"
wasmprinter = "0.221.2"
wasm-encoder = "0.221.2"
wasm-smith = "0.221.2"
wasm-mutate = "0.221.2"
wit-parser = "0.221.2"
wit-component = "0.221.2"
wasm-wave = "0.221.2"
wasmparser = { version = "0.223.0", default-features = false, features = ['simd'] }
wat = "1.223.0"
wast = "223.0.0"
wasmprinter = "0.223.0"
wasm-encoder = "0.223.0"
wasm-smith = "0.223.0"
wasm-mutate = "0.223.0"
wit-parser = "0.223.0"
wit-component = "0.223.0"
wasm-wave = "0.223.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down
29 changes: 29 additions & 0 deletions crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,32 @@ impl<'a, 'data> Translator<'a, 'data> {
| wasmparser::CanonicalFunction::ThreadHwConcurrency => {
bail!("unsupported intrinsic")
}

wasmparser::CanonicalFunction::TaskBackpressure
| wasmparser::CanonicalFunction::TaskPoll { .. }
| wasmparser::CanonicalFunction::TaskYield { .. }
| wasmparser::CanonicalFunction::SubtaskDrop
| wasmparser::CanonicalFunction::StreamNew { .. }
| wasmparser::CanonicalFunction::StreamRead { .. }
| wasmparser::CanonicalFunction::StreamWrite { .. }
| wasmparser::CanonicalFunction::StreamCancelRead { .. }
| wasmparser::CanonicalFunction::StreamCancelWrite { .. }
| wasmparser::CanonicalFunction::StreamCloseReadable { .. }
| wasmparser::CanonicalFunction::StreamCloseWritable { .. }
| wasmparser::CanonicalFunction::FutureNew { .. }
| wasmparser::CanonicalFunction::FutureRead { .. }
| wasmparser::CanonicalFunction::FutureWrite { .. }
| wasmparser::CanonicalFunction::FutureCancelRead { .. }
| wasmparser::CanonicalFunction::FutureCancelWrite { .. }
| wasmparser::CanonicalFunction::FutureCloseReadable { .. }
| wasmparser::CanonicalFunction::FutureCloseWritable { .. }
| wasmparser::CanonicalFunction::ErrorContextNew { .. }
| wasmparser::CanonicalFunction::ErrorContextDebugMessage { .. }
| wasmparser::CanonicalFunction::ErrorContextDrop
| wasmparser::CanonicalFunction::TaskReturn { .. }
| wasmparser::CanonicalFunction::TaskWait { .. } => {
bail!("unsupported intrinsic")
}
};
self.result.initializers.push(init);
}
Expand Down Expand Up @@ -920,6 +946,9 @@ impl<'a, 'data> Translator<'a, 'data> {
let idx = FuncIndex::from_u32(*idx);
ret.post_return = Some(idx);
}
wasmparser::CanonicalOption::Async | wasmparser::CanonicalOption::Callback(_) => {
todo!()
}
}
}
return ret;
Expand Down
3 changes: 3 additions & 0 deletions crates/environ/src/component/types_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ impl ComponentTypesBuilder {
ComponentDefinedType::Borrow(r) => {
InterfaceType::Borrow(self.resource_id(r.resource()))
}
ComponentDefinedType::Future(_)
| ComponentDefinedType::Stream(_)
| ComponentDefinedType::ErrorContext => bail!("unsupported async type"),
};
let info = self.type_information(&ret);
if info.depth > MAX_TYPE_DEPTH {
Expand Down
2 changes: 2 additions & 0 deletions crates/wasmtime/src/engine/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl Metadata<'_> {
component_model_nested_names,
component_model_more_flags,
component_model_multiple_returns,
component_model_async,
legacy_exceptions,
gc_types,
stack_switching,
Expand All @@ -252,6 +253,7 @@ impl Metadata<'_> {
assert!(!shared_everything_threads);
assert!(!legacy_exceptions);
assert!(!stack_switching);
assert!(!component_model_async);

Metadata {
target: engine.compiler().triple().to_string(),
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/src/runtime/component/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ impl Func {
results: &mut [Val],
src: &mut core::slice::Iter<'_, ValRaw>,
) -> Result<()> {
// FIXME: needs to read an i64 for memory64
// FIXME(#4311): needs to read an i64 for memory64
let ptr = usize::try_from(src.next().unwrap().get_u32())?;
if ptr % usize::try_from(results_ty.abi.align32)? != 0 {
bail!("return pointer not aligned");
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmtime/src/runtime/component/func/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ where
}

fn validate_inbounds<T: ComponentType>(memory: &[u8], ptr: &ValRaw) -> Result<usize> {
// FIXME: needs memory64 support
// FIXME(#4311): needs memory64 support
let ptr = usize::try_from(ptr.get_u32())?;
if ptr % usize::try_from(T::ALIGN32)? != 0 {
bail!("pointer not aligned");
Expand Down Expand Up @@ -406,7 +406,7 @@ where
}

fn validate_inbounds_dynamic(abi: &CanonicalAbiInfo, memory: &[u8], ptr: &ValRaw) -> Result<usize> {
// FIXME: needs memory64 support
// FIXME(#4311): needs memory64 support
let ptr = usize::try_from(ptr.get_u32())?;
if ptr % usize::try_from(abi.align32)? != 0 {
bail!("pointer not aligned");
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/src/runtime/component/func/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ unsafe impl Send for Options {}
unsafe impl Sync for Options {}

impl Options {
// TODO: prevent a ctor where the memory is memory64
// FIXME(#4311): prevent a ctor where the memory is memory64

/// Creates a new set of options with the specified components.
///
Expand Down
14 changes: 7 additions & 7 deletions crates/wasmtime/src/runtime/component/func/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ where
dst: &ValRaw,
) -> Result<Return> {
assert!(Return::flatten_count() > MAX_FLAT_RESULTS);
// FIXME: needs to read an i64 for memory64
// FIXME(#4311): needs to read an i64 for memory64
let ptr = usize::try_from(dst.get_u32())?;
if ptr % usize::try_from(Return::ALIGN32)? != 0 {
bail!("return pointer not aligned");
Expand Down Expand Up @@ -1052,7 +1052,7 @@ unsafe impl Lift for char {
}
}

// TODO: these probably need different constants for memory64
// FIXME(#4311): these probably need different constants for memory64
const UTF16_TAG: usize = 1 << 31;
const MAX_STRING_BYTE_LENGTH: usize = (1 << 31) - 1;

Expand Down Expand Up @@ -1096,7 +1096,7 @@ unsafe impl Lower for str {
debug_assert!(matches!(ty, InterfaceType::String));
debug_assert!(offset % (Self::ALIGN32 as usize) == 0);
let (ptr, len) = lower_string(cx, self)?;
// FIXME: needs memory64 handling
// FIXME(#4311): needs memory64 handling
*cx.get(offset + 0) = u32::try_from(ptr).unwrap().to_le_bytes();
*cx.get(offset + 4) = u32::try_from(len).unwrap().to_le_bytes();
Ok(())
Expand Down Expand Up @@ -1366,7 +1366,7 @@ unsafe impl Lift for WasmStr {
#[inline]
fn lift(cx: &mut LiftContext<'_>, ty: InterfaceType, src: &Self::Lower) -> Result<Self> {
debug_assert!(matches!(ty, InterfaceType::String));
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = src[0].get_u32();
let len = src[1].get_u32();
let (ptr, len) = (usize::try_from(ptr)?, usize::try_from(len)?);
Expand All @@ -1377,7 +1377,7 @@ unsafe impl Lift for WasmStr {
fn load(cx: &mut LiftContext<'_>, ty: InterfaceType, bytes: &[u8]) -> Result<Self> {
debug_assert!(matches!(ty, InterfaceType::String));
debug_assert!((bytes.as_ptr() as usize) % (Self::ALIGN32 as usize) == 0);
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = u32::from_le_bytes(bytes[..4].try_into().unwrap());
let len = u32::from_le_bytes(bytes[4..].try_into().unwrap());
let (ptr, len) = (usize::try_from(ptr)?, usize::try_from(len)?);
Expand Down Expand Up @@ -1670,7 +1670,7 @@ unsafe impl<T: Lift> Lift for WasmList<T> {
InterfaceType::List(i) => cx.types[i].element,
_ => bad_type_info(),
};
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = src[0].get_u32();
let len = src[1].get_u32();
let (ptr, len) = (usize::try_from(ptr)?, usize::try_from(len)?);
Expand All @@ -1683,7 +1683,7 @@ unsafe impl<T: Lift> Lift for WasmList<T> {
_ => bad_type_info(),
};
debug_assert!((bytes.as_ptr() as usize) % (Self::ALIGN32 as usize) == 0);
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = u32::from_le_bytes(bytes[..4].try_into().unwrap());
let len = u32::from_le_bytes(bytes[4..].try_into().unwrap());
let (ptr, len) = (usize::try_from(ptr)?, usize::try_from(len)?);
Expand Down
6 changes: 3 additions & 3 deletions crates/wasmtime/src/runtime/component/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Val {
}
InterfaceType::String => Val::String(<_>::lift(cx, ty, &[*next(src), *next(src)])?),
InterfaceType::List(i) => {
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = u32::lift(cx, InterfaceType::U32, next(src))? as usize;
let len = u32::lift(cx, InterfaceType::U32, next(src))? as usize;
load_list(cx, i, ptr, len)?
Expand Down Expand Up @@ -221,7 +221,7 @@ impl Val {
Val::Resource(ResourceAny::load(cx, ty, bytes)?)
}
InterfaceType::List(i) => {
// FIXME: needs memory64 treatment
// FIXME(#4311): needs memory64 treatment
let ptr = u32::from_le_bytes(bytes[..4].try_into().unwrap()) as usize;
let len = u32::from_le_bytes(bytes[4..].try_into().unwrap()) as usize;
load_list(cx, i, ptr, len)?
Expand Down Expand Up @@ -477,7 +477,7 @@ impl Val {
(InterfaceType::List(ty), Val::List(values)) => {
let ty = &cx.types[ty];
let (ptr, len) = lower_list(cx, ty.element, values)?;
// FIXME: needs memory64 handling
// FIXME(#4311): needs memory64 handling
*cx.get(offset + 0) = u32::try_from(ptr).unwrap().to_le_bytes();
*cx.get(offset + 4) = u32::try_from(len).unwrap().to_le_bytes();
Ok(())
Expand Down
9 changes: 4 additions & 5 deletions crates/wit-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ impl<'a> InterfaceGenerator<'a> {
TypeDefKind::Type(t) => self.type_alias(id, name, t, &ty.docs),
TypeDefKind::Future(_) => todo!("generate for future"),
TypeDefKind::Stream(_) => todo!("generate for stream"),
TypeDefKind::ErrorContext => todo!("generate for error-context"),
TypeDefKind::Handle(handle) => self.type_handle(id, name, handle, &ty.docs),
TypeDefKind::Resource => self.type_resource(id, name, ty, &ty.docs),
TypeDefKind::Unknown => unreachable!(),
Expand Down Expand Up @@ -3237,6 +3238,7 @@ fn type_contains_lists(ty: Type, resolve: &Resolve) -> bool {
Type::Id(id) => match &resolve.types[id].kind {
TypeDefKind::Resource
| TypeDefKind::Unknown
| TypeDefKind::ErrorContext
| TypeDefKind::Flags(_)
| TypeDefKind::Handle(_)
| TypeDefKind::Enum(_) => false,
Expand All @@ -3258,11 +3260,8 @@ fn type_contains_lists(ty: Type, resolve: &Resolve) -> bool {
.iter()
.any(|case| option_type_contains_lists(case.ty, resolve)),
TypeDefKind::Type(ty) => type_contains_lists(*ty, resolve),
TypeDefKind::Future(ty) => option_type_contains_lists(*ty, resolve),
TypeDefKind::Stream(Stream { element, end }) => {
option_type_contains_lists(*element, resolve)
|| option_type_contains_lists(*end, resolve)
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::List(_) => true,
},

Expand Down
18 changes: 5 additions & 13 deletions crates/wit-bindgen/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ pub trait RustGenerator<'a> {
| TypeDefKind::Enum(_)
| TypeDefKind::Tuple(_)
| TypeDefKind::Handle(_)
| TypeDefKind::Resource => true,
| TypeDefKind::Resource
| TypeDefKind::ErrorContext => true,
TypeDefKind::Type(Type::Id(t)) => {
needs_generics(resolve, &resolve.types[*t].kind)
}
Expand Down Expand Up @@ -165,18 +166,9 @@ pub trait RustGenerator<'a> {
TypeDefKind::Enum(_) => {
panic!("unsupported anonymous type reference: enum")
}
TypeDefKind::Future(ty) => {
self.push_str("Future<");
self.print_optional_ty(ty.as_ref(), mode);
self.push_str(">");
}
TypeDefKind::Stream(stream) => {
self.push_str("Stream<");
self.print_optional_ty(stream.element.as_ref(), mode);
self.push_str(",");
self.print_optional_ty(stream.end.as_ref(), mode);
self.push_str(">");
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::ErrorContext => todo!(),

TypeDefKind::Handle(handle) => {
self.print_handle(handle);
Expand Down
10 changes: 3 additions & 7 deletions crates/wit-bindgen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,9 @@ impl Types {
info = self.optional_type_info(resolve, r.ok.as_ref());
info |= self.optional_type_info(resolve, r.err.as_ref());
}
TypeDefKind::Future(ty) => {
info = self.optional_type_info(resolve, ty.as_ref());
}
TypeDefKind::Stream(stream) => {
info = self.optional_type_info(resolve, stream.element.as_ref());
info |= self.optional_type_info(resolve, stream.end.as_ref());
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::ErrorContext => todo!(),
TypeDefKind::Handle(_) => info.has_handle = true,
TypeDefKind::Resource => {}
TypeDefKind::Unknown => unreachable!(),
Expand Down
2 changes: 1 addition & 1 deletion supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4197,7 +4197,7 @@ end = "2025-12-02"
criteria = "safe-to-deploy"
user-id = 539 # Josh Stone (cuviper)
start = "2020-01-15"
end = "2024-07-06"
end = "2026-01-08"

[[trusted.io-extras]]
criteria = "safe-to-deploy"
Expand Down
Loading

0 comments on commit 6079e29

Please sign in to comment.