Remove NATURAL_ALIGNMENT (#46)
This commit is contained in:
parent
6e4bbb7490
commit
a3ad4b0e49
|
@ -10,9 +10,6 @@ use validation::Error;
|
||||||
use common::stack::StackWithLimit;
|
use common::stack::StackWithLimit;
|
||||||
use common::{BlockFrame, BlockFrameType};
|
use common::{BlockFrame, BlockFrameType};
|
||||||
|
|
||||||
/// Constant from wabt' validator.cc to skip alignment validation (not a part of spec).
|
|
||||||
const NATURAL_ALIGNMENT: u32 = 0xFFFFFFFF;
|
|
||||||
|
|
||||||
/// Maximum number of entries in value stack.
|
/// Maximum number of entries in value stack.
|
||||||
const DEFAULT_VALUE_STACK_LIMIT: usize = 16384;
|
const DEFAULT_VALUE_STACK_LIMIT: usize = 16384;
|
||||||
/// Maximum number of entries in frame stack.
|
/// Maximum number of entries in frame stack.
|
||||||
|
@ -403,11 +400,9 @@ impl Validator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_load(context: &mut FunctionValidationContext, align: u32, max_align: u32, value_type: ValueType) -> Result<InstructionOutcome, Error> {
|
fn validate_load(context: &mut FunctionValidationContext, align: u32, max_align: u32, value_type: ValueType) -> Result<InstructionOutcome, Error> {
|
||||||
if align != NATURAL_ALIGNMENT {
|
|
||||||
if 1u32.checked_shl(align).unwrap_or(u32::MAX) > max_align {
|
if 1u32.checked_shl(align).unwrap_or(u32::MAX) > max_align {
|
||||||
return Err(Error(format!("Too large memory alignment 2^{} (expected at most {})", align, max_align)));
|
return Err(Error(format!("Too large memory alignment 2^{} (expected at most {})", align, max_align)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.pop_value(ValueType::I32.into())?;
|
context.pop_value(ValueType::I32.into())?;
|
||||||
context.module.require_memory(DEFAULT_MEMORY_INDEX)?;
|
context.module.require_memory(DEFAULT_MEMORY_INDEX)?;
|
||||||
|
@ -416,11 +411,9 @@ impl Validator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_store(context: &mut FunctionValidationContext, align: u32, max_align: u32, value_type: ValueType) -> Result<InstructionOutcome, Error> {
|
fn validate_store(context: &mut FunctionValidationContext, align: u32, max_align: u32, value_type: ValueType) -> Result<InstructionOutcome, Error> {
|
||||||
if align != NATURAL_ALIGNMENT {
|
|
||||||
if 1u32.checked_shl(align).unwrap_or(u32::MAX) > max_align {
|
if 1u32.checked_shl(align).unwrap_or(u32::MAX) > max_align {
|
||||||
return Err(Error(format!("Too large memory alignment 2^{} (expected at most {})", align, max_align)));
|
return Err(Error(format!("Too large memory alignment 2^{} (expected at most {})", align, max_align)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
context.module.require_memory(DEFAULT_MEMORY_INDEX)?;
|
context.module.require_memory(DEFAULT_MEMORY_INDEX)?;
|
||||||
context.pop_value(value_type.into())?;
|
context.pop_value(value_type.into())?;
|
||||||
|
|
Loading…
Reference in New Issue