SlideShare a Scribd company logo
JavaScript on Microcontrollers 
Samsung Open Source Group 1 
Tilmann Scheller 
LLVM Compiler Engineer 
t.scheller@samsung.com 
Samsung Open Source Group 
Samsung Research UK 
2nd Samsung Web Tech Talk 
San Jose, USA, October 30, 2014
Overview 
● Introduction 
● JavaScript engine code size 
● JavaScript engine correctness/performance 
● Summary 
Samsung Open Source Group 2
Introduction 
Samsung Open Source Group 3
Introduction 
● Wearable devices becoming more and more widespread 
● Weight and energy efficiency a big concern 
● JavaScript very popular, easy to learn 
● Scales from embedded to servers 
● Execute JavaScript on a microcontroller! 
Samsung Open Source Group 4
Target hardware 
● Cortex-M3 microcontroller (32-bit ARM Thumb-2) 
● 96KB of RAM 
● 512KB of flash memory 
● Clocked at 84MHz 
Samsung Open Source Group 5
JS Engines 
● Goal: JS engine which fits in the microcontroller 
constraints 
● Option one: Pick an established JS engine and strip it 
down to fit on a microcontroller 
● Option two: Pick a lightweight engine and make sure that 
it meets all the requirements 
Samsung Open Source Group 6
JS Engines 
● Two approaches pursued in parallel: 
– Try to minimize JavaScriptCore so that it fits on a 
microcontroller 
– Get the lightweight Duktape engine running on a 
microcontroller 
Samsung Open Source Group 7
JavaScriptCore 
● Well-established JS engine running on millions of devices 
● High-performance (four distinct levels of optimization) 
● Never intended to run in resource-constrained 
environments, primary focus is maximum performance 
● Written in C++ 
Samsung Open Source Group 8
Duktape 
● Lightweight JS engine 
● Focus on portability and a low footprint 
● Written in C and about 40k lines of code (excluding 
comments) 
● ECMAScript E5/E5.1 compliant 
● Liberal license 
● Active community, has been around for several years 
Samsung Open Source Group 9
Code size 
Samsung Open Source Group 10
JavaScriptCore minimization 
● Challenge: JavaScriptCore was never intended for 
environments like this 
● First attempt: 
– Took r170522 (June 26, 2014) of WebKit and built the EFL 
configuration for Thumb-2 
● Original (3.63 MB) 
● Reduced (2.39 MB) 
● Static (21.21 MB) 
– Several MB of heap memory consumed during runtime 
Samsung Open Source Group 11
JavaScriptCore minimization 
● Current snapshot: way too big! 
● Second try: Use a snapshot from 2008 just before SquirrelFish was merged 
● Performed minimizations: 
– Qt dependency was removed 
– Reduced the size of ICU data by disabling extra features 
– Rebuilt ICU with the –Os compiler option 
– Pthread was removed 
– Built older ICU libs 
– Stripped static JSC binary is now 1,647 KB (was: 19,578 KB) 
– The engine part of is 311 KB 
– The Unicode libraries are 562 Kbyte and the remaining size comes from libc, libm 
and libstdc++ libraries. 
Samsung Open Source Group 12
JavaScriptCore minimization 
● Engine size close to target size 
● However, libraries rely on too many system calls to make 
it feasible to run on a baremetal system 
● Too much effort to get JSC working on a baremetal 
system 
● Aborting JSC investigation and directing all efforts 
towards Duktape 
Samsung Open Source Group 13
Duktape 
● Compiled for Thumb-2 
● Using the newlib C standard library 
● No OS running on the microcontroller 
● Statically linked binary 
● C library has a big impact on the size of the executable 
● Disabling certain optimizations (through preprocessor 
macros), helps to reduce code size even further 
Samsung Open Source Group 14
Code size 
Static binary 
Engine 
Libraries 
108 
161 
100 
83 
70 
59 
212 
187 
127 
318 
655 
790 
1207 
311 
0 200 400 600 800 1000 1200 1400 1600 1800 
Samsung Open Source Group 15 
1647 
Duktape Thumb-2 baremetal noopt 
Duktape Thumb-2 baremetal 
Duktape ARM baremetal 
Duktape ARM Linux glibc 
JSC Thumb-2 Linux glibc 
KB 
Compiled at -Os ..., noopt = Duktape optimizations not compiled in, 
baremetal builds link against Newlib
Correctness/Performance 
Samsung Open Source Group 16
Correctness - test262 
● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines 
● test262 (ECMAScript conformance test suite) results: 
– Ran 11824 tests 
● Passed 11411 tests (96.5%) 
● Failed 413 tests (3.5%) 
● Failure details: 
– 144 tests ran out of memory 
– 10 tests timed out (300 secs) 
– 90 tests failed because of an undefined gettimeofday() function 
– 169 tests fail because of other reasons (have to be investigated) 
– Summary: 167 failures specific to the Arduino Due and 246 tests which fail on 
x86-64 as well 
Samsung Open Source Group 17
test262 
85 713 
288957 
Min Avg Max 
350000 
300000 
250000 
200000 
150000 
100000 
50000 
0 
Execution time (ms) 
Samsung Open Source Group 18 
Min Avg Max 
80 
70 
60 
50 
40 
30 
20 
10 
0 
54 
57 
75 
Memory usage (KB)
SunSpider 
● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines 
● Ran 26 tests 
– Passed 9 tests (34.6%) 
– Failed 17 tests (65.4%) 
● Failure details: 
– 3 tests were too big (string-unpack-code.js (164K), string-tagcloud.js 
(172K), regexp-dna.js (400K)) 
– 13 tests run out of memory (3d-cube.js, 3d-morph.js, 3d-raytrace.js, 
access-binary-trees.js, access-nsieve.js, bitops-nsieve-bits.js, crypto-aes.js, 
crypto-md5.js, crypto-sha1.js, date-format-tofte.js, date-format-xparb.js, 
string-base64.js, string-validate-input.js) 
– 1 test failed because of undefined gettimeofday() function (math-cordic.js) 
Samsung Open Source Group 19
SunSpider 
access-nbody 
160 
140 
120 
100 
80 
60 
40 
20 
access-fannkuch 
bitops-bits-in-byte 
bitops-3bit-bits-in-byte 
controlflow-recursive 
bitops-bitwise-and 
math-partial-sums 
Samsung Open Source Group 20 
math-spectral-norm 
string-fasta 
0 
149 
41.5 
64.3 
74.8 
140.2 
25.9 
62.3 
21.8 
119.9 
54 
64 
50 49 50 
70 
51 53 57 
Execution time (s) 
Memory usage (KB)
Summary 
Samsung Open Source Group 21
Summary 
● JavaScriptCore proved to be unsuitable for 
microcontrollers 
● Duktape fits well into flash and main memory 
● Duktape has promising correctness results 
● Ongoing effort to evaluate Duktape performance 
Samsung Open Source Group 22
Thank you. 
Samsung Open Source Group 23
We are hiring! 
Contact Information: 
Tilmann Scheller 
t.scheller@samsung.com 
Samsung Open Source Group 
Samsung Research UK 
Samsung Open Source Group 24
Ad

