You are reading a single comment by @FManga and its replies. Click here to read the full conversation.
  • BTW as the floating point hardware can do only basic operations like +-*/ I tried to add -lm and use sinf() and it pulls quite a lot of code and the binary grows to 4KB. If I used double type and sin() instead the same code is almost 8KB.

  • For some reason I don't need to add -lm for my local EspruinoCompiler to find sinf, just like I didn't need -lgcc before.
    It would be nice if each compile/upload in the IDE would give some stats (amount of space taken up by strings, total space taken up in flash, free RAM on the connected device). As it is, I have no idea if 4KB is a lot or if that's acceptable.
    Since the code needs to be copied to RAM, I wonder if it makes sense to use heatshrink or LZ4 on it.

  • Since the code needs to be copied to RAM, I wonder if it makes sense to use heatshrink or LZ4 on it.

    Maybe, but the storage is not the bottleneck, I tried it with code that was about 600 bytes and it was not worth it but maybe it would make some sense with larger code. However Heatshrink may not be good for binary code
    if you would put this into declaration that comes out of inline C compiler as another method it would produce compressed declaration of the bin variable.

    As for the malloc code I think it would be more reliable to allocate one big array, send pointer to it once and do the malloc/free inside C on top of that.

    Also, does the GC know when it is safe to free the Uint8Array?

    Yes, keeping reference is enough but it is also about defragmentation and stuff moving, I think flat arrays are not moved(?) when E.defrag() is triggered, smaller stuff is moved.

    To call that from C it seems what I need is jspGetNamedVariable and jspeFunctionCall

    When you start using stuff in https://github.com/gfwilliams/EspruinoCompiler/blob/master/src/utils.js#L73 the output of inline compiler is fixed for specific device and FW version so cannot be distributed in binary form (it builds the code with hardcoded value from process.env.EXPTR of calling device). With slight change in the compiler it is possible to fix that so that the process.env.EXPTR is used at runtime instead of compile time. then the code from compiler looks like this

About

Avatar for FManga @FManga started