• I saw, that only Bluetooth enabled devices are supported. Could you explain why this is? I really would like to use this feature to speed up some computational work on the Microcontroller.
    I'm currently on version 2.17 and I'm using an Espruino WiFi.
    Thank you :)

  • It was more a case of testing and demand - I'd developed on the nRF52 chips, and nobody ever asked for it to on the STM32s so I never took the time to enable it and try it out.

    I've just had a quick go at enabling it and it does seem to work ok at least on the quick examples I tried, so if you now install one of the latest cutting edge builds then it should work.

    I haven't yet enabled it for the Original Espruino as that does have a slightly different processor (an M3 vs M4) as well as not enough free flash memory without removing other features.

  • Thank you very much. After a bit of experimenting, I'm currently trying to find out, why the following function hangs indefinitly. It's a function which scans a portion (from this.idx to this.next) of an array for a given sequence, starting at an offset using a given stepping width.

    find(sequence, offset, stepping) {
            "jit";
            if (stepping === undefined) {
                stepping = 1;
            }
    
            if (offset === undefined) {
                offset = 0;
            }
    
            for (let i = this.idx + offset; i < this.next - sequence.length; i+=stepping) {
                if (this.buffer[i] !== sequence[0]) {
                    continue;
                }
                
                let idx = i;
    
                for (let j = 1; j < sequence.length; j++) {
                    if (this.buffer[i + j] !== sequence[j]) {
                        idx = -1;
                        // JIT lacks break statement
                        j = sequence.length - 1;
                    }
                }
    
                if (idx !== -1) {
                    return idx;
                }
            }
    
            return -1;
        }
    

    When I run it without jit it works as expected. If the function is jitted, the application hangs without any error. Thank you for your reply

  • Ok, I found the mistake. "continue" is not supported. As I fixed that it worked after turning off any minification of the code. If I minify, it does somehow not work anymore but does not give me any hint why. I was finally able to shave off another 150ms from my computation, which is very good :) Thank you very much Gordon.

  • Great - glad it helped!

    When you used break and continue, did you not get an error? For example if I do:

    function j() { "jit";
       for (var i=0;i<10;i++) {
         print("Hi",i);
         continue;
       }
    }
    

    It says:

    JIT SyntaxError: Got continue expected EOF
     at line 1 col 42
    function j(){"jit";for(var i=0;i<10;i++){print("Hi",i);continue;}}
    
  • I was just the fact, that I enabled minification, which led to the fact, that no errors were shown at all. Once I turned it off, the error you mentioned appeared :)

  • If the "continue" was there, the error should still show even if minified.
    Could be that the minification had some optimizations enabled and optimized the "continue' away.
    Then the minified code could fail for completely different reason. So it would be interesting to see the minified code. Maybe there is something else in JIT that does not work correctly.

    However I don't know how in code from post #3 the continue could be optimized away, which type of minification you had enabled?

  • the esprima offline minifier makes it into

    function (a,b,c) {"jit";c===undefined&&(c=1),b===undefine­d&&(b=0);for(let d=this.idx+b;d<this.next-a.length;d+=c){­if(this.buffer[d]!==a[0])continue;let b=d;for(let e=1;e<a.length;e++)this.buffer[d+e]!==a[­e]&&(b=-1,e=a.length-1);if(b!==-1)return­ b}return-1}
    

    so there is comma operator and ifs changed into condition && body and continue is still there

    when uploading from IDE I see

    JIT SyntaxError: Got continue expected EOF
     at line 1 col 143 in find.js
    ...){if(this.buffer[d]!==a[0])continue;l­et b=d;for(let e=1;e<a....
                                  ^
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Why is JIT not enabled on devices like Espruino WiFi even if they are on the latest firmware?

Posted by Avatar for llakie @llakie

Actions