LibJS: Make GetById and GetByValue avoid get_identifier() in common case

We now defer looking up the various identifiers by IdentifierTableIndex
until the last moment. This allows us to avoid the retrieval in common
cases like when a property access is cached.

Knocks a ~12% item off the profile on https://ventrella.com/Clusters/
This commit is contained in:
Andreas Kling
2024-07-09 11:37:06 +02:00
committed by Andreas Kling
parent ae0cfe4f2d
commit 509c10d14d
4 changed files with 57 additions and 22 deletions

View File

@@ -453,6 +453,7 @@ CodeGenerationErrorOr<NonnullGCPtr<Executable>> Generator::compile(VM& vm, ASTNo
executable->source_map = move(source_map);
executable->local_variable_names = move(local_variable_names);
executable->local_index_base = number_of_registers + number_of_constants;
executable->length_identifier = generator.m_length_identifier;
generator.m_finished = true;
@@ -1075,6 +1076,7 @@ CodeGenerationErrorOr<Optional<ScopedOperand>> Generator::emit_named_evaluation_
void Generator::emit_get_by_id(ScopedOperand dst, ScopedOperand base, IdentifierTableIndex property_identifier, Optional<IdentifierTableIndex> base_identifier)
{
if (m_identifier_table->get(property_identifier) == "length"sv) {
m_length_identifier = property_identifier;
emit<Op::GetLength>(dst, base, move(base_identifier), m_next_property_lookup_cache++);
return;
}