mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-16 07:11:52 +00:00
LibJS: Use FlyString in PropertyKey instead of DeprecatedFlyString
This required dealing with *substantial* fallout.
This commit is contained in:
parent
fc744e3f3f
commit
46a5710238
Notes:
github-actions[bot]
2025-03-24 22:28:26 +00:00
Author: https://github.com/awesomekling
Commit: 46a5710238
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4067
Reviewed-by: https://github.com/trflynn89
110 changed files with 985 additions and 987 deletions
|
@ -788,7 +788,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> LabelledStatement::gene
|
|||
|
||||
// 14.13.4 Runtime Semantics: LabelledEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-labelledevaluation
|
||||
// LabelledStatement : LabelIdentifier : LabelledItem
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> LabelledStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> LabelledStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
Bytecode::Generator::SourceLocationScope scope(generator, *this);
|
||||
// Convert the m_labelled_item NNRP to a reference early so we don't have to do it every single time we want to use it.
|
||||
|
@ -836,7 +836,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> LabelledStatement::gene
|
|||
return stmt_result;
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> IterationStatement::generate_labelled_evaluation(Bytecode::Generator&, Vector<DeprecatedFlyString> const&, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> IterationStatement::generate_labelled_evaluation(Bytecode::Generator&, Vector<FlyString> const&, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
return Bytecode::CodeGenerationError {
|
||||
this,
|
||||
|
@ -850,7 +850,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> WhileStatement::generat
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> WhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> WhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
Bytecode::Generator::SourceLocationScope scope(generator, *this);
|
||||
// test
|
||||
|
@ -902,7 +902,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> DoWhileStatement::gener
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> DoWhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> DoWhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
Bytecode::Generator::SourceLocationScope scope(generator, *this);
|
||||
// jump always (true) body
|
||||
|
@ -960,7 +960,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForStatement::generate_
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
Bytecode::Generator::SourceLocationScope scope(generator, *this);
|
||||
// init
|
||||
|
@ -1142,17 +1142,17 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ObjectExpression::gener
|
|||
|
||||
if (is<StringLiteral>(property->key())) {
|
||||
auto& string_literal = static_cast<StringLiteral const&>(property->key());
|
||||
Bytecode::IdentifierTableIndex key_name = generator.intern_identifier(string_literal.value());
|
||||
Bytecode::IdentifierTableIndex key_name = generator.intern_identifier(MUST(FlyString::from_utf8(string_literal.value().bytes())));
|
||||
|
||||
Optional<ScopedOperand> value;
|
||||
if (property_kind == Bytecode::Op::PropertyKind::ProtoSetter) {
|
||||
value = TRY(property->value().generate_bytecode(generator)).value();
|
||||
} else {
|
||||
ByteString identifier = string_literal.value();
|
||||
auto identifier = string_literal.value();
|
||||
if (property_kind == Bytecode::Op::PropertyKind::Getter)
|
||||
identifier = ByteString::formatted("get {}", identifier);
|
||||
identifier = MUST(String::formatted("get {}", identifier));
|
||||
else if (property_kind == Bytecode::Op::PropertyKind::Setter)
|
||||
identifier = ByteString::formatted("set {}", identifier);
|
||||
identifier = MUST(String::formatted("set {}", identifier));
|
||||
auto name = generator.intern_identifier(identifier);
|
||||
value = TRY(generator.emit_named_evaluation_if_anonymous_function(property->value(), name)).value();
|
||||
}
|
||||
|
@ -1846,8 +1846,8 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ReturnStatement::genera
|
|||
auto received_completion_type = generator.allocate_register();
|
||||
auto received_completion_value = generator.allocate_register();
|
||||
|
||||
auto type_identifier = generator.intern_identifier("type");
|
||||
auto value_identifier = generator.intern_identifier("value");
|
||||
auto type_identifier = generator.intern_identifier("type"_fly_string);
|
||||
auto value_identifier = generator.intern_identifier("value"_fly_string);
|
||||
return_value = generate_await(generator, *return_value, received_completion, received_completion_type, received_completion_value, type_identifier, value_identifier);
|
||||
}
|
||||
|
||||
|
@ -1966,8 +1966,8 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> YieldExpression::genera
|
|||
auto received_completion_type = generator.allocate_register();
|
||||
auto received_completion_value = generator.allocate_register();
|
||||
|
||||
auto type_identifier = generator.intern_identifier("type");
|
||||
auto value_identifier = generator.intern_identifier("value");
|
||||
auto type_identifier = generator.intern_identifier("type"_fly_string);
|
||||
auto value_identifier = generator.intern_identifier("value"_fly_string);
|
||||
|
||||
if (m_is_yield_from) {
|
||||
// 15.5.5 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation
|
||||
|
@ -2102,7 +2102,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> YieldExpression::genera
|
|||
|
||||
// i. Let throw be ? GetMethod(iterator, "throw").
|
||||
auto throw_method = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::GetMethod>(throw_method, iterator, generator.intern_identifier("throw"));
|
||||
generator.emit<Bytecode::Op::GetMethod>(throw_method, iterator, generator.intern_identifier("throw"_fly_string));
|
||||
|
||||
// ii. If throw is not undefined, then
|
||||
auto& throw_method_is_defined_block = generator.make_block();
|
||||
|
@ -2187,7 +2187,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> YieldExpression::genera
|
|||
|
||||
// ii. Let return be ? GetMethod(iterator, "return").
|
||||
auto return_method = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::GetMethod>(return_method, iterator, generator.intern_identifier("return"));
|
||||
generator.emit<Bytecode::Op::GetMethod>(return_method, iterator, generator.intern_identifier("return"_fly_string));
|
||||
|
||||
// iii. If return is undefined, then
|
||||
auto& return_is_undefined_block = generator.make_block();
|
||||
|
@ -2542,7 +2542,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> TaggedTemplateLiteral::
|
|||
generator.emit_with_extra_operand_slots<Bytecode::Op::NewArray>(raw_string_regs.size(), raw_strings_array, raw_string_regs);
|
||||
}
|
||||
|
||||
generator.emit<Bytecode::Op::PutById>(strings_array, generator.intern_identifier("raw"), raw_strings_array, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache());
|
||||
generator.emit<Bytecode::Op::PutById>(strings_array, generator.intern_identifier("raw"_fly_string), raw_strings_array, Bytecode::Op::PropertyKind::KeyValue, generator.next_property_lookup_cache());
|
||||
|
||||
auto arguments = generator.allocate_register();
|
||||
if (!argument_regs.is_empty())
|
||||
|
@ -2661,7 +2661,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> TryStatement::generate_
|
|||
bool did_create_variable_scope_for_catch_clause = false;
|
||||
|
||||
TRY(m_handler->parameter().visit(
|
||||
[&](DeprecatedFlyString const& parameter) -> Bytecode::CodeGenerationErrorOr<void> {
|
||||
[&](FlyString const& parameter) -> Bytecode::CodeGenerationErrorOr<void> {
|
||||
if (!parameter.is_empty()) {
|
||||
generator.begin_variable_scope();
|
||||
did_create_variable_scope_for_catch_clause = true;
|
||||
|
@ -2762,7 +2762,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> SwitchStatement::genera
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> SwitchStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> SwitchStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
Bytecode::Generator::SourceLocationScope scope(generator, *this);
|
||||
|
||||
|
@ -2989,8 +2989,8 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AwaitExpression::genera
|
|||
|
||||
generator.emit<Bytecode::Op::Mov>(received_completion, generator.accumulator());
|
||||
|
||||
auto type_identifier = generator.intern_identifier("type");
|
||||
auto value_identifier = generator.intern_identifier("value");
|
||||
auto type_identifier = generator.intern_identifier("type"_fly_string);
|
||||
auto value_identifier = generator.intern_identifier("value"_fly_string);
|
||||
|
||||
return generate_await(generator, argument, received_completion, received_completion_type, received_completion_value, type_identifier, value_identifier);
|
||||
}
|
||||
|
@ -3144,7 +3144,7 @@ static Bytecode::CodeGenerationErrorOr<ForInOfHeadEvaluationResult> for_in_of_he
|
|||
}
|
||||
|
||||
// 14.7.5.7 ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind, lhsKind, labelSet [ , iteratorKind ] ), https://tc39.es/ecma262/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
|
||||
static Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> for_in_of_body_evaluation(Bytecode::Generator& generator, ASTNode const& node, Variant<NonnullRefPtr<ASTNode const>, NonnullRefPtr<BindingPattern const>> const& lhs, ASTNode const& body, ForInOfHeadEvaluationResult const& head_result, Vector<DeprecatedFlyString> const& label_set, Bytecode::BasicBlock& loop_end, Bytecode::BasicBlock& loop_update, IteratorHint iterator_kind = IteratorHint::Sync, [[maybe_unused]] Optional<ScopedOperand> preferred_dst = {})
|
||||
static Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> for_in_of_body_evaluation(Bytecode::Generator& generator, ASTNode const& node, Variant<NonnullRefPtr<ASTNode const>, NonnullRefPtr<BindingPattern const>> const& lhs, ASTNode const& body, ForInOfHeadEvaluationResult const& head_result, Vector<FlyString> const& label_set, Bytecode::BasicBlock& loop_end, Bytecode::BasicBlock& loop_update, IteratorHint iterator_kind = IteratorHint::Sync, [[maybe_unused]] Optional<ScopedOperand> preferred_dst = {})
|
||||
{
|
||||
// 1. If iteratorKind is not present, set iteratorKind to sync.
|
||||
|
||||
|
@ -3186,8 +3186,8 @@ static Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> for_in_of_body_e
|
|||
auto received_completion_type = generator.allocate_register();
|
||||
auto received_completion_value = generator.allocate_register();
|
||||
|
||||
auto type_identifier = generator.intern_identifier("type");
|
||||
auto value_identifier = generator.intern_identifier("value");
|
||||
auto type_identifier = generator.intern_identifier("type"_fly_string);
|
||||
auto value_identifier = generator.intern_identifier("value"_fly_string);
|
||||
|
||||
generator.emit<Bytecode::Op::Mov>(received_completion, generator.accumulator());
|
||||
auto new_result = generate_await(generator, next_result, received_completion, received_completion_type, received_completion_value, type_identifier, value_identifier);
|
||||
|
@ -3377,7 +3377,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForInStatement::generat
|
|||
}
|
||||
|
||||
// 14.7.5.5 Runtime Semantics: ForInOfLoopEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-forinofloopevaluation
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForInStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForInStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
auto& loop_end = generator.make_block();
|
||||
auto& loop_update = generator.make_block();
|
||||
|
@ -3393,7 +3393,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForOfStatement::generat
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
auto& loop_end = generator.make_block();
|
||||
auto& loop_update = generator.make_block();
|
||||
|
@ -3409,7 +3409,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForAwaitOfStatement::ge
|
|||
return generate_labelled_evaluation(generator, {});
|
||||
}
|
||||
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForAwaitOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ForAwaitOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set, [[maybe_unused]] Optional<ScopedOperand> preferred_dst) const
|
||||
{
|
||||
auto& loop_end = generator.make_block();
|
||||
auto& loop_update = generator.make_block();
|
||||
|
@ -3561,7 +3561,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ExportStatement::genera
|
|||
}
|
||||
|
||||
if (is<ClassExpression>(*m_statement)) {
|
||||
auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast<ClassExpression const&>(*m_statement), generator.intern_identifier("default"sv))).value();
|
||||
auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast<ClassExpression const&>(*m_statement), generator.intern_identifier("default"_fly_string))).value();
|
||||
|
||||
if (!static_cast<ClassExpression const&>(*m_statement).has_name()) {
|
||||
generator.emit<Bytecode::Op::InitializeLexicalBinding>(
|
||||
|
@ -3574,7 +3574,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ExportStatement::genera
|
|||
|
||||
// ExportDeclaration : export default AssignmentExpression ;
|
||||
VERIFY(is<Expression>(*m_statement));
|
||||
auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast<Expression const&>(*m_statement), generator.intern_identifier("default"sv))).value();
|
||||
auto value = TRY(generator.emit_named_evaluation_if_anonymous_function(static_cast<Expression const&>(*m_statement), generator.intern_identifier("default"_fly_string))).value();
|
||||
generator.emit<Bytecode::Op::InitializeLexicalBinding>(
|
||||
generator.intern_identifier(ExportStatement::local_name_for_default),
|
||||
value);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
virtual ~Executable() override;
|
||||
|
||||
DeprecatedFlyString name;
|
||||
FlyString name;
|
||||
Vector<u8> bytecode;
|
||||
Vector<PropertyLookupCache> property_lookup_caches;
|
||||
Vector<GlobalVariableCache> global_variable_caches;
|
||||
|
@ -85,15 +85,15 @@ public:
|
|||
|
||||
HashMap<size_t, SourceRecord> source_map;
|
||||
|
||||
Vector<DeprecatedFlyString> local_variable_names;
|
||||
Vector<FlyString> local_variable_names;
|
||||
size_t local_index_base { 0 };
|
||||
|
||||
Optional<IdentifierTableIndex> length_identifier;
|
||||
|
||||
ByteString const& get_string(StringTableIndex index) const { return string_table->get(index); }
|
||||
DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
|
||||
String const& get_string(StringTableIndex index) const { return string_table->get(index); }
|
||||
FlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
|
||||
|
||||
Optional<DeprecatedFlyString const&> get_identifier(Optional<IdentifierTableIndex> const& index) const
|
||||
Optional<FlyString const&> get_identifier(Optional<IdentifierTableIndex> const& index) const
|
||||
{
|
||||
if (!index.has_value())
|
||||
return {};
|
||||
|
|
|
@ -56,7 +56,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
|||
|
||||
if (function.m_arguments_object_needed) {
|
||||
Optional<Operand> dst;
|
||||
auto local_var_index = function.m_local_variables_names.find_first_index("arguments"sv);
|
||||
auto local_var_index = function.m_local_variables_names.find_first_index("arguments"_fly_string);
|
||||
if (local_var_index.has_value())
|
||||
dst = local(local_var_index.value());
|
||||
|
||||
|
@ -219,7 +219,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
|||
return {};
|
||||
}
|
||||
|
||||
CodeGenerationErrorOr<GC::Ref<Executable>> Generator::compile(VM& vm, ASTNode const& node, FunctionKind enclosing_function_kind, GC::Ptr<ECMAScriptFunctionObject const> function, MustPropagateCompletion must_propagate_completion, Vector<DeprecatedFlyString> local_variable_names)
|
||||
CodeGenerationErrorOr<GC::Ref<Executable>> Generator::compile(VM& vm, ASTNode const& node, FunctionKind enclosing_function_kind, GC::Ptr<ECMAScriptFunctionObject const> function, MustPropagateCompletion must_propagate_completion, Vector<FlyString> local_variable_names)
|
||||
{
|
||||
Generator generator(vm, function, must_propagate_completion);
|
||||
|
||||
|
@ -482,7 +482,7 @@ CodeGenerationErrorOr<GC::Ref<Executable>> Generator::compile(VM& vm, ASTNode co
|
|||
|
||||
CodeGenerationErrorOr<GC::Ref<Executable>> Generator::generate_from_ast_node(VM& vm, ASTNode const& node, FunctionKind enclosing_function_kind)
|
||||
{
|
||||
Vector<DeprecatedFlyString> local_variable_names;
|
||||
Vector<FlyString> local_variable_names;
|
||||
if (is<ScopeNode>(node))
|
||||
local_variable_names = static_cast<ScopeNode const&>(node).local_variables_names();
|
||||
return compile(vm, node, enclosing_function_kind, {}, MustPropagateCompletion::Yes, move(local_variable_names));
|
||||
|
@ -588,7 +588,7 @@ void Generator::end_variable_scope()
|
|||
}
|
||||
}
|
||||
|
||||
void Generator::begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set)
|
||||
void Generator::begin_continuable_scope(Label continue_target, Vector<FlyString> const& language_label_set)
|
||||
{
|
||||
m_continuable_scopes.append({ continue_target, language_label_set });
|
||||
start_boundary(BlockBoundaryType::Continue);
|
||||
|
@ -605,7 +605,7 @@ Label Generator::nearest_breakable_scope() const
|
|||
return m_breakable_scopes.last().bytecode_target;
|
||||
}
|
||||
|
||||
void Generator::begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set)
|
||||
void Generator::begin_breakable_scope(Label breakable_target, Vector<FlyString> const& language_label_set)
|
||||
{
|
||||
m_breakable_scopes.append({ breakable_target, language_label_set });
|
||||
start_boundary(BlockBoundaryType::Break);
|
||||
|
@ -902,21 +902,21 @@ void Generator::emit_set_variable(JS::Identifier const& identifier, ScopedOperan
|
|||
}
|
||||
}
|
||||
|
||||
static Optional<ByteString> expression_identifier(Expression const& expression)
|
||||
static Optional<String> expression_identifier(Expression const& expression)
|
||||
{
|
||||
if (expression.is_identifier()) {
|
||||
auto const& identifier = static_cast<Identifier const&>(expression);
|
||||
return identifier.string();
|
||||
return identifier.string().to_string();
|
||||
}
|
||||
|
||||
if (expression.is_numeric_literal()) {
|
||||
auto const& literal = static_cast<NumericLiteral const&>(expression);
|
||||
return literal.value().to_string_without_side_effects().to_byte_string();
|
||||
return literal.value().to_string_without_side_effects();
|
||||
}
|
||||
|
||||
if (expression.is_string_literal()) {
|
||||
auto const& literal = static_cast<StringLiteral const&>(expression);
|
||||
return ByteString::formatted("'{}'", literal.value());
|
||||
return MUST(String::formatted("'{}'", literal.value()));
|
||||
}
|
||||
|
||||
if (expression.is_member_expression()) {
|
||||
|
@ -933,7 +933,7 @@ static Optional<ByteString> expression_identifier(Expression const& expression)
|
|||
builder.appendff(".{}", *identifer);
|
||||
}
|
||||
|
||||
return builder.to_byte_string();
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -996,7 +996,7 @@ void Generator::generate_scoped_jump(JumpType type)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Generator::generate_labelled_jump(JumpType type, DeprecatedFlyString const& label)
|
||||
void Generator::generate_labelled_jump(JumpType type, FlyString const& label)
|
||||
{
|
||||
TemporaryChange temp { m_current_unwind_context, m_current_unwind_context };
|
||||
size_t current_boundary = m_boundaries.size();
|
||||
|
@ -1047,7 +1047,7 @@ void Generator::generate_break()
|
|||
generate_scoped_jump(JumpType::Break);
|
||||
}
|
||||
|
||||
void Generator::generate_break(DeprecatedFlyString const& break_label)
|
||||
void Generator::generate_break(FlyString const& break_label)
|
||||
{
|
||||
generate_labelled_jump(JumpType::Break, break_label);
|
||||
}
|
||||
|
@ -1057,7 +1057,7 @@ void Generator::generate_continue()
|
|||
generate_scoped_jump(JumpType::Continue);
|
||||
}
|
||||
|
||||
void Generator::generate_continue(DeprecatedFlyString const& continue_label)
|
||||
void Generator::generate_continue(FlyString const& continue_label)
|
||||
{
|
||||
generate_labelled_jump(JumpType::Continue, continue_label);
|
||||
}
|
||||
|
@ -1121,12 +1121,12 @@ void Generator::emit_get_by_id_with_this(ScopedOperand dst, ScopedOperand base,
|
|||
|
||||
void Generator::emit_iterator_value(ScopedOperand dst, ScopedOperand result)
|
||||
{
|
||||
emit_get_by_id(dst, result, intern_identifier("value"sv));
|
||||
emit_get_by_id(dst, result, intern_identifier("value"_fly_string));
|
||||
}
|
||||
|
||||
void Generator::emit_iterator_complete(ScopedOperand dst, ScopedOperand result)
|
||||
{
|
||||
emit_get_by_id(dst, result, intern_identifier("done"sv));
|
||||
emit_get_by_id(dst, result, intern_identifier("done"_fly_string));
|
||||
}
|
||||
|
||||
bool Generator::is_local_initialized(u32 local_index) const
|
||||
|
|
|
@ -153,9 +153,9 @@ public:
|
|||
|
||||
CodeGenerationErrorOr<Optional<ScopedOperand>> emit_named_evaluation_if_anonymous_function(Expression const&, Optional<IdentifierTableIndex> lhs_name, Optional<ScopedOperand> preferred_dst = {});
|
||||
|
||||
void begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set);
|
||||
void begin_continuable_scope(Label continue_target, Vector<FlyString> const& language_label_set);
|
||||
void end_continuable_scope();
|
||||
void begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set);
|
||||
void begin_breakable_scope(Label breakable_target, Vector<FlyString> const& language_label_set);
|
||||
void end_breakable_scope();
|
||||
|
||||
[[nodiscard]] Label nearest_continuable_scope() const;
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
return m_current_basic_block->is_terminated();
|
||||
}
|
||||
|
||||
StringTableIndex intern_string(ByteString string)
|
||||
StringTableIndex intern_string(String string)
|
||||
{
|
||||
return m_string_table->insert(move(string));
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
return m_regex_table->insert(move(regex));
|
||||
}
|
||||
|
||||
IdentifierTableIndex intern_identifier(DeprecatedFlyString string)
|
||||
IdentifierTableIndex intern_identifier(FlyString string)
|
||||
{
|
||||
return m_identifier_table->insert(move(string));
|
||||
}
|
||||
|
@ -265,10 +265,10 @@ public:
|
|||
bool must_enter_finalizer() const { return m_boundaries.contains_slow(BlockBoundaryType::ReturnToFinally); }
|
||||
|
||||
void generate_break();
|
||||
void generate_break(DeprecatedFlyString const& break_label);
|
||||
void generate_break(FlyString const& break_label);
|
||||
|
||||
void generate_continue();
|
||||
void generate_continue(DeprecatedFlyString const& continue_label);
|
||||
void generate_continue(FlyString const& continue_label);
|
||||
|
||||
template<typename OpType>
|
||||
void emit_return(ScopedOperand value)
|
||||
|
@ -343,14 +343,14 @@ public:
|
|||
private:
|
||||
VM& m_vm;
|
||||
|
||||
static CodeGenerationErrorOr<GC::Ref<Executable>> compile(VM&, ASTNode const&, FunctionKind, GC::Ptr<ECMAScriptFunctionObject const>, MustPropagateCompletion, Vector<DeprecatedFlyString> local_variable_names);
|
||||
static CodeGenerationErrorOr<GC::Ref<Executable>> compile(VM&, ASTNode const&, FunctionKind, GC::Ptr<ECMAScriptFunctionObject const>, MustPropagateCompletion, Vector<FlyString> local_variable_names);
|
||||
|
||||
enum class JumpType {
|
||||
Continue,
|
||||
Break,
|
||||
};
|
||||
void generate_scoped_jump(JumpType);
|
||||
void generate_labelled_jump(JumpType, DeprecatedFlyString const& label);
|
||||
void generate_labelled_jump(JumpType, FlyString const& label);
|
||||
|
||||
Generator(VM&, GC::Ptr<ECMAScriptFunctionObject const>, MustPropagateCompletion);
|
||||
~Generator() = default;
|
||||
|
@ -362,7 +362,7 @@ private:
|
|||
|
||||
struct LabelableScope {
|
||||
Label bytecode_target;
|
||||
Vector<DeprecatedFlyString> language_label_set;
|
||||
Vector<FlyString> language_label_set;
|
||||
};
|
||||
|
||||
BasicBlock* m_current_basic_block { nullptr };
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
IdentifierTableIndex IdentifierTable::insert(DeprecatedFlyString string)
|
||||
IdentifierTableIndex IdentifierTable::insert(FlyString string)
|
||||
{
|
||||
m_identifiers.append(move(string));
|
||||
VERIFY(m_identifiers.size() <= NumericLimits<u32>::max());
|
||||
return { static_cast<u32>(m_identifiers.size() - 1) };
|
||||
}
|
||||
|
||||
DeprecatedFlyString const& IdentifierTable::get(IdentifierTableIndex index) const
|
||||
FlyString const& IdentifierTable::get(IdentifierTableIndex index) const
|
||||
{
|
||||
return m_identifiers[index.value];
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/DistinctNumeric.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
@ -24,13 +24,13 @@ class IdentifierTable {
|
|||
public:
|
||||
IdentifierTable() = default;
|
||||
|
||||
IdentifierTableIndex insert(DeprecatedFlyString);
|
||||
DeprecatedFlyString const& get(IdentifierTableIndex) const;
|
||||
IdentifierTableIndex insert(FlyString);
|
||||
FlyString const& get(IdentifierTableIndex) const;
|
||||
void dump() const;
|
||||
bool is_empty() const { return m_identifiers.is_empty(); }
|
||||
|
||||
private:
|
||||
Vector<DeprecatedFlyString> m_identifiers;
|
||||
Vector<FlyString> m_identifiers;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -833,7 +833,7 @@ void Interpreter::enter_object_environment(Object& object)
|
|||
running_execution_context().lexical_environment = new_object_environment(object, true, old_environment);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<GC::Ref<Bytecode::Executable>> compile(VM& vm, ASTNode const& node, FunctionKind kind, DeprecatedFlyString const& name)
|
||||
ThrowCompletionOr<GC::Ref<Bytecode::Executable>> compile(VM& vm, ASTNode const& node, FunctionKind kind, FlyString const& name)
|
||||
{
|
||||
auto executable_result = Bytecode::Generator::generate_from_ast_node(vm, node, kind);
|
||||
if (executable_result.is_error())
|
||||
|
@ -1199,7 +1199,7 @@ inline ThrowCompletionOr<Value> get_global(Interpreter& interpreter, IdentifierT
|
|||
return vm.throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, identifier);
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value, Value value, Optional<DeprecatedFlyString const&> const& base_identifier, PropertyKey name, Op::PropertyKind kind, PropertyLookupCache* cache = nullptr)
|
||||
inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value, Value value, Optional<FlyString const&> const& base_identifier, PropertyKey name, Op::PropertyKind kind, PropertyLookupCache* cache = nullptr)
|
||||
{
|
||||
// Better error message than to_object would give
|
||||
if (vm.in_strict_mode() && base.is_nullish())
|
||||
|
@ -1219,14 +1219,14 @@ inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value thi
|
|||
case Op::PropertyKind::Getter: {
|
||||
auto& function = value.as_function();
|
||||
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(ByteString::formatted("get {}", name));
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(MUST(String::formatted("get {}", name)));
|
||||
object->define_direct_accessor(name, &function, nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
}
|
||||
case Op::PropertyKind::Setter: {
|
||||
auto& function = value.as_function();
|
||||
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(ByteString::formatted("set {}", name));
|
||||
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(MUST(String::formatted("set {}", name)));
|
||||
object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable);
|
||||
break;
|
||||
}
|
||||
|
@ -1306,7 +1306,7 @@ inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<Id
|
|||
Value value;
|
||||
|
||||
if (!function_node.has_name()) {
|
||||
DeprecatedFlyString name = {};
|
||||
FlyString name;
|
||||
if (lhs_name.has_value())
|
||||
name = vm.bytecode_interpreter().current_executable().get_identifier(lhs_name.value());
|
||||
value = function_node.instantiate_ordinary_function_expression(vm, name);
|
||||
|
@ -1323,7 +1323,7 @@ inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<Id
|
|||
return value;
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Optional<DeprecatedFlyString const&> const& base_identifier, Value property_key_value, Value value, Op::PropertyKind kind)
|
||||
inline ThrowCompletionOr<void> put_by_value(VM& vm, Value base, Optional<FlyString const&> const& base_identifier, Value property_key_value, Value value, Op::PropertyKind kind)
|
||||
{
|
||||
// OPTIMIZATION: Fast path for simple Int32 indexes in array-like objects.
|
||||
if ((kind == Op::PropertyKind::KeyValue || kind == Op::PropertyKind::DirectKeyValue)
|
||||
|
@ -1426,7 +1426,7 @@ struct CalleeAndThis {
|
|||
Value this_value;
|
||||
};
|
||||
|
||||
inline ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& name, EnvironmentCoordinate& cache)
|
||||
inline ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Bytecode::Interpreter& interpreter, FlyString const& name, EnvironmentCoordinate& cache)
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
|
@ -1472,14 +1472,14 @@ inline ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Byt
|
|||
}
|
||||
|
||||
// 13.2.7.3 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-regular-expression-literals-runtime-semantics-evaluation
|
||||
inline Value new_regexp(VM& vm, ParsedRegex const& parsed_regex, ByteString const& pattern, ByteString const& flags)
|
||||
inline Value new_regexp(VM& vm, ParsedRegex const& parsed_regex, String const& pattern, String const& flags)
|
||||
{
|
||||
// 1. Let pattern be CodePointsToString(BodyText of RegularExpressionLiteral).
|
||||
// 2. Let flags be CodePointsToString(FlagText of RegularExpressionLiteral).
|
||||
|
||||
// 3. Return ! RegExpCreate(pattern, flags).
|
||||
auto& realm = *vm.current_realm();
|
||||
Regex<ECMA262> regex(parsed_regex.regex, parsed_regex.pattern, parsed_regex.flags);
|
||||
Regex<ECMA262> regex(parsed_regex.regex, parsed_regex.pattern.to_byte_string(), parsed_regex.flags);
|
||||
// NOTE: We bypass RegExpCreate and subsequently RegExpAlloc as an optimization to use the already parsed values.
|
||||
auto regexp_object = RegExpObject::create(realm, move(regex), pattern, flags);
|
||||
// RegExpAlloc has these two steps from the 'Legacy RegExp features' proposal.
|
||||
|
@ -1514,7 +1514,7 @@ inline GC::RootVector<Value> argument_list_evaluation(VM& vm, Value arguments)
|
|||
return argument_values;
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<void> create_variable(VM& vm, DeprecatedFlyString const& name, Op::EnvironmentMode mode, bool is_global, bool is_immutable, bool is_strict)
|
||||
inline ThrowCompletionOr<void> create_variable(VM& vm, FlyString const& name, Op::EnvironmentMode mode, bool is_global, bool is_immutable, bool is_strict)
|
||||
{
|
||||
if (mode == Op::EnvironmentMode::Lexical) {
|
||||
VERIFY(!is_global);
|
||||
|
@ -1549,13 +1549,13 @@ inline ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM& vm, Value supe
|
|||
auto* class_environment = vm.lexical_environment();
|
||||
vm.running_execution_context().lexical_environment = vm.running_execution_context().saved_lexical_environments.take_last();
|
||||
|
||||
Optional<DeprecatedFlyString> binding_name;
|
||||
DeprecatedFlyString class_name;
|
||||
Optional<FlyString> binding_name;
|
||||
FlyString class_name;
|
||||
if (!class_expression.has_name() && lhs_name.has_value()) {
|
||||
class_name = interpreter.current_executable().get_identifier(lhs_name.value());
|
||||
} else {
|
||||
binding_name = name;
|
||||
class_name = name.is_null() ? ""sv : name;
|
||||
class_name = name;
|
||||
}
|
||||
|
||||
return TRY(class_expression.create_class_constructor(vm, class_environment, vm.lexical_environment(), super_class, element_keys, binding_name, class_name));
|
||||
|
|
|
@ -109,7 +109,7 @@ private:
|
|||
|
||||
extern bool g_dump_bytecode;
|
||||
|
||||
ThrowCompletionOr<GC::Ref<Bytecode::Executable>> compile(VM&, ASTNode const&, JS::FunctionKind kind, DeprecatedFlyString const& name);
|
||||
ThrowCompletionOr<GC::Ref<Bytecode::Executable>> compile(VM&, ASTNode const&, JS::FunctionKind kind, FlyString const& name);
|
||||
ThrowCompletionOr<GC::Ref<Bytecode::Executable>> compile(VM&, ECMAScriptFunctionObject const&);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DistinctNumeric.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibRegex/RegexParser.h>
|
||||
|
||||
|
@ -17,7 +17,7 @@ AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(size_t, RegexTableIndex, Comparison);
|
|||
|
||||
struct ParsedRegex {
|
||||
regex::Parser::Result regex;
|
||||
ByteString pattern;
|
||||
String pattern;
|
||||
regex::RegexOptions<ECMAScriptFlags> flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
StringTableIndex StringTable::insert(ByteString string)
|
||||
StringTableIndex StringTable::insert(String string)
|
||||
{
|
||||
m_strings.append(move(string));
|
||||
return m_strings.size() - 1;
|
||||
}
|
||||
|
||||
ByteString const& StringTable::get(StringTableIndex index) const
|
||||
String const& StringTable::get(StringTableIndex index) const
|
||||
{
|
||||
return m_strings[index.value()];
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DistinctNumeric.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
@ -21,13 +21,13 @@ class StringTable {
|
|||
public:
|
||||
StringTable() = default;
|
||||
|
||||
StringTableIndex insert(ByteString);
|
||||
ByteString const& get(StringTableIndex) const;
|
||||
StringTableIndex insert(String);
|
||||
String const& get(StringTableIndex) const;
|
||||
void dump() const;
|
||||
bool is_empty() const { return m_strings.is_empty(); }
|
||||
|
||||
private:
|
||||
Vector<ByteString> m_strings;
|
||||
Vector<String> m_strings;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue