function
jsc.numberOfDFGCompiles
func: (...args: any[]) => any
): number;
Returns how many times a function has been optimized: 1 if the function currently has DFG- or FTL-compiled code, plus one for each time its optimized code has been thrown away (reoptimizationRetryCount). Returns 0 while the function is still running in the interpreter or the baseline JIT, and 1000000 when the JIT is disabled.
import { numberOfDFGCompiles } from "bun:jsc";
function add(a: number, b: number) {
return a + b;
}
// Run until the optimizing compiler has picked up `add`
while (numberOfDFGCompiles(add) === 0) add(1, 2);