Recommended

Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
Isuru Perera
 
Java in flames
Java in flames
Isuru Perera
 
Training Slides: Advanced 302: Performing Schema Changes in a Multi-Site/Mult...
Training Slides: Advanced 302: Performing Schema Changes in a Multi-Site/Mult...
Continuent
 
Java Performance & Profiling
Java Performance & Profiling
Isuru Perera
 
Low latency & mechanical sympathy issues and solutions
Low latency & mechanical sympathy issues and solutions
Jean-Philippe BEMPEL
 
BKK16-208 EAS
BKK16-208 EAS
Linaro
 
Erasing Belady's Limitations: In Search of Flash Cache Offline Optimality
Erasing Belady's Limitations: In Search of Flash Cache Offline Optimality
Yue Cheng
 
Don't dump thread dumps
Don't dump thread dumps
Tier1 App
 
Le guide de dépannage de la jvm
Le guide de dépannage de la jvm
Jean-Philippe BEMPEL
 
Tools for Metaspace
Tools for Metaspace
Takahiro YAMADA
 
Using Flame Graphs
Using Flame Graphs
Isuru Perera
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJava
William Au
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
Isuru Perera
 
Multimaster
Multimaster
Stas Kelvich
 
Tuning Linux for MongoDB
Tuning Linux for MongoDB
Tim Vaillancourt
 
On the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
Jvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Get Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java Applications
ScyllaDB
 
Java GC, Off-heap workshop
Java GC, Off-heap workshop
Valerii Moisieienko
 
LXC on Ganeti
LXC on Ganeti
kawamuray
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
ScyllaDB
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
Alexey Lesovsky
 
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebula Project
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4 bcc
Viller Hsiao
 
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cruftex
 
Brief introduction to kselftest
Brief introduction to kselftest
SeongJae Park
 
Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)
Red Hat Developers
 
Tech giants of the last decade
Tech giants of the last decade
InVenture Partners
 
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
StandardlifeAEM
 

More Related Content

What's hot (20)

