summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmark/process/next-tick-breadth-args.js2
-rw-r--r--benchmark/process/next-tick-breadth.js2
-rw-r--r--benchmark/process/next-tick-depth-args.js2
-rw-r--r--benchmark/process/next-tick-depth.js2
-rw-r--r--benchmark/process/next-tick-exec-args.js2
-rw-r--r--benchmark/process/next-tick-exec.js2
-rw-r--r--lib/internal/fixed_queue.js2
-rw-r--r--lib/internal/process/task_queues.js42
8 files changed, 29 insertions, 27 deletions
diff --git a/benchmark/process/next-tick-breadth-args.js b/benchmark/process/next-tick-breadth-args.js
index 6baa8d9960..f7f9882c87 100644
--- a/benchmark/process/next-tick-breadth-args.js
+++ b/benchmark/process/next-tick-breadth-args.js
@@ -2,7 +2,7 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [4e6]
+ n: [1e7]
});
function main({ n }) {
diff --git a/benchmark/process/next-tick-breadth.js b/benchmark/process/next-tick-breadth.js
index 392d8e0209..297bf43495 100644
--- a/benchmark/process/next-tick-breadth.js
+++ b/benchmark/process/next-tick-breadth.js
@@ -2,7 +2,7 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [4e6]
+ n: [1e7]
});
function main({ n }) {
diff --git a/benchmark/process/next-tick-depth-args.js b/benchmark/process/next-tick-depth-args.js
index da61f90a64..d9fc37887e 100644
--- a/benchmark/process/next-tick-depth-args.js
+++ b/benchmark/process/next-tick-depth-args.js
@@ -2,7 +2,7 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [12e6]
+ n: [7e6]
});
function main({ n }) {
diff --git a/benchmark/process/next-tick-depth.js b/benchmark/process/next-tick-depth.js
index c88e042b96..5b0f817475 100644
--- a/benchmark/process/next-tick-depth.js
+++ b/benchmark/process/next-tick-depth.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [12e6]
+ n: [7e6]
});
function main({ n }) {
diff --git a/benchmark/process/next-tick-exec-args.js b/benchmark/process/next-tick-exec-args.js
index f5d0fb9422..ec172ea893 100644
--- a/benchmark/process/next-tick-exec-args.js
+++ b/benchmark/process/next-tick-exec-args.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [5e6]
+ n: [4e6]
});
function main({ n }) {
diff --git a/benchmark/process/next-tick-exec.js b/benchmark/process/next-tick-exec.js
index 936b253bfa..14fce9cccf 100644
--- a/benchmark/process/next-tick-exec.js
+++ b/benchmark/process/next-tick-exec.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
- n: [5e6]
+ n: [4e6]
});
function main({ n }) {
diff --git a/lib/internal/fixed_queue.js b/lib/internal/fixed_queue.js
index 7571a8f67e..a073ab7fc3 100644
--- a/lib/internal/fixed_queue.js
+++ b/lib/internal/fixed_queue.js
@@ -102,7 +102,7 @@ module.exports = class FixedQueue {
}
shift() {
- const { tail } = this;
+ const tail = this.tail;
const next = tail.shift();
if (tail.isEmpty() && tail.next !== null) {
// If there is another queue, it forms the new tail.
diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js
index 68b5d8b343..8906b4aa1e 100644
--- a/lib/internal/process/task_queues.js
+++ b/lib/internal/process/task_queues.js
@@ -71,10 +71,18 @@ function processTicksAndRejections() {
try {
const callback = tock.callback;
- if (tock.args === undefined)
+ if (tock.args === undefined) {
callback();
- else
- callback(...tock.args);
+ } else {
+ const args = tock.args;
+ switch (args.length) {
+ case 1: callback(args[0]); break;
+ case 2: callback(args[0], args[1]); break;
+ case 3: callback(args[0], args[1], args[2]); break;
+ case 4: callback(args[0], args[1], args[2], args[3]); break;
+ default: callback(...args);
+ }
+ }
} finally {
if (destroyHooksExist())
emitDestroy(asyncId);
@@ -88,22 +96,6 @@ function processTicksAndRejections() {
setHasRejectionToWarn(false);
}
-class TickObject {
- constructor(callback, args) {
- this.callback = callback;
- this.args = args;
-
- const asyncId = newAsyncId();
- const triggerAsyncId = getDefaultTriggerAsyncId();
- this[async_id_symbol] = asyncId;
- this[trigger_async_id_symbol] = triggerAsyncId;
-
- if (initHooksExist()) {
- emitInit(asyncId, 'TickObject', triggerAsyncId, this);
- }
- }
-}
-
// `nextTick()` will not enqueue any callback when the process is about to
// exit since the callback would not have a chance to be executed.
function nextTick(callback) {
@@ -127,7 +119,17 @@ function nextTick(callback) {
if (queue.isEmpty())
setHasTickScheduled(true);
- queue.push(new TickObject(callback, args));
+ const asyncId = newAsyncId();
+ const triggerAsyncId = getDefaultTriggerAsyncId();
+ const tickObject = {
+ [async_id_symbol]: asyncId,
+ [trigger_async_id_symbol]: triggerAsyncId,
+ callback,
+ args
+ };
+ if (initHooksExist())
+ emitInit(asyncId, 'TickObject', triggerAsyncId, tickObject);
+ queue.push(tickObject);
}
let AsyncResource;