Rename wasmstandalone::StandaloneRuntime to wasmstandalone::Runtime.
This commit is contained in:
@@ -12,7 +12,7 @@ use cton_wasm::TranslationResult;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use faerie::Artifact;
|
use faerie::Artifact;
|
||||||
use wasmstandalone::StandaloneRuntime;
|
use wasmstandalone;
|
||||||
|
|
||||||
type RelocRef = u16;
|
type RelocRef = u16;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ pub fn emit_module(
|
|||||||
trans_result: &TranslationResult,
|
trans_result: &TranslationResult,
|
||||||
obj: &mut Artifact,
|
obj: &mut Artifact,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
runtime: &StandaloneRuntime,
|
runtime: &wasmstandalone::Runtime,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
trans_result.start_index.is_none() ||
|
trans_result.start_index.is_none() ||
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use region::protect;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ptr::write_unaligned;
|
use std::ptr::write_unaligned;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use standalone::StandaloneRuntime;
|
use standalone;
|
||||||
|
|
||||||
type RelocRef = u16;
|
type RelocRef = u16;
|
||||||
|
|
||||||
@@ -60,11 +60,11 @@ pub struct ExecutableCode {
|
|||||||
start_index: FunctionIndex,
|
start_index: FunctionIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes a module that has been translated with the `StandaloneRuntime` runtime implementation.
|
/// Executes a module that has been translated with the `standalone::Runtime` runtime implementation.
|
||||||
pub fn compile_module(
|
pub fn compile_module(
|
||||||
trans_result: &TranslationResult,
|
trans_result: &TranslationResult,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
runtime: &StandaloneRuntime,
|
runtime: &standalone::Runtime,
|
||||||
) -> Result<ExecutableCode, String> {
|
) -> Result<ExecutableCode, String> {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
trans_result.start_index.is_none() ||
|
trans_result.start_index.is_none() ||
|
||||||
@@ -149,7 +149,7 @@ pub fn execute(exec: &ExecutableCode) -> Result<(), String> {
|
|||||||
fn relocate(
|
fn relocate(
|
||||||
functions_metatada: &[FunctionMetaData],
|
functions_metatada: &[FunctionMetaData],
|
||||||
functions_code: &mut Vec<Vec<u8>>,
|
functions_code: &mut Vec<Vec<u8>>,
|
||||||
runtime: &StandaloneRuntime,
|
runtime: &standalone::Runtime,
|
||||||
) {
|
) {
|
||||||
// The relocations are relative to the relocation's address plus four bytes
|
// The relocations are relative to the relocation's address plus four bytes
|
||||||
for (func_index, function_in_memory) in functions_metatada.iter().enumerate() {
|
for (func_index, function_in_memory) in functions_metatada.iter().enumerate() {
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ mod execution;
|
|||||||
mod standalone;
|
mod standalone;
|
||||||
|
|
||||||
pub use execution::{compile_module, execute, ExecutableCode};
|
pub use execution::{compile_module, execute, ExecutableCode};
|
||||||
pub use standalone::StandaloneRuntime;
|
pub use standalone::Runtime;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const PAGE_SIZE: usize = 65536;
|
|||||||
|
|
||||||
/// Object containing the standalone runtime information. To be passed after creation as argument
|
/// Object containing the standalone runtime information. To be passed after creation as argument
|
||||||
/// to `cton_wasm::translatemodule`.
|
/// to `cton_wasm::translatemodule`.
|
||||||
pub struct StandaloneRuntime {
|
pub struct Runtime {
|
||||||
/// Compilation setting flags.
|
/// Compilation setting flags.
|
||||||
flags: settings::Flags,
|
flags: settings::Flags,
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ pub struct StandaloneRuntime {
|
|||||||
the_heap: PackedOption<ir::Heap>,
|
the_heap: PackedOption<ir::Heap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StandaloneRuntime {
|
impl Runtime {
|
||||||
/// Allocates the runtime data structures with default flags.
|
/// Allocates the runtime data structures with default flags.
|
||||||
pub fn default() -> Self {
|
pub fn default() -> Self {
|
||||||
Self::with_flags(settings::Flags::new(&settings::builder()))
|
Self::with_flags(settings::Flags::new(&settings::builder()))
|
||||||
@@ -106,7 +106,7 @@ impl StandaloneRuntime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FuncEnvironment for StandaloneRuntime {
|
impl FuncEnvironment for Runtime {
|
||||||
fn flags(&self) -> &settings::Flags {
|
fn flags(&self) -> &settings::Flags {
|
||||||
&self.flags
|
&self.flags
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ impl FuncEnvironment for StandaloneRuntime {
|
|||||||
/// `cton_wasm::translatemodule` because it
|
/// `cton_wasm::translatemodule` because it
|
||||||
/// tells how to translate runtime-dependent wasm instructions. These functions should not be
|
/// tells how to translate runtime-dependent wasm instructions. These functions should not be
|
||||||
/// called by the user.
|
/// called by the user.
|
||||||
impl WasmRuntime for StandaloneRuntime {
|
impl WasmRuntime for Runtime {
|
||||||
fn declare_signature(&mut self, sig: &ir::Signature) {
|
fn declare_signature(&mut self, sig: &ir::Signature) {
|
||||||
self.signatures.push(sig.clone());
|
self.signatures.push(sig.clone());
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ impl WasmRuntime for StandaloneRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convenience functions for the user to be called after execution for debug purposes.
|
/// Convenience functions for the user to be called after execution for debug purposes.
|
||||||
impl StandaloneRuntime {
|
impl Runtime {
|
||||||
/// Returns a slice of the contents of allocated linear memory.
|
/// Returns a slice of the contents of allocated linear memory.
|
||||||
pub fn inspect_memory(&self, memory_index: usize, address: usize, len: usize) -> &[u8] {
|
pub fn inspect_memory(&self, memory_index: usize, address: usize, len: usize) -> &[u8] {
|
||||||
&self.memories
|
&self.memories
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ extern crate term;
|
|||||||
extern crate tempdir;
|
extern crate tempdir;
|
||||||
|
|
||||||
use cton_wasm::{translate_module, TranslationResult};
|
use cton_wasm::{translate_module, TranslationResult};
|
||||||
use wasmstandalone::{StandaloneRuntime, compile_module, execute};
|
use wasmstandalone::{compile_module, execute};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use wasmparser::{Parser, ParserState, WasmDecoder, SectionCode};
|
use wasmparser::{Parser, ParserState, WasmDecoder, SectionCode};
|
||||||
use wasmtext::Writer;
|
use wasmtext::Writer;
|
||||||
@@ -157,7 +157,7 @@ fn handle_module(args: &Args, path: PathBuf, name: &str, isa: &TargetIsa) -> Res
|
|||||||
|err| String::from(err.description()),
|
|err| String::from(err.description()),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
let mut runtime = StandaloneRuntime::with_flags(isa.flags().clone());
|
let mut runtime = wasmstandalone::Runtime::with_flags(isa.flags().clone());
|
||||||
let translation = {
|
let translation = {
|
||||||
match translate_module(&data, &mut runtime) {
|
match translate_module(&data, &mut runtime) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
@@ -320,7 +320,7 @@ fn pretty_print_translation(
|
|||||||
writer_wat: &mut Write,
|
writer_wat: &mut Write,
|
||||||
writer_cretonne: &mut Write,
|
writer_cretonne: &mut Write,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
runtime: &StandaloneRuntime,
|
runtime: &wasmstandalone::Runtime,
|
||||||
) -> Result<(), io::Error> {
|
) -> Result<(), io::Error> {
|
||||||
let mut terminal = term::stdout().unwrap();
|
let mut terminal = term::stdout().unwrap();
|
||||||
let mut parser = Parser::new(data);
|
let mut parser = Parser::new(data);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> {
|
|||||||
});
|
});
|
||||||
let isa = isa_builder.finish(settings::Flags::new(&flag_builder));
|
let isa = isa_builder.finish(settings::Flags::new(&flag_builder));
|
||||||
|
|
||||||
let mut runtime = wasmstandalone::StandaloneRuntime::with_flags(isa.flags().clone());
|
let mut runtime = wasmstandalone::Runtime::with_flags(isa.flags().clone());
|
||||||
|
|
||||||
let translation = {
|
let translation = {
|
||||||
match translate_module(&data, &mut runtime) {
|
match translate_module(&data, &mut runtime) {
|
||||||
|
|||||||
Reference in New Issue
Block a user