We exploit the first public data release of VIPERS to investigate environmental effects in galaxy evolution between $z\sim0.5$ and $0.9$. The large number of spectroscopic redshifts over an area of about $10\,\mathrm{deg}^2$ provides a galaxy sample with high statistical power. The accurate redshift measurements, with $\sigma_z = 0.00047(1+z_\mathrm{spec})$, allow us to robustly isolate galaxies living in the lowest- and highest-density environments, as defined in terms of spatial 3D density contrast. We estimate the stellar mass function (SMF) of galaxies residing in these two environments, and constrain its high-mass end with unprecedented precision. We find that the galaxy SMF in the densest regions has a different shape than that measured at low densities, with an enhancement of massive galaxies and a hint of a flatter (less negative) slope at $z<0.8$. We normalise each SMF to the comoving volume occupied by the corresponding environment, and relate estimates from different redshift bins. We observe an evolution of the SMF of VIPERS galaxies in high densities, while the low-density one is nearly constant. We compare these results to semi-analytical models and find consistent environmental signatures. We discuss how the halo mass function and fraction of central/satellite galaxies depend on the environments considered, making intrinsic and environmental properties of galaxies physically coupled, and therefore difficult to disentangle. The evolution of our low-density regions is well described by the formalism introduced by Peng et al.~(2010), and is consistent with the idea that galaxies become progressively passive because of internal physical processes. The same formalism could also describe the evolution of the SMF in the high density regions, but only if a significant contribution from dry mergers is considered. [Abridged]