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

lib,tools: fix perm deopts #13384

Merged
merged 4 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,25 @@ EventEmitter.prototype.prependListener =
};

function onceWrapper() {
this.target.removeListener(this.type, this.wrapFn);
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
this.listener.apply(this.target, arguments);
switch (arguments.length) {
case 0:
return this.listener.call(this.target);
case 1:
return this.listener.call(this.target, arguments[0]);
case 2:
return this.listener.call(this.target, arguments[0], arguments[1]);
case 3:
return this.listener.call(this.target, arguments[0], arguments[1],
arguments[2]);
default:
const args = new Array(arguments.length);
Copy link
Member

Choose a reason for hiding this comment

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

Can arrayClone() be reused here or does it have a negative performance impact?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because you cannot pass arguments without penalty except in only one or two cases. apply() is supposed to be one of those cases (which is what was used here before) but for some reason it can still cause a deopt (noticed this in some net benchmarks and tests).

Copy link
Contributor

Choose a reason for hiding this comment

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

does (...args) work (for everything) any better?
Ref: #12183

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rest parameters are still slower than fast path cases like those used above. I think rest params in general are getting faster, but still not quite where they need to be to replace fast paths.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

for (var i = 0; i < args.length; ++i)
args[i] = arguments[i];
this.listener.apply(this.target, args);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function setupProcessWarnings() {
if (isDeprecation && process.noDeprecation) return;
const trace = process.traceProcessWarnings ||
(isDeprecation && process.traceDeprecation);
let msg = `${prefix}`;
var msg = `${prefix}`;
if (warning.code)
msg += `[${warning.code}] `;
if (trace && warning.stack) {
Expand Down
4 changes: 2 additions & 2 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,8 @@ Socket.prototype.connect = function() {
// TODO(joyeecheung): use destructuring when V8 is fast enough
normalized = normalizeArgs(args);
}
const options = normalized[0];
const cb = normalized[1];
var options = normalized[0];
var cb = normalized[1];

if (this.write !== Socket.prototype.write)
this.write = Socket.prototype.write;
Expand Down
4 changes: 4 additions & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,10 @@ def GetConfiguration(self, context):
(file, pathname, description) = imp.find_module('testcfg', [ self.path ])
module = imp.load_module('testcfg', file, pathname, description)
self.config = module.GetConfiguration(context, self.path)
if hasattr(self.config, 'additional_flags'):
self.config.additional_flags += context.node_args
else:
self.config.additional_flags = context.node_args
finally:
if file:
file.close()
Expand Down