This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connect part of the llvm backend to the runtime
- Loading branch information
1 parent
d4ae5cd
commit 359ac5a
Showing
7 changed files
with
77 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/artifacts | ||
.DS_Store | ||
.idea | ||
**/.vscode |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "llvm-backend" | ||
name = "wasmer-llvm-backend" | ||
version = "0.1.0" | ||
authors = ["Lachlan Sneff <[email protected]>"] | ||
edition = "2018" | ||
|
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,38 @@ | ||
use wasmer_runtime::{compile, error, imports, Func}; | ||
|
||
use wabt::wat2wasm; | ||
|
||
static WAT: &'static str = r#" | ||
(module | ||
(type $t0 (func (param i32) (result i32))) | ||
(type $t1 (func (result i32))) | ||
(memory 1) | ||
(global $g0 (mut i32) (i32.const 0)) | ||
(export "foo" (func $foo)) | ||
(func $foo (type $t0) (param i32) (result i32) | ||
get_local 0 | ||
) | ||
) | ||
"#; | ||
|
||
fn get_wasm() -> Vec<u8> { | ||
wat2wasm(WAT).unwrap() | ||
} | ||
|
||
fn main() -> Result<(), error::Error> { | ||
let wasm = get_wasm(); | ||
|
||
let module = compile(&wasm)?; | ||
|
||
let imports = imports! {}; | ||
|
||
let instance = module.instantiate(&imports)?; | ||
|
||
let foo: Func<i32, i32> = instance.func("foo")?; | ||
|
||
let result = foo.call(42); | ||
|
||
println!("result: {:?}", result); | ||
|
||
Ok(()) | ||
} |
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