wasm_interp: Don't panic while pushing a stack frame

This commit is contained in:
Brian Carroll 2022-12-06 20:31:50 +00:00
parent 4cf5d19ace
commit 2abae1b5e1
No known key found for this signature in database
GPG key ID: 5C7B2EC4101703C0
4 changed files with 127 additions and 89 deletions

View file

@ -84,14 +84,17 @@ fn test_loop_help(end: i32, expected: i32) {
buf.push(OpCode::END as u8);
let mut state = default_state(&arena);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -152,14 +155,17 @@ fn test_if_else_help(condition: i32, expected: i32) {
buf.push(OpCode::END as u8);
let mut state = default_state(&arena);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -241,14 +247,17 @@ fn test_br() {
buf.push(OpCode::END as u8);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -339,14 +348,17 @@ fn test_br_if_help(condition: i32, expected: i32) {
buf.push(OpCode::END as u8);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -443,14 +455,17 @@ fn test_br_table_help(condition: i32, expected: i32) {
println!("{:02x?}", buf);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -776,14 +791,17 @@ fn test_select_help(first: Value, second: Value, condition: i32, expected: Value
buf.push(OpCode::END as u8);
let mut state = default_state(&arena);
state.call_stack.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
);
state
.call_stack
.push_frame(
0,
0,
&[],
&mut state.value_stack,
&module.code.bytes,
&mut state.program_counter,
)
.unwrap();
while let Ok(Action::Continue) = state.execute_next_instruction(&module) {}
@ -808,7 +826,8 @@ fn test_set_get_local() {
.serialize(&mut buffer);
state
.call_stack
.push_frame(0x1234, 0, &[], &mut vs, &buffer, &mut cursor);
.push_frame(0x1234, 0, &[], &mut vs, &buffer, &mut cursor)
.unwrap();
module.code.bytes.push(OpCode::I32CONST as u8);
module.code.bytes.encode_i32(12345);
@ -843,7 +862,8 @@ fn test_tee_get_local() {
.serialize(&mut buffer);
state
.call_stack
.push_frame(0x1234, 0, &[], &mut vs, &buffer, &mut cursor);
.push_frame(0x1234, 0, &[], &mut vs, &buffer, &mut cursor)
.unwrap();
module.code.bytes.push(OpCode::I32CONST as u8);
module.code.bytes.encode_i32(12345);