Skip to content

Commit

Permalink
Annotate some FIXMEs with issue numbers (#9951)
Browse files Browse the repository at this point in the history
Fill out #4311 throughout the codebase where I know of that it needs to
be handled.
  • Loading branch information
alexcrichton authored Jan 8, 2025
1 parent c1bb5ab commit 34680fb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
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

0 comments on commit 34680fb

Please sign in to comment.