Saturday, March 11, 2006

Compiler status update, Cocoa subclassing

I've finished a compiler refactoring eliminating branch splitting. This has resulted in a slight performance decrease, which I hope to nullify by rewriting the low-level optimizer and code generation code.

My plan for the new low-level optimizer is to hold values in registers, and only "commit" them to the stack before leaving a basic block (by jumping to a word definition, for example). Already, enough infrastructure is in place so that words which are compiler intrinsics take inputs from registers, and store them back into regsiters. However, the current low-level optimizer is not very smart with this, and always generates stack load/store code before and after an intrinsic. The basic block optimizer then applies some rewrite rules, so that in some cases a sequence of the form "intrinsic, stack store, stack load, intrinsic" becomes "intrinsic, intrinsic". However, this is a rather crude hack, and it only catches a small number of cases. The correct fix, of course, is to not generate the redundant store/load and load/store sequences in the first place.

Since my last status update, I have also been debugging the FFI, callbacks, and the Cocoa bindings. All three are now in a state where I can actually subclass Objective-C classes from Factor, and, for example, render OpenGL in a NSOpenGLView subclass which overrides the drawRect: method.

Check out the crappy screenshot.

I will continue hacking away at the Cocoa bindings. At this stage, it appears that all that remains to be done before I can re-target the Factor UI to Cocoa is to write some nice wrappers for Cocoa event handling. I'm really looking forward to ditching SDL. Multi-window UI goodness!

No comments: