1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibJS: Make JS::ECMAScriptFunctionObject smaller by reordering members

...and making heavy use of bitfields.
This commit is contained in:
Andreas Kling 2022-01-31 13:19:06 +01:00
parent fc04465fa3
commit 8d3f92c844
2 changed files with 26 additions and 25 deletions

View file

@ -56,19 +56,19 @@ ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(GlobalObject& global_
ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionNode::Parameter> formal_parameters, i32 function_length, Environment* parent_scope, PrivateEnvironment* private_scope, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function)
: FunctionObject(prototype)
, m_name(move(name))
, m_function_length(function_length)
, m_environment(parent_scope)
, m_private_environment(private_scope)
, m_formal_parameters(move(formal_parameters))
, m_ecmascript_code(ecmascript_code)
, m_realm(global_object().associated_realm())
, m_strict(strict)
, m_source_text(move(source_text))
, m_name(move(name))
, m_function_length(function_length)
, m_kind(kind)
, m_strict(strict)
, m_might_need_arguments_object(might_need_arguments_object)
, m_contains_direct_call_to_eval(contains_direct_call_to_eval)
, m_is_arrow_function(is_arrow_function)
, m_kind(kind)
{
// NOTE: This logic is from OrdinaryFunctionCreate, https://tc39.es/ecma262/#sec-ordinaryfunctioncreate

View file

@ -102,30 +102,31 @@ private:
ThrowCompletionOr<void> function_declaration_instantiation(Interpreter*);
FlyString m_name;
Optional<Bytecode::Executable> m_bytecode_executable;
i32 m_function_length { 0 };
// Internal Slots of ECMAScript Function Objects, https://tc39.es/ecma262/#table-internal-slots-of-ecmascript-function-objects
Environment* m_environment { nullptr }; // [[Environment]]
PrivateEnvironment* m_private_environment { nullptr }; // [[PrivateEnvironment]]
Vector<FunctionNode::Parameter> const m_formal_parameters; // [[FormalParameters]]
NonnullRefPtr<Statement> m_ecmascript_code; // [[ECMAScriptCode]]
ConstructorKind m_constructor_kind { ConstructorKind::Base }; // [[ConstructorKind]]
Realm* m_realm { nullptr }; // [[Realm]]
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
ThisMode m_this_mode { ThisMode::Global }; // [[ThisMode]]
bool m_strict { false }; // [[Strict]]
Object* m_home_object { nullptr }; // [[HomeObject]]
String m_source_text; // [[SourceText]]
Vector<InstanceField> m_fields; // [[Fields]]
Vector<PrivateElement> m_private_methods; // [[PrivateMethods]]
bool m_is_class_constructor { false }; // [[IsClassConstructor]]
ConstructorKind m_constructor_kind : 1 { ConstructorKind::Base }; // [[ConstructorKind]]
bool m_strict : 1 { false }; // [[Strict]]
bool m_is_class_constructor : 1 { false }; // [[IsClassConstructor]]
ThisMode m_this_mode : 2 { ThisMode::Global }; // [[ThisMode]]
FlyString m_name;
Optional<Bytecode::Executable> m_bytecode_executable;
i32 m_function_length { 0 };
FunctionKind m_kind { FunctionKind::Normal };
bool m_might_need_arguments_object { true };
bool m_contains_direct_call_to_eval { true };
bool m_is_arrow_function { false };
bool m_has_simple_parameter_list { false };
bool m_might_need_arguments_object : 1 { true };
bool m_contains_direct_call_to_eval : 1 { true };
bool m_is_arrow_function : 1 { false };
bool m_has_simple_parameter_list : 1 { false };
FunctionKind m_kind : 3 { FunctionKind::Normal };
};
}