@@ -56,12 +56,9 @@ function setupNextTick() {
56
56
// Two arrays that share state between C++ and JS.
57
57
const { async_hook_fields, async_uid_fields } = async_wrap ;
58
58
// Used to change the state of the async id stack.
59
- const { pushAsyncIds, popAsyncIds } = async_wrap ;
60
- // The needed emit*() functions.
61
59
const { emitInit, emitBefore, emitAfter, emitDestroy } = async_hooks ;
62
60
// Grab the constants necessary for working with internal arrays.
63
- const { kInit, kBefore, kAfter, kDestroy, kAsyncUidCntr } =
64
- async_wrap . constants ;
61
+ const { kInit, kDestroy, kAsyncUidCntr } = async_wrap . constants ;
65
62
const { async_id_symbol, trigger_id_symbol } = async_wrap ;
66
63
var nextTickQueue = new NextTickQueue ( ) ;
67
64
var microtasksScheduled = false ;
@@ -149,24 +146,6 @@ function setupNextTick() {
149
146
}
150
147
}
151
148
152
- // TODO(trevnorris): Using std::stack of Environment::AsyncHooks::ids_stack_
153
- // is much slower here than was the Float64Array stack used in a previous
154
- // implementation. Problem is the Float64Array stack was a bit brittle.
155
- // Investigate how to harden that implementation and possibly reintroduce it.
156
- function nextTickEmitBefore ( asyncId , triggerAsyncId ) {
157
- if ( async_hook_fields [ kBefore ] > 0 )
158
- emitBefore ( asyncId , triggerAsyncId ) ;
159
- else
160
- pushAsyncIds ( asyncId , triggerAsyncId ) ;
161
- }
162
-
163
- function nextTickEmitAfter ( asyncId ) {
164
- if ( async_hook_fields [ kAfter ] > 0 )
165
- emitAfter ( asyncId ) ;
166
- else
167
- popAsyncIds ( asyncId ) ;
168
- }
169
-
170
149
// Run callbacks that have no domain.
171
150
// Using domains will cause this to be overridden.
172
151
function _tickCallback ( ) {
@@ -182,7 +161,7 @@ function setupNextTick() {
182
161
// CHECK(Number.isSafeInteger(tock[trigger_id_symbol]))
183
162
// CHECK(tock[trigger_id_symbol] > 0)
184
163
185
- nextTickEmitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
164
+ emitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
186
165
// emitDestroy() places the async_id_symbol into an asynchronous queue
187
166
// that calls the destroy callback in the future. It's called before
188
167
// calling tock.callback so destroy will be called even if the callback
@@ -200,7 +179,7 @@ function setupNextTick() {
200
179
// performance hit associated with using `fn.apply()`
201
180
_combinedTickCallback ( args , callback ) ;
202
181
203
- nextTickEmitAfter ( tock [ async_id_symbol ] ) ;
182
+ emitAfter ( tock [ async_id_symbol ] ) ;
204
183
205
184
if ( kMaxCallbacksPerLoop < tickInfo [ kIndex ] )
206
185
tickDone ( ) ;
@@ -227,7 +206,7 @@ function setupNextTick() {
227
206
// CHECK(Number.isSafeInteger(tock[trigger_id_symbol]))
228
207
// CHECK(tock[trigger_id_symbol] > 0)
229
208
230
- nextTickEmitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
209
+ emitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
231
210
// TODO(trevnorris): See comment in _tickCallback() as to why this
232
211
// isn't a good solution.
233
212
if ( async_hook_fields [ kDestroy ] > 0 )
@@ -238,7 +217,7 @@ function setupNextTick() {
238
217
// performance hit associated with using `fn.apply()`
239
218
_combinedTickCallback ( args , callback ) ;
240
219
241
- nextTickEmitAfter ( tock [ async_id_symbol ] ) ;
220
+ emitAfter ( tock [ async_id_symbol ] ) ;
242
221
243
222
if ( kMaxCallbacksPerLoop < tickInfo [ kIndex ] )
244
223
tickDone ( ) ;
0 commit comments