Skip to main content

News

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Flying Jester

16
http://www.ludumdare.com/compo/

August 22-25. Sadly, I am moving over the weekend! Ludum Dare, y u always have such bad timing for me?

17
I call shenanigans on that name. I was using the word "Turbo" in conjunction with V8 long before Google ever did! And, what, they're relating a component of a car's engine to a style of jet engine? That makes less sense than calling the compiler a crankshaft!

https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fwww.golem.de%2Fnews%2Fturbofan-googles-neuer-v8-compiler-fuer-chrome-1408-108291.html&edit-text=&act=url

https://codereview.chromium.org/426233002

https://groups.google.com/forum/#!msg/v8-dev/ab8V5Z58_70/5-05DvysCt8J

This literally just landed in the Chromium branch of V8 a day ago, so that's the only source I can find that describes it. But someone I know at Mozilla says that this patch finally makes V8 faster than SpiderMonkey again. A long time ago, I said that I had faith that V8 would remain faster than SM. For about the last year, it was the other way around.

I did a tiny bit of profiling, and I think I see why TurboFan is so much better. V8's old high optimizer (Lithium? Or was it Hydrogen?) In Crankshaft had a really hard time spinning up--it would take thousands of loop runs, tens of thousands of function calls, sometimes it would spin up and down without reaching equilibrium. It seemed that the old compiler's optimizer was petrified of making an optimization that would need to be reversed. Newer SM does the opposite, optimizing after as few as ten loops or calls. And it seemed to pay off! I think that TurboFan has new optimizer (or perhaps just provides better info to the same old optimizer?), either way it spins up way faster and more consistently.

It also looks like TurboFan can compile to true 64-bit machine code, which is something V8 didn't do before! I'm excited to see this in action!
18
Programming / Fasm for OS X
My favorite assembler by far is FASM (the Flat Assembler). Generally, I don't do very much ASM work, but I prefer FASM because it makes it extremely simple to link the object files it generates with C/C++ projects simply using my C/C++ linker.

It's also very nice that is an extremely in-depth x86 (16 and 32 bit) and amd64 assembly guide, complete with an entire listing of instructions, included with it.

FASM isn't distributed for OS X, but a 'blank' assembled ELF32 object file is for Unix-like OS's. After a little work, and using Agner Fog's object converter, I managed to get this converted to the native Mach-O format of OS X, change its symbols to use underscores (since basically all C libraries require/expect this). After that, it was a simple matter to link the resulting object file, and get a working FASM executable.

Any files created with it would have to be converted to Mach-O to be used with Clang/LLVM, but that's simple with objconv. And given that, if you get to that point, you just wrote a bunch of ASM and are linking it with a native C/C++ project, I doubt that adding a builder definition to your build scripts would be too complex to handle :)

I've looked around, and I can't find any other place where this process is detailed, and I found lots of unanswered questions when DuckDuckGo'ing for 'Fasm for OS X'. So if I'm not the first to get this working, whoever else has done it isn't talking about it.

A copy of the OS X Fasm executable, along with the source, the intermediate files, and full instructions on how to build it yourself can be found at https://github.com/FlyingJester/fasm.
19
Off-Topic Discussions / I made a Firefox add-on!
Get 'New Tab On The Left', a Firefox add-on

If the above link doesn't work, you can also get it from my Google drive here. But you help me out by getting your download counted if you use the mozilla.org link, so I recommend using the first link if possible  :)

So I guess I made a Firefox add-on or something. I found that, really often, I would want to open a new tab all the way on the left of the tab bar. So what I would do is open a new tab, and then drag it all the way to the left. I often have large numbers of tabs open, in the triple digits, and you kind of have to jiggle the tab as you drag it to get it to keep going (I don't even know if that's a bug or not). So I figured, you know what would be cool? If I made a Firefox addon that opened tabs on the left.

Creatively, I call it 'New tab on the left'.

