Skip to content

Commit

Permalink
events: avoid emit() eager deopt
Browse files Browse the repository at this point in the history
This commit makes sure EventEmitter.emit() doesn't get deoptimized by
V8. The deopt happens when accessing out of bound indexes of the
`arguments` object.

This issue has been raised here: #10323 and this specific case might
become a more serious performance issue in upcoming V8 releases.

PR-URL: #10568
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
vhf authored and italoacasas committed Jan 27, 2017
1 parent a77940c commit 5cca693
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ EventEmitter.prototype.emit = function emit(type) {

// If there is no 'error' event listener then throw.
if (doError) {
er = arguments[1];
if (arguments.length > 1)
er = arguments[1];
if (domain) {
if (!er)
er = new Error('Uncaught, unspecified "error" event');
Expand Down

0 comments on commit 5cca693

Please sign in to comment.