Re: Compiling procedure/closure application natively



Andreas wrote:
Finally, my question is this: Was my encoding procedures as "address in
memory" without additional heap allocation a case of premature
optimization?

Yes. You can reconsider that optimization later.

What is the usual way this is done? I did have a look at larceny's
assembly output on x86 and it appeared to me to do a similar dispatch,
i.e. distinguish between closure and procedure at every call-site.

No. Larceny represents *all* procedures as closures.
The runtime checking you saw was probably for (1) global
variable references, to make sure the variable has been
given a value or (2) to make sure that the value being
called is a procedure, not a number or boolean or string
or whatever. (When calling a top-level procedure, the
peephole optimizer should combine checks (1) and (2),
but Larceny's x86 code generator is still pretty crude
and may not do that yet.)

Larceny's Twobit compiler also performs a first-order
closure analysis to identify procedures that are *only*
called (Aziz's first category). Those procedures don't
have to represented as values at all. In Larceny, their
code will be merged into the codevector for some other
procedure, making it hard for you to locate their code
when looking at the input to or output from the Sassy
or Nasm assemblers.

Will

.



Relevant Pages

  • Re: Does 32 bits value assignment needs locking operation
    ... there is demonstrated need for the optimization and the optimization ... breaks when snazzy new CPU Y comes out. ... is working on x86 32-bit platform as s simple sign. ...
    (comp.programming.threads)
  • Re: optimizers are overrated
    ... cause it to iterate in either order; as long as the loop executes the ... not done) or intimate knowledge of how the x86 CPU behaves (which I ... whether the optimization would be worthwhile. ... already meets the performance specifications. ...
    (comp.lang.c)
  • Re: optimizers are overrated
    ... copx is assuming that a test against 0 is going to ... Without either measurement (which copx has ... not done) or intimate knowledge of how the x86 CPU behaves (which I ... whether the optimization would be worthwhile. ...
    (comp.lang.c)
  • Re: optimizers are overrated
    ... cause it to iterate in either order; as long as the loop executes the ... not done) or intimate knowledge of how the x86 CPU behaves (which I ... whether the optimization would be worthwhile. ... already meets the performance specifications. ...
    (comp.lang.c)
  • Re: A better algorithm to calculate a leap year?
    ... From reading the assembly output of GCC I saw the ... > same optimization, ... If the compiler can do the optimisation, ...
    (comp.lang.c)