Despite everything you've heard, it turns out that dolphins don't actually whistle. Dolphins produce a sound from their nose that they use to identify themselves to dolphins, which for years has been described as a whistle. But scientists discovered that the frequency of the sound never changed, even deep under water, where the sound of an actual whistle would be changed.
So they did what any good scientist would do, and got a trained dolphin to whistle in heliox, which should provide a higher pitch than in air. Still no change!
See, whistling is produced by hitting a resonant frequency inside an air volume — like your mouth. If the air changes density, either through compression or by using a different gas, then the sound will be different. Since the sound being produced by the dolphins is the same regardless of situation, it's not a whistle.
So, what is it? Well, dolphins produce tonal sounds using tissue vibrations, just like we do. Like humans — and most animals — they vibrate tissue in a specific way to create noises, be those barks, word or chirps. Dolphins just have the extra ability to do it with their noses.