From 9274e141ced45be9d370cac7d4e30d4a3424c5b6 Mon Sep 17 00:00:00 2001
From: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Date: Fri, 9 Dec 2016 15:37:32 -0500
Subject: [PATCH] timers: cleanup extraneous property on Immediates

This was originally changed in 6f75b6672ca08c2bc3bf5fe14abb1a9648601e2
but it appears unnecessary and benhcmark results show little difference
without the extra property.

Refs: https://github.com/nodejs/node/pull/6436
---
 lib/timers.js                                     | 14 +++++---------
 test/message/eval_messages.out                    |  8 ++++----
 test/message/stdin_messages.out                   |  8 ++++----
 test/message/unhandled_promise_trace_warnings.out |  2 +-
 4 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/lib/timers.js b/lib/timers.js
index 56af3a92d6bfe2..b1c8ad6cb8a688 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -586,8 +586,6 @@ function processImmediate() {
     if (domain)
       domain.enter();
 
-    immediate._callback = immediate._onImmediate;
-
     // Save next in case `clearImmediate(immediate)` is called from callback
     var next = immediate._idleNext;
 
@@ -646,16 +644,16 @@ function runCallback(timer) {
   switch (argc) {
     // fast-path callbacks with 0-3 arguments
     case 0:
-      return timer._callback();
+      return timer._onImmediate();
     case 1:
-      return timer._callback(argv[0]);
+      return timer._onImmediate(argv[0]);
     case 2:
-      return timer._callback(argv[0], argv[1]);
+      return timer._onImmediate(argv[0], argv[1]);
     case 3:
-      return timer._callback(argv[0], argv[1], argv[2]);
+      return timer._onImmediate(argv[0], argv[1], argv[2]);
     // more than 3 arguments run slower with .apply
     default:
-      return timer._callback.apply(timer, argv);
+      return timer._onImmediate.apply(timer, argv);
   }
 }
 
@@ -665,7 +663,6 @@ function Immediate() {
   // so have caller annotate the object (node v6.0.0, v8 5.0.71.35)
   this._idleNext = null;
   this._idlePrev = null;
-  this._callback = null;
   this._argv = null;
   this._onImmediate = null;
   this.domain = process.domain;
@@ -701,7 +698,6 @@ exports.setImmediate = function(callback, arg1, arg2, arg3) {
 function createImmediate(args, callback) {
   // declaring it `const immediate` causes v6.0.0 to deoptimize this function
   var immediate = new Immediate();
-  immediate._callback = callback;
   immediate._argv = args;
   immediate._onImmediate = callback;
 
diff --git a/test/message/eval_messages.out b/test/message/eval_messages.out
index 44965be374bac5..1307c3df0b1de3 100644
--- a/test/message/eval_messages.out
+++ b/test/message/eval_messages.out
@@ -6,7 +6,7 @@ SyntaxError: Strict mode code may not include a with statement
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([eval]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -21,7 +21,7 @@ Error: hello
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([eval]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -34,7 +34,7 @@ Error: hello
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([eval]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -48,7 +48,7 @@ ReferenceError: y is not defined
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([eval]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
diff --git a/test/message/stdin_messages.out b/test/message/stdin_messages.out
index 828bee92cb6f7f..ae92a4478abe61 100644
--- a/test/message/stdin_messages.out
+++ b/test/message/stdin_messages.out
@@ -7,7 +7,7 @@ SyntaxError: Strict mode code may not include a with statement
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([stdin]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -23,7 +23,7 @@ Error: hello
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([stdin]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -37,7 +37,7 @@ Error: hello
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([stdin]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
@@ -52,7 +52,7 @@ ReferenceError: y is not defined
     at Object.exports.runInThisContext (vm.js:*)
     at Object.<anonymous> ([stdin]-wrapper:*:*)
     at Module._compile (module.js:*:*)
-    at Immediate.<anonymous> (bootstrap_node.js:*:*)
+    at Immediate._onImmediate (bootstrap_node.js:*:*)
     at runCallback (timers.js:*:*)
     at tryOnImmediate (timers.js:*:*)
     at processImmediate [as _immediateCallback] (timers.js:*:*)
diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.out
index 80cf948cf118a3..3696d3b62d09bb 100644
--- a/test/message/unhandled_promise_trace_warnings.out
+++ b/test/message/unhandled_promise_trace_warnings.out
@@ -25,7 +25,7 @@
     at *
     at Promise.then (native)
     at Promise.catch (native)
-    at Immediate.setImmediate (*test*message*unhandled_promise_trace_warnings.js:*)
+    at Immediate.setImmediate [as _onImmediate] (*test*message*unhandled_promise_trace_warnings.js:*)
     at *
     at *
     at *