Le guide de dépannage de la jvm
Le guide de dépannage de la jvm
Jean-Philippe BEMPEL
 
Tools for Metaspace
Tools for Metaspace
Takahiro YAMADA
 
Using Flame Graphs
Using Flame Graphs
Isuru Perera
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJava
William Au
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
Isuru Perera
 
Multimaster
Multimaster
Stas Kelvich
 
Tuning Linux for MongoDB
Tuning Linux for MongoDB
Tim Vaillancourt
 
On the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
Jvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Get Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java Applications
ScyllaDB
 
Java GC, Off-heap workshop
Java GC, Off-heap workshop
Valerii Moisieienko
 
LXC on Ganeti
LXC on Ganeti
kawamuray
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
ScyllaDB
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
Alexey Lesovsky
 
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebula Project
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4 bcc
Viller Hsiao
 
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cruftex
 
Brief introduction to kselftest
Brief introduction to kselftest
SeongJae Park
 
Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)
Red Hat Developers
 
Using Flame Graphs
Using Flame Graphs
Isuru Perera
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJava
William Au
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
Isuru Perera
 
On the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
Jvm problem diagnostics
Jvm problem diagnostics
Danijel Mitar
 
Get Lower Latency and Higher Throughput for Java Applications
Get Lower Latency and Higher Throughput for Java Applications
ScyllaDB
 
LXC on Ganeti
LXC on Ganeti
kawamuray
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
OSv Unikernel — Optimizing Guest OS to Run Stateless and Serverless Apps in t...
ScyllaDB
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
Alexey Lesovsky
 
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebulaconf2017US: Rapid scaling of research computing to over 70,000 cor...
OpenNebula Project
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4 bcc
Viller Hsiao
 
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cache2k, Java Caching, Turbo Charged, FOSDEM 2015
cruftex
 
Brief introduction to kselftest
Brief introduction to kselftest
SeongJae Park
 
Analyzing Java Applications Using Thermostat (Omair Majid)
Analyzing Java Applications Using Thermostat (Omair Majid)
Red Hat Developers
 

Viewers also liked (19)

Tech giants of the last decade
Tech giants of the last decade
InVenture Partners
 
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
StandardlifeAEM
 
標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇
StandardlifeAEM
 
what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?
furbymojo
 
Danielle hardin
Danielle hardin
Danielle Hardin
 
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek
 
Polish Stocks 6. January 2017
Polish Stocks 6. January 2017
Gieldowy Wizjer
 
Slideshare ps2
Slideshare ps2
imcneal71
 
Vocabulary movie stars
Vocabulary movie stars
patpen55
 
baocao
baocao
Hoangdinhthanh Thành
 
IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013
Newsmonkey
 
Kelompok 2 komite etik
Kelompok 2 komite etik
Aprillia Indah Fajarwati
 
Final proposal pp
Final proposal pp
Kayleigh Wright
 
Magazine world is magnifique june 2014
Magazine world is magnifique june 2014
Prakash Montroy
 
Η Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια Πόλη
angelosozil118
 
Digital marketing lecture flow
Digital marketing lecture flow
Pranay Gothi
 
Digital marketing lecture flow
Digital marketing lecture flow
Pranay Gothi
 
CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015
Siddhant Mishra
 
Sap basis slide . pp
Sap basis slide . pp
shanmukha rao dondapati
 
Tech giants of the last decade
Tech giants of the last decade
InVenture Partners
 
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
標準人壽My Smart Planner Android 應用程式 - 轉換投資選擇
StandardlifeAEM
 
標準人壽 iOS應用程式 - 轉換投資選擇
標準人壽 iOS應用程式 - 轉換投資選擇
StandardlifeAEM
 
what kind of media institution might distribute your media product and why?
what kind of media institution might distribute your media product and why?
furbymojo
 
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek: 5 Useful Commerical Real Estate Tips
Frank Jermusek
 
Polish Stocks 6. January 2017
Polish Stocks 6. January 2017
Gieldowy Wizjer
 
Slideshare ps2
Slideshare ps2
imcneal71
 
Vocabulary movie stars
Vocabulary movie stars
patpen55
 
IAB Native Advertising Playbook 12-04-2013
IAB Native Advertising Playbook 12-04-2013
Newsmonkey
 
Magazine world is magnifique june 2014
Magazine world is magnifique june 2014
Prakash Montroy
 
Η Ρώμη - Η Αιώνια Πόλη
Η Ρώμη - Η Αιώνια Πόλη
angelosozil118
 
Digital marketing lecture flow
Digital marketing lecture flow
Pranay Gothi
 
Digital marketing lecture flow
Digital marketing lecture flow
Pranay Gothi
 
