mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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:
parent
b73b17aab4
commit
a2448308fd
Notes:
github-actions[bot]
2024-08-06 23:11:18 +00:00
Author: https://github.com/dzfrias
Commit: a2448308fd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/960
Reviewed-by: https://github.com/alimpfard
2 changed files with 1 additions and 19 deletions
|
@ -63,14 +63,8 @@ void BytecodeInterpreter::branch_to_label(Configuration& configuration, LabelInd
|
||||||
configuration.label_stack().take_last();
|
configuration.label_stack().take_last();
|
||||||
auto label = configuration.label_stack().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());
|
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();
|
configuration.ip() = label.continuation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,17 +403,6 @@ double BytecodeInterpreter::read_value<double>(ReadonlyBytes data)
|
||||||
return bit_cast<double>(static_cast<u64>(raw_value));
|
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)
|
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());
|
dbgln_if(WASM_TRACE_DEBUG, "Executing instruction {} at ip {}", instruction_name(instruction.opcode()), ip.value());
|
||||||
|
|
|
@ -79,7 +79,6 @@ protected:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T read_value(ReadonlyBytes data);
|
T read_value(ReadonlyBytes data);
|
||||||
|
|
||||||
Vector<Value> pop_values(Configuration& configuration, size_t count);
|
|
||||||
ALWAYS_INLINE bool trap_if_not(bool value, StringView reason)
|
ALWAYS_INLINE bool trap_if_not(bool value, StringView reason)
|
||||||
{
|
{
|
||||||
if (!value)
|
if (!value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue