Abundance of peaks and dips in 3D mass and halo density fields: a test for cosmology