CDP Supply-Chain-report-2015
CDP Supply-Chain-report-2015
Siddhant Mishra
 
Ad

Similar to Js on-microcontrollers (20)

Introduction to IoT.JS
Introduction to IoT.JS
Samsung Open Source Group
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
Samsung Open Source Group
 
Introduction to IoT.JS
Introduction to IoT.JS
Samsung Open Source Group
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
Samsung Open Source Group
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Anna Shymchenko
 
Cat @ scale
Cat @ scale
Rohit Jnagal
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
Chester Chen
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
Jelastic Multi-Cloud PaaS
 
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
eurobsdcon
 
20141111_SOS3_Gallo
20141111_SOS3_Gallo
Andrea Gallo
 
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
inside-BigData.com
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
ScyllaDB
 
Clang: More than just a C/C++ Compiler
Clang: More than just a C/C++ Compiler
Samsung Open Source Group
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql Loader
GregSmith458515
 
module01.ppt
module01.ppt
Subhasis Dash
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)
Brendan Gregg
 
OpenDS_Jazoon2010
OpenDS_Jazoon2010
Ludovic Poitou
 
SOSCON 2016 JerryScript
SOSCON 2016 JerryScript
Samsung Open Source Group
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
Tier1 app
 
IBM Runtimes Performance Observations with Apache Spark
IBM Runtimes Performance Observations with Apache Spark
AdamRobertsIBM
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
Samsung Open Source Group
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Thin...
Samsung Open Source Group
 
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Вячеслав Блинов «Java Garbage Collection: A Performance Impact»
Anna Shymchenko
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
Chester Chen
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
Jelastic Multi-Cloud PaaS
 
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
Improving DragonFly's performance with PostgreSQL by Francois Tigeot
eurobsdcon
 
20141111_SOS3_Gallo
20141111_SOS3_Gallo
Andrea Gallo
 
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
Big Lab Problems Solved with Spectrum Scale: Innovations for the Coral Program
inside-BigData.com
 
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
Optimizing Servers for High-Throughput and Low-Latency at Dropbox
ScyllaDB
 
Speedrunning the Open Street Map osm2pgsql Loader
Speedrunning the Open Street Map osm2pgsql Loader
GregSmith458515
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)
Brendan Gregg
 
7 jvm-arguments-Confoo
7 jvm-arguments-Confoo
Tier1 app
 
IBM Runtimes Performance Observations with Apache Spark
IBM Runtimes Performance Observations with Apache Spark
AdamRobertsIBM
 
Ad

Recently uploaded (20)

Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 

