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

Feature: JavaScript VM #2432

Merged
merged 2 commits into from
Nov 30, 2021
Merged

Feature: JavaScript VM #2432

merged 2 commits into from
Nov 30, 2021

Conversation

slaff
Copy link
Contributor

@slaff slaff commented Nov 23, 2021

These libraries allow running JavaScript in a sandbox on all architectures supported by Sming. The actual JavaScript engine is JerryScript.

This is port from the initial work done for the U:Kit project.

Tasks:

  • Copyright headers
  • Add documentation
  • Move to submodule

Copy link
Contributor

@mikee47 mikee47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had an initial play with this, pushed some changest to your repo.
Looks great! Need to move jerryscript and jsvm into submodules though.
Maybe jerryscript could be contained within jsvm?

@mikee47
Copy link
Contributor

mikee47 commented Nov 23, 2021

I see there's a docker image to work with, but is there an easy way to compile .js into compatible snaps which might be integrated into the build system somehow?

@slaff
Copy link
Contributor Author

slaff commented Nov 24, 2021

but is there an easy way to compile .js into compatible snaps which might be integrated into the build system somehow?

Yes, there is. I will add further documentation and also improve the build system.
In short: JerryScript has JavaScript parser, compiler to byte code (called snapshots) and vm that executes the snapshots. In order to save space the JerryScript library here is compiled ONLY to execute the snapshots. Parsing and compiling the snapshots can be done via a compiled C binary running on Host or directly in the browser (using Emscripten). This allows for example users to change the JavaScript code directly in their browsers, compile it again in the browser and upload it to the embedded device. In addition since the modern browsers understand JavaScript it should be doable to run and debug the code in a sort of simulator directly in the browser. I guess I have to add another sample where the JavaScript code can be edited and compiled in the browser.

@mikee47
Copy link
Contributor

mikee47 commented Nov 24, 2021

but is there an easy way to compile .js into compatible snaps which might be integrated into the build system somehow?

Yes, there is....

@slaff Thanks for the clarification. I've had a play we can just use the standard jerryscript build tool to create the jerry-snapshot tool (it works for both Linux and Windows). If you like I'll try integrating that so the sample can use it to build the snapshot automatically.

@slaff
Copy link
Contributor Author

slaff commented Nov 24, 2021

If you like I'll try integrating that so the sample can use it to build the snapshot automatically.

This would be awesome :)

@slaff slaff changed the title [WIP] Feature: JavaScript VM Feature: JavaScript VM Nov 25, 2021
@slaff slaff added this to the 4.5.0 milestone Nov 25, 2021
@slaff slaff force-pushed the feature/jerryscript-vm branch from 498910b to 8053af4 Compare November 25, 2021 10:24
@slaff slaff requested a review from mikee47 November 25, 2021 10:29
@lgtm-com
Copy link

lgtm-com bot commented Nov 25, 2021

This pull request introduces 4 alerts when merging 194c17d into 7ca48eb - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class
  • 1 for Missing variable declaration
  • 1 for Use of returnless function

@mikee47
Copy link
Contributor

mikee47 commented Nov 25, 2021

@slaff Can you create a submodule for this? I'll review then.

@lgtm-com
Copy link

lgtm-com bot commented Nov 25, 2021

This pull request introduces 3 alerts when merging fe2ace4 into 7ca48eb - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class
  • 1 for Use of returnless function

@mikee47 mikee47 force-pushed the feature/jerryscript-vm branch from 9f0352c to 62297da Compare November 30, 2021 10:06
@slaff slaff merged commit 87718a2 into SmingHub:develop Nov 30, 2021
@slaff slaff mentioned this pull request Nov 30, 2021
5 tasks
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

Successfully merging this pull request may close these issues.

3 participants