Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b6a9b84dae1faa215e4deb5a9f5932aee10d12e5
      
https://github.com/WebKit/WebKit/commit/b6a9b84dae1faa215e4deb5a9f5932aee10d12e5
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-09 (Tue, 09 Jun 2026)

  Changed paths:
    A JSTests/microbenchmarks/class-fields-anonymous-arrow-function-fields.js
    A JSTests/stress/class-fields-anonymous-function-name-edge-cases.js
    A JSTests/stress/class-fields-anonymous-function-name-inference.js
    M Source/JavaScriptCore/parser/ASTBuilder.h
    M Source/JavaScriptCore/parser/Parser.cpp

  Log Message:
  -----------
  [JSC] Set class field function names at parse time instead of via 
`SetFunctionName`
https://bugs.webkit.org/show_bug.cgi?id=316646

Reviewed by Yusuke Suzuki.

Anonymous functions and classes in class field initializers get their names
via op_set_function_name, which eagerly reifies the "name" property on every
closure created each time an instance is constructed (FunctionRareData +
JSString + butterfly per function-valued field). Object literal properties and
assignments already avoid this by inferring the name at parse time, but class
fields miss that inference because their initializers are re-parsed separately
via parseClassFieldInitializerSourceElements.

Apply the same ecmaName inference in ASTBuilder::createDefineField for
non-computed field names, so no op_set_function_name is emitted and "name" is
reified lazily like any named function. Also iterate class element definitions
by reference, since ClassExprNode::setEcmaName captures a pointer to the
identifier. The inferred name now also becomes visible to static member
initializers per spec.

                                        baseline                 parseronly
class-fields-anonymous-arrow-function-fields
                                    43.1214+-0.3197     ^      4.6281+-0.1775   
 ^ definitely 9.3172x faster

Tests: JSTests/microbenchmarks/class-fields-anonymous-arrow-function-fields.js
       JSTests/stress/class-fields-anonymous-function-name-edge-cases.js
       JSTests/stress/class-fields-anonymous-function-name-inference.js

* JSTests/microbenchmarks/class-fields-anonymous-arrow-function-fields.js: 
Added.
(bench):
* JSTests/stress/class-fields-anonymous-function-name-edge-cases.js: Added.
(shouldBe):
(shouldBe.O):
(prototype.shouldBe.O.prototype.string_appeared_here):
(prototype.shouldBe.O):
(prototype.shouldBe):
(prototype.shouldBe.O.prototype.p):
(prototype.shouldBe.O.prototype.t.true):
(prototype.shouldBe.O.prototype.a):
(prototype.shouldBe.O.async g):
(prototype.shouldBe.O.ag):
(prototype.shouldBe.O.async af):
(O.inner):
(O):
(prototype.shouldBe.make.D):
(prototype.throw.new.Error.makeClass.return.f):
(prototype.throw.new.Error.makeClass):
(prototype.throw.new.Error):
(prototype.shouldBe.Base):
* JSTests/stress/class-fields-anonymous-function-name-inference.js: Added.
(shouldBe):
(C.g):
(C.n):
(C.prototype.getP):
(prototype.shouldBe):
(prototype.shouldBe.S):
(prototype.shouldBe.make.D):
(prototype.shouldBe.make):
(prototype.shouldBe.E.m):
(prototype.shouldBe.E):
(prototype.shouldBe.F):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createDefineField):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):

Canonical link: https://commits.webkit.org/314873@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to