|
@@ -812,23 +812,24 @@ ThrowCompletionOr<void> GetVariable::execute_impl(Bytecode::Interpreter& interpr
|
|
{
|
|
{
|
|
auto& vm = interpreter.vm();
|
|
auto& vm = interpreter.vm();
|
|
|
|
|
|
- if (m_cached_environment_coordinate.has_value()) {
|
|
|
|
|
|
+ auto& cached_environment_coordinate = interpreter.current_executable().environment_variable_caches[m_cache_index];
|
|
|
|
+ if (cached_environment_coordinate.has_value()) {
|
|
auto environment = vm.running_execution_context().lexical_environment;
|
|
auto environment = vm.running_execution_context().lexical_environment;
|
|
- for (size_t i = 0; i < m_cached_environment_coordinate->hops; ++i)
|
|
|
|
|
|
+ for (size_t i = 0; i < cached_environment_coordinate->hops; ++i)
|
|
environment = environment->outer_environment();
|
|
environment = environment->outer_environment();
|
|
VERIFY(environment);
|
|
VERIFY(environment);
|
|
VERIFY(environment->is_declarative_environment());
|
|
VERIFY(environment->is_declarative_environment());
|
|
if (!environment->is_permanently_screwed_by_eval()) {
|
|
if (!environment->is_permanently_screwed_by_eval()) {
|
|
- interpreter.accumulator() = TRY(verify_cast<DeclarativeEnvironment>(*environment).get_binding_value_direct(vm, m_cached_environment_coordinate.value().index, vm.in_strict_mode()));
|
|
|
|
|
|
+ interpreter.accumulator() = TRY(verify_cast<DeclarativeEnvironment>(*environment).get_binding_value_direct(vm, cached_environment_coordinate.value().index, vm.in_strict_mode()));
|
|
return {};
|
|
return {};
|
|
}
|
|
}
|
|
- m_cached_environment_coordinate = {};
|
|
|
|
|
|
+ cached_environment_coordinate = {};
|
|
}
|
|
}
|
|
|
|
|
|
auto const& string = interpreter.current_executable().get_identifier(m_identifier);
|
|
auto const& string = interpreter.current_executable().get_identifier(m_identifier);
|
|
auto reference = TRY(vm.resolve_binding(string));
|
|
auto reference = TRY(vm.resolve_binding(string));
|
|
if (reference.environment_coordinate().has_value())
|
|
if (reference.environment_coordinate().has_value())
|
|
- m_cached_environment_coordinate = reference.environment_coordinate();
|
|
|
|
|
|
+ cached_environment_coordinate = reference.environment_coordinate();
|
|
interpreter.accumulator() = TRY(reference.get_value(vm));
|
|
interpreter.accumulator() = TRY(reference.get_value(vm));
|
|
return {};
|
|
return {};
|
|
}
|
|
}
|
|
@@ -837,27 +838,28 @@ ThrowCompletionOr<void> GetCalleeAndThisFromEnvironment::execute_impl(Bytecode::
|
|
{
|
|
{
|
|
auto& vm = interpreter.vm();
|
|
auto& vm = interpreter.vm();
|
|
|
|
|
|
- if (m_cached_environment_coordinate.has_value()) {
|
|
|
|
|
|
+ auto& cached_environment_coordinate = interpreter.current_executable().environment_variable_caches[m_cache_index];
|
|
|
|
+ if (cached_environment_coordinate.has_value()) {
|
|
auto environment = vm.running_execution_context().lexical_environment;
|
|
auto environment = vm.running_execution_context().lexical_environment;
|
|
- for (size_t i = 0; i < m_cached_environment_coordinate->hops; ++i)
|
|
|
|
|
|
+ for (size_t i = 0; i < cached_environment_coordinate->hops; ++i)
|
|
environment = environment->outer_environment();
|
|
environment = environment->outer_environment();
|
|
VERIFY(environment);
|
|
VERIFY(environment);
|
|
VERIFY(environment->is_declarative_environment());
|
|
VERIFY(environment->is_declarative_environment());
|
|
if (!environment->is_permanently_screwed_by_eval()) {
|
|
if (!environment->is_permanently_screwed_by_eval()) {
|
|
- interpreter.reg(m_callee_reg) = TRY(verify_cast<DeclarativeEnvironment>(*environment).get_binding_value_direct(vm, m_cached_environment_coordinate.value().index, vm.in_strict_mode()));
|
|
|
|
|
|
+ interpreter.reg(m_callee_reg) = TRY(verify_cast<DeclarativeEnvironment>(*environment).get_binding_value_direct(vm, cached_environment_coordinate.value().index, vm.in_strict_mode()));
|
|
Value this_value = js_undefined();
|
|
Value this_value = js_undefined();
|
|
if (auto base_object = environment->with_base_object())
|
|
if (auto base_object = environment->with_base_object())
|
|
this_value = base_object;
|
|
this_value = base_object;
|
|
interpreter.reg(m_this_reg) = this_value;
|
|
interpreter.reg(m_this_reg) = this_value;
|
|
return {};
|
|
return {};
|
|
}
|
|
}
|
|
- m_cached_environment_coordinate = {};
|
|
|
|
|
|
+ cached_environment_coordinate = {};
|
|
}
|
|
}
|
|
|
|
|
|
auto const& string = interpreter.current_executable().get_identifier(m_identifier);
|
|
auto const& string = interpreter.current_executable().get_identifier(m_identifier);
|
|
auto reference = TRY(vm.resolve_binding(string));
|
|
auto reference = TRY(vm.resolve_binding(string));
|
|
if (reference.environment_coordinate().has_value())
|
|
if (reference.environment_coordinate().has_value())
|
|
- m_cached_environment_coordinate = reference.environment_coordinate();
|
|
|
|
|
|
+ cached_environment_coordinate = reference.environment_coordinate();
|
|
|
|
|
|
interpreter.reg(m_callee_reg) = TRY(reference.get_value(vm));
|
|
interpreter.reg(m_callee_reg) = TRY(reference.get_value(vm));
|
|
|
|
|