mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibJS/Bytecode: Don't emit GetGlobal undefined
We know that `undefined` in the global scope is always the proper undefined value. This commit takes advantage of that by simply emitting a constant undefined value instead. Unfortunately we can't be so sure in other scopes.
This commit is contained in:
parent
448f837d38
commit
caf2e675bf
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/awesomekling
Commit: caf2e675bf
Pull-request: https://github.com/SerenityOS/serenity/pull/24276
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/shannonbooth
1 changed files with 4 additions and 0 deletions
|
@ -382,6 +382,10 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> Identifier::generate_by
|
|||
return local;
|
||||
}
|
||||
|
||||
if (is_global() && m_string == "undefined"sv) {
|
||||
return generator.add_constant(js_undefined());
|
||||
}
|
||||
|
||||
auto dst = choose_dst(generator, preferred_dst);
|
||||
if (is_global()) {
|
||||
generator.emit<Bytecode::Op::GetGlobal>(dst, generator.intern_identifier(m_string), generator.next_global_variable_cache());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue