Repository navigation
[JSC] Load each private name once in straight-line bytecode - #76308
Open
sosukesuzuki wants to merge 1 commit into
Open
sosukesuzuki wants to merge 1 commit into
sosukesuzuki wants to merge 1 commit into
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 35b4a4f) Details |
sosukesuzuki
marked this pull request as draft
October 8, 2026 12:37
https://bugs.webkit.org/show_bug.cgi?id=326801 Reviewed by NOBODY (OOPS!). Every private field access loads the private name symbol from the class scope with resolve_scope and get_from_scope, so `this.#x * other.#x` loads the same symbol twice. This patch keeps a loaded private name in a register and reuses it until a label is emitted, since code after a label can be reached without passing the load. The registers are reserved when BytecodeGenerator is constructed, so they sit below the temporaries used by expressions and are neither interleaved with the operands of new_array or strcat nor overwritten by a callee frame. To know how many to reserve, the parser counts the private names used by the function. At most 16 registers are reserved, and further names are loaded into a temporary as before. The loaded names are also dropped when a class with private names is entered or left, since it may declare the same name. m_seenPrivateNameUseInNonReparsingFunctionMode is renamed to m_seenPrivateNameUse because it is now also read while reparsing a function. Test: JSTests/stress/private-name-register-reuse.js * JSTests/stress/private-name-register-reuse.js: Added. (shouldBe): (join): (Point): (Point.count): (Point.sub): (Point.prototype.method): (Point.prototype.get accessor): (Point.prototype.dot): (Point.prototype.array): (Point.prototype.template): (Point.prototype.concat): (Point.prototype.call): (Point.prototype.nestedCall): (Point.prototype.acrossCall): (Point.prototype.spread): (Point.prototype.construct): (Point.prototype.conditional): (Point.prototype.branch): (Point.prototype.logical): (Point.prototype.optional): (Point.prototype.loop): (Point.prototype.labeled): (Point.prototype.select): (Point.prototype.tryCatch): (Point.prototype.tryFinally): (Point.prototype.has): (Point.prototype.write): (Point.prototype.swap): (Point.prototype.mixed): (Point.prototype.generator): (Point.prototype.async asynchronous): (Point.prototype.arrow): (Point.prototype.defaultParameter): (Point.prototype.evaluate): (Point.prototype.shadow.try.Inner): (Point.prototype.shadow): (Many.prototype.sum): (Many.prototype.array): (Many): (testStraightLine): (testCalls): (testControlFlow): (i.p.asynchronous.then): * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::GenericLabel<JSGeneratorTraits>::setLocation): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitLoadPrivateName): (JSC::BytecodeGenerator::pushPrivateAccessNames): (JSC::BytecodeGenerator::popPrivateAccessNames): * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::invalidateLoadedPrivateNames): * Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp: (JSC::BaseDotNode::emitGetPropertyValue): (JSC::BaseDotNode::emitPutProperty): (JSC::PostfixNode::emitDot): (JSC::PrefixNode::emitDot): (JSC::InNode::emitBytecode): (JSC::DefineFieldNode::emitBytecode): * Source/JavaScriptCore/parser/Nodes.h: (JSC::ScopeNode::usedPrivateNameCount const): (JSC::ScopeNode::setUsedPrivateNameCount): * Source/JavaScriptCore/parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseBinaryExpression): (JSC::Parser<LexerType>::parseMemberExpression): * Source/JavaScriptCore/parser/Parser.h: (JSC::Parser<LexerType>::parse):
sosukesuzuki
force-pushed
the
eng/load-each-private-name-once-in-straight-line-bytecode
branch
from
October 9, 2026 05:20
35b4a4f to
302131c
Compare
Collaborator
|
EWS run on current version of this PR (hash 302131c) Details |
sosukesuzuki
marked this pull request as ready for review
October 9, 2026 05:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
302131c
302131c