サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
Pixel 9
kripken.github.io
The software ecosystem has a lot of useful but unsafe code, and the easier it is to sandbox that code, the more often that’ll happen. If it were as simple as passing the compiler a --sandbox flag that makes an unsafe library unable to see or affect anything outside of it, that would be incredible! We can’t get it quite that easy, but this post describes WasmBoxC, a sandboxing approach that is very
Pausing and resuming code can be useful for various things, like implementing coroutines, async/await, limiting how much CPU time untrusted code gets, and so forth. If you are customizing a WebAssembly VM then you have various ways to instrument the compiled code to do this. On the other hand, if you want to do this in “userspace”, that is, if you are running inside of a standard WebAssembly VM an
Dec 9th 2015 an open source LLVM-based compiler from C and C++ to JavaScript C++ ⇒ LLVM ⇒ Emscripten ⇒ JS float array[5000]; // C++ int main() { for (int i = 0; i < 5000; ++i) { array[i] += 1.0f; } } ⇒ Emscripten ⇒ function main() { // JavaScript var a = 0, b = 0; do { a = (8 + (b << 2)) | 0; HEAPF32[a >> 2] = +HEAPF32[a >> 2] + 1.0; b = (b + 1) | 0; } while ((b | 0) < 5000); } This is asm.j
Emscripten & asm.js: C++'s role in the modern web Alon Zakai / @kripken All major web browsers are written in C++ For the obvious reasons: fast, familiar, library support For the same reasons, people want to use C++ to write web content too, that is, websites That's what this talk is about The Web Largest open platform in existence No C++ there :( What about non-standardized approaches (ActiveX, F
Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform.
input extern void puts(const char *str); int main() { puts("hello, world!"); return 0; } console Limitations C preprocessor is not hooked up. If you want to also execute the code, use this LLVM IR runner or one of the many CPU emulators out there in JS. This is a quick hack, build size and perf have not been optimized yet.
JS engines don't always run at full speed Motivated asm.js, an easy to optimize subset of JS function asmCode(global, env, buffer) { 'use asm'; var HEAP = new global.Uint8Array(buffer); function fib_like(x) { x = x|0; if ((x >>> 0) < 2) return HEAP[x]|0; return ((fib_like((x-2)|0)|0) + (fib_like((x-1)|0)|0))|0; } return fib_like; } HEAP cannot be replaced |0 trick ensures 32-bit ints Typed arrays
Alon Zakai (Mozilla) @kripken QCon Other Languages? Why? ;) JavaScript is great Runs in all browsers Familiar syntax Dynamic typing Other languages are great too Mixing Languages: examples Spreadsheets: C/C++ and VBA, etc Web browsers: C/C++ and JavaScript Game engines: C/C++ and Lua, etc. Libraries for scripting languages: Python and C/C++ modules like NumPy, etc. Mixing Languages When useful, gi
FAQ Are you really porting the entire Lua VM? Yes: The entire Lua 5.2.2 codebase written in C is compiled to JavaScript here, including a full incremental GC and everything else. It fits in 200K of gzipped JavaScript. How can a VM running in a VM be fast? Lua is implemented in portable C. It is possible to run C compiled to JavaScript at speeds approaching that of a native build (using the asm.js
Alon Zakai / Mozilla Compiling to JavaScript JavaScript is standards-based and the only language that runs in all web browsers You can run only JavaScript in browsers, but you can write in another language - if you compile it to JavaScript First set of demos BananaBread Qt Ruby Compiling to JavaScript: Nothing New! 2006: Google Web Toolkit (GWT), Java to JS 2007: pyjamas, Python into JS Adoption J
This is a demo of compiling and running LLVM assembly in JavaScript. Press the button to see it compile and run a tiny "hello world" program. You can also try modifying the LLVM assembly and pressing the button again - note though that LLVM assembly is typed, so if you add characters to the string for example, you will need to adjust its length, both where it is defined and where it is used (other
このページを最初にブックマークしてみませんか?
『http://kripken.github.io/』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く