7. SANDBOXED EXECUTION
ENVIRONMENT FOR NATIVE
CODE
Code is generated by dedicated toolchain (gcc based)
Static code analysis and verification before execution
No access to OS or memory outside the sandbox
OS functionality only via browser API
8. PORTABLE NATIVE CLIENT
(PNACL)
Compiles to LLVM bytecode
LLVM / clang toolchain
Translated to machine code by the browser at runtime
Only a single, architecture independent binary
10. COMPATIBILITY
SO FAR ONLY CHROME :(
Supported platforms: x86, ARM, MIPS
Chrome on Windows, Linux, OSX, ChromeOS
No mobile systems yet
NACL and PNACL for packaged apps
PNACL for the web
12. PEPPER
Similar to the pepper plugin API (PPAPI)
C and OOP C++ wrapper
Asynchroneous, callback based
Access to HTML5 filesystem
Video, including OpenGL ES 2.0
Audio
HTTP, TCP / UDP sockets (packaged apps only)
Communication with Javascript via postMessage style
messages
13. POSIX IS AVAILABLE AS WELL
Virtual filesystem
Resides in memory
HTML5 filesystem and server can be mounted
Enables standard POSIX file operations
Network Sockets
POSIX threads
→ Lots of existing POSIX-complient code just compiles out
of the box!
14. NACL-PORTS
Collection of opensource libraries and applications ported
to run on NaCl
Boost
Bullet
ffmpeg
ImageMagick
OpenCV
SDL
...
Most require only minor patches to the build system!
15. HOW DOES A NACL APP
LOOK LIKE?
(WARNING: C++ AHEAD)
26. ASM.JS
Bytecode-like subset of JS
JIT can optimize very well
Static type information
No garbage collection
Firefox has a dedicated JIT codepath: Odinmonkey
27. Compiles C / C++ to Asm.js via LLVM / clang
EMSCRIPTEN
28. Compilation to native code
NaCl: Ahead-of-time
Asm.js: Just-in-time
Performance
NaCl: Almost native (Google: 80%-90%), predictable
Asm.js: 2x - 3x native, highly dependent on browser
Threads
NaCl: full POSIX threads
Asm.js: No threading
Compatibility
NaCl: Just Chrome atm
Asm.js: Everything that runs JS (performance varies)
29. PEPPER.JS
Implements Pepper API in Javascript
Allows to compile applications for both NaCl and JS via
Emscripten
Can be used to target both NaCl and other browsers via
Asm.js
Obviously still no threads :(
30. WRAP-UP
Powerful technology
Runs existing C / C++ code almost unmodified in the
browser
Supports threading
Useful for both background processing and visible
interaction
Perfect package existing applicatons as Chrome apps
Currently only Chrome :(