1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibJS: Make Optional<StringTableIndex> use less space

We can use the index's invalid state to signal an empty optional.
This makes Optional<StringTableIndex> 4 bytes instead of 8,
shrinking every bytecode instruction that uses these.
This commit is contained in:
Andreas Kling 2025-04-05 21:46:37 +02:00 committed by Andreas Kling
parent f1a54ef281
commit 42cc481091
Notes: github-actions[bot] 2025-04-06 00:06:34 +00:00
3 changed files with 110 additions and 6 deletions

View file

@ -1280,7 +1280,7 @@ static inline Completion throw_type_error_for_callee(Bytecode::Interpreter& inte
auto& vm = interpreter.vm();
if (expression_string.has_value())
return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, callee.to_string_without_side_effects(), callee_type, interpreter.current_executable().get_string(expression_string->value()));
return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, callee.to_string_without_side_effects(), callee_type, interpreter.current_executable().get_string(*expression_string));
return vm.throw_completion<TypeError>(ErrorType::IsNotA, callee.to_string_without_side_effects(), callee_type);
}
@ -3078,9 +3078,10 @@ ByteString NewObject::to_byte_string_impl(Bytecode::Executable const& executable
ByteString NewRegExp::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return ByteString::formatted("NewRegExp {}, source:{} (\"{}\") flags:{} (\"{}\")",
return ByteString::formatted("NewRegExp {}, source:\"{}\" flags:\"{}\"",
format_operand("dst"sv, dst(), executable),
m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index));
executable.get_string(m_source_index),
executable.get_string(m_flags_index));
}
ByteString CopyObjectExcludingProperties::to_byte_string_impl(Bytecode::Executable const& executable) const