1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +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:
Andreas Kling 2024-03-03 11:34:36 +01:00
parent fd694e8672
commit 46d209c55b
8 changed files with 27 additions and 52 deletions

View file

@ -136,26 +136,6 @@ JS_ENUMERATE_COMMON_BINARY_OPS_WITH_FAST_PATH(JS_DECLARE_COMMON_BINARY_OP)
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
#undef JS_DECLARE_COMMON_UNARY_OP
class NewString final : public Instruction {
public:
NewString(Operand dst, StringTableIndex string)
: Instruction(Type::NewString, sizeof(*this))
, m_dst(dst)
, m_string(string)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Operand dst() const { return m_dst; }
StringTableIndex index() const { return m_string; }
private:
Operand m_dst;
StringTableIndex m_string;
};
class NewObject final : public Instruction {
public:
explicit NewObject(Operand dst)