-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
src: remove calls to deprecated v8 functions (IntegerValue) #22129
Conversation
src/node.cc
Outdated
@@ -3123,11 +3123,9 @@ void DebugProcess(const FunctionCallbackInfo<Value>& args) { | |||
return env->ThrowError("Invalid number of arguments."); | |||
} | |||
|
|||
pid_t pid; | |||
int r; | |||
pid_t pid = args[0].As<Integer>()->Value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add CHECK(args[0]->IsInteger());
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no v8::Value::IsInteger
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I looked at V8's implementation of the Integer
class and here is what I found:
Integer::Value()
can be called on anyNumber
. The value is cast toint64_t
..As<Integer>()
can also be called on anyNumber
. The CheckCast doesobj->IsNumber()
.
src/node_buffer.cc
Outdated
@@ -172,7 +172,7 @@ inline MUST_USE_RESULT bool ParseArrayIndex(Local<Value> arg, | |||
return true; | |||
} | |||
|
|||
int64_t tmp_i = arg->IntegerValue(); | |||
int64_t tmp_i = arg.As<Integer>()->Value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ditto, and everywhere else where it’s not obvious that the value already is an integer)
src/process_wrap.cc
Outdated
int fd = static_cast<int>(stdio->Get(context, fd_key) | ||
.ToLocalChecked() | ||
.As<Integer>() | ||
->Value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be checked first before converting, I’d say.
lib/buffer.js
Outdated
@@ -779,6 +779,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
|
|||
function slowIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
var loweredCase = false; | |||
byteOffset = +byteOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already done inside of bidirectionalIndexOf
2d67e9f
to
778ffc7
Compare
@addaleax I think this one is also ready. Copying my inline response from yesterday: So, I looked at V8's implementation of the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but casting Number to Integer seems like relying on V8 implementation details, even if it currently works.
I would feel more comfortable if we could add this pattern to the V8 API cctest suite first?
src/node.cc
Outdated
@@ -2565,7 +2563,8 @@ static void DebugProcess(const FunctionCallbackInfo<Value>& args) { | |||
goto out; | |||
} | |||
|
|||
pid = (DWORD) args[0]->IntegerValue(); | |||
CHECK(args[0]->IsNumber()); | |||
DWORD pid = (DWORD) args[0].As<Integer>()->Value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you happen to be able to test it on Windows without much extra work – I think the cast here is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It compiles fine, thanks
I created a CL to add cctests: https://chromium-review.googlesource.com/c/v8/v8/+/1200983 |
@targos Thank you :) |
Needs a rebase now unfortunately. |
Remove all calls to deprecated v8 functions (here: Value::IntegerValue) inside the code (src directory only). Co-authored-by: Michaël Zasso <targos@protonmail.com>
e59d646
to
76e79b1
Compare
Rebased |
The V8 CL landed. This is ready. New CI: https://ci.nodejs.org/job/node-test-pull-request/17025/ Edit: Windows rebuild: https://ci.nodejs.org/job/node-test-commit-windows-fanned/20550/ |
Landed in f464ac3 |
Remove all calls to deprecated v8 functions (here: Value::IntegerValue) inside the code (src directory only). Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #22129 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::IntegerValue) inside the code (src directory only). Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #22129 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::IntegerValue) inside the code (src directory only). Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #22129 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2555cb4 introduced a crash when a non-number value was passed to `ParseArrayIndex()`. We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable. Refs: nodejs#22129 Fixes: nodejs#23668
2555cb4 introduced a crash when a non-number value was passed to `ParseArrayIndex()`. We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable. Refs: nodejs#22129 Fixes: nodejs#23668
2555cb4 introduced a crash when a non-number value was passed to `ParseArrayIndex()`. We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable. Refs: #22129 Fixes: #23668 PR-URL: #25154 Reviewed-By: James M Snell <jasnell@gmail.com>
2555cb4 introduced a crash when a non-number value was passed to `ParseArrayIndex()`. We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable. Refs: #22129 Fixes: #23668 PR-URL: #25154 Reviewed-By: James M Snell <jasnell@gmail.com>
2555cb4 introduced a crash when a non-number value was passed to `ParseArrayIndex()`. We do not always have JS typechecking for that in place, though. This returns back to the previous behavior of coercing values to integers, which is certainly questionable. Refs: nodejs#22129 Fixes: nodejs#23668 PR-URL: nodejs#25154 Reviewed-By: James M Snell <jasnell@gmail.com>
Remove all calls to deprecated v8 functions (here:
Value::IntegerValue) inside the code (src directory only).
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes/cc @addaleax @hashseed