refactor(pass-style): faster isObject#2860
Merged
Merged
Conversation
9771078 to
3859088
Compare
This was referenced Jun 16, 2025
gibson042
approved these changes
Jun 23, 2025
gibson042
left a comment
Member
There was a problem hiding this comment.
This change has minor impact in V8, but Object(value) must be very slow in XS because the speedup there is significant.
kriskowal
approved these changes
Jun 23, 2025
isObject
3859088 to
c68c807
Compare
erights
commented
Jun 24, 2025
|
|
||
|
|
||
| const { details: X, Fail } = assert; | ||
| export { X, Fail } from '@endo/errors'; |
Contributor
Author
There was a problem hiding this comment.
This is a pure-refactor drive-by
erights
commented
Jun 24, 2025
| // Note that this step will fail if `specimen` would be a passable container | ||
| // except that it contains non-passable errors that could be converted. | ||
| // This will need to be fixed to do the TODO above. | ||
| const passStyle = /** @type {PassStyle} */ (passStyleOf(specimen)); |
Contributor
Author
There was a problem hiding this comment.
Moving the call to passStyleOf inside the conditional is a drive-by. But typescript's imprecision about the negation of an is result type provoked the extra cast.
erights
commented
Jun 24, 2025
| /** | ||
| * The actual JS primitive types. | ||
| */ | ||
| export type JSPrimitive = |
Contributor
Author
There was a problem hiding this comment.
Made it easier to define the type of isPrimitive.
erights
commented
Jun 24, 2025
| if (!isObject(obj)) { | ||
| throw TypeError(`Object expected: ${path}, ${obj}, ${protoName}`); | ||
| if (isPrimitive(obj)) { | ||
| throw TypeError(`Object expected: ${path}, ${String(obj)}, ${protoName}`); |
Contributor
Author
There was a problem hiding this comment.
The better typing of isPrimitive (thanks @gibson042) provoked typescript into reporting this genuine bug as a type error. So this bug fix is more than a drive-by.
c68c807 to
ccbf2e5
Compare
erights
added a commit
that referenced
this pull request
Jul 16, 2025
Closes: #XXXX Refs: #2860 ## Description #2860 deprecated `isObject` as confusing and promoted use of `isPrimitive` instead. However, it also made the type of `isObject` more precise, which accidentally broken a bunch of client code in agoric-sdk (and possibly elsewhere) that relied on the type being less precise. Since `isObject` is now deprecated and all clients should eventually switch to `!isPrimitive` anyway, it costs nothing to lose this extra type precision of `isObject`. This PR restores the old imprecise type. ### Security Considerations none ### Scaling Considerations none ### Documentation Considerations none ### Testing Considerations none ### Compatibility Considerations The point. This PR restores the compatibility that #2860 accidentally broke. ### Upgrade Considerations none
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.
Closes: #XXXX
Refs: Agoric/agoric-sdk#11497
Description
Experiment with possible endo speedups. This was originally motivated to try for fewer benchmark errors in Agoric/agoric-sdk#11497 vs Agoric/agoric-sdk#11459 . However, the relevant bottleneck for those, while still not diagnosed, is not addressed or affected by this PR.
Nevertheless, according to @gibson042 's comment at #2860 (review) below
Since we care most of all about performance in XS, this change is worth it.
Security Considerations
none
Scaling Considerations
No change to complexity measure, so no change to "scaling" per se. But more colloquially, we include in "scaling" a significant performance improvement.
Documentation Considerations
In light of @gibson042 's suggestion below, this PR will deprecate
isObject, exportisPrimitiveas the inverted replacement, because the name is clearer, and will switch all current callers ofisObjectto callisPrimitiveinstead. This should be reflected in the generated typedoc commentary.Testing Considerations
None.
Compatibility Considerations
Because we're only deprecating
isObject, and because we make no change to its observable behavior, none.Upgrade Considerations
NEWS.mdwithisPrimitiveand the deprecation ofisObject.