Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move parameter environment creation to bytecode #3433

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions boa_engine/src/bytecompiler/declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
bytecompiler::{ByteCompiler, FunctionCompiler, FunctionSpec, NodeKind},
environments::CompileTimeEnvironment,
js_string,
vm::{create_function_object_fast, BindingOpcode, CodeBlockFlags, Opcode},
vm::{create_function_object_fast, BindingOpcode, Opcode},
JsNativeError, JsResult,
};
use boa_ast::{
Expand Down Expand Up @@ -909,8 +909,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
20 changes: 5 additions & 15 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,17 @@ 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 = 0b0001_0000;
const IN_CLASS_FIELD_INITIALIZER = 0b0000_1000;

/// `[[ConstructorKind]]`
const IS_DERIVED_CONSTRUCTOR = 0b0010_0000;
const IS_DERIVED_CONSTRUCTOR = 0b0001_0000;

const IS_ASYNC = 0b0100_0000;
const IS_GENERATOR = 0b0000_1000_0000;
const IS_ASYNC = 0b0010_0000;
const IS_GENERATOR = 0b0100_0000;

/// Arrow and method functions don't have `"prototype"` property.
const HAS_PROTOTYPE_PROPERTY = 0b0001_0000_0000;
const HAS_PROTOTYPE_PROPERTY = 0b1000_0000;

/// Trace instruction execution to `stdout`.
#[cfg(feature = "trace")]
Expand Down Expand Up @@ -221,13 +218,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
Loading