buffer: Prevent Buffer constructor deopt#4158
Closed
brycebaril wants to merge 1 commit intonodejs:masterfrom
Closed
buffer: Prevent Buffer constructor deopt#4158brycebaril wants to merge 1 commit intonodejs:masterfrom
brycebaril wants to merge 1 commit intonodejs:masterfrom
Conversation
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt.
Contributor
|
LGTM |
Member
|
LGTM. Good catch. |
Contributor
|
LGTM. Obligatory CI: https://ci.nodejs.org/job/node-test-pull-request/926/ |
Member
|
LGTM as CI is happy :) |
Member
|
+1 go for it @JungMinu |
JungMinu
pushed a commit
that referenced
this pull request
Dec 5, 2015
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: #4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Member
|
Thanks, landed in 7239494 |
rvagg
pushed a commit
that referenced
this pull request
Dec 8, 2015
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: #4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
This was referenced Dec 8, 2015
Closed
MylesBorins
pushed a commit
that referenced
this pull request
Dec 29, 2015
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: #4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Jan 19, 2016
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: #4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Merged
Contributor
|
Wow, does passing arguments[n] really deopt? That's amazing. We have a lot of these cases, in order of level of concern (imho) in:
Those should all be addressed then, no? |
Contributor
|
only if n >= arguments.length |
Contributor
|
Aaah, understood. Thank you. No cause for alarm then I guess. |
scovetta
pushed a commit
to scovetta/node
that referenced
this pull request
Apr 2, 2016
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: nodejs#4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
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.
The Buffer constructor will generally get inlined, but any call to the Buffer
constructor for a string without encoding will cause an eager deoptimization
of any function that inlined the Buffer constructor. This is due to a an
out-of-bounds read on
arguments[1]. This change prevents that deopt.This example script demonstrates the deoptimization:
If run with
--trace-deopt:Here is the output of IRHydra showing the deopts:
We can see that the Buffer constructor has been inlined:

The inlined Buffer constructor has been deoptimized due to

arguments[1]out-of-bounds read:After this patch, the Buffer constructor no longer will get deoptimized for out-of-bounds arguments reads:
(no output)
cc: @trevnorris