[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_S

From: Paul Eggert
Subject: Re: Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_Strings]
Date: Wed, 03 Sep 2014 23:45:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

Dmitry Antipov wrote:
I'm talking about the case when we can't us __attribute__ ((aligned (X))).

How about something like this?

typedef unsigned long uintptr_t;

typedef uintptr_t Lisp_Object;

struct Lisp_Cons
  Lisp_Object car;
  Lisp_Object cdr;

static Lisp_Object
cons_init (void *result, Lisp_Object a, Lisp_Object b)
struct Lisp_Cons *p = (struct Lisp_Cons *) (((uintptr_t) result + 7) & -8);
  p->car = a;
  p->cdr = b;
  return (Lisp_Object) p + 3;

#define BCONS(a, b) cons_init ((char[sizeof (struct Lisp_Cons) + 7]){}, a, b)
#define untag(x) ((struct Lisp_Cons *) (uintptr_t) ((x) - 3))

foo (void)
  Lisp_Object a = BCONS (0, 0);
  Lisp_Object b = BCONS (0, a);
  return untag (untag(b) -> cdr) -> car;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]