1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:38: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

@ -25,6 +25,8 @@ namespace JS::Bytecode {
class Generator {
public:
VM& vm() { return m_vm; }
enum class SurroundingScopeKind {
Global,
Function,
@ -261,6 +263,8 @@ public:
}
private:
VM& m_vm;
enum class JumpType {
Continue,
Break,
@ -268,7 +272,7 @@ private:
void generate_scoped_jump(JumpType);
void generate_labelled_jump(JumpType, DeprecatedFlyString const& label);
Generator();
explicit Generator(VM&);
~Generator() = default;
void grow(size_t);
@ -286,7 +290,7 @@ private:
NonnullOwnPtr<StringTable> m_string_table;
NonnullOwnPtr<IdentifierTable> m_identifier_table;
NonnullOwnPtr<RegexTable> m_regex_table;
Vector<Value> m_constants;
MarkedVector<Value> m_constants;
u32 m_next_register { Register::reserved_register_count };
u32 m_next_block { 1 };