@@ -56,12 +56,9 @@ function setupNextTick() {
5656 // Two arrays that share state between C++ and JS.
5757 const { async_hook_fields, async_uid_fields } = async_wrap ;
5858 // Used to change the state of the async id stack.
59- const { pushAsyncIds, popAsyncIds } = async_wrap ;
60- // The needed emit*() functions.
6159 const { emitInit, emitBefore, emitAfter, emitDestroy } = async_hooks ;
6260 // 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 ;
6562 const { async_id_symbol, trigger_id_symbol } = async_wrap ;
6663 var nextTickQueue = new NextTickQueue ( ) ;
6764 var microtasksScheduled = false ;
@@ -149,24 +146,6 @@ function setupNextTick() {
149146 }
150147 }
151148
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-
170149 // Run callbacks that have no domain.
171150 // Using domains will cause this to be overridden.
172151 function _tickCallback ( ) {
@@ -182,7 +161,7 @@ function setupNextTick() {
182161 // CHECK(Number.isSafeInteger(tock[trigger_id_symbol]))
183162 // CHECK(tock[trigger_id_symbol] > 0)
184163
185- nextTickEmitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
164+ emitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
186165 // emitDestroy() places the async_id_symbol into an asynchronous queue
187166 // that calls the destroy callback in the future. It's called before
188167 // calling tock.callback so destroy will be called even if the callback
@@ -200,7 +179,7 @@ function setupNextTick() {
200179 // performance hit associated with using `fn.apply()`
201180 _combinedTickCallback ( args , callback ) ;
202181
203- nextTickEmitAfter ( tock [ async_id_symbol ] ) ;
182+ emitAfter ( tock [ async_id_symbol ] ) ;
204183
205184 if ( kMaxCallbacksPerLoop < tickInfo [ kIndex ] )
206185 tickDone ( ) ;
@@ -227,7 +206,7 @@ function setupNextTick() {
227206 // CHECK(Number.isSafeInteger(tock[trigger_id_symbol]))
228207 // CHECK(tock[trigger_id_symbol] > 0)
229208
230- nextTickEmitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
209+ emitBefore ( tock [ async_id_symbol ] , tock [ trigger_id_symbol ] ) ;
231210 // TODO(trevnorris): See comment in _tickCallback() as to why this
232211 // isn't a good solution.
233212 if ( async_hook_fields [ kDestroy ] > 0 )
@@ -238,7 +217,7 @@ function setupNextTick() {
238217 // performance hit associated with using `fn.apply()`
239218 _combinedTickCallback ( args , callback ) ;
240219
241- nextTickEmitAfter ( tock [ async_id_symbol ] ) ;
220+ emitAfter ( tock [ async_id_symbol ] ) ;
242221
243222 if ( kMaxCallbacksPerLoop < tickInfo [ kIndex ] )
244223 tickDone ( ) ;
0 commit comments