Skip to content
Closed
Changes from 1 commit
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
Next Next commit
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.
  • Loading branch information
vhf committed Jan 2, 2017
commit 91cf36959edc273376d3b011c3c48dab43c7d8c1
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