From 3f5bad78885ae889e37844b303a91936eb1556d9 Mon Sep 17 00:00:00 2001
From: Haled Odat <8566042+HalidOdat@users.noreply.github.com>
Date: Sun, 21 May 2023 12:15:34 +0200
Subject: [PATCH] Shrink environment binding locators (#2950)
---
boa_engine/src/builtins/eval/mod.rs | 4 +-
boa_engine/src/builtins/function/arguments.rs | 20 ++++---
boa_engine/src/bytecompiler/class.rs | 8 +--
boa_engine/src/bytecompiler/env.rs | 6 +--
boa_engine/src/bytecompiler/function.rs | 4 +-
boa_engine/src/bytecompiler/mod.rs | 4 +-
.../src/bytecompiler/statement/block.rs | 4 +-
boa_engine/src/bytecompiler/statement/loop.rs | 24 ++++-----
.../src/bytecompiler/statement/switch.rs | 4 +-
boa_engine/src/bytecompiler/statement/try.rs | 4 +-
boa_engine/src/environments/compile.rs | 16 +++---
.../runtime/declarative/function.rs | 6 +--
.../runtime/declarative/global.rs | 4 +-
.../runtime/declarative/lexical.rs | 6 +--
.../environments/runtime/declarative/mod.rs | 20 +++----
.../runtime/declarative/module.rs | 18 +++----
boa_engine/src/environments/runtime/mod.rs | 52 +++++++++----------
.../src/object/internal_methods/arguments.rs | 12 ++---
boa_engine/src/realm.rs | 4 +-
boa_engine/src/vm/code_block.rs | 4 +-
boa_engine/src/vm/opcode/push/environment.rs | 4 +-
21 files changed, 116 insertions(+), 112 deletions(-)
diff --git a/boa_engine/src/builtins/eval/mod.rs b/boa_engine/src/builtins/eval/mod.rs
index 05d01ae258..5881a0f069 100644
--- a/boa_engine/src/builtins/eval/mod.rs
+++ b/boa_engine/src/builtins/eval/mod.rs
@@ -232,8 +232,8 @@ impl Eval {
compiler.compile_statement_list(&body, true, false);
let env_info = compiler.pop_compile_environment();
- compiler.patch_jump_with_target(push_env.0, env_info.num_bindings as u32);
- compiler.patch_jump_with_target(push_env.1, env_info.index as u32);
+ compiler.patch_jump_with_target(push_env.0, env_info.num_bindings);
+ compiler.patch_jump_with_target(push_env.1, env_info.index);
compiler.emit_opcode(Opcode::PopEnvironment);
let code_block = Gc::new(compiler.finish());
diff --git a/boa_engine/src/builtins/function/arguments.rs b/boa_engine/src/builtins/function/arguments.rs
index aafd5f98ea..8251e649e4 100644
--- a/boa_engine/src/builtins/function/arguments.rs
+++ b/boa_engine/src/builtins/function/arguments.rs
@@ -12,14 +12,14 @@ use rustc_hash::FxHashMap;
/// This struct stores all the data to access mapped function parameters in their environment.
#[derive(Debug, Clone, Trace, Finalize)]
pub struct ParameterMap {
- binding_indices: Vec