mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibJS/Bytecode: Defer GetGlobal identifier lookup until cache misses
This way we avoid looking up the identifier when the cache hits.
This commit is contained in:
parent
6ec4d6f668
commit
a06441c88c
Notes:
sideshowbarker
2024-07-17 05:05:51 +09:00
Author: https://github.com/awesomekling
Commit: a06441c88c
Pull-request: https://github.com/SerenityOS/serenity/pull/24296
2 changed files with 4 additions and 2 deletions
|
@ -231,7 +231,7 @@ inline ThrowCompletionOr<Value> get_by_value(VM& vm, Optional<DeprecatedFlyStrin
|
|||
return TRY(object->internal_get(property_key, base_value));
|
||||
}
|
||||
|
||||
inline ThrowCompletionOr<Value> get_global(Bytecode::Interpreter& interpreter, DeprecatedFlyString const& identifier, GlobalVariableCache& cache)
|
||||
inline ThrowCompletionOr<Value> get_global(Interpreter& interpreter, IdentifierTableIndex identifier_index, GlobalVariableCache& cache)
|
||||
{
|
||||
auto& vm = interpreter.vm();
|
||||
auto& binding_object = interpreter.global_object();
|
||||
|
@ -246,6 +246,8 @@ inline ThrowCompletionOr<Value> get_global(Bytecode::Interpreter& interpreter, D
|
|||
|
||||
cache.environment_serial_number = declarative_record.environment_serial_number();
|
||||
|
||||
auto& identifier = interpreter.current_executable().get_identifier(identifier_index);
|
||||
|
||||
if (vm.running_execution_context().script_or_module.has<NonnullGCPtr<Module>>()) {
|
||||
// NOTE: GetGlobal is used to access variables stored in the module environment and global environment.
|
||||
// The module environment is checked first since it precedes the global environment in the environment chain.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue