You are reading a single comment by @Mark_M and its replies. Click here to read the full conversation.
  • If you upload modules with the IDE (or use the app loader to do it) by default they will be minified.

    If you use that method, when required the modules do use up some RAM, but only enough to hold the declarations for every function that you export or that is defined at module scope. So... if your module just exports a single function but that function is huge, the RAW usage will actually be very low and the function is executed from flash.

  • 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 Mark_M @Mark_M started