Split the runtime and execution code into separate crates.
This commit is contained in:
14
lib/execute/Cargo.toml
Normal file
14
lib/execute/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "wasmstandalone_execute"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
description = "JIT-style runtime support for WebAsssembly code in Cretonne"
|
||||
repository = "https://github.com/sunfishcode/wasmstandalone"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
region = "0.0.8"
|
||||
wasmstandalone_runtime = { path = "../runtime" }
|
||||
@@ -1,3 +1,12 @@
|
||||
//! JIT-style runtime for WebAssembly using Cretonne.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate cretonne;
|
||||
extern crate cton_wasm;
|
||||
extern crate region;
|
||||
extern crate wasmstandalone_runtime;
|
||||
|
||||
use cretonne::Context;
|
||||
use cretonne::settings;
|
||||
use cretonne::isa::TargetIsa;
|
||||
@@ -15,7 +24,6 @@ use region::protect;
|
||||
use std::collections::HashMap;
|
||||
use std::ptr::write_unaligned;
|
||||
use std::fmt::Write;
|
||||
use standalone;
|
||||
|
||||
type RelocRef = u16;
|
||||
|
||||
@@ -64,7 +72,7 @@ pub struct ExecutableCode {
|
||||
pub fn compile_module(
|
||||
trans_result: &TranslationResult,
|
||||
isa: &TargetIsa,
|
||||
runtime: &standalone::Runtime,
|
||||
runtime: &wasmstandalone_runtime::Runtime,
|
||||
) -> Result<ExecutableCode, String> {
|
||||
debug_assert!(
|
||||
trans_result.start_index.is_none() ||
|
||||
@@ -149,7 +157,7 @@ pub fn execute(exec: &ExecutableCode) -> Result<(), String> {
|
||||
fn relocate(
|
||||
functions_metatada: &[FunctionMetaData],
|
||||
functions_code: &mut Vec<Vec<u8>>,
|
||||
runtime: &standalone::Runtime,
|
||||
runtime: &wasmstandalone_runtime::Runtime,
|
||||
) {
|
||||
// The relocations are relative to the relocation's address plus four bytes
|
||||
for (func_index, function_in_memory) in functions_metatada.iter().enumerate() {
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "wasm2obj"
|
||||
name = "wasmstandalone_obj"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
@@ -7,5 +7,5 @@ publish = false
|
||||
[dependencies]
|
||||
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
wasmstandalone = { path = "../wasmstandalone" }
|
||||
wasmstandalone_runtime = { path = "../runtime" }
|
||||
faerie = { git = "https://github.com/m4b/faerie" }
|
||||
@@ -11,7 +11,7 @@ use cretonne::binemit::{RelocSink, Reloc, CodeOffset};
|
||||
use cton_wasm::TranslationResult;
|
||||
use std::fmt::Write;
|
||||
use faerie::Artifact;
|
||||
use wasmstandalone;
|
||||
use wasmstandalone_runtime;
|
||||
|
||||
type RelocRef = u16;
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn emit_module(
|
||||
trans_result: &TranslationResult,
|
||||
obj: &mut Artifact,
|
||||
isa: &TargetIsa,
|
||||
runtime: &wasmstandalone::Runtime,
|
||||
runtime: &wasmstandalone_runtime::Runtime,
|
||||
) -> Result<(), String> {
|
||||
debug_assert!(
|
||||
trans_result.start_index.is_none() ||
|
||||
@@ -1,7 +1,7 @@
|
||||
extern crate cretonne;
|
||||
extern crate cton_wasm;
|
||||
extern crate faerie;
|
||||
extern crate wasmstandalone;
|
||||
extern crate wasmstandalone_runtime;
|
||||
|
||||
mod emit_module;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
[package]
|
||||
name = "wasmstandalone"
|
||||
name = "wasmstandalone_runtime"
|
||||
version = "0.0.0"
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
publish = false
|
||||
description = "Standalone JIT-style runtime support for WebAsssembly code in Cretonne"
|
||||
repository = "https://github.com/stoklund/cretonne"
|
||||
description = "Standalone runtime support for WebAsssembly code in Cretonne"
|
||||
repository = "https://github.com/sunfishcode/wasmstandalone"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
cretonne = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
cretonne-wasm = { git = "https://github.com/stoklund/cretonne.git" }
|
||||
region = "0.0.8"
|
||||
@@ -1,3 +1,13 @@
|
||||
//! Standalone runtime for WebAssembly using Cretonne. Provides functions to translate
|
||||
//! `get_global`, `set_global`, `current_memory`, `grow_memory`, `call_indirect` that hardcode in
|
||||
//! the translation the base addresses of regions of memory that will hold the globals, tables and
|
||||
//! linear memories.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate cretonne;
|
||||
extern crate cton_wasm;
|
||||
|
||||
use cton_wasm::{FunctionIndex, GlobalIndex, TableIndex, MemoryIndex, Global, GlobalInit, Table,
|
||||
Memory, WasmRuntime, FuncEnvironment, GlobalValue, SignatureIndex};
|
||||
use cretonne::ir::{InstBuilder, FuncRef, ExtFuncData, FunctionName, Signature, ArgumentType,
|
||||
@@ -12,17 +22,22 @@ use std::mem::transmute;
|
||||
use std::ptr::copy_nonoverlapping;
|
||||
use std::ptr::write;
|
||||
|
||||
/// Runtime state of a WebAssembly table element.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum TableElement {
|
||||
/// A element that, if called, produces a trap.
|
||||
Trap(),
|
||||
/// A function.
|
||||
Function(FunctionIndex),
|
||||
}
|
||||
|
||||
struct GlobalInfo {
|
||||
/// Information about a WebAssembly global variable.
|
||||
pub struct GlobalInfo {
|
||||
global: Global,
|
||||
offset: usize,
|
||||
}
|
||||
|
||||
/// Runtime state of a WebAssembly global variable.
|
||||
pub struct GlobalsData {
|
||||
data: Vec<u8>,
|
||||
info: Vec<GlobalInfo>,
|
||||
@@ -1,16 +0,0 @@
|
||||
//! Standalone JIT-style runtime for WebAssembly using Cretonne. Provides functions to translate
|
||||
//! `get_global`, `set_global`, `current_memory`, `grow_memory`, `call_indirect` that hardcode in
|
||||
//! the translation the base addresses of regions of memory that will hold the globals, tables and
|
||||
//! linear memories.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
extern crate cretonne;
|
||||
extern crate cton_wasm;
|
||||
extern crate region;
|
||||
|
||||
mod execution;
|
||||
mod standalone;
|
||||
|
||||
pub use execution::{compile_module, execute, ExecutableCode};
|
||||
pub use standalone::Runtime;
|
||||
Reference in New Issue
Block a user