LibJS: Wire NewClass to ClassBlueprint

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.
This commit is contained in:
Andreas Kling
2026-02-11 00:28:10 +01:00
committed by Andreas Kling
parent fa6a3f31dc
commit ec2f4e4a7b
Notes: github-actions[bot] 2026-02-11 23:01:20 +00:00
10 changed files with 157 additions and 38 deletions

View File

@@ -18,17 +18,17 @@ JS bytecode executable "array_destructuring_with_class_default"
[ 70] JumpFalse condition:reg6, target:@98
[ 80] 1: Mov dst:reg11, src:Undefined
[ 90] Jump target:@98
[ 98] 2: JumpUndefined condition:reg11, true_target:@a8, false_target:@108
[ 98] 2: JumpUndefined condition:reg11, true_target:@a8, false_target:@100
[ a8] 3: CreateLexicalEnvironment dst:reg12, parent:reg4, capacity:0
[ b8] CreateVariable identifier:C, is_immutable:true, is_global:false, is_strict:false
[ c8] SetLexicalEnvironment environment:reg4
[ d0] NewClass dst:reg13, class_environment:reg12
[ f8] Mov dst:reg11, src:reg13
[ 108] 4: Mov dst:x~0, src:reg11
[ 118] JumpFalse condition:reg6, target:@130
[ 128] 5: Return value:x~0
[ 130] 6: IteratorClose iterator_object:reg7, iterator_next:reg8, iterator_done:reg9
[ 150] Return value:x~0
[ d0] NewClass dst:reg13, class_environment:reg12, class_blueprint_index:0
[ f0] Mov dst:reg11, src:reg13
[ 100] 4: Mov dst:x~0, src:reg11
[ 110] JumpFalse condition:reg6, target:@128
[ 120] 5: Return value:x~0
[ 128] 6: IteratorClose iterator_object:reg7, iterator_next:reg8, iterator_done:reg9
[ 148] Return value:x~0
JS bytecode executable "object_destructuring_with_function_default"
[ 0] 0: GetLexicalEnvironment dst:reg4