Skip to content

Commit

Permalink
timers: cleanup extraneous property on Immediates
Browse files Browse the repository at this point in the history
This was originally changed in 6f75b66
but it appears unnecessary and benhcmark results show little difference
without the extra property.

Refs: nodejs#6436
  • Loading branch information
Fishrock123 committed Dec 9, 2016
1 parent d8c7534 commit 9274e14
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
14 changes: 5 additions & 9 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions test/message/eval_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*)
Expand All @@ -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:*:*)
Expand All @@ -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:*:*)
Expand All @@ -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:*:*)
Expand Down
8 changes: 4 additions & 4 deletions test/message/stdin_messages.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:*:*)
Expand All @@ -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:*:*)
Expand All @@ -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:*:*)
Expand All @@ -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:*:*)
Expand Down
2 changes: 1 addition & 1 deletion test/message/unhandled_promise_trace_warnings.out
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

0 comments on commit 9274e14

Please sign in to comment.