You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • the function is executed from flash

    Am I understanding it right? A function is loaded into from flash into RAM line by line while executed? Or is loaded as a whole and then executed and then unloaded? Or CPU is capable to work with flash same as with RAM just slower?

    Please do not reply. I am reading https://www.espruino.com/Performance

  • A function is loaded into from flash into RAM line by line while executed? Or is loaded as a whole and then executed and then unloaded?

    no and no. Except when you put "ram" marker into function body or use `E.setFlags({pretokenise:true}), then it is parsed into copy in ram

    function is not 'loaded', it gets first parsed when the part with definition is executed like

    function x(){
    //whatever
    }
    

    and later when you call it, it already knows where the string of the body is located (ram or flash)

    Or CPU is capable to work with flash same as with RAM just slower?

    yes for internal nrf52 flash, that's also where the whole native espruino code is, no for SPI flash, but that one also has special support so the string is streamed from spi flash in small chunks. So in both cases RAM size is not a problem. And in both cases it works mostly the same.

About

Avatar for fanoush @fanoush started