From: Andreas Schwab <schwab@suse.de>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: [RFC] temporary Lisp_Strings
Date: Tue, 02 Sep 2014 15:21:35 +0200 [thread overview]
Message-ID: <mvm38canoo0.fsf@hawking.suse.de> (raw)
In-Reply-To: <5405BE5D.1090003@yandex.ru> (Dmitry Antipov's message of "Tue, 02 Sep 2014 16:55:57 +0400")
Dmitry Antipov <dmantipov@yandex.ru> writes:
> I'm thinking about temporary Lisp_Strings on C stack (allocated with alloca).
> Simple implementation (with no check whether it fits on stack) and a few use
> cases attached. Among others, the question is: is there a way to make sure
> that an address returned by alloca fits in Lisp_Object?
There is none. The stack could be in a completely different address
region that may not be suitable in non-USE_LSB_TAG configurations.
> +#define alloca_string(str) \
> + ({ Lisp_Object string; \
> + struct Lisp_String *s; \
> + ptrdiff_t nchars, nbytes, size = strlen (str); \
> + parse_str_as_multibyte ((const unsigned char *) str, \
> + size, &nchars, &nbytes); \
> + s = alloca (sizeof *s + nbytes + 1); \
> + s->data = (unsigned char *) s + sizeof (*s); \
> + memcpy (s->data, str, nbytes); \
> + s->data[size] = '\0'; \
> + s->intervals = NULL; \
> + if (nbytes == nchars || nbytes != size) \
> + s->size = size, s->size_byte = -1; \
> + else \
> + s->size = nchars, s->size_byte = nbytes; \
> + XSETSTRING (string, s); string; })
This will eventually fail with USE_LSB_TAG, since you don't enforce
alignment.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
next prev parent reply other threads:[~2014-09-02 13:21 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 12:55 [RFC] temporary Lisp_Strings Dmitry Antipov
2014-09-02 13:21 ` Andreas Schwab [this message]
2014-09-02 13:47 ` Dmitry Antipov
2014-09-02 14:14 ` Andreas Schwab
2014-09-02 15:00 ` Eli Zaretskii
2014-09-02 14:00 ` Stefan Monnier
2014-09-02 15:13 ` Dmitry Antipov
2014-09-02 17:32 ` Stefan Monnier
2014-09-03 10:23 ` Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_Strings] Dmitry Antipov
2014-09-03 13:14 ` Stefan Monnier
2014-09-03 14:39 ` Paul Eggert
2014-09-03 15:39 ` Dmitry Antipov
2014-09-03 16:42 ` Paul Eggert
2014-09-03 17:47 ` Stefan Monnier
2014-09-03 18:00 ` Paul Eggert
2014-09-04 4:59 ` Dmitry Antipov
2014-09-04 5:13 ` Paul Eggert
2014-09-04 5:51 ` Dmitry Antipov
2014-09-04 6:45 ` Paul Eggert
2014-09-04 13:11 ` Stefan Monnier
2014-09-04 13:37 ` Dmitry Antipov
2014-09-04 14:46 ` Dmitry Antipov
2014-09-04 16:03 ` Paul Eggert
2014-09-05 4:00 ` Dmitry Antipov
2014-09-05 4:24 ` Stefan Monnier
2014-09-05 9:28 ` Dmitry Antipov
2014-09-05 7:15 ` Paul Eggert
2014-09-05 9:16 ` Dmitry Antipov
2014-09-05 14:35 ` Paul Eggert
2014-09-05 15:35 ` Stefan Monnier
2014-09-08 10:33 ` Dmitry Antipov
2014-09-08 12:01 ` Dmitry Antipov
2014-09-08 13:30 ` Stefan Monnier
2014-09-08 12:44 ` Stefan Monnier
2014-09-08 13:30 ` Stefan Monnier
2014-09-02 14:37 ` [RFC] temporary Lisp_Strings Paul Eggert
2014-09-02 15:24 ` Dmitry Antipov
2014-09-02 15:28 ` Dmitry Antipov
-- strict thread matches above, loose matches on Subject: below --
2014-09-02 12:56 Dmitry Antipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvm38canoo0.fsf@hawking.suse.de \
--to=schwab@suse.de \
--cc=dmantipov@yandex.ru \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.