Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
171f24a
Fix signatures registered with modules-in-components
alexcrichton Jul 5, 2023
92560e6
Initial support for resources
alexcrichton Apr 25, 2023
2c755bd
Start supporting destructors
alexcrichton Jul 5, 2023
b12f079
Get some basic drop tests working
alexcrichton Jul 5, 2023
1f66eb7
Fix rebase issue
alexcrichton Jul 5, 2023
b082ea6
Fix a failing test
alexcrichton Jul 5, 2023
e73c1c3
I am zorthax, destroyer of resources
alexcrichton Jul 5, 2023
71dbce7
Remove a branch in compiled code
alexcrichton Jul 5, 2023
fb46bf7
Fix the test suite
alexcrichton Jul 6, 2023
505b46b
Add embedder API to destroy resources
alexcrichton Jul 6, 2023
33f7c62
Add TODO for factc
alexcrichton Jul 6, 2023
933bea8
Fix a warning and leave a comment
alexcrichton Jul 6, 2023
4ebed1f
Integrate resources into `Type`
alexcrichton Jul 6, 2023
25c1b28
Implement `Val::Own`
alexcrichton Jul 6, 2023
a67737d
Implement reentrance check for destructors
alexcrichton Jul 6, 2023
e206278
Merge remote-tracking branch 'origin/main' into resources
alexcrichton Jul 10, 2023
7c0b9a2
Use cast instead of transmute
alexcrichton Jul 10, 2023
9c21f23
Fill out some cranelift-shared comments
alexcrichton Jul 10, 2023
725ddc2
Update codegen for resource.drop shim
alexcrichton Jul 10, 2023
4d6b2bf
Update wasm-tools crates to latest `main`
alexcrichton Jul 10, 2023
1f7696f
Update resource.drop binary format
alexcrichton Jul 10, 2023
8fa6b8c
Add some docs
alexcrichton Jul 10, 2023
8f1708d
Implement dynamic tracking for borrow resources
alexcrichton Jul 11, 2023
9cb30b7
Merge remote-tracking branch 'origin/main' into resources
alexcrichton Jul 11, 2023
4fbf2e7
Remove git overrides
alexcrichton Jul 11, 2023
136ced3
Remove no-longer-needed arms in wit-bindgen
alexcrichton Jul 11, 2023
a2c8772
Prepare for mutability in `LiftContext`
alexcrichton Jul 11, 2023
099f1f9
Lowering a borrow is infallible
alexcrichton Jul 12, 2023
5702532
Use `ResourceAny` for both own/borrow
alexcrichton Jul 12, 2023
23d72ac
Initial implementation of borrowed resources
alexcrichton Jul 12, 2023
faa0f3a
Add a suite of tests for borrowing resources
alexcrichton Jul 13, 2023
252fb2f
Fill in an issue for bindgen todo
alexcrichton Jul 13, 2023
2e1df2b
Add docs, still more to go
alexcrichton Jul 13, 2023
45d7c64
Fill out more documentation
alexcrichton Jul 14, 2023
451cf0a
Fill out a test TODO
alexcrichton Jul 14, 2023
8b60719
Update the host `Resource<T>` type
alexcrichton Jul 14, 2023
89cbf53
Document `ResourceAny`
alexcrichton Jul 14, 2023
1f97279
Debug assert dtor is non-null
alexcrichton Jul 21, 2023
3820cee
Review comments on loading libcalls
alexcrichton Jul 21, 2023
8190672
Update some comments
alexcrichton Jul 21, 2023
9c88a0c
Update a comment
alexcrichton Jul 21, 2023
fec8d27
Fix some typos
alexcrichton Jul 21, 2023
8242c0b
Add a test that host types are the same when guest types differ
alexcrichton Jul 21, 2023
0d95c57
Fix some typos
alexcrichton Jul 21, 2023
491d105
Thread things through a bit less
alexcrichton Jul 21, 2023
fa65029
Undo CompileKey-related changes
alexcrichton Jul 21, 2023
9492a87
Gate an async function on the async feature
alexcrichton Jul 21, 2023
96f57f1
Fix doc links
alexcrichton Jul 21, 2023
5b4cff6
Skip resources tests in miri
alexcrichton Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions crates/component-macro/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn expand_record_for_component_type(
#[inline]
fn typecheck(
ty: &#internal::InterfaceType,
types: &#internal::ComponentTypes,
types: &#internal::InstanceType<'_>,
) -> #internal::anyhow::Result<()> {
#internal::#typecheck(ty, types, &[#typecheck_argument])
}
Expand Down Expand Up @@ -422,7 +422,7 @@ impl Expander for LiftExpander {
unsafe impl #impl_generics wasmtime::component::Lift for #name #ty_generics #where_clause {
#[inline]
fn lift(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
Expand All @@ -434,7 +434,7 @@ impl Expander for LiftExpander {

#[inline]
fn load(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
Expand Down Expand Up @@ -525,7 +525,7 @@ impl Expander for LiftExpander {
unsafe impl #impl_generics wasmtime::component::Lift for #name #ty_generics #where_clause {
#[inline]
fn lift(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
Expand All @@ -538,7 +538,7 @@ impl Expander for LiftExpander {

#[inline]
fn load(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
Expand Down Expand Up @@ -888,7 +888,7 @@ impl Expander for ComponentTypeExpander {
#[inline]
fn typecheck(
ty: &#internal::InterfaceType,
types: &#internal::ComponentTypes,
types: &#internal::InstanceType<'_>,
) -> #internal::anyhow::Result<()> {
#internal::#typecheck(ty, types, &[#case_names_and_checks])
}
Expand Down Expand Up @@ -1312,7 +1312,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {

unsafe impl wasmtime::component::Lift for #name {
fn lift(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
_ty: #internal::InterfaceType,
src: &Self::Lower,
) -> #internal::anyhow::Result<Self> {
Expand All @@ -1328,7 +1328,7 @@ pub fn expand_flags(flags: &Flags) -> Result<TokenStream> {
}

fn load(
cx: &#internal::LiftContext<'_>,
cx: &mut #internal::LiftContext<'_>,
_ty: #internal::InterfaceType,
bytes: &[u8],
) -> #internal::anyhow::Result<Self> {
Expand Down
11 changes: 10 additions & 1 deletion crates/cranelift-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ fn to_flag_value(v: &settings::Value) -> FlagValue {
/// Trap code used for debug assertions we emit in our JIT code.
const DEBUG_ASSERT_TRAP_CODE: u16 = u16::MAX;

/// Code used as the user-defined trap code.
/// A custom code with `TrapCode::User` which is used by always-trap shims which
/// indicates that, as expected, the always-trapping function indeed did trap.
/// This effectively provides a better error message as opposed to a bland
/// "unreachable code reached"
pub const ALWAYS_TRAP_CODE: u16 = 100;

/// A custom code with `TrapCode::User` corresponding to being unable to reenter
/// a component due to its reentrance limitations. This is used in component
/// adapters to provide a more useful error message in such situations.
pub const CANNOT_ENTER_CODE: u16 = 101;

/// Converts machine traps to trap information.
pub fn mach_trap_to_trap(trap: &MachTrap) -> Option<TrapInformation> {
let &MachTrap { offset, code } = trap;
Expand All @@ -77,6 +85,7 @@ pub fn mach_trap_to_trap(trap: &MachTrap) -> Option<TrapInformation> {
ir::TrapCode::UnreachableCodeReached => Trap::UnreachableCodeReached,
ir::TrapCode::Interrupt => Trap::Interrupt,
ir::TrapCode::User(ALWAYS_TRAP_CODE) => Trap::AlwaysTrapAdapter,
ir::TrapCode::User(CANNOT_ENTER_CODE) => Trap::CannotEnterComponent,
ir::TrapCode::NullReference => Trap::NullReference,

// These do not get converted to wasmtime traps, since they
Expand Down
7 changes: 3 additions & 4 deletions crates/cranelift/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ impl wasmtime_environ::Compiler for Compiler {

fn compile_wasm_to_native_trampoline(
&self,
translation: &ModuleTranslation,
wasm_func_ty: &WasmFuncType,
) -> Result<Box<dyn Any + Send>, CompileError> {
let isa = &*self.isa;
Expand Down Expand Up @@ -379,14 +378,14 @@ impl wasmtime_environ::Compiler for Compiler {
caller_vmctx,
wasmtime_environ::VMCONTEXT_MAGIC,
);
let offsets = VMOffsets::new(isa.pointer_bytes(), &translation.module);
let ptr = isa.pointer_bytes();
let limits = builder.ins().load(
pointer_type,
MemFlags::trusted(),
caller_vmctx,
i32::try_from(offsets.vmctx_runtime_limits()).unwrap(),
i32::try_from(ptr.vmcontext_runtime_limits()).unwrap(),
);
save_last_wasm_exit_fp_and_pc(&mut builder, pointer_type, &offsets.ptr, limits);
save_last_wasm_exit_fp_and_pc(&mut builder, pointer_type, &ptr, limits);

// If the native call signature for this function uses a return pointer
// then allocate the return pointer here on the stack and pass it as the
Expand Down
Loading