0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00

events: avoid emit() eager deopt

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: https://github.com/nodejs/node/pull/10568
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
Victor Felder 2017-01-02 22:28:04 +01:00 committed by James M Snell
parent 26b8c2127d
commit e52fee50a0

View File

@ -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');