unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Custom allocation of cells
@ 2005-05-03 15:09 Ludovic Courtès
  2005-06-06 18:56 ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2005-05-03 15:09 UTC (permalink / raw)


Hi,

I'd like to know whether one can reliably allocate a cell on its own,
without using `scm_cell ()'.  Basically, I read appendix A of the manual
and I'm now naively trying to do my own cell allocation.  Here is a
(stupid and ugly) example:

  SCM_DEFINE (scm_do_pair, "do-pair", 2, 0, 0,
              (SCM car, SCM cdr),
              "")
  {
    static SCM room[512];
    static SCM *where = &room[0];
    SCM the_pair;
    size_t incr;

    if ((scm_t_bits)where & 6)
      {
        /* Align the cell pointer so that Guile considers it as a
           non-immediate object (see tags.h).  */
        incr = (scm_t_bits)where & 6;
        incr = (~incr) & 7;
        where += incr;
      }

    where[0] = car;
    where[1] = cdr;

    the_pair = PTR2SCM (where);

    return (the_pair);
  }

This does return a pair, but the next time the GC runs, Guile
segfaults.  This is because `SCM_SET_GC_MARK ()' assumes that WHERE is
located within a cell segment, which is not the case here.

So my question is: Is there a way to allocate cells, cheaper than
`scm_cell ()', that could be used?  This would be particularly useful
for Guile-VM.  When calling a procedure (i.e. with the interpreter, via
`scm_apply ()'), the VM as to build a list out of the arguments which
are already available on the stack, and this turns out to be pretty
costly.

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Custom allocation of cells
  2005-05-03 15:09 Custom allocation of cells Ludovic Courtès
@ 2005-06-06 18:56 ` Marius Vollmer
  2005-06-07  7:18   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Vollmer @ 2005-06-06 18:56 UTC (permalink / raw)
  Cc: guile-devel

ludovic.courtes@laas.fr (Ludovic Courtès) writes:

> Hi,
>
> I'd like to know whether one can reliably allocate a cell on its own,
> without using `scm_cell ()'.

No.

> So my question is: Is there a way to allocate cells, cheaper than
> `scm_cell ()', that could be used?

If there is a cheaper way (very possible), then we should use it to
implement scm_cell.

> This would be particularly useful for Guile-VM.  When calling a
> procedure (i.e. with the interpreter, via `scm_apply ()'), the VM as
> to build a list out of the arguments which are already available on
> the stack, and this turns out to be pretty costly.

Hmm, without knowning any details, my first thought is that you might
need to invent a new calling convention that does not not to call
scm_cell if you want to avoid scm_cell.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Custom allocation of cells
  2005-06-06 18:56 ` Marius Vollmer
@ 2005-06-07  7:18   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2005-06-07  7:18 UTC (permalink / raw)
  Cc: guile-devel

Hi,

Marius Vollmer <mvo@zagadka.de> writes:

> If there is a cheaper way (very possible), then we should use it to
> implement scm_cell.

Sure.  But an having the ability to implement an application-specific,
Guile-compatible, cell allocation method would be nice, no matter how
well `scm_cell ()' performs.

> Hmm, without knowning any details, my first thought is that you might
> need to invent a new calling convention that does not not to call
> scm_cell if you want to avoid scm_cell.

Indeed, this is what Guile-VM already does for calls to compiled code.
The problem arises for calls to regular Guile procedures (so it doesn't
hurt that much).

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-07  7:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-03 15:09 Custom allocation of cells Ludovic Courtès
2005-06-06 18:56 ` Marius Vollmer
2005-06-07  7:18   ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).