News for hackers. Stuff that matters.
Re:Let’s Stop Bashing C by taeric on Friday December 02, 2016 @09:16PM (#13093883)
That is certainly the high level language way. Because the magic involved in the code generator is quite high.

C, however, gives you hold onto the generator to say "use this assembly". So, for new or one off instructions, it is a quick way to get an edge.

Re:Let’s Stop Bashing C by geofft on Saturday December 03, 2016 @02:28PM (#13097105)
My question is, does it actually get you an edge?

When you use inline assembly, the compiler (more or less) has to execute that inline assembly, right where you say it is. It can't speculatively execute it, it can't refactor the call into a different function if you're calling it twice, it can't optimize it out in certain circumstances, etc. It can't move the instruction around or choose a different form depending on register pressure. If you specify the right flags about what registers it clobbers, what memory barriers it requires, etc., the compiler can do some of it, but it's not going to be nearly as good as the compiler actually understanding what's happening, I think.

Telling the code generator (and C is a high-level language in this respect, if you want any performance out of C) what you're doing is likely to get you more of an edge, no?

I can certainly imagine cases where letting the compiler reorder a slow square root around a memory access will be faster in practice than a fast square root that can't be reordered.

Re:Let’s Stop Bashing C by kazinator on Friday December 02, 2016 @09:22PM (#13093910)
Support for inline assembly language in C is a compiler extension.

It is not exclusive to C compilers.

Re:Let’s Stop Bashing C by taeric on Friday December 02, 2016 @11:09PM (#13094259)
Indeed it isn't. It does seem to be most common there, though. (See sibling post for comments of early lisps supporting this. Well aware of it, but many higher level languages do not commonly support it.)
Re:Let’s Stop Bashing C by nickpsecurity on Saturday December 03, 2016 @06:08PM (#13097938)
Burroughs ALGOL, Modula-2, and industrial Pascals could all do that. Amomg others. They were safer by default and fast. C looks weaker at this point.