mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibJS/Bytecode: Make primitive strings be constants
Instead of emitting a NewString instruction to construct a primitive string from a parsed literal, we now instantiate the PrimitiveString on the heap during codegen.
This commit is contained in:
parent
fd694e8672
commit
46d209c55b
Notes:
sideshowbarker
2024-07-16 22:14:49 +09:00
Author: https://github.com/awesomekling
Commit: 46d209c55b
Pull-request: https://github.com/SerenityOS/serenity/pull/23444
Reviewed-by: https://github.com/trflynn89
8 changed files with 27 additions and 52 deletions
|
@ -63,6 +63,8 @@ static ByteString format_operand(StringView name, Operand operand, Bytecode::Exe
|
|||
builder.appendff("Int32({})", value.as_i32());
|
||||
else if (value.is_double())
|
||||
builder.appendff("Double({})", value.as_double());
|
||||
else if (value.is_string())
|
||||
builder.appendff("String(\"{}\")", value.as_string().utf8_string_view());
|
||||
else if (value.is_undefined())
|
||||
builder.append("Undefined"sv);
|
||||
else if (value.is_null())
|
||||
|
@ -899,12 +901,6 @@ ThrowCompletionOr<void> IteratorToArray::execute_impl(Bytecode::Interpreter& int
|
|||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> NewString::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.set(dst(), PrimitiveString::create(interpreter.vm(), interpreter.current_executable().get_string(m_string)));
|
||||
return {};
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> NewObject::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
|
@ -1656,13 +1652,6 @@ ByteString IteratorToArray::to_byte_string_impl(Bytecode::Executable const& exec
|
|||
format_operand("iterator"sv, iterator(), executable));
|
||||
}
|
||||
|
||||
ByteString NewString::to_byte_string_impl(Bytecode::Executable const& executable) const
|
||||
{
|
||||
return ByteString::formatted("NewString {}, \"{}\"",
|
||||
format_operand("dst"sv, dst(), executable),
|
||||
executable.string_table->get(m_string));
|
||||
}
|
||||
|
||||
ByteString NewObject::to_byte_string_impl(Bytecode::Executable const& executable) const
|
||||
{
|
||||
return ByteString::formatted("NewObject {}", format_operand("dst"sv, dst(), executable));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue