Skip to content

Commit e52fee5

Browse files
vhfjasnell
authored andcommitted
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: #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]>
1 parent 26b8c21 commit e52fee5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/events.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ EventEmitter.prototype.emit = function emit(type) {
148148

149149
// If there is no 'error' event listener then throw.
150150
if (doError) {
151-
er = arguments[1];
151+
if (arguments.length > 1)
152+
er = arguments[1];
152153
if (domain) {
153154
if (!er)
154155
er = new Error('Uncaught, unspecified "error" event');

0 commit comments

Comments
 (0)