What do you describe
As you describe the problem, it looks like you think that the JavaScript virtual machine puts functions into standby mode (stopping them) during their execution (i.e. before they return) to do something else, and then resume functions.
The image you are showing does not imply that to me at all.
What I see
VM performs:
callback that calls- some function whose name is hidden by a tooltip that calls:
fireWith , which calls:fire , which calls:- etc...
Then the deepest function returns, and the called function returns, etc. etc., until fire returns, fireWith returned, a function whose name we cannot read is returned, and callback returns.
Then the virtual machine starts the RegExp function and calls the function called callback again, and it all starts again. In other words, the second column is with callback , and the rest is a new function call. Functions do not "ping for a short time": they are called several times.
I see this all the time in libraries that respond to events. Usually they iterate over event handlers to call them. Given a rather complex library, there is a sufficient amount of glue code that can be between the loop that calls the handlers and your own code, so there are many recurring calls that appear during profiling.
source share