better asserts and errors in various places
This commit is contained in:
parent
63616b502a
commit
0b72e1df5a
|
@ -153,21 +153,21 @@ impl<'a> WasmFuncBackend<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WasmBlock::BlockParams { from, to } => {
|
// WasmBlock::BlockParams { from, to } => {
|
||||||
debug_assert_eq!(from.len(), to.len());
|
// debug_assert_eq!(from.len(), to.len());
|
||||||
for (&from, &(_, to)) in from.iter().zip(to.iter()) {
|
// for (&from, &(_, to)) in from.iter().zip(to.iter()) {
|
||||||
if self.locals.values[to].is_empty() {
|
// if self.locals.values[to].is_empty() {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
self.lower_value(from, func);
|
// self.lower_value(from, func);
|
||||||
}
|
// }
|
||||||
for &(_, to) in to.iter().rev() {
|
// for &(_, to) in to.iter().rev() {
|
||||||
if self.locals.values[to].is_empty() {
|
// if self.locals.values[to].is_empty() {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
self.lower_set_value(to, func);
|
// self.lower_set_value(to, func);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
WasmBlock::Return { values } => {
|
WasmBlock::Return { values } => {
|
||||||
for &value in &values[..] {
|
for &value in &values[..] {
|
||||||
self.lower_value(value, func);
|
self.lower_value(value, func);
|
||||||
|
@ -180,6 +180,31 @@ impl<'a> WasmFuncBackend<'a> {
|
||||||
}
|
}
|
||||||
func.instruction(&wasm_encoder::Instruction::ReturnCall(f.index() as u32));
|
func.instruction(&wasm_encoder::Instruction::ReturnCall(f.index() as u32));
|
||||||
}
|
}
|
||||||
|
WasmBlock::BlockParams { from, to } => {
|
||||||
|
debug_assert_eq!(from.len(), to.len());
|
||||||
|
for (&from, &(to_ty, to)) in from.iter().zip(to.iter()) {
|
||||||
|
if self.locals.values[to].is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let from_ty = self.body.values[self.body.resolve_alias(from)]
|
||||||
|
.ty(&self.body.type_pool)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(from_ty, to_ty);
|
||||||
|
if self.locals.values[from].len() == 1 {
|
||||||
|
assert_eq!(from_ty, self.locals.locals[self.locals.values[from][0]]);
|
||||||
|
}
|
||||||
|
self.lower_value(from, func);
|
||||||
|
}
|
||||||
|
for &(to_ty, to) in to.iter().rev() {
|
||||||
|
if self.locals.values[to].is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if self.locals.values[to].len() == 1 {
|
||||||
|
assert_eq!(to_ty, self.locals.locals[self.locals.values[to][0]]);
|
||||||
|
}
|
||||||
|
self.lower_set_value(to, func);
|
||||||
|
}
|
||||||
|
}
|
||||||
WasmBlock::ReturnCallIndirect { sig, table, values } => {
|
WasmBlock::ReturnCallIndirect { sig, table, values } => {
|
||||||
for &value in &values[..] {
|
for &value in &values[..] {
|
||||||
self.lower_value(value, func);
|
self.lower_value(value, func);
|
||||||
|
|
|
@ -423,8 +423,8 @@ impl FunctionBody {
|
||||||
let u = self.resolve_alias(u);
|
let u = self.resolve_alias(u);
|
||||||
if block_inst[u].is_none() {
|
if block_inst[u].is_none() {
|
||||||
bad.push(format!(
|
bad.push(format!(
|
||||||
"Use of arg {} at {:?} illegal: not defined",
|
"Use of arg {} at {:?} in {} illegal: not defined",
|
||||||
u, inst
|
u, inst, block
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue