Repository navigation
Conversation
getPropertyNameIDs returns the names of the enumerable properties of an object as PropNameIDs, in the order of getPropertyNames, without creating a JS array. It's an IRuntime method with a default implementation in jsi::Runtime, built on getPropertyNames, like getStringData. The decorators forward it, and TracingRuntime uses the default implementation, so traces record the calls that it's equivalent to. Hermes keeps the for-in names of ordinary objects as symbols, so it returns them directly instead of converting them to strings, and the property values can be read with getProperty(PropNameID) without converting the names back.
tsapeta
force-pushed
the
tsapeta/property-name-ids
branch
from
November 13, 2026 10:27
6102915 to
9026353
Compare
Object::getPropertyNameIDs to JSI
tsapeta
marked this pull request as ready for review
November 13, 2026 11:18
Contributor
|
This breaks the ABI like #2319. Worth discussing whether two separate calls for essentially the same thing are needed. |
tsapeta
marked this pull request as draft
November 13, 2026 17:58
This branch has not been 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
React Native reads every props object with
Object::getPropertyNames, thengetValueAtIndex,getString,getProperty(String)andutf8for each name. In Hermes, for-in keeps the names of ordinary objects as symbols, so this converts each symbol to a string, wraps it in a JS array, reads it back, and converts the string to a symbol again for the property lookup.This adds
getPropertyNameIDsto JSI:It returns the same names as
getPropertyNames, in the same order, asPropNameIDs and without a JS array.getStringDataandsetPrototypeOf: anIRuntimemethod with a default implementation injsi::Runtime(jsi.cpp), built ongetPropertyNames, so every runtime has it.RuntimeDecoratorforwards it, andWithRuntimeDecoratorforwards it insideAround, so the thread-safe runtime takes its lock.TracingRuntimeuses the default implementation, so a trace records thegetPropertyNamesand other calls that it's equivalent to, and replay doesn't need a new event.stringToSymbolID(index keys withnumberToStringPrimitivefirst). The values can then be read withgetProperty(PropNameID), which looks the symbol up directly.#2319 (
forEachProperty) adds a walk that also reads the values and gives UTF-8 names, for callers that read each name once. This one is for callers that keep the names, for example to read the same properties again withgetProperty.Test Plan
JSITest.GetPropertyNameIDsTestinjsi/test/testlib.cpp, for the runtime's implementation and, through aRuntimeDecorator, for the default one: for objects with string, index, non-ASCII, symbol, inherited, getter and non-enumerable properties, an array and an empty object, the names andgetPropertyvalues are the same as withgetPropertyNames.APITests: all 439 tests pass.hermesABIRuntimeWrapper,hermesSandboxRuntime,synthTraceandtraceInterpreterbuild.APITests(macOS host, Release, median of 9 samples of 200,000 iterations, not part of this PR) for the walk React Native does: names, values and UTF-8 names, on objects with number-valued props.makeHermesRuntimemakeThreadSafeHermesRuntimegetPropertyNames+ strings, 1 propgetPropertyNameIDs, 1 propgetPropertyNames+ strings, 6 propsgetPropertyNameIDs, 6 propsgetPropertyNames+ strings, 20 propsgetPropertyNameIDs, 20 props#2317 makes the
getPropertyNameswalk about 45% faster on its own; with both, thePropNameIDwalk is still about a third faster than the string walk.