LibJS: Emit PutById instead of PutByValue when key is string literal
Some checks failed
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled

Basically convert o["foo"]=x into o.foo=x when emitting bytecode.
These are effectively the same thing, and the latter format opts
into using an inline cache for the property lookups.
This commit is contained in:
Andreas Kling 2025-04-03 14:29:44 +02:00 committed by Andreas Kling
parent 4426c50a18
commit 3169747989
Notes: github-actions[bot] 2025-04-03 16:48:32 +00:00
3 changed files with 34 additions and 7 deletions

View file

@ -625,9 +625,9 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
if (expression.is_computed()) {
if (!lhs_is_super_expression)
generator.emit<Bytecode::Op::PutByValue>(*base, *computed_property, rval, Bytecode::Op::PropertyKind::KeyValue, move(base_identifier));
generator.emit_put_by_value(*base, *computed_property, rval, Bytecode::Op::PropertyKind::KeyValue, move(base_identifier));
else
generator.emit<Bytecode::Op::PutByValueWithThis>(*base, *computed_property, *this_value, rval);
generator.emit_put_by_value_with_this(*base, *computed_property, *this_value, rval, Op::PropertyKind::KeyValue);
} else if (expression.property().is_identifier()) {
auto identifier_table_ref = generator.intern_identifier(as<Identifier>(expression.property()).string());
if (!lhs_is_super_expression)
@ -1180,7 +1180,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> ObjectExpression::gener
auto property_name = TRY(property->key().generate_bytecode(generator)).value();
auto value = TRY(property->value().generate_bytecode(generator)).value();
generator.emit<Bytecode::Op::PutByValue>(object, property_name, value, property_kind);
generator.emit_put_by_value(object, property_name, value, property_kind, {});
}
}