This commit is contained in:
Sergey Pepyakin
2017-12-11 18:52:07 +01:00
parent ebbfa6acf6
commit 8d3b32f4a6
6 changed files with 3 additions and 51 deletions

View File

@ -1,5 +1,4 @@
use std::u32;
use std::sync::Arc;
use std::ops::Range;
use std::cmp;
use parking_lot::RwLock;

View File

@ -1,14 +1,6 @@
use elements::{InitExpr, Opcode, Type, FunctionType, Internal, External, ResizableLimits, Local, ValueType, BlockType};
use elements::ResizableLimits;
use interpreter::Error;
use interpreter::runner::{FunctionContext};
use interpreter::VariableType;
use interpreter::RuntimeValue;
use common::stack::StackWithLimit;
/// Maximum number of entries in value stack.
const DEFAULT_VALUE_STACK_LIMIT: usize = 16384;
/// Maximum number of entries in frame stack.
const DEFAULT_FRAME_STACK_LIMIT: usize = 1024;
/// Execution context.
pub struct ExecutionParams<'a, St: 'static> {
@ -36,36 +28,6 @@ pub enum ItemIndex {
External(u32),
}
/// Caller context.
pub struct CallerContext<'a> {
/// Value stack limit
pub value_stack_limit: usize,
/// Frame stack limit
pub frame_stack_limit: usize,
/// Stack of the input parameters
pub value_stack: &'a mut StackWithLimit<RuntimeValue>,
}
impl<'a> CallerContext<'a> {
/// Top most args
pub fn topmost(args: &'a mut StackWithLimit<RuntimeValue>) -> Self {
CallerContext {
value_stack_limit: DEFAULT_VALUE_STACK_LIMIT,
frame_stack_limit: DEFAULT_FRAME_STACK_LIMIT,
value_stack: args,
}
}
/// Nested context
pub fn nested(outer: &'a mut FunctionContext) -> Self {
CallerContext {
value_stack_limit: outer.value_stack().limit() - outer.value_stack().len(),
frame_stack_limit: outer.frame_stack().limit() - outer.frame_stack().len(),
value_stack: &mut outer.value_stack,
}
}
}
pub fn check_limits(limits: &ResizableLimits) -> Result<(), Error> {
if let Some(maximum) = limits.maximum() {
if maximum < limits.initial() {

View File

@ -2,7 +2,6 @@
use std::collections::HashMap;
use elements::Module;
use interpreter::Error;
use interpreter::module::{ExecutionParams};
use interpreter::store::{Store, ModuleId};
use interpreter::host::HostModuleBuilder;

View File

@ -1,6 +1,5 @@
use std::mem;
use std::ops;
use std::sync::Arc;
use std::{u32, usize};
use std::fmt::{self, Display};
use std::iter::repeat;
@ -8,7 +7,6 @@ use std::collections::{HashMap, VecDeque};
use elements::{Opcode, BlockType, Local, FunctionType};
use interpreter::Error;
use interpreter::store::{Store, FuncId, ModuleId, FuncInstance};
use interpreter::module::{CallerContext, ExecutionParams};
use interpreter::value::{
RuntimeValue, TryInto, WrapInto, TryTruncateInto, ExtendInto,
ArithmeticOps, Integer, Float, LittleEndianConvert, TransmuteInto,

View File

@ -3,8 +3,7 @@ use parking_lot::RwLock;
use elements::{TableType, ResizableLimits};
use interpreter::Error;
use interpreter::module::check_limits;
use interpreter::variable::{VariableInstance, VariableType};
use interpreter::value::RuntimeValue;
use interpreter::variable::VariableType;
use interpreter::store::FuncId;
/// Table instance.
@ -16,11 +15,6 @@ pub struct TableInstance {
}
/// Table element. Cloneable wrapper around VariableInstance.
struct TableElement {
pub var: VariableInstance,
}
impl TableInstance {
/// New instance of the table
pub fn new(table_type: &TableType) -> Result<Self, Error> {

View File

@ -1,6 +1,6 @@
use std::fmt;
use parking_lot::RwLock;
use elements::{GlobalType, ValueType, TableElementType};
use elements::{GlobalType, ValueType};
use interpreter::Error;
use interpreter::value::RuntimeValue;