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

[v14.x backport] lib: revert primordials in a hot path #38972

Closed
wants to merge 250 commits into from

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Jun 8, 2021

Evidence has shown that use of primordials have sometimes an impact of
performance. This commit reverts the changes who are most likely to be
responsible for performance regression in the HTTP response path.

PR-URL: #38248
Reviewed-By: Benjamin Gruenbaum benjamingr@gmail.com
Reviewed-By: Matteo Collina matteo.collina@gmail.com
Reviewed-By: Michaël Zasso targos@protonmail.com
Reviewed-By: Rich Trott rtrott@gmail.com

targos and others added 30 commits May 16, 2021 15:10
I added a new custom ESLint rule to fix these problems.

We have a lot of replaceable codes with primordials.
Accessing built-in objects is restricted by existing rule
(no-restricted-globals), but accessing property in the built-in objects
is not restricted right now. We manually review codes that can be
replaced by primordials, but there's a lot of code that actually needs
to be fixed. We have often made pull requests to replace the primordials
with.

Restrict accessing global built-in objects such as `Promise`.
Restrict calling static methods such as `Array.from` or `Symbol.for`.
Don't restrict prototype methods to prevent false-positive.

PR-URL: nodejs#35448
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
PR-URL: nodejs#36017
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Make the linter recommend replacing `globalThis.Map` by
`primordials.SafeMap`, and similar for `Set`, `WeakSet`, and `WeakMap`.

PR-URL: nodejs#36026
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Co-authored-by: Benjamin Gruenbaum <benjamingr@gmail.com>
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: nodejs#36006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Refs: nodejs#35448
Refs: nodejs#36003
Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: nodejs#36016
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
PR-URL: nodejs#36024
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Update ESLint to 7.11.0

PR-URL: nodejs#35578
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Update ESLint to 7.12.0

PR-URL: nodejs#35799
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Update ESLint to 7.12.1

PR-URL: nodejs#35799
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Update ESLint to 7.13.0

PR-URL: nodejs#36031
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This makes sure that all async functions finish as expected.

PR-URL: nodejs#34363
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The result of an async IIFE should always be handled in our tests,
typically by adding `.then(common.mustCall())` to verify that the
async function actually finishes executing at some point.

PR-URL: nodejs#34363
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
It's possible to annotate failures in Actions by printing
"::error file={},line={},col={}::{message}". This methos is preferrable
over using a problem matcher because problem matchers only allow
single-line messages, whereas ::error allows multi-line messages.

PR-URL: nodejs#34590
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Fixes: nodejs#35237

PR-URL: nodejs#35257
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Fixes: nodejs#35740

Refs: nodejs#31553
Refs: nodejs#32953
Refs: nodejs#33991
Refs: nodejs#34001
Refs: nodejs#34055
Refs: nodejs#34962

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Trivikram Kamat <trivikr.dev@gmail.com>
Co-authored-by: Rich Trott <rtrott@gmail.com>

PR-URL: nodejs#34002
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#36003
Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#36025
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#36132
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#36140
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#36167
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
In preparation for a cpplint version bump, move labels to be unindented.
The one space indentation we use now is flagged in cpplint 1.5.2.

Refs: https://softwareengineering.stackexchange.com/q/151806/26510

PR-URL: nodejs#36213
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Update ESLint to 7.14.0

PR-URL: nodejs#36217
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This rule is new in ESLint 7.14.0.

PR-URL: nodejs#36217
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This is done to avoid creating an array and gain performance.

Co-authored-by: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>

PR-URL: nodejs#36221
Refs: https://v8.dev/blog/v8-release-80#optimizing-higher-order-builtins
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Adds methods for fetching stack trace information about
enclosing function.

Refs nodejs#36042

