-
Notifications
You must be signed in to change notification settings - Fork 570
syscalls: move away from deprecated CloneElementAt #810
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
Conversation
@neelance - would appreciate if you had a couple of minutes spare to look this over. @shurcooL @hajimehoshi - this PR is also ready for review. |
I'm not familiar with node details, so I'd like to defer to other reviewers on this :-) |
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.
Thanks for working on this! Just a few comments for things I could spot.
Does anyone know where the syscall.cc
code comes from? Is there an "upstream" version of it? Knowing if that's the case could make reviewing this easier.
node-syscall/syscall.cc
Outdated
@@ -25,7 +25,17 @@ intptr_t toNative(Local<Value> value) { | |||
Local<Array> array = Local<Array>::Cast(value); | |||
intptr_t* native = reinterpret_cast<intptr_t*>(malloc(array->Length() * sizeof(intptr_t))); // TODO memory leak | |||
for (uint32_t i = 0; i < array->Length(); i++) { | |||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION) | |||
v8::Local<v8::Value> elem = array->Get(i); |
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 file does using namespace v8;
on top, and 4 lines above we have Local<Array> array
instead of v8::Local<v8::Array> array
, etc.
So I think it'd be better to be consistent and drop the namespace here as well:
Local<Value> elem = array->Get(i);
Similarly on another line below.
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.
Fixed.
node-syscall/syscall.cc
Outdated
@@ -25,7 +25,17 @@ intptr_t toNative(Local<Value> value) { | |||
Local<Array> array = Local<Array>::Cast(value); | |||
intptr_t* native = reinterpret_cast<intptr_t*>(malloc(array->Length() * sizeof(intptr_t))); // TODO memory leak | |||
for (uint32_t i = 0; i < array->Length(); i++) { | |||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION) |
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.
What's the difference between NODE_MODULE_VERSION
(here) and NODE_MAJOR_VERSION
(above, on line 10)? Is it better to use NODE_MODULE_VERSION
here?
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.
I honestly don't know; rather pattern matching when it comes to C++... I've switched to using NODE_MAJOR_VERSION
No, I don't, hence why I pinged @neelance in case he had a couple of minutes to review. I've just pushed up a couple of fixes in response to your comments. Given the tests pass, which make fairly heavy use of this layer, I think we can be fairly confident the fix is "good enough". |
I wrote the Is it even necessary to do the |
I'm really unsure; I would defer to you on that question 😄 I've pushed up accaa71 in an attempt to see whether the clone is required or not, at least against the reference that is our CI test suite. |
I honestly don't know without looking into it some more. |
FWIW I dig into syscall.cc and see no reason to use a Clone(). Get() seems fine. My C++ is pretty rusty, but it looks like Get() returns a |
Node.js 10.5.0 is the latest current version according to https://nodejs.org/en/download/current/.
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.
Thanks for the investigation and the fix. Sorry about the delay.
I've tested it and didn't find any issues. LGTM.
CI tests are all passing, except:
$ diff -u <(echo -n) <(git status --porcelain)
--- /dev/fd/63 2018-06-28 18:30:03.118797187 +0000
+++ /dev/fd/62 2018-06-28 18:30:03.118797187 +0000
@@ -0,0 +1 @@
+ M package-lock.json
diff -u <(echo -n) <(git status --porcelain) returned exit code 1
That's not happening on master
.
The diff I get after running diff --git a/package-lock.json b/package-lock.json
index ed79b7a..6118aad 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,8 +21,8 @@
"integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==",
"dev": true,
"requires": {
- "commander": "2.13.0",
- "source-map": "0.6.1"
+ "commander": "~2.13.0",
+ "source-map": "~0.6.1"
}
}
} |
I guess I'll go with |
We don't want npm install to be saving to dependencies and modifying package-lock.json in CI. That should only be done by developers locally. Reference: https://docs.npmjs.com/cli/install.
We don't want the inferred npm install command to run without --no-save.
Node.js 10.0.5 comes with a newer npm which causes package-lock.json to be modified after npm install runs. Just use 10.0.0 for now where that doesn't happen.
Ended up going back to Node.js 10.0.0 which doesn't cause |
govendor fetch +vendor +modified This pulls in gopherjs/gopherjs#810 for gopherjs to fix the build.
We currently use Node 6.2.2 in CI for our
gopherjs test
runs.Ever since the start of the Node 6.x series,
v8::Array::CloneElementAt
has been deprecated; here's an example from our most recentmaster
build:Per #809, in Node 10.x they have finally removed this method and hence attempts to follow the syscall steps fail with:
This PR therefore drops our usage of the deprecated method, instead preferring to use
v8::Object::Clone()
as required.My C++ skills are however sorely lacking... so perhaps @neelance can offer some thoughts here (given I assume he originated the code?)
We also bump to using Node 10.x in the CI which brings us up-to-date and helps to verify the fix (all the tests pass).
Fixes #809