forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3461a7
commit 3691d9c
Showing
10 changed files
with
190 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::prelude::*; | ||
use crate::runtime::vm::VMOpaqueContext; | ||
use crate::ValRaw; | ||
use core::marker; | ||
use core::mem; | ||
use core::ptr::NonNull; | ||
use pulley_interpreter::interp::{Vm, XRegVal}; | ||
|
||
#[repr(transparent)] | ||
pub struct Interpreter { | ||
pulley: Box<Vm>, | ||
} | ||
|
||
impl Interpreter { | ||
pub fn new() -> Interpreter { | ||
Interpreter { | ||
pulley: Box::new(Vm::new()), | ||
} | ||
} | ||
|
||
pub fn as_interpreter_ref(&mut self) -> InterpreterRef<'_> { | ||
InterpreterRef(&mut self.pulley) | ||
} | ||
} | ||
|
||
#[repr(transparent)] | ||
pub struct InterpreterRef<'a>(&'a mut Vm); | ||
|
||
impl InterpreterRef<'_> { | ||
pub unsafe fn call( | ||
&mut self, | ||
bytecode: NonNull<u8>, | ||
callee: *mut VMOpaqueContext, | ||
caller: *mut VMOpaqueContext, | ||
args_and_results: *mut [ValRaw], | ||
) { | ||
let args = [ | ||
XRegVal::new_ptr(callee).into(), | ||
XRegVal::new_ptr(caller).into(), | ||
XRegVal::new_ptr(args_and_results.cast::<u8>()).into(), | ||
XRegVal::new_u64(args_and_results.len() as u64).into(), | ||
]; | ||
// TODO: handle result | ||
let _ = self.0.call(bytecode, &args, []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::runtime::vm::VMOpaqueContext; | ||
use crate::ValRaw; | ||
use core::marker; | ||
use core::mem; | ||
use core::ptr::NonNull; | ||
|
||
pub struct Interpreter { | ||
empty: Void, | ||
} | ||
|
||
const _: () = assert!(mem::size_of::<Interpreter>() == 0); | ||
const _: () = assert!(mem::size_of::<Option<Interpreter>>() == 0); | ||
|
||
enum Void {} | ||
|
||
impl Interpreter { | ||
pub fn new() -> Interpreter { | ||
unreachable!() | ||
} | ||
|
||
pub fn as_interpreter_ref(&mut self) -> InterpreterRef<'_> { | ||
match self.empty {} | ||
} | ||
} | ||
|
||
pub struct InterpreterRef<'a> { | ||
empty: Void, | ||
_marker: marker::PhantomData<&'a mut Interpreter>, | ||
} | ||
|
||
const _: () = assert!(mem::size_of::<InterpreterRef<'_>>() == 0); | ||
const _: () = assert!(mem::size_of::<Option<InterpreterRef<'_>>>() == 0); | ||
|
||
impl InterpreterRef<'_> { | ||
pub unsafe fn call( | ||
&mut self, | ||
_bytecode: NonNull<u8>, | ||
_callee: *mut VMOpaqueContext, | ||
_caller: *mut VMOpaqueContext, | ||
_args_and_results: *mut [ValRaw], | ||
) { | ||
match self.empty {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.