Wednesday, March 27, 2013

[ LLVM ]

Subject: [ LLVM ]

  • note: originally emailed 03/27/2013 and sanitized for public consumption
  • sidenote: posting here so i can lead people here whenever they ask me about this stuff...



While looking at the [XYZ] features, and wanting to use node.js – it is possible to take existing code (logic mostly) that can be 'converted' (for example, from C or C++) to run in the Google's V8 javascript engine – that node.js also uses.

But this isn't about javascript.  The piece of technology I want to bring to attention is called LLVM – Low Level Virtual Machine.  This project was only called a VM for legacy reasons.  But LLVM is much much more.  It's now known as the "LLVM compiler infrastructure".

Basically, it is possible to take (for example) a C++ library, convert it (for example) to javascript.

And since we like pictures to help describe things:
  • At the core, the programming language is generated to an "intermediate representation" (IR)
  • This IR object can then be used to be 'compiled to' the target platform
    • This can hardware (machine code)
    • But can also be software (byte code)

  • Here's an example of how nVidia took the LLVM project make their CUDA compiler

  • Here's another example of how source code from one language can be used to generate source code in another language

Here’s a pretty good slide deck intro to LLVM:

Mozilla and UE GDC talk

Subject: Mozilla and UE GDC talk

  • note: originally emailed 03/27/2013 and sanitized for public consumption
  • sidenote: posting here so i can lead people here whenever they ask me about this stuff...

-----Original Message-----
From: XXX
Sent: Wednesday, March 27, 2013
Subject: Mozilla and UE GDC talk

I went to a talk given by mozilla and UE this morning. They demonstrated the UE3 engine, and game, running natively in the firefox web browser. Mozilla developed 2 tools that were used to port the engine
  • emscripten converts c/c++ into js
  • they created a js library called asm.js that creates and executes high performance java script. This is accomplished through AOT js compilation and by enforcing types in the js.
[SNIP] UE and mozilla said this is the key to getting performance out of js running in a web browser.

With the use of these tools they said the port took 1 week. The [UE3] running in a browser gets about half the performance of the native engine on the same hardware. It was a really impressive demo.  They showed a full game getting 60fps and said they can get 100fps.

The solution requires webGL so it works with firefox, Chrome, safari and any browser that supports web gl. IE does not support webGL.

Really cool stuff. What you can do natively in browsers (no plug ins) is very impressive.


This jogged my memory a bit:

About a year and a half ago: UE on flash and my comments about webGL under the hood.
From: Nick Shin
Sent: Friday, October 07, 2011 12:01 PM
Subject: News: Epic shows Unreal Tournament 3... running in a web browser -

This is webGL under the hood. The fact that you need to go through a flash layer is, in my humble opinion, kinda redundant.

Once webGL becomes open for public consumption (in other words, the browsers have them enabled by default) flash will go away.

Flash will not run on iPad.

You will see the Unreal Engine, Unity and all other game engines, 3D modelers and even 2D animation tools all move to webGL without the intermediary flash layer.

[ ... SNIP ... ]

-----Original Message-----
From: [Boss]
Sent: Friday, October 07, 2011 11:52 AM
Subject: News: Epic shows Unreal Tournament 3... running in a web browser -

Thoughts? Would this run on an Android or iPad?

Before that, I also wrote about emscripten
Sent: Monday, June 20, 2011 6:20 PM
Subject: Weekend Tech updates

A few weeks ago, we were looking into javascript frameworks
-----Original Message-----
Sent: Tuesday, May 31, 2011
Subject: JavaScript and UI Frameworks comparisons...

Here's a fun page I just ran into recently:

This basically means you can use (almost) any common programming languages to generate javascript code, greatly increasing the number of frameworks you can use.

[ SNIP ]

My most favorite: a C/C++ LLVM (low level virtual machine) to JavaScript compiler: Emscripten

and I noted: Emscripten from the following project:

Continuing with the original email thread:
We all know DOOM can run in a browser, but how many of you know how he did it?

[ ... SNIP ... ]

Really, I thought this would be a good excuse to talk about the LLVM (low level virtual machine) project. [snip] LLVM practically replaces the need to learn that (old stuff) with a much easier to grasp and modern programming methods. As a bonus, you get to learn about compiling architectures. If you ever wanted to create your own programming language, as well as a compiler for it to run natively -- this is a really cool tool to use.

A couple months ago, I wrote this to the lunch crowd: [a] full game engine that was also ported converted to JS (again via emscripten).
Sent: Thursday, Janurary 17, 2013 9:12 AM
Subject: Weekend Tech updates
Here's the article I was talking about -> C++ project ported to JS (with webGL) via Emscripten.

I really like where webGL is going.
Sent: Monday, February 13, 2012 1:40 PM
Subject: streaming full application to an HTML5 browser

I'm a big fan of openGL and the 3D modeler Blender.

Here's a fun project that shows a live feed of the 3D modeler's output in action in a webGL enabled browser.

This is truly going to be the future of seamless, plug-in-less, extremely powerful apps in a browser.

[ SNIP ]

-----Original Message-----
Sent: Wednesday, February 08, 2012 4:59 PM
Subject: streaming full application to an HTML5 browser

So I was reading through my RSS feeds and ran into this article:

[ SNIP ]

But it leads me to find this:
The HTML5 "Broadway" backend allows rendering GTK applications in HTML5-capable browsers.

[ SNIP ]

[ SNIP ]

I've saved the following for last: but I will email it in a follow up message (it's been sitting in my drafts folder for a few weeks -- waiting for a good reason to send it [snip]...

And this is the CORE of what [XXX] is talking about.  The AOT (ahead of time) 'compiler' part of the demo.

What I'm talking about is LLVM - or Low Level Virtual Machine.

The [new] thing I got out of the message [above] is "asm.js" - which isn't a javascript file that I can download and use.

But it is a spec that I would *love* to see the browsers pick up and run with it.  However, I have some serious doubts that we'll see this get picked up by all major browsers and I don't think we'll see this on the mobile platform at all...