Actionscript3 to LLVM to ? (Reverse Alchemy)
I've been wonderin开发者_运维知识库g if it's possible to change the backend of the LLVM implementation from ARM to something else for instance C or C++? Currently Adobe uses a Actionscript3 frontend (which I can't currently find - closed source?) for the LLVM to produce iOS applications. I'm wondering why there isn't more options for other backends? Of course there are limitations to going this route, no loading of external swf files at runtime (to name just one), but the iOS applications seem to manage really well with this feat.
I did find this pdf which talks about the AS3 LLVM frontend, but no guidance to where the code is or how to investigate...
I just think it's a missed opportunity that Adobe are missing and wondered how much work it would be to do such a feat?
Please note: I know Haxe can output to C++ very well at the moment ;-)
[Edit: updated the Haxe note]
I like the way you think, I once ventured down that road and really investigated hard into how to accomplish the same thing. See this answer for more details about how the alchemy toolchain works (specific to iOS):
Adobe Air ios packager
Basically you're right, adobe is using an internal version of the actionscript compiler that is not open source. However, if you want to live dangerously (lol) you can always download the old packager for iphone or the new AIR 2.7 SDK and extract their version of the ASC from ADT.jar. You'll notice there are a ton of new LLVM related classes that interface with a LLVM dll that is included with the SDK now (and the old PFI). This is the front end, these LLVM java classes are what intercept the bytecode at during compilation and pass them out the LLVM library which in turn exports to ARM. Now you MIGHT be able to compile your own LLVM library and replace the existing one, and just set the output target on YOUR LLVM lib to whatever is current supported by LLVM ( I believe there is a C/CPP back end). This COULD be possible because like I said, from what I understand the LLVM compiled library doesn't have the front end built into it, the front end is written in Java and basically converts the AVM bytecode into LLVM IR, and then passes that IR to the LLVM lib. If you do manage to do this please find be on here and let me know because I'd be really interested in this. I just don't have the time to pursue it myself atm.
This flow (AS3/SWF -> other targets) is a fascinating topic that I'd love to learn more about. Basically the question is, how can you get flash-based content outside the Flash Player? Ideally with Stage3D support.
One obvious target is JavaScript + webgl (aka, HTML5 technologies).
Here are a few resources I'm aware of:
I believe Emscripten / asm.js was introduced since your discussion above. It is an LLVM to JavaScript compiler, primarily for porting C/C++ to JavaScript (see slide). The list of apps ported to JS via emscripten is impressive - from ScummVM to Doom to Linux! As you mention, the AIR compiler (adt.jar) generates LLVM at one point - perhaps it's possible for AIR apps to be ported to JS via LLVM / emscripten.
Renaun Erickson posted about a starling example ported to JavaSciprt and webgl using the (sadly now defunt) Randori Framework. But the git repos are all still in place, and his demo works swimmingly in Chrome (though not on iPad with iOS 8.1, webgl support, hmm.)
The above-mentioned Jangaroo is interesting, though 1) seems limited in performance, 2) implements a subset of AS3, and 3) doesn't seem to mention Stage3D (GPU acceleration).
OpenFL is worth mentioning, as it supports many more targets than AIR, including C/C++ and HTML5/webgl, though it would require source translation from AS3 to Haxe (which are related, but different enough to make translation irritating.) Here's a starling demo in HTML5 via OpenFL (and related thread).
This is probably more of a wiki / discussion than an answer, but I hope our collection of info morphs into a good workflow and answer for this question.
精彩评论