Js on-microcontrollers

  • 1. JavaScript on Microcontrollers Samsung Open Source Group 1 Tilmann Scheller LLVM Compiler Engineer [email protected] Samsung Open Source Group Samsung Research UK 2nd Samsung Web Tech Talk San Jose, USA, October 30, 2014
  • 2. Overview ● Introduction ● JavaScript engine code size ● JavaScript engine correctness/performance ● Summary Samsung Open Source Group 2
  • 3. Introduction Samsung Open Source Group 3
  • 4. Introduction ● Wearable devices becoming more and more widespread ● Weight and energy efficiency a big concern ● JavaScript very popular, easy to learn ● Scales from embedded to servers ● Execute JavaScript on a microcontroller! Samsung Open Source Group 4
  • 5. Target hardware ● Cortex-M3 microcontroller (32-bit ARM Thumb-2) ● 96KB of RAM ● 512KB of flash memory ● Clocked at 84MHz Samsung Open Source Group 5
  • 6. JS Engines ● Goal: JS engine which fits in the microcontroller constraints ● Option one: Pick an established JS engine and strip it down to fit on a microcontroller ● Option two: Pick a lightweight engine and make sure that it meets all the requirements Samsung Open Source Group 6
  • 7. JS Engines ● Two approaches pursued in parallel: – Try to minimize JavaScriptCore so that it fits on a microcontroller – Get the lightweight Duktape engine running on a microcontroller Samsung Open Source Group 7
  • 8. JavaScriptCore ● Well-established JS engine running on millions of devices ● High-performance (four distinct levels of optimization) ● Never intended to run in resource-constrained environments, primary focus is maximum performance ● Written in C++ Samsung Open Source Group 8
  • 9. Duktape ● Lightweight JS engine ● Focus on portability and a low footprint ● Written in C and about 40k lines of code (excluding comments) ● ECMAScript E5/E5.1 compliant ● Liberal license ● Active community, has been around for several years Samsung Open Source Group 9
  • 10. Code size Samsung Open Source Group 10
  • 11. JavaScriptCore minimization ● Challenge: JavaScriptCore was never intended for environments like this ● First attempt: – Took r170522 (June 26, 2014) of WebKit and built the EFL configuration for Thumb-2 ● Original (3.63 MB) ● Reduced (2.39 MB) ● Static (21.21 MB) – Several MB of heap memory consumed during runtime Samsung Open Source Group 11
  • 12. JavaScriptCore minimization ● Current snapshot: way too big! ● Second try: Use a snapshot from 2008 just before SquirrelFish was merged ● Performed minimizations: – Qt dependency was removed – Reduced the size of ICU data by disabling extra features – Rebuilt ICU with the –Os compiler option – Pthread was removed – Built older ICU libs – Stripped static JSC binary is now 1,647 KB (was: 19,578 KB) – The engine part of is 311 KB – The Unicode libraries are 562 Kbyte and the remaining size comes from libc, libm and libstdc++ libraries. Samsung Open Source Group 12
  • 13. JavaScriptCore minimization ● Engine size close to target size ● However, libraries rely on too many system calls to make it feasible to run on a baremetal system ● Too much effort to get JSC working on a baremetal system ● Aborting JSC investigation and directing all efforts towards Duktape Samsung Open Source Group 13
  • 14. Duktape ● Compiled for Thumb-2 ● Using the newlib C standard library ● No OS running on the microcontroller ● Statically linked binary ● C library has a big impact on the size of the executable ● Disabling certain optimizations (through preprocessor macros), helps to reduce code size even further Samsung Open Source Group 14
  • 15. Code size Static binary Engine Libraries 108 161 100 83 70 59 212 187 127 318 655 790 1207 311 0 200 400 600 800 1000 1200 1400 1600 1800 Samsung Open Source Group 15 1647 Duktape Thumb-2 baremetal noopt Duktape Thumb-2 baremetal Duktape ARM baremetal Duktape ARM Linux glibc JSC Thumb-2 Linux glibc KB Compiled at -Os ..., noopt = Duktape optimizations not compiled in, baremetal builds link against Newlib
  • 17. Correctness - test262 ● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines ● test262 (ECMAScript conformance test suite) results: – Ran 11824 tests ● Passed 11411 tests (96.5%) ● Failed 413 tests (3.5%) ● Failure details: – 144 tests ran out of memory – 10 tests timed out (300 secs) – 90 tests failed because of an undefined gettimeofday() function – 169 tests fail because of other reasons (have to be investigated) – Summary: 167 failures specific to the Arduino Due and 246 tests which fail on x86-64 as well Samsung Open Source Group 17
  • 18. test262 85 713 288957 Min Avg Max 350000 300000 250000 200000 150000 100000 50000 0 Execution time (ms) Samsung Open Source Group 18 Min Avg Max 80 70 60 50 40 30 20 10 0 54 57 75 Memory usage (KB)
  • 19. SunSpider ● Duktape 0.12 and Arduino library 1.5.8, without DUK_OPT defines ● Ran 26 tests – Passed 9 tests (34.6%) – Failed 17 tests (65.4%) ● Failure details: – 3 tests were too big (string-unpack-code.js (164K), string-tagcloud.js (172K), regexp-dna.js (400K)) – 13 tests run out of memory (3d-cube.js, 3d-morph.js, 3d-raytrace.js, access-binary-trees.js, access-nsieve.js, bitops-nsieve-bits.js, crypto-aes.js, crypto-md5.js, crypto-sha1.js, date-format-tofte.js, date-format-xparb.js, string-base64.js, string-validate-input.js) – 1 test failed because of undefined gettimeofday() function (math-cordic.js) Samsung Open Source Group 19
  • 20. SunSpider access-nbody 160 140 120 100 80 60 40 20 access-fannkuch bitops-bits-in-byte bitops-3bit-bits-in-byte controlflow-recursive bitops-bitwise-and math-partial-sums Samsung Open Source Group 20 math-spectral-norm string-fasta 0 149 41.5 64.3 74.8 140.2 25.9 62.3 21.8 119.9 54 64 50 49 50 70 51 53 57 Execution time (s) Memory usage (KB)
  • 21. Summary Samsung Open Source Group 21
  • 22. Summary ● JavaScriptCore proved to be unsuitable for microcontrollers ● Duktape fits well into flash and main memory ● Duktape has promising correctness results ● Ongoing effort to evaluate Duktape performance Samsung Open Source Group 22
  • 23. Thank you. Samsung Open Source Group 23
  • 24. We are hiring! Contact Information: Tilmann Scheller [email protected] Samsung Open Source Group Samsung Research UK Samsung Open Source Group 24