mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
wasm_interp: Don't panic while pushing a stack frame
This commit is contained in:
parent
4cf5d19ace
commit
2abae1b5e1
4 changed files with 127 additions and 89 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue