[ANN] Clue 0.6

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Clue 0.6

David Given
After being prodded to finally fix the bit rot that was preventing Clue
0.5 from working, I've just released version 0.6 of my C to Lua,
Javascript, Java and Perl compiler.

http://cluecc.sourceforge.net/

New in this release: a Lua 5.2 dialect target which uses goto.
(Thank-you! Thank-you!) This has more than doubled performance using the
stock Lua interpreter from Lua 5.1, which has to emulate goto using what
amounts to a switch statement.

Of course, LuaJIT falls upon this code with cries of glee.

Backend Interpreter     Whetstone   gcc comparison (larger is better)
(gcc)                   2500        100%
lua     LuaJIT jon      2500        100%
c       gcc             2400         96%
java    Sun Java 6       790         32%
lua     LuaJIT joff      155          6.2%
js      node.js (V8)     110          4.4%
lua     Lua 5.2.1         84          3.4%
lua     Lua 5.1.3         29          1.2%
perl5   Perl 5             2.7        0.11%

Now, don't get too excited; the Whetstone benchmark is wholly synthetic
and not indicative of anything much. But, yes, some of the subbenchmarks
(and some of the other test loads I'm running) *are* running on LuaJIT
faster than they run when compiled directly with gcc (with -Os). I
suspect this is mostly due to loop unrolling, which is a bit unfair.

I'm also running some of the CLBG tests, which are slightly more
real-world (although only slightly). The results of the Mandelbrot test
look a bit more realistic:

               Time       Factor (smaller is better)
gcc            0.098   1.000
clue -> c      0.149   1.514
luajit2-jon    0.376   3.835
java           1.011  10.299
luajit2-joff   3.487  35.520
js             4.281  43.610
lua52          6.454  65.749
lua51         11.050 112.566
perl5         42.619 434.153

If anyone can suggest any more real-world test loads that are worth
trying, I'd like to give them a go --- although bear in mind that Clue's
C environment is *distinctly* weird, although mostly
standards-compliant, and the runtime library is almost non-existent.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "Of course, on a sufficiently small planet, 40 km/hr is, in fact,
│ sufficient to punt the elastic spherical cow into low orbit." ---
│ Brooks Moses on r.a.sf.c


signature.asc (267 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Clue 0.6

Sean Conner
It was thus said that the Great David Given once stated:
> After being prodded to finally fix the bit rot that was preventing Clue
> 0.5 from working, I've just released version 0.6 of my C to Lua,
> Javascript, Java and Perl compiler.

  Okay, I tried it and failed.  

  First off, the version of sparse you use, 0.4.1, isn't readily available
at the link you provide, only 0.4.4.  I had to clone the git repository
(git://git.kernel.org/pub/scm/devel/sparse/sparse.git) to get (or
"checkout") 0.4.1.  I then applied the given patch from clue-0.6, then built
sparse and then clue.  

  Then it failed on test/helloworld.c (-mlua51) with the following:

#0  0x0804b690 in declare_symbol (sym=0xb7ef050c) at src/clue/compile.c:235
235             if (sym->ctype.base_type->type == SYM_FN)

  I then added a few calls to assert() just before the problematic line and:

[spc]lucy:~/apps/clue-0.6>./bin/clue -mlua51 test/helloworld.c
clue: src/clue/compile.c:237: declare_symbol: Assertion `sym->ctype.base_type != ((void *)0)' failed.
Aborted (core dumped)

  I'm running CentOS release 4.4 (yes, it's old---I rarely upgrade) Linux
2.6.9, 32-bit system.

  Any ideas?

  -spc


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Clue 0.6

David Given
Sean Conner wrote:
[...]
>   First off, the version of sparse you use, 0.4.1, isn't readily available
> at the link you provide, only 0.4.4.  I had to clone the git repository
> (git://git.kernel.org/pub/scm/devel/sparse/sparse.git) to get (or
> "checkout") 0.4.1.  I then applied the given patch from clue-0.6, then built
> sparse and then clue.

Grar. Okay, try this one. (This is the one I actually took the diff
against.)

http://ftp.be.debian.org/pub/software/devel/sparse/dist/sparse-0.4.1.tar.bz2

I have a feeling that not all sparse 0.4.1 source code bundles are the
same, as that's the only way to explain some of the oddities people have
reported.

At some point I should probably try to update the patch to the latest
sparse version, but the patch is a bit pervasive and I've rather
forgotten how sparse works inside.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────

│ 𝕻𝖍'𝖓𝖌𝖑𝖚𝖎 𝖒𝖌𝖑𝖜'𝖓𝖆𝖋𝖍 𝕮𝖙𝖍𝖚𝖑𝖍𝖚 𝕽'𝖑𝖞𝖊𝖍
𝖜𝖌𝖆𝖍'𝖓𝖆𝖌𝖑 𝖋𝖍𝖙𝖆𝖌𝖓.



signature.asc (271 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Clue 0.6

David Manura
In reply to this post by David Given
On Thu, Mar 14, 2013 at 8:06 PM, David Given <[hidden email]> wrote:
> http://cluecc.sourceforge.net/

Installation also requires "apt-get install libgc-dev".
In "Usage: clue [-m[lua|js|perl5|c|lisp|java]] file.c ..", the "lua"
should read "lua51|lua52".

> ...and the runtime library is almost non-existent.

lpeg would have minimal RT requirements:

$ ./bin/clue -mlua52 ../lpeg-0.10.2/lpeg.c
../lpeg-0.10.2/lpeg.c:9:11: error: unable to open 'assert.h'
     .. but how to specify the -I include search paths? and -D defines?

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Clue 0.6

David Given
On 17/03/13 02:45, David Manura wrote:
[...]
> Installation also requires "apt-get install libgc-dev".
> In "Usage: clue [-m[lua|js|perl5|c|lisp|java]] file.c ..", the "lua"
> should read "lua51|lua52".

Thank-you, corrected.

(Actually I've just taken out the dependency on libgc. Compilers have a
long and honourable history of leaking memory like a sieve.)

[...]
> $ ./bin/clue -mlua52 ../lpeg-0.10.2/lpeg.c
> ../lpeg-0.10.2/lpeg.c:9:11: error: unable to open 'assert.h'

Easiest thing to do here is to either add an assert.h to
src/libc/include, or else just edit lpeg.c not to need it.

>      .. but how to specify the -I include search paths? and -D defines?

Right now you don't: clue is in an experimental
held-together-with-duct-tape-and-string stage, and is not really
intended to be used at all, let alone in an environment when that sort
of thing is necessary. (I will admit that -I and -D would be nice to
have, and not very difficult.)

The preprocessor used is built-in to sparse; if you really need to tweak
the standard setup, edit src/clue/main.c, look at the main() function,
and adjust the calls to add_pre_buffer().

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "Of course, on a sufficiently small planet, 40 km/hr is, in fact,
│ sufficient to punt the elastic spherical cow into low orbit." ---
│ Brooks Moses on r.a.sf.c


signature.asc (267 bytes) Download Attachment