New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local 'JIT' compiled JavaScript #4
Comments
Ok, now a mile better. Just grab EspruinoTools and run This actually produces real assembled code now - not that it works or anything :) Biggest thing right now is 'exporting' the function pointers. You'll have to compile your own Espruino firmware, look at the |
Ok, this now actually works (a bit). You need the
IF and >1 argument now added TODO
|
See latest post: http://forum.espruino.com/conversations/259821/#comment12009165 Much better now, in fact probably useful - just need local variables and a few minor tweaks. Function calls/object access would be cool too |
Some other bugs discovered by JumJum too. See above post. |
@gfwilliams am I missing something, as the js_compiler branch no longer seems to be in the Espruino repo here on GH? |
@maks it's actually been merged into master/gh_pages now (Just check out the main branch in EspruinoWebIde/EsoruinoTools and you'll be fine). To update:
|
Closing this now. Project has moved to https://github.com/gfwilliams/EspruinoCompiler - it's an online compiler, but honestly something like GCC is a much better bet for producing fast, reliable code. Maybe at some point we'll be able to cross-compile ARM-GCC into JS with emscripten, and at that point it can move offline again :) |
Recently I've been wondering a bit about ways to get more 'native' speed out of Espruino. While it's fast enough for most things, sometimes you still notice problems - when doing things like manipulating images or decoding raw waveforms from the radio.
So, right now the solutions seem to fall into:
I've been talking to a few people about this, and another option has come up that's kind of a hybrid of the last 3 approaches... What if we could compile JavaScript to assembler inside the Web IDE, where there's more memory available?
It wouldn't have to be 100% full JS coverage - just enough that the stuff that needs to run quickly can do.
I just did a very quick proof of concept of this using acorn for the parsing. It's 150 lines so far, and if you type the following code:
Then when you click 'upload' it'll get parsed and will be converted to the following 'pseudo-assembler':
There's obviously still a bit to do before it's useful, but it's surprisingly close. While the generated code isn't super-fast, it'll still be a massive improvement over interpreting.
TODO
jsvMathsOp
/jspeiFindInScopes
/etc from the interpreter. This could just be a struct somewhere in memory with this stuff in a predefined order.jsvUnLock
properly when calling functionsassembler.js
And a few obvious optimisations
Anyway, the hacky proof of concept is in https://github.com/espruino/EspruinoTools/tree/js_compiler. To use it, just add
plugins/compiler.js
to the Web IDE's main.html file and it'll spring into lifeThe text was updated successfully, but these errors were encountered: