- Notifications
You must be signed in to change notification settings - Fork59
js.js: A JavaScript JavaScript interpreter
License
jterrace/js.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
js.js is a JavaScript interpreter in JavaScript. Instead of trying to create aninterpreter from scratch,SpiderMonkey is compiled intoLLVM and thenemscripten translates the output into JavaScript.
See several running demoshere.
Academic paper to appear atWebApps 2012 locatedhere.
The compiled version of js.js is 3MB and only594KB after gzip compression.Using theSunspider benchmark, the interpreter is about200 times slowerthan Spidermonkey's native interpreter with the JIT compiler turned off. Moreoptimizations and benchmarks are coming soon.
Here is an example of how to use the API:
var jsObjs = JSJS.Init();var rval = JSJS.EvaluateScript(jsObjs.cx, jsObjs.glob, "1 + 1");var d = JSJS.ValueToNumber(jsObjs.cx, rval);window.alert(d); //2JSJS.End(jsObjs);
More examples are available in theexamples directory.
The following files are located in thesrc directory.
| File | Description |
|---|---|
js.O0.js | Command-line JS shell, no optimizations |
js.O0.min.js | Command-line JS shell, no optimizations, closure compiled |
js.O1.js | Command-line JS shell, O1 optimizations |
js.O1.min.js | Command-line JS shell, O1 optimizations, closure compiled |
js.O2.js | Command-line JS shell, O2 optimizations |
js.O2.min.js | Command-line JS shell, O2 optimizations, closure compiled |
libjs.O0.js | JSAPI shared library, no optimizations |
libjs.O0.min.js | JSAPI shared library, no optimizations, closure compiled with js.js wrapper |
libjs.O1.js | JSAPI shared library, O1 optimizations |
libjs.O1.min.js | JSAPI shared library, O1 optimizations, closure compiled with js.js wrapper |
libjs.O2.js | JSAPI shared library, O2 optimizations |
libjs.O2.min.js | JSAPI shared library, O2 optimizations, closure compiled with js.js wrapper |
jsjs-wrapper.js | js.js wrapper API to make using the JSAPI easier |
To run the shell, you want to run one of these:
js js.O2.min.js -e "print('hello');"node js.O2.min.js -e "print('hello');"To include the API in your website, include the minified libjs like this:
<script type="text/javascript" src="libjs.O2.min.js"></script>
Alternatively, you can use the wrapper script directly with a non-minifiedversion (useful for debugging and modifications):
<script type="text/javascript" src="libjs.O2.js"></script><script type="text/javascript" src="jsjs-wrapper.js"></script>
About
js.js: A JavaScript JavaScript interpreter
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.