mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWasm: Once more fix structured instruction label indices
This finally works correctly. ™️
This commit is contained in:
parent
d05e5dbdcf
commit
c31a4e9013
Notes:
sideshowbarker
2024-07-18 17:22:59 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/c31a4e9013b Pull-request: https://github.com/SerenityOS/serenity/pull/7395 Reviewed-by: https://github.com/linusg
2 changed files with 7 additions and 5 deletions
|
@ -22,7 +22,7 @@ public:
|
|||
{
|
||||
m_current_frame = frame.ptr();
|
||||
m_stack.push(move(frame));
|
||||
m_stack.push(make<Label>(m_current_frame->arity(), m_current_frame->expression().instructions().size() - 1));
|
||||
m_stack.push(make<Label>(m_current_frame->arity(), m_current_frame->expression().instructions().size()));
|
||||
}
|
||||
auto& frame() const { return m_current_frame; }
|
||||
auto& frame() { return m_current_frame; }
|
||||
|
|
|
@ -376,7 +376,7 @@ void Interpreter::interpret(Configuration& configuration, InstructionPointer& ip
|
|||
auto& args = instruction.arguments().get<Instruction::StructuredInstructionArgs>();
|
||||
if (args.block_type.kind() != BlockType::Empty)
|
||||
arity = 1;
|
||||
configuration.stack().push(make<Label>(arity, ip.value()));
|
||||
configuration.stack().push(make<Label>(arity, ip.value() + 1));
|
||||
return;
|
||||
}
|
||||
case Instructions::if_.value(): {
|
||||
|
@ -388,14 +388,16 @@ void Interpreter::interpret(Configuration& configuration, InstructionPointer& ip
|
|||
auto entry = configuration.stack().pop();
|
||||
auto value = entry.get<NonnullOwnPtr<Value>>()->to<i32>();
|
||||
TRAP_IF_NOT(value.has_value());
|
||||
configuration.stack().push(make<Label>(arity, args.end_ip));
|
||||
auto end_label = make<Label>(arity, args.end_ip.value());
|
||||
if (value.value() == 0) {
|
||||
if (args.else_ip.has_value()) {
|
||||
configuration.ip() = args.else_ip.value();
|
||||
configuration.stack().push(move(end_label));
|
||||
} else {
|
||||
configuration.ip() = args.end_ip;
|
||||
configuration.stack().pop();
|
||||
configuration.ip() = args.end_ip.value() + 1;
|
||||
}
|
||||
} else {
|
||||
configuration.stack().push(move(end_label));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue