News for hackers. Stuff that matters.
Re:Author of LuaJIT explains why compilers can't beat hand-c... by barrkel on Thursday May 26, 2011 @04:13PM (#2589246)
The paradoxical reason why pragmas don't work well is that the machine is better than the human.

http://lua-users.org/lists/lua-l/2011-01/msg00978.html

"Also, it's not a good idea to second-guess the region selection heuristics. I tried this many times ('This can't be the best path!') and failed miserably. The selected traces are sometimes very strange, but so far they turned out to be near optimal. It's quite embarrasing if your own creation turns out to make smarter decisions than yourself. ;-)"

What you'll ultimately end up doing is spending more time fiddling with pragmas and code layout trying to control what machine code the compiler produces than you save by not writing the assembler directly yourself.

It has to be said, though, that we really are talking about a critical loop here. This is no real justification for using assembler instead of a compiler outside of extremely hot (or extremely odd, e.g. dynamic invocation, coroutine stack switching etc.) pieces of code. An interpreter loop is the ultimate hot loop; all code goes through it.

Re:Author of LuaJIT explains why compilers can't beat hand-c... by fanf2 on Friday May 27, 2011 @09:57AM (#2591437)
Coroutine stack switching doesn't need assembler in many C implementations: http://fanf.livejournal.com/105413.html?nc=6
Re:Author of LuaJIT explains why compilers can't beat hand-c... by barrkel on Friday May 27, 2011 @03:20PM (#2592729)
Sure, if you presume the existence of setjmp and longjmp. I'm more normally in the position of writing those routines, not using them.