Skip to content

JavaScript bytecode virtual machine implemented in Go

Notifications You must be signed in to change notification settings

siyul-park/minijs

Repository files navigation

minijs

go report go doc release ci code coverage

minijs is a JavaScript bytecode virtual machine implemented in Go. It converts JavaScript code into bytecode for execution and, with high compatibility with Go, can be seamlessly embedded into various Go-based applications.

Key Features

  • Bytecode Execution: Optimizes performance by converting JavaScript code into bytecode and executing it in a virtual machine.
  • High Compatibility with Go: Developed in Go, making it easy to integrate into Go-based applications.

Installation

minijs runs in a Go environment. You can clone the repository and build it using the following commands:

git clone https://github.com/siyul-park/minijs.git  
cd minijs  
make build  

Usage

Running the REPL

You can execute JavaScript code interactively in the REPL (Read-Eval-Print Loop).

minijs  
> 'b'+'a'+ +'a'+'a'  
"baNaNa"  

Bytecode Output

To print the corresponding bytecode, use the -print-bytecode flag.

minijs --print-bytecode  
> 'b'+'a'+ +'a'+'a'  
section .text:  
        global _main  

_main:  
        cload 0x00000000 0x00000001  
        cload 0x00000002 0x00000001  
        cadd  
        cload 0x00000002 0x00000001  
        ctof64  
        f64toc  
        cadd  
        cload 0x00000002 0x00000001  
        cadd  

.section .data:  
        b  
        a  

"baNaNa"  

Executing a JavaScript File

When executing a file, minijs applies optimization processes to make the bytecode more efficient. To run a JavaScript file, use the following command:

minijs bababa.js  

Printing Bytecode from a File

To print the bytecode while executing a file, use the -print-bytecode flag.

minijs -print-bytecode bababa.js  
section .text:
        global _main

_main:
        cload 0x00000000 0x00000006
        pop

.section .data:
        baNaNa

About

JavaScript bytecode virtual machine implemented in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published