mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 21:12:08 +02:00
Replace the ClassExpression const& reference in the NewClass instruction with a u32 class_blueprint_index. The interpreter now reads from the ClassBlueprint stored on the Executable and calls construct_class() instead of the AST-based create_class_constructor(). Literal field initializers (numbers, booleans, null, strings, negated numbers) are used directly in construct_class() without creating an ECMAScriptFunctionObject, avoiding function creation overhead for common field patterns like `x = 0` or `name = "hello"`. Set class_field_initializer_name on SharedFunctionInstanceData at codegen time for statically-known field keys (identifiers, private identifiers, string literals, and numeric literals). For computed keys, the name is set at runtime in construct_class(). ClassExpression AST nodes are no longer referenced from bytecode.
33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
JS bytecode executable ""
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] GetGlobal dst:reg6, identifier:console
|
|
[ 18] GetById dst:reg7, base:reg6, property:log, base_identifier:console
|
|
[ 30] GetGlobal dst:reg9, identifier:classWithName
|
|
[ 40] Call dst:reg8, callee:reg9, this_value:Undefined, classWithName
|
|
[ 60] Call dst:reg5, callee:reg7, this_value:reg6, console.log, arguments:[reg8]
|
|
[ 88] End value:reg5
|
|
|
|
JS bytecode executable "classWithName"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 18] CreateVariable identifier:Foo, is_immutable:true, is_global:false, is_strict:false
|
|
[ 28] SetLexicalEnvironment environment:reg4
|
|
[ 30] NewClass dst:C~0, class_environment:reg5, class_blueprint_index:0, element_keys:[element_keys:String("method")]
|
|
[ 58] Mov dst:reg7, src:C~0
|
|
[ 68] CallConstruct dst:reg6, callee:reg7, C
|
|
[ 80] GetById dst:reg7, base:reg6, property:method
|
|
[ 98] Call dst:reg5, callee:reg7, this_value:reg6, <object>.method
|
|
[ b8] StrictlyEquals dst:reg7, lhs:reg5, rhs:C~0
|
|
[ c8] Return value:reg7
|
|
|
|
JS bytecode executable "Foo"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] End value:Undefined
|
|
|
|
JS bytecode executable "method"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] GetBinding dst:reg5, identifier:Foo
|
|
[ 20] Return value:reg5
|
|
|
|
true
|