aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-04-18 17:49:33 -0400
committerStefan Monnier2010-04-18 17:49:33 -0400
commite951580547dfd926f757e200c8e86e71b59ee596 (patch)
treefe39dc1921da2cba76e1e87e49fa9cb02afbb53f
parentf8ea0098d95f535fc3d8049b7cae524d6ea33aa8 (diff)
downloademacs-e951580547dfd926f757e200c8e86e71b59ee596.tar.gz
emacs-e951580547dfd926f757e200c8e86e71b59ee596.zip
Hash-cons pure data.
* alloc.c (Fpurecopy): Hash-cons if requested. (syms_of_alloc): Update purify-flag docstring. * loadup.el: Setup hash-cons for pure data.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/loadup.el11
-rw-r--r--src/ChangeLog5
-rw-r--r--src/alloc.c28
4 files changed, 36 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 56127c0f504..d6de8167231 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,7 @@
12010-04-18 Stefan Monnier <monnier@iro.umontreal.ca> 12010-04-18 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * loadup.el: Setup hash-cons for pure data.
4
3 Fix duplicate entries in cedet's loaddefs.el files. 5 Fix duplicate entries in cedet's loaddefs.el files.
4 * emacs-lisp/autoload.el (autoload-file-load-name): Be more clever. 6 * emacs-lisp/autoload.el (autoload-file-load-name): Be more clever.
5 Should make most file-local generated-autoload-file unnecessary. 7 Should make most file-local generated-autoload-file unnecessary.
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 85222ce7d9e..95af8cdb47e 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -64,6 +64,10 @@
64 (expand-file-name "international" dir) 64 (expand-file-name "international" dir)
65 (expand-file-name "textmodes" dir))))) 65 (expand-file-name "textmodes" dir)))))
66 66
67(if (eq t purify-flag)
68 ;; Hash consing saved around 11% of pure space in my tests.
69 (setq purify-flag (make-hash-table :test 'equal)))
70
67(message "Using load-path %s" load-path) 71(message "Using load-path %s" load-path)
68 72
69(if (or (member (nth 3 command-line-args) '("dump" "bootstrap")) 73(if (or (member (nth 3 command-line-args) '("dump" "bootstrap"))
@@ -345,6 +349,10 @@
345;; At this point, we're ready to resume undo recording for scratch. 349;; At this point, we're ready to resume undo recording for scratch.
346(buffer-enable-undo "*scratch*") 350(buffer-enable-undo "*scratch*")
347 351
352;; Avoid error if user loads some more libraries now and make sure the
353;; hash-consing hash table is GC'd.
354(setq purify-flag nil)
355
348(if (null (garbage-collect)) 356(if (null (garbage-collect))
349 (setq pure-space-overflow t)) 357 (setq pure-space-overflow t))
350 358
@@ -378,9 +386,6 @@
378 (add-name-to-file "emacs" name t))) 386 (add-name-to-file "emacs" name t)))
379 (kill-emacs))) 387 (kill-emacs)))
380 388
381;; Avoid error if user loads some more libraries now.
382(setq purify-flag nil)
383
384;; For machines with CANNOT_DUMP defined in config.h, 389;; For machines with CANNOT_DUMP defined in config.h,
385;; this file must be loaded each time Emacs is run. 390;; this file must be loaded each time Emacs is run.
386;; So run the startup code now. First, remove `-l loadup' from args. 391;; So run the startup code now. First, remove `-l loadup' from args.
diff --git a/src/ChangeLog b/src/ChangeLog
index 9789b3dbd04..c0bc876b28c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12010-04-18 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * alloc.c (Fpurecopy): Hash-cons if requested.
4 (syms_of_alloc): Update purify-flag docstring.
5
12010-04-18 Jan Djärv <jan.h.d@swipnet.se> 62010-04-18 Jan Djärv <jan.h.d@swipnet.se>
2 7
3 * gtkutil.c (xg_set_geometry): Set size in geometry string also. 8 * gtkutil.c (xg_set_geometry): Set size in geometry string also.
diff --git a/src/alloc.c b/src/alloc.c
index 98d60067f9e..37ec06c7be1 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4893,14 +4893,21 @@ Does not copy symbols. Copies strings without text properties. */)
4893 if (PURE_POINTER_P (XPNTR (obj))) 4893 if (PURE_POINTER_P (XPNTR (obj)))
4894 return obj; 4894 return obj;
4895 4895
4896 if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */
4897 {
4898 Lisp_Object tmp = Fgethash (obj, Vpurify_flag, Qnil);
4899 if (!NILP (tmp))
4900 return tmp;
4901 }
4902
4896 if (CONSP (obj)) 4903 if (CONSP (obj))
4897 return pure_cons (XCAR (obj), XCDR (obj)); 4904 obj = pure_cons (XCAR (obj), XCDR (obj));
4898 else if (FLOATP (obj)) 4905 else if (FLOATP (obj))
4899 return make_pure_float (XFLOAT_DATA (obj)); 4906 obj = make_pure_float (XFLOAT_DATA (obj));
4900 else if (STRINGP (obj)) 4907 else if (STRINGP (obj))
4901 return make_pure_string (SDATA (obj), SCHARS (obj), 4908 obj = make_pure_string (SDATA (obj), SCHARS (obj),
4902 SBYTES (obj), 4909 SBYTES (obj),
4903 STRING_MULTIBYTE (obj)); 4910 STRING_MULTIBYTE (obj));
4904 else if (COMPILEDP (obj) || VECTORP (obj)) 4911 else if (COMPILEDP (obj) || VECTORP (obj))
4905 { 4912 {
4906 register struct Lisp_Vector *vec; 4913 register struct Lisp_Vector *vec;
@@ -4920,10 +4927,15 @@ Does not copy symbols. Copies strings without text properties. */)
4920 } 4927 }
4921 else 4928 else
4922 XSETVECTOR (obj, vec); 4929 XSETVECTOR (obj, vec);
4923 return obj;
4924 } 4930 }
4925 else if (MARKERP (obj)) 4931 else if (MARKERP (obj))
4926 error ("Attempt to copy a marker to pure storage"); 4932 error ("Attempt to copy a marker to pure storage");
4933 else
4934 /* Not purified, don't hash-cons. */
4935 return obj;
4936
4937 if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */
4938 Fputhash (obj, obj, Vpurify_flag);
4927 4939
4928 return obj; 4940 return obj;
4929} 4941}
@@ -6371,7 +6383,9 @@ If this portion is smaller than `gc-cons-threshold', this is ignored. */);
6371 6383
6372 DEFVAR_LISP ("purify-flag", &Vpurify_flag, 6384 DEFVAR_LISP ("purify-flag", &Vpurify_flag,
6373 doc: /* Non-nil means loading Lisp code in order to dump an executable. 6385 doc: /* Non-nil means loading Lisp code in order to dump an executable.
6374This means that certain objects should be allocated in shared (pure) space. */); 6386This means that certain objects should be allocated in shared (pure) space.
6387It can also be set to a hash-table, in which case this table is used to
6388do hash-consing of the objects allocated to pure space. */);
6375 6389
6376 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, 6390 DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
6377 doc: /* Non-nil means display messages at start and end of garbage collection. */); 6391 doc: /* Non-nil means display messages at start and end of garbage collection. */);