You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • 1 - not sure if "typically" but yes it can run from RAM or from flash. When in ram the parsed string of each function is in RAM (possibly minified and tokenized) as a variable. in javascript there is no big difference between variable referencing integer value, string or function object

    if loaded from flash the difference is that function object has pointer to string of the body which is in flash, also plain strings work like that not just functions so if code in flash has
    var s = "very long string .. " than the string is also in flash, not in ram

    2 it is based on number of variables (=JSVAR_CACHE_SIZE) see https://github.com/espruino/Espruino/blo­b/master/src/jsutils.h#L195

    3 there is no performance penalty when running from internal flash, there is small one when running from SPI flash (Bangle watches)

    the size is defined in board files like this https://github.com/espruino/Espruino/blo­b/master/boards/PUCKJS.py#L25

    the size is basically determined by trial and error - you check how much free RAM you have with everything built in + CPU stack and you divide size of free ram by variable size. For PUCKJS with 2756 variables it needs 35828 bytes of RAM (out of 64KB), the rest is for static C data, CPU stack and bluetooth - NRF softdevice

About

Avatar for fanoush @fanoush started