mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-29 04:37:55 +00:00
LibWasm: Directly remove from the stack when clearing a label
Theoretically, the previous "pop, then push" method should be faster, but it's actually faster to just remove from the stack directly.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
b73b17aab4
commit
a2448308fd
@@ -63,14 +63,8 @@ void BytecodeInterpreter::branch_to_label(Configuration& configuration, LabelInd
|
||||
configuration.label_stack().take_last();
|
||||
auto label = configuration.label_stack().last();
|
||||
dbgln_if(WASM_TRACE_DEBUG, "...which is actually IP {}, and has {} result(s)", label.continuation().value(), label.arity());
|
||||
auto results = pop_values(configuration, label.arity());
|
||||
|
||||
while (configuration.value_stack().size() != label.stack_height())
|
||||
configuration.value_stack().take_last();
|
||||
|
||||
for (auto& result : results.in_reverse())
|
||||
configuration.value_stack().append(result);
|
||||
|
||||
configuration.value_stack().remove(label.stack_height(), configuration.value_stack().size() - label.stack_height() - label.arity());
|
||||
configuration.ip() = label.continuation();
|
||||
}
|
||||
|
||||
@@ -409,17 +403,6 @@ double BytecodeInterpreter::read_value<double>(ReadonlyBytes data)
|
||||
return bit_cast<double>(static_cast<u64>(raw_value));
|
||||
}
|
||||
|
||||
Vector<Value> BytecodeInterpreter::pop_values(Configuration& configuration, size_t count)
|
||||
{
|
||||
Vector<Value> results;
|
||||
results.resize(count);
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
results[i] = configuration.value_stack().take_last();
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void BytecodeInterpreter::interpret_instruction(Configuration& configuration, InstructionPointer& ip, Instruction const& instruction)
|
||||
{
|
||||
dbgln_if(WASM_TRACE_DEBUG, "Executing instruction {} at ip {}", instruction_name(instruction.opcode()), ip.value());
|
||||
|
||||
Reference in New Issue
Block a user