1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

LibJS: Add a separate "identifier table" to bytecode executables

This is a specialized string table for storing identifiers only.
Identifiers are always FlyStrings, which makes many common operations
faster by allowing O(1) comparison.
This commit is contained in:
Andreas Kling 2021-10-24 15:34:30 +02:00
parent 13f04e37e5
commit da98212001
10 changed files with 121 additions and 37 deletions

View file

@ -9,6 +9,7 @@
#pragma once
#include <LibCrypto/BigInt/SignedBigInteger.h>
#include <LibJS/Bytecode/IdentifierTable.h>
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Label.h>
#include <LibJS/Bytecode/Register.h>
@ -281,7 +282,7 @@ private:
class SetVariable final : public Instruction {
public:
explicit SetVariable(StringTableIndex identifier)
explicit SetVariable(IdentifierTableIndex identifier)
: Instruction(Type::SetVariable)
, m_identifier(identifier)
{
@ -292,12 +293,12 @@ public:
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
private:
StringTableIndex m_identifier;
IdentifierTableIndex m_identifier;
};
class GetVariable final : public Instruction {
public:
explicit GetVariable(StringTableIndex identifier)
explicit GetVariable(IdentifierTableIndex identifier)
: Instruction(Type::GetVariable)
, m_identifier(identifier)
{
@ -308,12 +309,12 @@ public:
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
private:
StringTableIndex m_identifier;
IdentifierTableIndex m_identifier;
};
class GetById final : public Instruction {
public:
explicit GetById(StringTableIndex property)
explicit GetById(IdentifierTableIndex property)
: Instruction(Type::GetById)
, m_property(property)
{
@ -324,12 +325,12 @@ public:
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
private:
StringTableIndex m_property;
IdentifierTableIndex m_property;
};
class PutById final : public Instruction {
public:
explicit PutById(Register base, StringTableIndex property)
explicit PutById(Register base, IdentifierTableIndex property)
: Instruction(Type::PutById)
, m_base(base)
, m_property(property)
@ -342,7 +343,7 @@ public:
private:
Register m_base;
StringTableIndex m_property;
IdentifierTableIndex m_property;
};
class GetByValue final : public Instruction {