It adds an item to the context menu, 'Open Link in New Tab on the Left' for links, and an action button that opens a new tab all the way on the left. With Australis, you can put that button next to the normal 'new tab' button, or (if you don't have OS X  :( ) put it on the left side of the tab bar. Or whatever. Australis lets you put things in any ol' place.

It needs Australis (29 +), since it uses the new APIs for the tab elements.
20
Read about this on my blog?

I was recently thinking about how hard it would be to make a JIT compiler. The first question is, how would I actually generate code? As in, actually get arbitrary machine code put into memory at run time to execute?

Turns out it's not that hard.
https://gist.github.com/FlyingJester/0e6549a20a141900915b


Note that all these snippets assume you have a Unix-like environment, an amd64 CPU, and are compiling for 64 bits.

Here, I'm making up an array of raw bytes. They are all NOPs (no operations, the CPU sees this and does nothing about it), and finally a 'ret' statement. As long as we are in 64-bits or a have a normal calling convention, 'ret' is just like the proper keyword 'return'.

The kind of funky thing is that we not only need to mark the memory we want to execute as executable (which makes sense, here it's the call to mprotect()), we can't do that on just any memory. Normally, all mapped memory is read/write, but not executable.

In Unix/Posix, we can ask for a memory page with mmap(). This ensure we get a whole page, and assures that the address returned meets a bunch of special rules that we aren't too concerned with the details of. The important part is that addresses returned by mmap can be mprotect'd to arbitrary access usage.
Conveniently, we can mmap a page for read/write, copy our machine code to it, and then mark it as executable without too much hassle.

All we have to do then is explain to our C++ compiler that the addresslPage can be called like a function (which it kind of is). Interestingly, you NEED a C-style cast here. C++'s wonderful casts simply don't allow you to cross the data/instruction barrier this way.

But, that's not really a compiler of any sort, it's just injecting arbitrary code into a program.

Well, the array of chars that is our machine code could be modified. Say we want to make up some machine code that adds two arbitrary numbers, but we don't want to load the numbers, we want them written into the machine code itself once they are known.

It would look something like this:

https://gist.github.com/FlyingJester/369647a80d62ea5c7e62


So that's actually much cooler. Now, we are generating machine code on the fly!

But you know what would be even cooler? If we made the code's behaviour even more dynamic. Just modifying data is cool and all, but we could have just coded in addresses and used pointers in our machine code (that also would have been kind of cool, given that now our machine code would have embedded instance-specific addresses...). What if we actually change both instructions and data to generate our code?

https://gist.github.com/FlyingJester/1f6d3464f391045c7a41


Now that's much more like it.

So, what did I learn from this adventure?

Dynamic code generation and execution is frighteningly easy. I didn't expect this to be so simple, or to work so easily.
Of course, this is bordering on the kind of black magic that could destroy any project. It's ridiculous and completely unnecessary. Don't actually do this unless it is the intended product of your program.

...But it's also really fun to do!
21
Off-Topic Discussions / My Internship
I've been sitting on this for a while, so I thought I would share.

I've just begun an internship with Mozilla. I'm working as a platform engineer for FireFox on Android. Today was my first day, and I am very impressed with the company.

One really cool part of this experience, for me, is that I am finally in the presence of people who know a thing or two about computers. For once in my life, I can finally have a face-to-face conversation about things like language bindings, or emscripten, or the Google NDK. I hate to say it, but you really can't get a thing like that in Alaska. I even had a talk with another intern who is working on porting SDL2 to emscripten--something I have wanted for a long time!

Funny thing, I got the idea to apply for an internship with Mozilla from reading Chad Austin's ancient blog posts, about how he got an internship with Netscape and was really impressed with them. Another funny thing, I'm certain that it was my work with TurboSphere and related projects that gave me the knowledge and skills to manage this. For all the things you can say about Sphere, it certainly can be said that it helps people move to bigger and better things!
22
Off-Topic Discussions / yED, a graphical editor
http://www.yworks.com/en/products_yed_about.html

Often times, I like to collect my thoughts using flow charts and diagrams. I used to use dia, but dia has horrendous issues with rasterizing text.

I found out about yED recently. It's alright. Fewer features than dia, but much more reliable.
23
Programming / Demonstration of Threaded OpenGL
It seems like the knee-jerk reaction every programmer has when I tell them that TurboSphere has a threaded OpenGL rendering backend is 'You can't thread OpenGL!'

Well you can. And more than just putting ALL OpenGL calls in a different thread, you can perform data manipulation in one thread and rendering commands in another. You can even upload data to the GPU completely asynchronously.

Here is the proof: https://github.com/FlyingJester/GL_On_A_Stick.

Don't let anyone tell you that OpenGL can't be threaded. You just need to be careful and confident about it :)
24
Engine Development / FJ-GL Graphics Backend
Now available for Windows

rpgmaker.net/users/FlyingJester/locker/sphere16fj.zip

FJ-GL offers more performance in more situations than Standard32, better optimized performance than SphereGL, and no known bugs.

It does require you to use the specially compiled version of Sphere 1.6, however (It's all included in the link!). But it's better than ordinary Sphere 1.6 anyway. The only difference in the Engine executables are that this version is compiled with MSVC++ 2010 standard libraries, instead of the MSVC++ 2005 libraries that ordinary Sphere 1.6 uses.

Background

So, after getting Sphere 1.6 compiled on Linux, I noticed something. The SDL_GL graphics backend is SLOW. I know that it was always a case of 'It can be fast, treat it nice', but after looking through its source, I decided that was silly. For instance, it draws ellipses and circles on a per-pixel basis.

So I decided to write my own GL-based Sphere graphics backend. FJ-GL! It's almost 200% faster than the existing OpenGL driver for Linux--and I haven't done anything crazy or even all that modern to make it that fast.

I've only compiled it on Linux so far (that's where a new graphics backend is needed most!), but it should compile on Windows as well, once a shim function is written for the InitVideo function there.


I've written it for OpenGL 3.1, because that will run on all my machines. I plan on adding an OpenGL 4.3 version as well.
EDIT: The Windows version only requires OpenGL 2.0
25
It would be useful if the Ellipse functions also took an angle parameter. This would change how the x and y axes were aligned, and let you draw arbitrary ellipses (rather than only cardinally aligned ellipses). It would be an optional parameter, and leaving it out would have the function default to the Sphere 1.5/1.6 behaviour.

Code: [Select]

    OutlinedEllipse(x, y, rx, ry, c [, a])
    FilledEllipse(x, y, rx, ry, c [, a])


This would be a valuable addition to the Sphere API because there is no simple way to do this in script, but it would be very simple in engine.
26
Resources / [code] Gravity Simulation wth Demo
A quick little demo I made for modelling gravity.
27
Sphere Support / What exactly are Map Engine Triggers?
Could someone please explain how a trigger works in the MapEngine?

I've never used them, and there isn't a whole lot to go on from the new wiki about it.
28
I seem to have lost my copy of my old Breakout clone. I have a very old version, 0.4.

Anyone still have a copy of it (greater than 0.4) lying around?
29
Off-Topic Discussions / The New Mac Pro
Something about the Mac Pro has changed...

I for one am very excited for this. I really like the Apple of Old because it was so strange, yet could be seriously used. I'm glad to see that some of that maniac, radical, and sometimes elegant touch remains.
30
Off-Topic Discussions / PRISM
I may just dump Google+ for Twitter. I kind of use Google+ like Twitter anyway.

I don't really know what to think about the whole thing. I guess I've always operated under the assumption that anything I put online might as well be public knowledge.

But I like that someone said no. It makes the whole 'Lets use Linux and stick it to the man!' and 'Indie games so that big corporations don't get our money!' part of me just overjoyed.