Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things - FOSDEM 2017

13,624 views

Published on

Tilmann Scheller explains how JerryScript can be valuable for building IoT devices

Published in: Software
  • Be the first to comment

  • Be the first to like this

JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things - FOSDEM 2017

  1. 1. 1Samsung Open Source Group JerryScript An ultra-lightweight JavaScript engine for the Internet of Things Tilmann Scheller Principal Compiler Engineer t.scheller@samsung.com Samsung Open Source Group Samsung Research UK FOSDEM 2017 Brussels, Belgium, February 4 – 5, 2017
  2. 2. 2Samsung Open Source Group Overview ● Introduction ● Demo ● Questions
  3. 3. 3Samsung Open Source Group Introduction
  4. 4. 4Samsung Open Source Group What is JerryScript? ● A really lightweight JavaScript engine ● Has a base footprint of ~3KB of RAM ● Optimized for microcontrollers ● Originally developed from scratch by Samsung ● JerryScript is an open source project released under the Apache License 2.0 ● Actively developed on GitHub
  5. 5. 5Samsung Open Source Group Why JavaScript on microcontrollers? ● There's a huge pool of JavaScript developers ● Opens up the possibility for web developers to easily write software for embedded devices ● Performance overhead of JavaScript less of an issue for control tasks ● Increased productivity, shorter time to market ● Ability to load code dynamically over the network
  6. 6. 6Samsung Open Source Group JerryScript ● Heavily optimized for a low memory footprint ● Interpreter-only ● Compact object representation ● Compressed pointers ● No AST, directly creating byte code ● Compact byte code heavily optimized for low memory consumption
  7. 7. 7Samsung Open Source Group JerryScript ● Written in pure C99 ● About 91KLOC ● Code size at 133KB when compiled with GCC in LTO mode for ARM Thumb-2 ● Implements the entire ECMAScript 5.1 standard, passes 100% of the test262 conformance test suite ● C API for embedding JerryScript ● Byte code snapshot feature
  8. 8. 8Samsung Open Source Group JerryScript Portability ● Extremely portable ● Self-contained ● Small C standard library ● Can run on bare-metal ● Supports the STM32F4, Arduino 101, FRDM-K64F, Photon, ESP8266 (experimental) boards ● OS support: NuttX, Zephyr, mbed OS, RIOT ● Runs on Linux/macOS as well
  9. 9. 9Samsung Open Source Group Target hardware ● Particle Photon board ● Cortex-M3 clocked at 120 MHz ● 128KB of RAM ● 1MB of flash memory ● Integrated Wi-Fi ● Small footprint (37mm x 20mm)
  10. 10. 10Samsung Open Source Group Memory consumption/ Performance
  11. 11. 11Samsung Open Source Group SunSpider 1.0.2 - Memory consumption 3d-cube 3d-raytrace access-binary-trees access-fannkuch access-nbody bitops-3bit-bits-in-byte bitops-bits-in-byte bitops-bitwise-and bitops-nsieve-bits controlflow-recursive crypto-aes crypto-md5 crypto-sha1 date-format-tofte date-format-xparb math-cordic math-partial-sums math-spectral-norm string-base64 string-fasta 0 50 100 150 200 250 300 350 400 35 185 38 11 11 5 5 4 139 80 57 142 92 21 21 6 5 12 125 20 138 339 160 101 106 98 97 97 207 135 190 261 169 352 147 102 101 102 267 107 JerryScript 1.0 Duktape 1.5.1 Max RSS in KB (lower is better) Measured on a Raspberry Pi 2
  12. 12. 12Samsung Open Source Group SunSpider 1.0.2 - Performance 3d-cube 3d-raytrace access-binary-trees access-fannkuch access-nbody bitops-3bit-bits-in-byte bitops-bits-in-byte bitops-bitwise-and bitops-nsieve-bits controlflow-recursive crypto-aes crypto-md5 crypto-sha1 date-format-tofte date-format-xparb math-cordic math-partial-sums math-spectral-norm string-base64 string-fasta 0 1 2 3 4 5 6 7 8 0.94 1.11 0.59 2.38 1.08 0.58 0.85 1.01 1.8 0.38 1.11 0.73 0.7 0.87 0.47 1.33 0.73 0.58 2.06 1.39 1.01 1.62 1.23 2.19 1.65 1.51 1.71 7.4 2.88 1.13 1.76 1.44 1.33 3.08 1.64 2.56 2.69 0.83 4.18 4.53 JerryScript 1.0 Duktape 1.5.1 Execution time in seconds (lower is better) Measured on a Raspberry Pi 2
  13. 13. 13Samsung Open Source Group Demo
  14. 14. 14Samsung Open Source Group JerryScript 6LoWPAN Demo ● Multiplayer implementation of the classic Pong game ● Each device drives one LED matrix as a display ● Game implemented in JavaScript ● Running on Photon board/Raspberry Pi 2 ● Low-power wireless communication via 6LoWPAN ● "AI" opponent running on the microcontroller
  15. 15. 15Samsung Open Source Group JerryScript 6LoWPAN Demo Raspberry Pi 2 (1GB RAM, 8GB Flash) Pong JerryScript Linux Particle Photon (128KB RAM, 1MB Flash) Pong JerryScript RIOT USB Keypad LED Matrix LED Matrix I2C I2C Switches via GPIO 6LoWPAN
  16. 16. Thank you. 16Samsung Open Source Group
  17. 17. 17Samsung Open Source Group Contact Information: Tilmann Scheller t.scheller@samsung.com Samsung Open Source Group Samsung Research UK

×