Skip to content
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

jspEvaluate can use MemoryArea rather than creating a string #817

Closed
gfwilliams opened this issue Mar 8, 2016 · 2 comments
Closed

jspEvaluate can use MemoryArea rather than creating a string #817

gfwilliams opened this issue Mar 8, 2016 · 2 comments

Comments

@gfwilliams
Copy link
Member

No description provided.

@wilberforce
Copy link
Member

Please expand on what your are thinking here as I think this means we may be able to read modules from flash without copying into memory first

@gfwilliams
Copy link
Member Author

Right now jspEvaluate takes a char*, creates a new JS string from it and executes that. It could very easily execute without the copy into the JS string.

To be honest it's not high priority because jspEvaluate isn't used a great deal.

This has been covered many times before on the forum and GitHub, but sure - you can use 'Modules.addModule` with a MemoryArea, but that won't magically store your module in flash. The string is still executed and the result of execution is stored in RAM. The end result after uploading is the exact same memory usage.

With some huge hacks to Espruino you could maybe store the module source in flash with memoryarea, but it's not saving you that much as the function declarations still have to be in RAM, as does 1 JsVar representing the memoryarea itself. It means that unless your function has more than 16 characters of code in it you're going to be worse off using flash for it.

By far the best solution on systems with lots of flash is to use the variable cache branch. This stores everything in flash, and only uses RAM as a cache for the most-used JS Objects.

I spent quite a bit of time on it, but it still needs some tweaking to get it passing all the tests, and to make a flash filesystem for the variables. Sadly nobody else has picked it up and I don't have the time given ESP8266 is the only thing that really benefits.

Probably the most useful solution for all involved is to make the Web IDE capable of loading all modules into one file and then minifying. I just added an issue for this here: espruino/EspruinoTools#27

While it doesn't use flash, it would reduce code size so much that it's unlikely anyone would care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants