Switch to passing the vmctx hidden argument at the beginning.

This switches to passing the vmctx hidden argument at the beginning of
the argument list, rather than the end.
This commit is contained in:
Dan Gohman
2019-01-31 16:38:57 -08:00
parent e66f01b923
commit 4675948c2a
7 changed files with 43 additions and 27 deletions

View File

@@ -387,7 +387,7 @@ impl InstanceContents {
};
// Make the call.
unsafe { wasmtime_call(callee_address, callee_vmctx) }
unsafe { wasmtime_call(callee_vmctx, callee_address) }
.map_err(InstantiationError::StartTrap)
}

View File

@@ -90,9 +90,9 @@ pub extern "C" fn wasmtime_f64_nearest(x: f64) -> f64 {
/// Implementation of memory.grow for locally-defined 32-bit memories.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_memory32_grow(
vmctx: *mut VMContext,
delta: u32,
memory_index: u32,
vmctx: *mut VMContext,
) -> u32 {
let instance_contents = (&mut *vmctx).instance_contents();
let memory_index = DefinedMemoryIndex::from_u32(memory_index);
@@ -105,9 +105,9 @@ pub unsafe extern "C" fn wasmtime_memory32_grow(
/// Implementation of memory.grow for imported 32-bit memories.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_imported_memory32_grow(
vmctx: *mut VMContext,
delta: u32,
memory_index: u32,
vmctx: *mut VMContext,
) -> u32 {
let instance_contents = (&mut *vmctx).instance_contents();
let memory_index = MemoryIndex::from_u32(memory_index);
@@ -119,7 +119,7 @@ pub unsafe extern "C" fn wasmtime_imported_memory32_grow(
/// Implementation of memory.size for locally-defined 32-bit memories.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_memory32_size(memory_index: u32, vmctx: *mut VMContext) -> u32 {
pub unsafe extern "C" fn wasmtime_memory32_size(vmctx: *mut VMContext, memory_index: u32) -> u32 {
let instance_contents = (&mut *vmctx).instance_contents();
let memory_index = DefinedMemoryIndex::from_u32(memory_index);
@@ -129,8 +129,8 @@ pub unsafe extern "C" fn wasmtime_memory32_size(memory_index: u32, vmctx: *mut V
/// Implementation of memory.size for imported 32-bit memories.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_imported_memory32_size(
memory_index: u32,
vmctx: *mut VMContext,
memory_index: u32,
) -> u32 {
let instance_contents = (&mut *vmctx).instance_contents();
let memory_index = MemoryIndex::from_u32(memory_index);

View File

@@ -91,9 +91,9 @@ fn push_jmp_buf(buf: jmp_buf) {
/// return values will be written.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_call_trampoline(
vmctx: *mut VMContext,
callee: *const VMFunctionBody,
values_vec: *mut u8,
vmctx: *mut VMContext,
) -> Result<(), String> {
// Reset JMP_BUFS if the stack is unwound through this point.
let _guard = ScopeGuard::new();
@@ -106,8 +106,8 @@ pub unsafe extern "C" fn wasmtime_call_trampoline(
push_jmp_buf(buf);
// Call the function!
let func: fn(*mut u8, *mut VMContext) = mem::transmute(callee);
func(values_vec, vmctx);
let func: fn(*mut VMContext, *mut u8) = mem::transmute(callee);
func(vmctx, values_vec);
Ok(())
}
@@ -116,8 +116,8 @@ pub unsafe extern "C" fn wasmtime_call_trampoline(
/// return values.
#[no_mangle]
pub unsafe extern "C" fn wasmtime_call(
callee: *const VMFunctionBody,
vmctx: *mut VMContext,
callee: *const VMFunctionBody,
) -> Result<(), String> {
// Reset JMP_BUFS if the stack is unwound through this point.
let _guard = ScopeGuard::new();