Repository navigation
Conversation
`createPropNameIDFromAscii` and `createPropNameIDFromUtf8` made a string on the GC heap for every call, and then looked it up in the identifier table. When the name was already an identifier, the string was garbage at once. When the name was new, `getOrCreateIdentifier` copied it into a second new string, so the first one was garbage too. `createPropNameIDFromAscii` now looks up the name with `IdentifierTable::getSymbolID`, which makes a string only for a new name. `createPropNameIDFromUtf8` sends an ASCII name to the same path. `PropNameID::forAscii` for a known name goes from 22.6 ns to 16.2 ns, and `PropNameID::forUtf8` from 21.9 ns to 18.4 ns (Release build, Apple M2 Pro).
`createPropNameIDFromAscii` makes no handles now, so its `GCScope` is not used: - `getSymbolID` passes a null handle to `getOrCreateIdentifier`. - `allocateDynamicString` has its own `GCScope` for a new name. - `throwPendingError` has its own `GCScope` for an error. `PropNameID::forAscii` for a known name goes from 15.6 ns to 13.4 ns, and `PropNameID::forUtf8` from 17.6 ns to 15.3 ns (Release build, Apple M2 Pro).
`createPropNameIDFromUtf8` sends a name to the ASCII path when `isAllASCII` says that it is ASCII. `isAllASCII` has separate code for names of up to 4 bytes, up to 16 bytes, and longer names, but the test had only one short non-ASCII name. The new test puts one non-ASCII character at each position of names of up to 40 characters, and checks each name against UTF-16 that the test builds itself. It also checks a non-ASCII name that JS made first, and that invalid UTF-8 still stops the name before the first invalid code point.
tsapeta
marked this pull request as ready for review
November 21, 2026 21:36
This branch was successfully deployed
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.
Summary
createPropNameIDFromAsciiandcreatePropNameIDFromUtf8made a string on the GC heap for every call, and then looked it up in the identifier table. For a known name, that string was garbage at once. For a new name,getOrCreateIdentifiercopied it into a second string, so the first one was garbage too.createPropNameIDFromAsciinow looks up the name withIdentifierTable::getSymbolID, which makes a string only for a new name. The lookup makes no handles, so the function no longer has aGCScope.createPropNameIDFromUtf8sends an ASCII name to the same path. Other UTF-8 names use the old code, after the ASCII check, which makes them 0.3% to 1.6% slower on Android.Time to create a
PropNameIDand release it, as the median of interleaved runs of the old and new library:MinSizeRel, LTO,HEAP_HV_PREFER32)."a", already an identifier, also compared with anotherPropNameID(6 runs). New name: 16 bytes, not an identifier yet, each case in its own process (10 runs).forAscii, known nameforUtf8, known nameforAscii, new nameforUtf8, new name¹ Within noise.
Test Plan
HermesRuntimeTest.PropNameIDFromAsciiAndUtf8checks a known name, a new name (with a garbage collection while only thePropNameIDrefers to it), and a non-ASCII UTF-8 name against the name that JS uses.HermesRuntimeTest.PropNameIDFromUtf8NonAsciiputs one non-ASCII character at each position of names of up to 40 characters, which covers each branch ofisAllASCII. It also checks invalid UTF-8.APITestspass in the ASan Debug build.