Secure code makes exploitation easier with CPU vulnerabilities

I researched CPU vulnerabilities in the past, such as Specta and Meltdown.

I read that one of those attacks is actually made easier if the code is a certain way. I cannot remember if it was related to being efficiently wrote, securely wrote, or some other reason. However, now I need this quote I cannot find it anywhere.

Simply put – what factors in the code make Spectre and/or Meltdown easier to perform the attack?

Forgive me for asking here but I cannot find this anywhere, and was hoping for a link.