Every function has a property invocation_count in FeedbackVector to record the number of times the function was called. But after a function is optimized, its invocation count will not be increased when I call this function again. Is there any way to get the invocation count or update the invocation count attribute in FeedbackVector after a function has been optimized?
(V8 developer here.)
No, there isn't. Optimized functions don't count how often they've been called (because they have no reason to; having them update a counter would be a waste of time).
If you really care, you have two options:
(1) You could add counters in the JavaScript source of the function(s) in question:
var myFuncCalled = 0;
function myFunc() {
myFuncCalled++;
// rest of the function's code...
}
And dump those counters at the end of the program.
(2) You could modify V8 to make optimized code update the count in the feedback vector. Off the top of my head I'm not sure how exactly you'd do that, but it's certainly possible. (We wouldn't want to upstream such a patch, this would be just for your local experimentation.)