LibJS/Bytecode: Rename GetVariable => GetBinding

This commit is contained in:
Andreas Kling
2024-05-14 11:32:04 +02:00
parent b7c04f999a
commit 6ca94bd0b1
5 changed files with 12 additions and 12 deletions

View File

@@ -397,7 +397,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> Identifier::generate_by
if (is_global()) { if (is_global()) {
generator.emit<Bytecode::Op::GetGlobal>(dst, generator.intern_identifier(m_string), generator.next_global_variable_cache()); generator.emit<Bytecode::Op::GetGlobal>(dst, generator.intern_identifier(m_string), generator.next_global_variable_cache());
} else { } else {
generator.emit<Bytecode::Op::GetVariable>(dst, generator.intern_identifier(m_string)); generator.emit<Bytecode::Op::GetBinding>(dst, generator.intern_identifier(m_string));
} }
return dst; return dst;
} }
@@ -520,7 +520,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
generator.emit<Bytecode::Op::ResolveSuperBase>(*base); generator.emit<Bytecode::Op::ResolveSuperBase>(*base);
} }
} else if (is<Identifier>(*lhs)) { } else if (is<Identifier>(*lhs)) {
// NOTE: For Identifiers, we cannot perform GetVariable and then write into the reference it retrieves, only SetVariable can do this. // NOTE: For Identifiers, we cannot perform GetBinding and then write into the reference it retrieves, only SetVariable can do this.
// FIXME: However, this breaks spec as we are doing variable lookup after evaluating the RHS. This is observable in an object environment, where we visibly perform HasOwnProperty and Get(@@unscopables) on the binded object. // FIXME: However, this breaks spec as we are doing variable lookup after evaluating the RHS. This is observable in an object environment, where we visibly perform HasOwnProperty and Get(@@unscopables) on the binded object.
} else { } else {
(void)TRY(lhs->generate_bytecode(generator)); (void)TRY(lhs->generate_bytecode(generator));
@@ -1150,7 +1150,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> FunctionDeclaration::ge
Bytecode::Generator::SourceLocationScope scope(generator, *this); Bytecode::Generator::SourceLocationScope scope(generator, *this);
auto index = generator.intern_identifier(name()); auto index = generator.intern_identifier(name());
auto value = generator.allocate_register(); auto value = generator.allocate_register();
generator.emit<Bytecode::Op::GetVariable>(value, index); generator.emit<Bytecode::Op::GetBinding>(value, index);
generator.emit<Bytecode::Op::SetVariableBinding>(index, value); generator.emit<Bytecode::Op::SetVariableBinding>(index, value);
} }
return Optional<ScopedOperand> {}; return Optional<ScopedOperand> {};

View File

@@ -133,7 +133,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
if (id.is_local()) { if (id.is_local()) {
emit<Op::Mov>(initial_value, local(id.local_variable_index())); emit<Op::Mov>(initial_value, local(id.local_variable_index()));
} else { } else {
emit<Op::GetVariable>(initial_value, intern_identifier(id.string())); emit<Op::GetBinding>(initial_value, intern_identifier(id.string()));
} }
} }

View File

@@ -63,7 +63,7 @@
O(GetObjectFromIteratorRecord) \ O(GetObjectFromIteratorRecord) \
O(GetObjectPropertyIterator) \ O(GetObjectPropertyIterator) \
O(GetPrivateById) \ O(GetPrivateById) \
O(GetVariable) \ O(GetBinding) \
O(GreaterThan) \ O(GreaterThan) \
O(GreaterThanEquals) \ O(GreaterThanEquals) \
O(HasPrivateId) \ O(HasPrivateId) \

View File

@@ -577,7 +577,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point)
HANDLE_INSTRUCTION(GetObjectFromIteratorRecord); HANDLE_INSTRUCTION(GetObjectFromIteratorRecord);
HANDLE_INSTRUCTION(GetObjectPropertyIterator); HANDLE_INSTRUCTION(GetObjectPropertyIterator);
HANDLE_INSTRUCTION(GetPrivateById); HANDLE_INSTRUCTION(GetPrivateById);
HANDLE_INSTRUCTION(GetVariable); HANDLE_INSTRUCTION(GetBinding);
HANDLE_INSTRUCTION(GreaterThan); HANDLE_INSTRUCTION(GreaterThan);
HANDLE_INSTRUCTION(GreaterThanEquals); HANDLE_INSTRUCTION(GreaterThanEquals);
HANDLE_INSTRUCTION(HasPrivateId); HANDLE_INSTRUCTION(HasPrivateId);
@@ -1237,7 +1237,7 @@ ThrowCompletionOr<void> ConcatString::execute_impl(Bytecode::Interpreter& interp
return {}; return {};
} }
ThrowCompletionOr<void> GetVariable::execute_impl(Bytecode::Interpreter& interpreter) const ThrowCompletionOr<void> GetBinding::execute_impl(Bytecode::Interpreter& interpreter) const
{ {
auto& vm = interpreter.vm(); auto& vm = interpreter.vm();
auto& executable = interpreter.current_executable(); auto& executable = interpreter.current_executable();
@@ -2122,9 +2122,9 @@ ByteString GetCalleeAndThisFromEnvironment::to_byte_string_impl(Bytecode::Execut
executable.identifier_table->get(m_identifier)); executable.identifier_table->get(m_identifier));
} }
ByteString GetVariable::to_byte_string_impl(Bytecode::Executable const& executable) const ByteString GetBinding::to_byte_string_impl(Bytecode::Executable const& executable) const
{ {
return ByteString::formatted("GetVariable {}, {}", return ByteString::formatted("GetBinding {}, {}",
format_operand("dst"sv, dst(), executable), format_operand("dst"sv, dst(), executable),
executable.identifier_table->get(m_identifier)); executable.identifier_table->get(m_identifier));
} }

View File

@@ -846,10 +846,10 @@ private:
mutable EnvironmentCoordinate m_cache; mutable EnvironmentCoordinate m_cache;
}; };
class GetVariable final : public Instruction { class GetBinding final : public Instruction {
public: public:
explicit GetVariable(Operand dst, IdentifierTableIndex identifier) explicit GetBinding(Operand dst, IdentifierTableIndex identifier)
: Instruction(Type::GetVariable) : Instruction(Type::GetBinding)
, m_dst(dst) , m_dst(dst)
, m_identifier(identifier) , m_identifier(identifier)
{ {