Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Small Variant Records in C |
| Date | 2011-12-19 02:52 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jcm8vd$kdr$1@dont-email.me> (permalink) |
| References | (4 earlier) <jcltbr$pe8$1@dont-email.me> <59e2f8be-ff38-4ca1-ac7e-ce07c3018000@g41g2000yqa.googlegroups.com> <jcm1v5$mfa$1@dont-email.me> <jcm4fk$1g3$1@dont-email.me> <4574386b-4d90-4548-911c-a5e372aae2f6@n39g2000yqh.googlegroups.com> |
"Marco Devillers" <marco.devillers@gmail.com> wrote in message
news:4574386b-4d90-4548-911c-a5e372aae2f6@n39g2000yqh.googlegroups.com...
>> But the product might be too slow to be successful (if you have to take a
>> completely different, and less efficient, approach just so you can give
>> the
>> compiler a chance to optimise, and it might not even manage that).
> Moving in this direction won't make it a very fast language like C or
> OCaml, but I'll be able to bit-pack representations better and move
> towards handling texts natively, so it looks like a good choice.
>
> Anyway, I got a bit fed up with small incremental changes, so breaking
> that routine and just redeveloping the VM bottom-up feels like a good
> idea too. I like hacking in C. ;-)
>
> I would appreciate examples of languages which use this representation
> though.
I use a variant structure roughly equivalent to:
struct {
int16 tag;
int8 stuff;
int8 other stuff;
int32 value/ptr;
int32 value2/length;
}
The two value fields can be accessed together as 64-bits, in a way that C
doesn't like! So I don't use C for this.
Used in a VM with solely dynamic typing, it's about 5x as slow, on average,
as lcc-win32 (a C compiler not known for it's fast code so better to compare
with...). This is for integer benchmarks. For strings, it uses counted
strings so compares much better with C.
For an example of a language with minimal tag bits, look at Euphoria; it
identifies integers with just a single bit! Leaving 31 bits for value. And
this was also very fast, although I believe it's partly typed. This language
also implements strings as integer arrays, and it doesn't seem to affect the
speed much..
Have a look also at the implementation of Lua (not the JIT version), which
uses a union/struct scheme along the same lines as yours
(http://www.lua.org/doc/jucs05.pdf).
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 10:16 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 18:50 +0000
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 15:00 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 12:23 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 21:15 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 14:13 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:25 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:08 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:24 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 11:43 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 15:21 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 13:38 -0800
Re: Small Variant Records in C James Kuyper <jameskuyper@verizon.net> - 2011-12-19 16:48 -0500
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 17:19 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 15:14 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 21:44 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 14:02 -0800
Re: Small Variant Records in C Kaz Kylheku <kaz@kylheku.com> - 2011-12-19 18:38 +0000
Re: Small Variant Records in C jgk@panix.com (Joe keane) - 2012-01-04 03:52 +0000
Re: Small Variant Records in C Ian Collins <ian-news@hotmail.com> - 2012-01-04 20:25 +1300
Re: Small Variant Records in C Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 15:53 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 18:35 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 16:01 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 17:02 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 19:53 -0500
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 01:36 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 18:21 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:52 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:17 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 09:24 -0500
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:18 +0000
csiph-web