  We investigate the chemistry in a radiation-hydrodynamics model of
star-forming core which evolves from a cold ($\sim 10$ K) prestellar core to
the main accretion phase in $\sim 10^5$ yr. A rotationally-supported
gravitationally unstable disk is formed around a protostar. We extract the
temporal variation of physical parameters in $\sim 1.5 \times 10^3$ SPH
particles which end up in the disk, and perform post-processing calculations of
the gas-grain chemistry adopting a three-phase model. Inside the disk, the SPH
particles migrate both inward and outward. Since a significant fraction of
volatiles such as CO can be trapped in the water-dominant ice in the
three-phase model, the ice mantle composition depends not only on the current
position in the disk but also on whether the dust grain has ever experienced
higher temperatures than the water sublimation temperature. Stable molecules
such as H$_2$O, CH$_4$, NH$_3$ and CH$_3$OH are already abundant at the onset
of gravitational collapse and simply sublimated as the fluid parcels migrate
inside the water snow line. On the other hand, various molecules such as carbon
chains and complex organic molecules (COMs) are formed in the disk. COMs
abundance sensitively depends on the outcomes of photodissociation and
diffusion rates of photofragments in bulk ice mantle. As for S-bearing species,
H$_2$S ice is abundant in the collapse phase. In the warm regions in the disk,
H$_2$S is sublimated to be destroyed, while SO, H$_2$CS, OCS and SO$_2$ become
abundant.