Original commit message:

    Reland "stack-trace-api: implement getEnclosingLine/Column"

    This reverts commit 5557a63beb5a53c93e9b590eaf2933e21bcb3768.

    Reason for revert: Sheriff's mistake, failing test was previously flaking.

    Original change's description:
    > Revert "stack-trace-api: implement getEnclosingLine/Column"
    >
    > This reverts commit c48ae2d96cbfdc2216706a5e9a79ae1dce5a638b.
    >
    > Reason for revert: Breaks a profiling test:
    > https://ci.chromium.org/p/v8/builders/ci/V8%20Win32/30010
    >
    > Original change's description:
    > > stack-trace-api: implement getEnclosingLine/Column
    > >
    > > Introduces getEnclosingColumn and getEnclosingLine on CallSite
    > > so that the position can be used to lookup the original symbol
    > > for function when source maps are used.
    > >
    > > BUG=v8:11157
    > >
    > > Change-Id: I06c4c374d172d206579abb170c7b7a2bd3bb159f
    > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2547218
    > > Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    > > Commit-Queue: Benjamin Coe <bencoe@google.com>
    > > Cr-Commit-Position: refs/heads/master@{#71343}
    >
    > TBR=jkummerow@chromium.org,yangguo@chromium.org,bencoe@google.com
    >
    > Change-Id: Iab5c250c1c4fbdab86971f4a7e40abc8f87cf79c
    > No-Presubmit: true
    > No-Tree-Checks: true
    > No-Try: true
    > Bug: v8:11157
    > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555384
    > Reviewed-by: Bill Budge <bbudge@chromium.org>
    > Commit-Queue: Bill Budge <bbudge@chromium.org>
    > Cr-Commit-Position: refs/heads/master@{#71345}

    TBR=bbudge@chromium.org,jkummerow@chromium.org,yangguo@chromium.org,bencoe@google.com

    # Not skipping CQ checks because this is a reland.

    Bug: v8:11157
    Change-Id: I8dba19ceb29a24594469d2cf79626f741dc4cad3
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555499
    Reviewed-by: Bill Budge <bbudge@chromium.org>
    Commit-Queue: Bill Budge <bbudge@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#71348}

Refs: v8/v8@86991d0

PR-URL: nodejs#36254
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: nodejs#36210
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
PR-URL: nodejs#36272
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#36284
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#36285
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Trott and others added 9 commits June 5, 2021 11:17
PR-URL: nodejs#36235
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Cherry-pick 12c8b4d
Original commit message:
    This commit is a suggestion for adding a rule for NULL usages in the
    code base. This will currently report a number of errors which could be
    ignored using // NOLINT (readability/null_usage)

    PR-URL: nodejs#17373
    Reviewed-By: Jon Moss <me@jonathanmoss.me>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Timothy Gu <timothygu99@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
    Reviewed-By: Tobias Nießen <tniessen@tnie.de>

Refs: nodejs@12c8b4d

Cherry-pick fc81e80
Original commit message:

    Update cpplint.py to check for inline headers when the corresponding
    header is already included.

    PR-URL: nodejs#21521
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: James M Snell <jasnell@gmail.com>

Refs: nodejs@fc81e80

Cherry-pick cbc3dd9
Original commit message:

    src, tools: add check for left leaning pointers

    This commit adds a rule to cpplint to check that pointers in the code
    base lean to the left and not right, and also fixes the violations
    reported.

    PR-URL: nodejs#21010
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
    Reviewed-By: James M Snell <jasnell@gmail.com>

Refs: nodejs@cbc3dd9

Cherry-pick 9029981
Original commit message:

    tools: fix cpplint.py header rules

    THIS COMMIT SHOULD GO WITH THE NEXT. IT WILL FIND NEW LINT.

    PR-URL: nodejs#26306
    Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>

Refs: nodejs@9029981

Cherry-pick 0a25ace
Original commit message:

    tools: move cpplint configuration to .cpplint

    PR-URL: nodejs#27098
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

Refs: nodejs@0a25ace

Cherry-pick afa9a72
Original commit message:

    tools: refloat update link to google styleguide for cpplint

    This commit updates two old links to Google's C++ styleguide which
    currently result in a 404 when accessed.

    PR-URL: nodejs#30876
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: David Carlier <devnexen@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>

Refs: nodejs@afa9a72

Cherry-pick e23bf8f
Original commit message:

    tools,src: refloat forbid usage of v8::Persistent

    `v8::Persistent` comes with the surprising catch that it requires
    manual cleanup. `v8::Global` doesn’t, making it easier to use,
    and additionally provides move semantics. New code should always
    use `v8::Global`.

    PR-URL: nodejs#31018
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: David Carlier <devnexen@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Gus Caplan <me@gus.host>
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>

PR-URL: nodejs#35569
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

PR-URL: nodejs#35719
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: nodejs#35866

PR-URL: nodejs#36213
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>

PR-URL: nodejs#36235
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: nodejs#36324
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Cherry-pick 12c8b4d
Original commit message:
    This commit is a suggestion for adding a rule for NULL usages in the
    code base. This will currently report a number of errors which could be
    ignored using // NOLINT (readability/null_usage)

    PR-URL: nodejs#17373
    Reviewed-By: Jon Moss <me@jonathanmoss.me>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Timothy Gu <timothygu99@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
    Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
    Reviewed-By: Tobias Nießen <tniessen@tnie.de>

Refs: nodejs@12c8b4d

Cherry-pick fc81e80
Original commit message:

    Update cpplint.py to check for inline headers when the corresponding
    header is already included.

    PR-URL: nodejs#21521
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: James M Snell <jasnell@gmail.com>

Refs: nodejs@fc81e80

Cherry-pick cbc3dd9
Original commit message:

    src, tools: add check for left leaning pointers

    This commit adds a rule to cpplint to check that pointers in the code
    base lean to the left and not right, and also fixes the violations
    reported.

    PR-URL: nodejs#21010
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
    Reviewed-By: James M Snell <jasnell@gmail.com>

Refs: nodejs@cbc3dd9

Cherry-pick 9029981
Original commit message:

    tools: fix cpplint.py header rules

    THIS COMMIT SHOULD GO WITH THE NEXT. IT WILL FIND NEW LINT.

    PR-URL: nodejs#26306
    Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>

Refs: nodejs@9029981

Cherry-pick 0a25ace
Original commit message:

    tools: move cpplint configuration to .cpplint

    PR-URL: nodejs#27098
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

Refs: nodejs@0a25ace

Cherry-pick afa9a72
Original commit message:

    tools: refloat update link to google styleguide for cpplint

    This commit updates two old links to Google's C++ styleguide which
    currently result in a 404 when accessed.

    PR-URL: nodejs#30876
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: David Carlier <devnexen@gmail.com>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>

Refs: nodejs@afa9a72

Cherry-pick e23bf8f
Original commit message:

    tools,src: refloat forbid usage of v8::Persistent

    `v8::Persistent` comes with the surprising catch that it requires
    manual cleanup. `v8::Global` doesn’t, making it easier to use,
    and additionally provides move semantics. New code should always
    use `v8::Global`.

    PR-URL: nodejs#31018
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Richard Lau <riclau@uk.ibm.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: David Carlier <devnexen@gmail.com>
    Reviewed-By: Rich Trott <rtrott@gmail.com>
    Reviewed-By: Gus Caplan <me@gus.host>
    Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
    Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
    Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>

PR-URL: nodejs#35569
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>

PR-URL: nodejs#35719
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: nodejs#35866

PR-URL: nodejs#36213
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>

PR-URL: nodejs#36235
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

PR-URL: nodejs#36324
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
This allows to build Node.js at the (temporary) cost of longer build
times.

Refs: nodejs#38872
Refs: https://github.com/dotnet/msbuild/releases/tag/v16.10.0
Refs: dotnet/msbuild#6465
Refs: dotnet/msbuild#6373

PR-URL: nodejs#38873
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Currently, when a JS Http2Session object is created, we have
to handle the situation in which the native object corresponding
to it does not yet exist. As part of that, we create a typed array
for storing options that are passed through the `AliasedStruct`
mechanism, and up until now, we copied that typed array over
the native one once the native one was available.

This was not good, because it was overwriting the defaults that
were set during construction of the native typed array with zeroes.

In order to fix this, create a wrapper for the JS-created typed array
that keeps track of which fields were changed, which enables us to
only overwrite fields that were intentionally changed on the JS side.

It is surprising that this behavior was not tested (which is,
guessing from the commit history around these features, my fault).
The subseqeuent commit introduces a test that would fail without
this change.

PR-URL: nodejs#37875
Backport-PR-URL: nodejs#38673
Fixes: nodejs#37849
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Use the existing mechanism that we have to keep track of invalid frames
for treating this specific kind of invalid frame.

The commit that originally introduced this check was 695e38b,
which was supposed to proected against CVE-2019-9518, which in turn
was specifically about a *flood* of empty data frames. While these are
still invalid frames either way, it makes sense to be forgiving here
and just treat them like other invalid frames, i.e. to allow a small
(configurable) number of them.

Fixes: nodejs#37849

PR-URL: nodejs#37875
Backport-PR-URL: nodejs#38673
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This addresses a TODO comment, and removes invalid `.ToLocalChecked()`
calls from our code base.

PR-URL: nodejs#35486
Backport-PR-URL: nodejs#38786
Reviewed-By: James M Snell <jasnell@gmail.com>
Evidence has shown that use of primordials have sometimes an impact of
performance. This commit reverts the changes who are most likely to be
responsible for performance regression in the HTTP response path.

PR-URL: nodejs#38248
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@github-actions github-actions bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. v14.x labels Jun 8, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 marked this pull request as ready for review June 9, 2021 08:53
@aduh95 aduh95 requested a review from targos June 9, 2021 08:53
@nodejs-github-bot
Copy link
Collaborator

@bmeck
Copy link
Member

bmeck commented Jun 9, 2021

Can we make a V8 issue on this?

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@targos
Copy link
Member

targos commented Jun 11, 2021

Landed in eb8f7ee. Thanks!

targos pushed a commit that referenced this pull request Jun 11, 2021
Evidence has shown that use of primordials have sometimes an impact of
performance. This commit reverts the changes who are most likely to be
responsible for performance regression in the HTTP response path.

PR-URL: #38248
Backport-PR-URL: #38972
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@targos targos closed this Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet