eJSTK is a toolkit to develop a subset of JavaScript VM.
Takafumi Kataoka, Tomoharu Ugawa, Hideya Iwasaki: A Framework for Constructing JavaScript Virtual Machines with Customized Datatype Representations, ACM SAC 2018.
This repository contains three submodules for tools developed in the eJS project.
ejsvm--- eJSVM compilervmgen--- tools for generating datatype part and instruction part of the eJSVMejsc--- JavaScript compiler to eJSVM code
Please note that eJSVM currently supports only a subset of JavaScript. If your JavaScript program does not work, please try a simpler example.
-
Clone all submodules
-
Make symbolic link to vmgen under ejsvm
cd ejsvm
ln -s ../vmgen
- Download the following files and place them under
ejsc/libs.
- antlr-4.5.3-complete.jar
- javax.json-1.0.4.jar
-
Build by
make compiler.jarunderejscdirectory. -
compiler.jarwill be created. Execute it. Following command will compile a JavaScript filesample.jsand createsample.sbc.
$ java -jar compiler.jar sample.js
-
Build vmgen by
antunder theejsvm/vmgendirectory. -
Create the common part of Makefile
ejsvm/common.mk.ejsvm/common.mk.templateis the template. You may need to modify it for your environment. -
Create a build directory. For example,
mkdir ejsvm/build. -
Create a
Makefileunder the build directory.Makefilespecifies a datatype definition file and a operand specification file, and includescommon.mk. The following example is a Makefile for a VM with default type definitions and instructions accepting any datatype of operands.
.PRECIOUS: %.c %.h
DATATYPES=../datatypes/default.def
OPERANDSPEC=../operand-spec/any.spec
CFLAGS=-DNDEBUG -UDEBUG -O3
include ../common.mk
-
Build by
make. -
Execute an sbc file by
./ejsvm sample.sbcexecutesample.sbc.