Optimize {__proto__:null} object literal creation#1118
Merged
bnoordhuis merged 1 commit intoquickjs-ng:masterfrom Jul 28, 2025
Merged
Optimize {__proto__:null} object literal creation#1118bnoordhuis merged 1 commit intoquickjs-ng:masterfrom
bnoordhuis merged 1 commit intoquickjs-ng:masterfrom
Conversation
Speeds up the common pattern of creating prototype-less objects by 40%:
TEST N TIME (ns) REF (ns) SCORE (%)
object_null 20000 124.50
TEST N TIME (ns) REF (ns) SCORE (%)
object_null 50000 74.30
It's so much faster the benchmarker decides to run it 50,000 times
instead of merely 20,000 times. Win.
bnoordhuis
commented
Jun 30, 2025
| goto exception; | ||
| break; | ||
| case OP_SPECIAL_OBJECT_NULL_PROTO: | ||
| *sp++ = JS_NewObjectProtoClass(ctx, JS_NULL, JS_CLASS_OBJECT); |
Contributor
Author
There was a problem hiding this comment.
I tried caching the shape for prototype-less objects on the JSContext (like it's done for ctx->array_shape) and calling JS_NewObjectFromShape(ctx, js_dup_shape(ctx->null_proto_shape), JS_CLASS_OBJECT) but it has no measurable impact on the micro-benchmark.
Contributor
Author
|
Ping @saghul |
saghul
approved these changes
Jul 28, 2025
mochaaP
added a commit
to mcha-forks/quickjs
that referenced
this pull request
Oct 11, 2025
fixup: 0a00011 ("Optimize {__proto__:null} object literal creation", quickjs-ng#1118)
mochaaP
added a commit
to mcha-forks/quickjs
that referenced
this pull request
Oct 14, 2025
fixup: 0a00011 ("Optimize {__proto__:null} object literal creation", quickjs-ng#1118)
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.
Speeds up the common pattern of creating prototype-less objects by 40%:
It's so much faster the benchmarker decides to run it 50,000 times instead of merely 20,000 times. Win.