fix interleaving of native and js optimization passes