Skip to content

Conversation

@marxin
Copy link
Contributor

@marxin marxin commented Oct 24, 2025

First part of the warning clean-up, these changes make it possible to run cargo build --all without any warning.

@marxin marxin requested a review from syrusakbary as a code owner October 24, 2025 07:24
@marxin marxin force-pushed the fix-compilation-warnings branch from 21c1cac to 082fbbf Compare October 28, 2025 12:23
}
}

pub(crate) struct VMExceptionRef(*mut wasm_ref_t);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be private. Why it needs to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The place where the type is exposed to a public API is here:

warning: type `backend::v8::vm::VMExceptionRef` is more private than the item `vm::VMExceptionRef::V8::0`
   --> lib/api/src/vm/mod.rs:22:16
    |
22  |             V8(crate::backend::v8::vm::[<VM $name>]),
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `vm::VMExceptionRef::V8::0` is reachable at visibility `pub`
...
445 | define_vm_like!(ExceptionRef);
    | ----------------------------- in this macro invocation
    |
note: but type `backend::v8::vm::VMExceptionRef` is only usable at visibility `pub(crate)`

let mem_size: TypedFunction<(), i32> = instance
.exports
.get_typed_function(&mut store, "mem_size")?;
#[cfg(not(feature = "wamr"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not in wamr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the code down below makes use of the functions only conditionally:

wasmer/examples/memory.rs

Lines 112 to 145 in b4bff3c

#[cfg(not(feature = "wamr"))]
{
// Here we are requesting two more pages for our memory.
memory.grow(&mut store, 2)?;
let memory_view = memory.view(&store);
assert_eq!(memory_view.size(), Pages::from(3));
assert_eq!(memory_view.data_size(), 65536 * 3);
// Now that we know how to query and adjust the size of the memory,
// let's see how wa can write to it or read from it.
//
// We'll only focus on how to do this using exported functions, the goal
// is to show how to work with memory addresses. Here we'll use absolute
// addresses to write and read a value.
let mem_addr = 0x2220;
let val = 0xFEFEFFE;
set_at.call(&mut store, mem_addr, val)?;
let result = get_at.call(&mut store, mem_addr)?;
println!("Value at {:#x?}: {:?}", mem_addr, result);
assert_eq!(result, val);
// Now instead of using hard coded memory addresses, let's try to write
// something at the end of the second memory page and read it.
let page_size = 0x1_0000;
let mem_addr = (page_size * 2) - mem::size_of_val(&val) as i32;
let val = 0xFEA09;
set_at.call(&mut store, mem_addr, val)?;
let result = get_at.call(&mut store, mem_addr)?;
println!("Value at {:#x?}: {:?}", mem_addr, result);
assert_eq!(result, val);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants