Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: (timers) make arguments array PACKED in all cases #54771

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'use strict';

const {
ArrayPrototypePush,
MathTrunc,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down Expand Up @@ -154,7 +155,7 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 5; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 2] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
Copy link
Member

@RedYetiDev RedYetiDev Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ArrayPrototypePush(args, arguments[i]);
args[args.length] = arguments[i];

Out of curiosity, is this faster?

Copy link
Contributor Author

@gurgunday gurgunday Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect they will all be similar

The goal here is to minimize HOLEY internal arrays and not press on objects too much, it might put stress on other parts of V8

}
break;
}
Expand Down Expand Up @@ -224,7 +225,7 @@ function setInterval(callback, repeat, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 5; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 2] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
}
break;
}
Expand Down Expand Up @@ -296,7 +297,7 @@ function setImmediate(callback, arg1, arg2, arg3) {
args = [arg1, arg2, arg3];
for (i = 4; i < arguments.length; i++) {
// Extend array dynamically, makes .apply run much faster in v6.0.0
args[i - 1] = arguments[i];
ArrayPrototypePush(args, arguments[i]);
}
break;
}
Expand Down
Loading