Skip to content

Commit

Permalink
Move parameter environment creation to opcode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Oct 30, 2023
1 parent 8365701 commit f084460
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
9 changes: 3 additions & 6 deletions boa_engine/src/bytecompiler/declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use crate::{
bytecompiler::{ByteCompiler, FunctionCompiler, FunctionSpec, NodeKind},
environments::CompileTimeEnvironment,
js_string,
vm::{
create_function_object_fast, create_generator_function_object, BindingOpcode,
CodeBlockFlags, Opcode,
},
vm::{create_function_object_fast, create_generator_function_object, BindingOpcode, Opcode},
JsNativeError, JsResult,
};
use boa_ast::{
Expand Down Expand Up @@ -930,8 +927,8 @@ impl ByteCompiler<'_, '_> {
// c. Let env be NewDeclarativeEnvironment(calleeEnv).
// d. Assert: The VariableEnvironment of calleeContext is calleeEnv.
// e. Set the LexicalEnvironment of calleeContext to env.
let _ = self.push_compile_environment(false);
self.code_block_flags |= CodeBlockFlags::PARAMETERS_ENV_BINDINGS;
let env_index = self.push_compile_environment(false);
self.emit_with_varying_operand(Opcode::PushDeclarativeEnvironment, env_index);
};

let env = self.lexical_environment.clone();
Expand Down
16 changes: 0 additions & 16 deletions boa_engine/src/object/internal_methods/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ pub(crate) fn function_call(
FunctionSlots::new(this, function_object.clone(), None),
);

if code.has_parameters_env_bindings() {
last_env += 1;
context
.vm
.environments
.push_lexical(code.constant_compile_time_environment(last_env));
}

Ok(CallValue::Ready)
}

Expand Down Expand Up @@ -216,14 +208,6 @@ fn function_construct(
),
);

if code.has_parameters_env_bindings() {
last_env += 1;
context
.vm
.environments
.push_lexical(code.constant_compile_time_environment(last_env));
}

// Insert `this` value
context
.vm
Expand Down
12 changes: 1 addition & 11 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ bitflags! {
/// The `[[IsClassConstructor]]` internal slot.
const IS_CLASS_CONSTRUCTOR = 0b0000_0100;

/// Does this function have a parameters environment.
const PARAMETERS_ENV_BINDINGS = 0b0000_1000;

/// The `[[ClassFieldInitializerName]]` internal slot.
const IN_CLASS_FIELD_INITIALIZER = 0b0010_0000;
const IN_CLASS_FIELD_INITIALIZER = 0b0000_1000;

/// `[[ConstructorKind]]`
const IS_DERIVED_CONSTRUCTOR = 0b0100_0000;
Expand Down Expand Up @@ -222,13 +219,6 @@ impl CodeBlock {
.contains(CodeBlockFlags::HAS_BINDING_IDENTIFIER)
}

/// Does this function have a parameters environment.
pub(crate) fn has_parameters_env_bindings(&self) -> bool {
self.flags
.get()
.contains(CodeBlockFlags::PARAMETERS_ENV_BINDINGS)
}

/// Does this function have the `[[ClassFieldInitializerName]]` internal slot set to non-empty value.
pub(crate) fn in_class_field_initializer(&self) -> bool {
self.flags
Expand Down

0 comments on commit f084460

Please sign in to comment.