File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
Userland/Libraries/LibJS/Bytecode Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
120
120
}
121
121
}
122
122
} else {
123
- emit<Op::CreateVariableEnvironment>();
123
+ emit<Op::CreateVariableEnvironment>(function. m_var_environment_bindings_count );
124
124
125
125
if (scope_body) {
126
126
for (auto const & variable_to_initialize : function.m_var_names_to_initialize_binding ) {
@@ -158,7 +158,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
158
158
if (!function.m_strict ) {
159
159
bool can_elide_declarative_environment = !function.m_contains_direct_call_to_eval && (!scope_body || !scope_body->has_non_local_lexical_declarations ());
160
160
if (!can_elide_declarative_environment) {
161
- emit<Op::CreateLexicalEnvironment>();
161
+ emit<Op::CreateLexicalEnvironment>(function. m_lex_environment_bindings_count );
162
162
}
163
163
}
164
164
Original file line number Diff line number Diff line change @@ -1256,7 +1256,9 @@ ThrowCompletionOr<void> DeleteVariable::execute_impl(Bytecode::Interpreter& inte
1256
1256
void CreateLexicalEnvironment::execute_impl (Bytecode::Interpreter& interpreter) const
1257
1257
{
1258
1258
auto make_and_swap_envs = [&](auto & old_environment) {
1259
- GCPtr<Environment> environment = new_declarative_environment (*old_environment).ptr ();
1259
+ auto declarative_environment = new_declarative_environment (*old_environment).ptr ();
1260
+ declarative_environment->ensure_capacity (m_capacity);
1261
+ GCPtr<Environment> environment = declarative_environment;
1260
1262
swap (old_environment, environment);
1261
1263
return environment;
1262
1264
};
@@ -1268,6 +1270,7 @@ ThrowCompletionOr<void> CreateVariableEnvironment::execute_impl(Bytecode::Interp
1268
1270
{
1269
1271
auto & running_execution_context = interpreter.vm ().running_execution_context ();
1270
1272
auto var_environment = new_declarative_environment (*running_execution_context.lexical_environment );
1273
+ var_environment->ensure_capacity (m_capacity);
1271
1274
running_execution_context.variable_environment = var_environment;
1272
1275
running_execution_context.lexical_environment = var_environment;
1273
1276
return {};
Original file line number Diff line number Diff line change @@ -443,24 +443,32 @@ enum class EnvironmentMode {
443
443
444
444
class CreateLexicalEnvironment final : public Instruction {
445
445
public:
446
- explicit CreateLexicalEnvironment ()
446
+ explicit CreateLexicalEnvironment (u32 capacity = 0 )
447
447
: Instruction(Type::CreateLexicalEnvironment)
448
+ , m_capacity(capacity)
448
449
{
449
450
}
450
451
451
452
void execute_impl (Bytecode::Interpreter&) const ;
452
453
ByteString to_byte_string_impl (Bytecode::Executable const &) const ;
454
+
455
+ private:
456
+ u32 m_capacity { 0 };
453
457
};
454
458
455
459
class CreateVariableEnvironment final : public Instruction {
456
460
public:
457
- explicit CreateVariableEnvironment ()
461
+ explicit CreateVariableEnvironment (u32 capacity = 0 )
458
462
: Instruction(Type::CreateVariableEnvironment)
463
+ , m_capacity(capacity)
459
464
{
460
465
}
461
466
462
467
ThrowCompletionOr<void > execute_impl (Bytecode::Interpreter&) const ;
463
468
ByteString to_byte_string_impl (Bytecode::Executable const &) const ;
469
+
470
+ private:
471
+ u32 m_capacity { 0 };
464
472
};
465
473
466
474
class EnterObjectEnvironment final : public Instruction {
You can’t perform that action at this time.
0 commit comments