Espruino speed improvements - compiled JavaScript?

Posted on
Page
of 3
Prev
/ 3
Next
  • Python 2.6.9

  • Ahh. That's your problem then :)

    Perhaps just changing the #! bit at the top to explicitly mention python2.7 would do it?

  • (back onto the main topic - i lost interest in trying to generate the docs)

    I seem to be missing something. I'm using the webide from github, but it's still not compiling functions, even using the examples you posted above. What do I need to do to get the js-compiling version of the webide?

  • Argh, sorry - forgot to commit a file. Try updating the Web IDE now.

  • Just a note here - the Web IDE (as it comes from the Chrome Web Store) now had this all built-in and ready to go.

  • Gordon, why you refuse offline compilation?

  • Gordon, why you refuse offline compilation?

    I'm not sure I understand. Do you mean why am I switching to using a compiler on my server?

    It's because it's just too painful to re-write a complete compiler for the Thumb architecture - and after all that, it's not even going to be that fast. While I had something working there were lots of obscure bugs that were hard to find - and I don't think anyone else was really willing to help out with it.

    By using GCC on a server I can avoid those bugs completely, debug everything more easily, and also get really fast code out the end.

    However if someone could make a C->Thumb compiler that could run in JavaScript (like a port of TCC) then I'd be happy to switch back to offline compilation.

  • When I try to run functions with the "compiled" tag from the Web IDE an error message that says 'Error contacting server: unable to compile code right now' pops up. I've tried both the chrome store version and the github version of the Web IDE, and am using the Espruino board. Has anyone encountered a similar issue?

  • I just checked and the compile server had crashed - if you try now it should be better - I've made sure it'll automatically restart if something happens

  • Hi Gordon,
    I'am playing with the compiled functions and my Espruino (1v75) based on your code from post #9 outputs the following:
    ...
    echo(0);
    129297
    Slow = 0.23056221008
    91078231610832719163859600607397376772912088895903881996317739501
    Fast = 0.05572032928
    =undefined
    ...
    I have also tried division, multiplication and even substraction and all return different values for "slow" and "fast". I have also tried both online and offline (git) compiler with the same results. Am I doin' smtg wrong ?

  • I get the same thing here - I'm afraid there's some kind of problem with the compiled code's handling of function parameters. I haven't been able to figure it out yet I'm afraid.

    For instance:

    function t(a,b,c) { 
      "compiled";
      return a+","+b+","+c;
    }
    
    >t(1,2,3)
    ="1,1,3"
    >t("a","b","c")
    ="a,a,c"
    

    However the C++ function that's being created from it appears to be fine:

    extern "C" {
     JsVar *myFunction(JsVar *a, JsVar *b, JsVar *c) {
      return SV(jsvMathsOp(SV(jsvMathsOp(SV(jsvMathsOp(SV(jsvMathsOp(SV::notOwned(a), SV(jsvNewFromString(",")), '+')), SV::notOwned(b), '+')), SV(jsvNewFromString(",")), '+')), SV::notOwned(c), '+')).give();
      return 0; // just in case
     }
    }
    

    (SV is a 'smart pointer' class). I can only assume it's something to do with the way GCC is actually compiling the code :(

  • Wohoo! Fixed it!

    Turns out it wasn't anything difficult at all. To execute Thumb code the CPU expects the function address to have the bottom bit set - it was as simple as changing E.nativeCall(0, ... to E.nativeCall(1, ....

    I've changed this on the server, and compiled code should work properly!

  • When I insert "compiled" into a function (fast) the execution is hanging. I'am playing with the compiled functions and my Espruino (1v76) based on your code from post #9 hangs. Any thoughts to what this could be.

  • Oops - sorry, it turns out it goes with a fix I made to the firmware too. To bodge it up for now you could step back in the history to where 'E.nativeCall' was added, change 1 to 16, and I think that would work.

    Otherwise you could install the firmware from here: http://www.espruino.com/binaries/git/commits/76a88bfe13a60b021a5cb1839a1e3933240ca5a9

    It should auto-compile in a few minutes.

  • Hello,
    In my case there is no compiling. The WebIDE says: "compiler not active as no process.env.EXPORTS avalable. Is your firmware up to date?"

    The board is HYSTM32_24VE, the Espruino is 1v76. There are many EXPORTS fields in process.env object. Why is nothing compiled?

  • After connecting to a board, WebIDE trys to read process.env.
    If you have, like me, problems with serial port in chrome, sometimes you will not get the data.
    Usually I disconnect and reconnect until I get the all data for process.env
    Board information is available in settings/about tab at the bottom.

  • Really, there is no information about the board in settings menu :-( ,
    althoug when I type "process.env.EXPORTS" on the left hand panel, IDE prints many fields of this object

    How can I teach it to see the board?

  • Are you connecting via the USART USB connector rather than the USB that goes straight to the STM32 chip? Often if you use the USART it just ends up being so slow that the Web IDE times out while waiting for a response.

  • I use the USB that connects to STM as USART (through PL2303HX USB-UART transducer)

    If I try to connect via pure USB that connects to STM directly, nothing is found in system.

    How can I connect to the board via pure USB?

    Is it possible to increase the timeout in Web IDE?

  • If I try to connect via pure USB that connects to STM directly, nothing is found in system.

    Is it that nothing is found, or that you don't have the drivers installed? Perhaps your board is different yet again and they've changed the pin that USB Disconnect is on.

    There isn't an option to change the timeout - you'd have to download the Web IDE source and set it yourself.

    Honestly, if you want to try compilation out - just get a proper Espruino board and try with that.

  • What driver must I install?

    I have install VCP, and when I connect to second USB (through PL2303), the com-port appears in system. When I connect to first USB (it is really connected to STM32 - PA11 and PA12), it is no reaction...

  • What driver must I install?

    The ST VCP drivers, which is sounds like you have done.

    When I connect to first USB (it is really connected to STM32 - PA11 and PA12), it is no reaction...

    That's odd, because usually it should come up and at the very least tell you it doesn't have drivers. My guess is that your board has a different layout to the one that I built Espruino for, and that the USB disconnect transistor isn't connected to the pin that Espruino expects.

  • Ok, you are right. There is transistor, that connects the USP_DP via 1k5 resistor to +3,3V, if PC13 is LOW. When the board is restart, there is HIGH on PC13 and system doesn't see on USB the Espruino. I have reset PC13 and then computer find the board.

    But this didn't give the result: the program with "compiled" function hangs...

    @TrapperBob had same situation (post #38 in this theme), I think so :-)

    PS. I have connected those base resistor of Q1 from PC13 to ground, and now the USB is seen always. And additional I have the free port PC13 :-)

  • @Uhv: Are you running the latest version I released today - 1v77

  • Entschuldigung... I have not seen the Download section yet. Just a moment...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Espruino speed improvements - compiled JavaScript?

Posted by Avatar for Gordon @Gordon

Actions