Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #15381

Re: code snippet

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: code snippet
Date 2012-01-03 19:58 +0000
Organization A noiseless patient Spider
Message-ID <20120103113739.535@kylheku.com> (permalink)
References (13 earlier) <0.f11c74e6cc5bf465d9c4.20111222031918GMT.87hb0tmgy1.fsf@bsb.me.uk> <9453445.440.1324566701765.JavaMail.geo-discussion-forums@prez5> <slrnjf6ocv.1rti.usenet-nospam@guild.seebs.net> <jcvrjq$feg$1@dont-email.me> <4F035609.2E6947C8@bytecraft.com>

Show all headers | View raw


On 2012-01-03, Walter Banks <walter@bytecraft.com> wrote:
>
>
> BartC wrote:
>
>> > When you're about to pop out to the store, do you take your car's fuel
>> > system apart and rebuild the carburetor?
>>
>> But if you're working in automobile design and production, this is just the
>> sort of thing you might do. Then you end with a version with a very slightly
>> better fuel consumption, but which is significant over a million units and
>> thousands of journeys each.
>
> I have worked in automotive for close to a couple decades and it is the type
> of thing that this industry would not do for a couple reasons.
>
> First there is very few things that can be done in asm that cannot be done in C.

However, those things are of high importance. Just maybe not to some C
programmers.

Assembly gives you the access to the machine at a level that allows you to
implement things like accurate stack unwinding, exception handling and
completely precise garbage collection.

Not all of these can be done by merely calling assembly routines or inline
code from C, because they depend coding conventions, and so control over the
compiler is necessary). 

If your view of computing embraces such capabilities, then you will find
assembly language to be more capable than C.

For instance, take garbage collection.  Suppose that in some function there is
a statement "x = NULL", where x is local and there are no more uses of x in the
remaining block.  An optimizing C compiler could simply not bother with this
assignment since x has no next use.  But what if there is garbage collection?
The variable x could be the last reference to a large amount of memory, whose
reclamation will be prevented if the assignment is optimized away.
The C compiler does not know that x has a kind of next use: it can be visited
"behind the scenes" by the garbage collector!  C compilers are GC-unfriendly in
numerous ways, one of which is this generation of semantic garbage: keeping
values in memory or registers beyond the point at which they have become
garbage in the source semantics.  In assembly we don't have this problem;
since we know what we put into every memory location and register.

We would like to be able to extend the C compiler with new rules such as
"whenever a pointer variable has no next use, generate code to overwrite it
with null", but the language doesn't give us a way to direct the translation in
such ways.

> Very few as in some C compilers actually check that everything that can be
> done in asm can be done in C.

Really? An example or two would go a long way here.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 20:51 -0500
  Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 18:29 -0800
    Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 21:51 -0500
      Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 22:24 -0500
        Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 19:53 -0800
          Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 23:32 -0500
            Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 20:57 -0800
              Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 00:01 -0500
                Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 21:13 -0800
                Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:42 -0500
      Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-18 20:14 -0800
        Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 23:27 -0500
      Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-19 12:33 +0000
        Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:33 -0500
          Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-20 00:20 +0000
            Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 19:46 -0500
              Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-20 01:14 +0000
                Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 15:51 -0500
                Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-21 14:11 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-21 07:03 -0800
                Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-21 21:41 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-21 16:35 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 01:03 +0000
                Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-22 03:19 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 07:11 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 16:59 +0000
                Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-22 18:38 +0100
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 10:40 -0800
                Re: code snippet Markus Wichmann <nullplan@gmx.net> - 2011-12-22 19:12 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 03:50 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-28 17:06 +0100
                Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-01 20:04 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-01 12:38 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-02 10:14 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-03 04:56 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-03 18:26 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-04 00:09 -0800
                Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 21:53 +1300
                Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-04 16:14 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-01 12:28 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-02 10:18 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-03 04:56 -0800
                Re: code snippet "BartC" <bc@freeuk.com> - 2011-12-22 18:05 +0000
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 18:14 +0000
                Re: code snippet superpollo <superpollo@tznvy.pbz> - 2011-12-22 20:00 +0100
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 19:08 +0000
                Re: code snippet superpollo <superpollo@tznvy.pbz> - 2011-12-22 22:43 +0100
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
                Re: code snippet BruceS <bruces42@hotmail.com> - 2011-12-23 16:26 -0800
                Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-22 19:21 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 11:33 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-23 09:10 +0100
                Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-23 14:43 +0000
                Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-23 17:14 +0000
                Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-23 12:10 -0800
                Re: code snippet Walter Banks <walter@bytecraft.com> - 2012-01-03 14:24 -0500
                Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-03 19:58 +0000
                Re: code snippet Walter Banks <walter@bytecraft.com> - 2012-01-03 16:15 -0500
                Re: code snippet blp@cs.stanford.edu (Ben Pfaff) - 2012-01-03 13:26 -0800
                Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-03 22:04 +0000
                Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 15:44 +1300
                Re: code snippet "BartC" <bc@freeuk.com> - 2012-01-04 23:34 +0000
                Re: code snippet James Harris <james.harris.1@googlemail.com> - 2012-01-04 15:57 -0800
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-05 23:34 -0800
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-06 00:40 -0800
                Re: code snippet Kleuske <kleuske@nowhere.net> - 2012-01-06 10:33 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-06 04:30 -0800
                Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 15:37 +1300
                Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-04 03:37 +0000
                Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 20:23 +1300
                Re: code snippet jacob navia <jacob@spamsink.net> - 2011-12-22 18:26 +0100
                Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-22 19:34 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 11:57 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 20:18 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 12:52 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 20:37 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 13:27 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 14:09 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-23 04:01 -0800
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 14:24 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-01 23:06 -0800
                Re: code snippet Hans Vlems <hvlems@freenet.de> - 2011-12-22 23:35 -0800
                Re: code snippet "BartC" <bc@freeuk.com> - 2011-12-23 12:26 +0000
                Re: code snippet jacob navia <jacob@spamsink.net> - 2011-12-23 18:32 +0100
                Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 04:04 -0800
                Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-23 09:10 +0100
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-25 11:13 -0800
                Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-25 19:31 +0000
                Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-26 21:53 +0000
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-26 16:10 -0800
                Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-26 18:11 -0800
                Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-26 23:56 -0800
                Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 15:57 -0500
                Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-21 12:39 +0000
                Re: code snippet Bill Reid <hormelfree@gmail.com> - 2011-12-22 15:29 -0800
          Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-19 19:19 -0800
            Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 13:51 -0500
              Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-20 11:08 -0800
  Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-19 11:37 +0000
    Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:38 -0500
      Re: code snippet "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-12-19 17:02 -0500
    Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 17:21 -0500
      Re: code snippet John Gordon <gordon@panix.com> - 2011-12-19 22:35 +0000

csiph-web