From 91cf36959edc273376d3b011c3c48dab43c7d8c1 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Mon, 2 Jan 2017 22:28:04 +0100 Subject: [PATCH 1/2] 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. --- lib/events.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/events.js b/lib/events.js index 4ccec4e595cdc5..05e33072f7a7e8 100644 --- a/lib/events.js +++ b/lib/events.js @@ -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'); From 8db254650381f43466776fc69f1c3a6a98adb670 Mon Sep 17 00:00:00 2001 From: Victor Felder Date: Mon, 2 Jan 2017 22:32:21 +0100 Subject: [PATCH 2/2] benchmark: fix typo "categoty" -> "category" --- benchmark/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/run.js b/benchmark/run.js index 52ce74024e1ae4..297d4e3b788796 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -6,7 +6,7 @@ const CLI = require('./_cli.js'); const cli = CLI(`usage: ./node run.js [options] [--] ... Run each benchmark in the directory a single time, more than one - directory can be specified. + directory can be specified. --filter pattern string to filter benchmark scripts --set variable=value set benchmark variable (can be repeated)