V7

embedded JS VM

@CesantaHQ

by Marko Mikuličić, Cesanta Software, for FOSDEM 2016

What is V7

  • Embedded JavaScript engine written in C
  • Compliant to ISO C90 and ISO C++98
  • Targets embedded systems
  • Or C/C++ programs that need scripting engine
  • Conforms to ECMA 5.1 standard
  • Easy to embed: only two files, v7.c and v7.h
  • Easy to use embedding API
  • Open Source, under GPLv2/commercial license
  • GitHub repo: https://github.com/cesanta/v7/

Who are we

  • Irish Startup founded by ex-Googlers in 2013
  • Makers of the Mongoose embedded web server, over 1M downloads since 2004
  • Goal: make it easy for everyone to make connected devices

Why JavaScript ?

Why JavaScript

  • Why not Lua, Python, LISP, brainfeck, ... 
  • Well, why scripting ?

Why JavaScript

  • Everybody (thinks) to know (a bit of) it
  • Popular, Widely available
  • Maturing but not stagnating

Goals: V7 vs other JS VMs

  • Portable
  • Small runtime overhead
  • Small code footprint
  • Reasonably fast
  • Simple

Memory savings

Techniques

  • Implicit data structures
  • Compacting GC.
  • Static object graph snapshots
  • mmapping pre-compiled bcode
  • coroutine based parser (segmented stack)

Questions ?

Implicit data structures

Implicit data structures are data structures with negligible space overhead;  auxiliary information is mostly represented by permuting the elements cleverly

AST

AST

AST

AST - no pointers

(mostly)

Made with Slides.com