From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: Luc Teirlinck <teirllm@dms.auburn.edu>,
rms@gnu.org, ralphm@members.fsf.org, emacs-devel@gnu.org,
Stefan Monnier <monnier@iro.umontreal.ca>,
Eli Zaretskii <eliz@gnu.org>,
mathias.dahl@gmail.com
Subject: Re: Building Emacs overflowed pure space
Date: Tue, 25 Jul 2006 10:14:05 +0900 [thread overview]
Message-ID: <wlodvetrj6.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <m3slkt1bgr.fsf@kfs-l.imdomain.dk>
>>>>> On Sun, 23 Jul 2006 01:11:48 +0200, storm@cua.dk (Kim F. Storm) said:
>>> If the string data in the pure storage can be assumed to be
>>> completely read-only (including the preloading stage), another
>>> hack could be considered. That is, sharing postfixes of string
>>> data among multiple pure strings. The following experimental
>>> patch shows another ~40KB reduction of the pure storage usage. (A
>>> slow and naive but reliable version not using Boyer-Moore also
>>> shows the same size of reduction.)
>>
> I tried the exact the same thing (using the naive version), but the
> dumped emacs crashed immediately after loadup, thinking that "nil"
> was a filename... So I didn't think it was safe to do this.
I'm not sure if this should be counted as an objection. If so, can I
have a look at the code just to make sure?
BTW, a condition was missing at the entrance of the function in my
previous patch. Below is a revised one:
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
Index: src/alloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/alloc.c,v
retrieving revision 1.397
diff -c -p -r1.397 alloc.c
*** src/alloc.c 20 Jul 2006 01:01:04 -0000 1.397
--- src/alloc.c 23 Jul 2006 04:21:49 -0000
*************** check_pure_size ()
*** 4767,4772 ****
--- 4767,4839 ----
}
+ /* Find the byte sequence {DATA[0], ..., DATA[NBYTES-1], '\0'} from
+ the non-Lisp data pool of the pure storage, and return its start
+ address. Return NULL if not found. */
+
+ static char *
+ find_string_data_in_pure (data, nbytes)
+ char *data;
+ int nbytes;
+ {
+ int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max;
+ unsigned char *p;
+ char *non_lisp_beg;
+
+ if (pure_bytes_used_non_lisp < nbytes + 1)
+ return NULL;
+
+ /* Set up the Boyer-Moore table. */
+ skip = nbytes + 1;
+ for (i = 0; i < 256; i++)
+ bm_skip[i] = skip;
+
+ p = (unsigned char *) data;
+ while (--skip > 0)
+ bm_skip[*p++] = skip;
+
+ last_char_skip = bm_skip['\0'];
+
+ non_lisp_beg = purebeg + pure_size - pure_bytes_used_non_lisp;
+ start_max = pure_bytes_used_non_lisp - (nbytes + 1);
+
+ /* See the comments in the function `boyer_moore' (search.c) for the
+ use of `infinity'. */
+ infinity = pure_bytes_used_non_lisp + 1;
+ bm_skip['\0'] = infinity;
+
+ p = (unsigned char *) non_lisp_beg + nbytes;
+ start = 0;
+ do
+ {
+ /* Check the last character (== '\0'). */
+ do
+ {
+ start += bm_skip[*(p + start)];
+ }
+ while (start <= start_max);
+
+ if (start < infinity)
+ /* Couldn't find the last character. */
+ return NULL;
+
+ /* No less than `infinity' means we could find the last
+ character at `p[start - infinity]'. */
+ start -= infinity;
+
+ /* Check the remaining characters. */
+ if (memcmp (data, non_lisp_beg + start, nbytes) == 0)
+ /* Found. */
+ return non_lisp_beg + start;
+
+ start += last_char_skip;
+ }
+ while (start <= start_max);
+
+ return NULL;
+ }
+
+
/* Return a string allocated in pure space. DATA is a buffer holding
NCHARS characters, and NBYTES bytes of string data. MULTIBYTE
non-zero means make the result string multibyte.
*************** make_pure_string (data, nchars, nbytes,
*** 4785,4795 ****
struct Lisp_String *s;
s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
! s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
s->size = nchars;
s->size_byte = multibyte ? nbytes : -1;
- bcopy (data, s->data, nbytes);
- s->data[nbytes] = '\0';
s->intervals = NULL_INTERVAL;
XSETSTRING (string, s);
return string;
--- 4852,4866 ----
struct Lisp_String *s;
s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
! s->data = find_string_data_in_pure (data, nbytes);
! if (s->data == NULL)
! {
! s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
! bcopy (data, s->data, nbytes);
! s->data[nbytes] = '\0';
! }
s->size = nchars;
s->size_byte = multibyte ? nbytes : -1;
s->intervals = NULL_INTERVAL;
XSETSTRING (string, s);
return string;
next prev parent reply other threads:[~2006-07-25 1:14 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 8:38 Building Emacs overflowed pure space Mathias Dahl
2006-07-18 9:02 ` Ralph Moritz
2006-07-18 12:06 ` Mathias Dahl
2006-07-18 13:37 ` David Hansen
2006-07-18 15:00 ` Richard Stallman
2006-07-18 18:55 ` Luc Teirlinck
2006-07-18 20:16 ` Eli Zaretskii
2006-07-18 20:56 ` Stefan Monnier
2006-07-19 2:51 ` Eli Zaretskii
2006-07-19 4:35 ` Stefan Monnier
2006-07-19 4:42 ` Miles Bader
2006-07-19 18:13 ` Eli Zaretskii
2006-07-19 13:52 ` mituharu
2006-07-19 15:07 ` Stefan Monnier
2006-07-19 21:16 ` Richard Stallman
2006-07-20 1:12 ` YAMAMOTO Mitsuharu
2006-07-22 9:06 ` YAMAMOTO Mitsuharu
2006-07-22 16:03 ` Stefan Monnier
2006-07-22 23:11 ` Kim F. Storm
2006-07-23 3:47 ` Stefan Monnier
2006-07-25 1:14 ` YAMAMOTO Mitsuharu [this message]
2006-07-25 4:13 ` Richard Stallman
2006-07-25 10:41 ` YAMAMOTO Mitsuharu
2006-07-25 10:56 ` David Kastrup
2006-07-25 11:00 ` Andreas Schwab
2006-07-25 11:05 ` David Kastrup
[not found] ` <85ejwahrqi.fsf@lola.goethe.zz>
2006-07-25 11:08 ` Andreas Schwab
2006-07-25 11:23 ` David Kastrup
2006-07-23 5:26 ` Richard Stallman
2006-07-18 22:01 ` Luc Teirlinck
2006-07-18 23:44 ` Chong Yidong
2006-07-19 0:06 ` Luc Teirlinck
2006-07-19 0:14 ` Luc Teirlinck
2006-07-19 0:21 ` Luc Teirlinck
2006-07-19 2:56 ` Eli Zaretskii
2006-07-18 19:29 ` Luc Teirlinck
2006-07-19 6:04 ` Richard Stallman
2006-07-19 9:22 ` YAMAMOTO Mitsuharu
2006-07-19 9:46 ` YAMAMOTO Mitsuharu
2006-07-19 15:05 ` Stefan Monnier
2006-07-19 23:13 ` Kim F. Storm
2006-07-20 4:05 ` Stefan Monnier
2006-07-20 2:13 ` YAMAMOTO Mitsuharu
2006-07-20 2:21 ` Richard Stallman
2006-07-20 2:21 ` Richard Stallman
2006-07-20 4:07 ` Stefan Monnier
2006-07-20 8:14 ` Kim F. Storm
2006-07-20 15:26 ` Stefan Monnier
2006-07-20 18:16 ` Richard Stallman
2006-07-19 21:15 ` Richard Stallman
2006-07-19 22:47 ` Kim F. Storm
2006-07-20 15:33 ` Richard Stallman
2006-07-20 9:34 ` Kim F. Storm
2006-07-20 9:58 ` David Kastrup
2006-07-20 11:35 ` Kim F. Storm
2006-07-20 13:46 ` David Kastrup
2006-07-20 18:16 ` Richard Stallman
2006-07-21 8:36 ` Kim F. Storm
2006-07-21 19:36 ` Richard Stallman
2006-07-21 19:48 ` David Kastrup
2006-07-21 20:40 ` Andreas Schwab
2006-07-21 20:49 ` David Kastrup
2006-07-22 15:49 ` Richard Stallman
2006-07-20 16:03 ` Stefan Monnier
2006-07-20 21:46 ` Richard Stallman
2006-07-20 22:11 ` Stefan Monnier
2006-07-21 4:46 ` Richard Stallman
2006-07-21 12:57 ` Stefan Monnier
2006-07-21 19:37 ` Richard Stallman
2006-07-19 0:44 ` Katsumi Yamaoka
-- strict thread matches above, loose matches on Subject: below --
2006-08-07 13:30 Klaus Zeitler
2006-08-08 9:20 ` Klaus Zeitler
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=wlodvetrj6.wl%mituharu@math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=mathias.dahl@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=ralphm@members.fsf.org \
--cc=rms@gnu.org \
--cc=teirllm@dms.auburn.edu \
/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.