mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibJS: Make JS::ECMAScriptFunctionObject smaller by reordering members
...and making heavy use of bitfields.
This commit is contained in:
parent
fc04465fa3
commit
8d3f92c844
2 changed files with 26 additions and 25 deletions
|
@ -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)
|
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)
|
: FunctionObject(prototype)
|
||||||
|
, m_name(move(name))
|
||||||
|
, m_function_length(function_length)
|
||||||
, m_environment(parent_scope)
|
, m_environment(parent_scope)
|
||||||
, m_private_environment(private_scope)
|
, m_private_environment(private_scope)
|
||||||
, m_formal_parameters(move(formal_parameters))
|
, m_formal_parameters(move(formal_parameters))
|
||||||
, m_ecmascript_code(ecmascript_code)
|
, m_ecmascript_code(ecmascript_code)
|
||||||
, m_realm(global_object().associated_realm())
|
, m_realm(global_object().associated_realm())
|
||||||
, m_strict(strict)
|
|
||||||
, m_source_text(move(source_text))
|
, m_source_text(move(source_text))
|
||||||
, m_name(move(name))
|
, m_strict(strict)
|
||||||
, m_function_length(function_length)
|
|
||||||
, m_kind(kind)
|
|
||||||
, m_might_need_arguments_object(might_need_arguments_object)
|
, m_might_need_arguments_object(might_need_arguments_object)
|
||||||
, m_contains_direct_call_to_eval(contains_direct_call_to_eval)
|
, m_contains_direct_call_to_eval(contains_direct_call_to_eval)
|
||||||
, m_is_arrow_function(is_arrow_function)
|
, m_is_arrow_function(is_arrow_function)
|
||||||
|
, m_kind(kind)
|
||||||
{
|
{
|
||||||
// NOTE: This logic is from OrdinaryFunctionCreate, https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
|
// NOTE: This logic is from OrdinaryFunctionCreate, https://tc39.es/ecma262/#sec-ordinaryfunctioncreate
|
||||||
|
|
||||||
|
|
|
@ -102,30 +102,31 @@ private:
|
||||||
|
|
||||||
ThrowCompletionOr<void> function_declaration_instantiation(Interpreter*);
|
ThrowCompletionOr<void> function_declaration_instantiation(Interpreter*);
|
||||||
|
|
||||||
// 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]]
|
|
||||||
|
|
||||||
FlyString m_name;
|
FlyString m_name;
|
||||||
Optional<Bytecode::Executable> m_bytecode_executable;
|
Optional<Bytecode::Executable> m_bytecode_executable;
|
||||||
i32 m_function_length { 0 };
|
i32 m_function_length { 0 };
|
||||||
FunctionKind m_kind { FunctionKind::Normal };
|
|
||||||
bool m_might_need_arguments_object { true };
|
// Internal Slots of ECMAScript Function Objects, https://tc39.es/ecma262/#table-internal-slots-of-ecmascript-function-objects
|
||||||
bool m_contains_direct_call_to_eval { true };
|
Environment* m_environment { nullptr }; // [[Environment]]
|
||||||
bool m_is_arrow_function { false };
|
PrivateEnvironment* m_private_environment { nullptr }; // [[PrivateEnvironment]]
|
||||||
bool m_has_simple_parameter_list { false };
|
Vector<FunctionNode::Parameter> const m_formal_parameters; // [[FormalParameters]]
|
||||||
|
NonnullRefPtr<Statement> m_ecmascript_code; // [[ECMAScriptCode]]
|
||||||
|
Realm* m_realm { nullptr }; // [[Realm]]
|
||||||
|
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
|
||||||
|
Object* m_home_object { nullptr }; // [[HomeObject]]
|
||||||
|
String m_source_text; // [[SourceText]]
|
||||||
|
Vector<InstanceField> m_fields; // [[Fields]]
|
||||||
|
Vector<PrivateElement> m_private_methods; // [[PrivateMethods]]
|
||||||
|
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]]
|
||||||
|
|
||||||
|
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 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue