Molecular oxygen has been detected in the coma of comet 67P/Churyumov--Gerasimenko with a mean abundance of 3.80 $pm$ 0.85% by the ROSINA mass spectrometer on board the Rosetta spacecraft. To account for the presence of this species in comet 67P/Churyumov--Gerasimenko, it has been shown that the radiolysis of ice grains precursors of comets is a viable mechanism in low-density environments, such as molecular clouds. Here, we investigate the alternative possibility that the icy grains present in the midplane of the protosolar nebula were irradiated during their vertical transport between the midplane and the upper layers over a large number of cycles, as a result of turbulent mixing. Consequently, these grains spent a non-negligible fraction of their lifetime in the disks upper regions, where the irradiation by cosmic rays was strong. To do so, we used a coupled disk-transport-irradiation model to calculate the time evolution of the molecular oxygen abundance radiolytically produced in ice grains. Our computations show that, even if a significant fraction of the icy particles have followed a back and forth cycle towards the upper layers of the disk over 10 million of years, a timespan far exceeding the formation timescale of comet 67P/Churyumov--Gerasimenko, the amount of produced molecular oxygen is at least two orders of magnitude lower than the Rosetta observations. We conclude that the most likely scenario remains the formation of molecular oxygen in low-density environments, such as the presolar cloud, prior to the genesis of the protosolar nebula.