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

Bug Fix for Issue #17668 - Unused prototype objects from V8 FunctionTemplate initialization #20321

Conversation

brandontruggles
Copy link
Contributor

@brandontruggles brandontruggles commented Apr 26, 2018

For issue #17668. I followed the advice of @TimothyGu to implement this fix. Please let me know if there are any issues, and I will address them as soon as possible.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes

9 JS tests here fail, although they fail when I make a fresh clone of the repo, so I do not believe they are failing due to my commits.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Apr 26, 2018
@AyushG3112
Copy link
Contributor

You might need to change your commit messages to conform to the Commit Guidelines

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Can you squash your commits and write a commit log using the format described in the contribution guide? Thanks.

.binding('udp_wrap').UDP.prototype.bind6.prototype),
'undefined',
'Unnecessary prototype "process.binding("udp_wrap").\
UDP.prototype.bind6.prototype" was generated!');
Copy link
Member

Choose a reason for hiding this comment

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

  1. Does this pass make lint?

  2. I'd maybe drop the message, it's just restating the code as prose.

  3. Perhaps additionally check that 'prototype' in UDP.prototype.bind6 is false.

  4. Maybe check a few more methods, also from other binding objects (e.g. process.binding('tcp_wrap').TCP)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bnoordhuis I have verified that my tests pass make lint. I also cut down the messages in my asserts to say only the names of the prototypes that they are testing, and nothing else, to avoid bloat. Furthermore, I added a few more method tests, including tests for process.binding('tcp_wrap').TCP, and some protoype in tests as well.

Please let me know if there are any further improvements needed.

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

LGTM, assuming @bnoordhuis's comments get fixed.

@TimothyGu
Copy link
Member

Should we run CITGM on this?

@brandontruggles
Copy link
Contributor Author

@TimothyGu @bnoordhuis I just added a new squashed commit with the changes that @bnoordhuis requested. Please let me know if everything checks out OK. Thank you!

@joyeecheung
Copy link
Member

joyeecheung commented Apr 27, 2018

require('../common/fixtures');

// This test ensures that unnecessary prototypes are no longer
// being genrated by Environment::NewFunctionTemplate
Copy link
Member

@BridgeAR BridgeAR Apr 29, 2018

Choose a reason for hiding this comment

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

Nit: typo in generated. While being on it, please also punctuate the sentence (add a dot at the end).

@@ -0,0 +1,57 @@
'use strict';
require('../common');
require('../common/fixtures');
Copy link
Member

Choose a reason for hiding this comment

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

Nit: unnecessary require (../common/fixtures).


const assert = require('assert');


Copy link
Member

Choose a reason for hiding this comment

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

Nit: unnecessary double line breaks.


assert.strictEqual((process
.binding('udp_wrap').UDP.prototype.bind6.prototype), undefined,
'process.binding("udp_wrap").UDP.prototype.bind6.prototype');
Copy link
Member

Choose a reason for hiding this comment

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

All the process.[...].prototype === undefined checks in here are redundant and should be removed.

'prototype' in process.[...] already checks this as well.

As soon as that is the case, the tests could be shortened to e.g.,

[
  process.binding('udp_wrap').UDP.prototype.bind6,
  process.binding('tcp_wrap').TCP.prototype.bind6,
  ...
].forEach((binding, i) => {
  assert.strictEqual('prototype' in binding, false, `Test ${i} failed`);
}); 

Added an optional parameter of type v8::ConstructorBehavior to
Environment::NewFunctionTemplate, defaulting to
v8::ConstructorBehavior::kAllow. Also modified
Environment::SetProtoMethod to pass
v8::ConstructorBehavior::kThrow to its
call to Environment::NewFunctionTemplate.

Fixes: nodejs#17668
Refs: nodejs#20321
@brandontruggles
Copy link
Contributor Author

@BridgeAR I've updated my commit to reflect the changes you requested above. I've also ensured that the updated tests pass make test. Thank you for the feedback, and please let me know if there are further issues.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Just reaffirming my earlier approval :)

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 29, 2018
@BridgeAR
Copy link
Member

@addaleax
Copy link
Member

addaleax commented May 5, 2018

Landed in 64348f5 🎉 Congratulations to your first commit!

@addaleax addaleax closed this May 5, 2018
addaleax pushed a commit that referenced this pull request May 5, 2018
Added an optional parameter of type v8::ConstructorBehavior to
Environment::NewFunctionTemplate, defaulting to
v8::ConstructorBehavior::kAllow. Also modified
Environment::SetProtoMethod to pass
v8::ConstructorBehavior::kThrow to its
call to Environment::NewFunctionTemplate.

Fixes: #17668
Refs: #20321
PR-URL: #20321
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request May 8, 2018
Added an optional parameter of type v8::ConstructorBehavior to
Environment::NewFunctionTemplate, defaulting to
v8::ConstructorBehavior::kAllow. Also modified
Environment::SetProtoMethod to pass
v8::ConstructorBehavior::kThrow to its
call to Environment::NewFunctionTemplate.

Fixes: #17668
Refs: #20321
PR-URL: #20321
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@MylesBorins MylesBorins mentioned this pull request May 8, 2018
MylesBorins pushed a commit that referenced this pull request May 8, 2018
Added an optional parameter of type v8::ConstructorBehavior to
Environment::NewFunctionTemplate, defaulting to
v8::ConstructorBehavior::kAllow. Also modified
Environment::SetProtoMethod to pass
v8::ConstructorBehavior::kThrow to its
call to Environment::NewFunctionTemplate.

Fixes: #17668
Refs: #20321
PR-URL: #20321
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request May 9, 2018
Added an optional parameter of type v8::ConstructorBehavior to
Environment::NewFunctionTemplate, defaulting to
v8::ConstructorBehavior::kAllow. Also modified
Environment::SetProtoMethod to pass
v8::ConstructorBehavior::kThrow to its
call to Environment::NewFunctionTemplate.

Fixes: #17668
Refs: #20321
PR-URL: #20321
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants