diff options
| author | Stefan Monnier | 2017-02-18 22:37:05 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2017-02-18 22:37:05 -0500 |
| commit | fe927ecfe45f66ec58d9e7cab6f2526fc87a6803 (patch) | |
| tree | 2bf00f13cb623dcdebda530dfcef75af69a4a13a /src | |
| parent | b2a83eed23d540b4b0ab9e0bf5605821011bfd7d (diff) | |
| download | emacs-fe927ecfe45f66ec58d9e7cab6f2526fc87a6803.tar.gz emacs-fe927ecfe45f66ec58d9e7cab6f2526fc87a6803.zip | |
Change type of `rehash_threshold' and `pure' fields in hash-tables
* src/lisp.h (struct Lisp_Hash_Table): Change type of
`rehash_threshold' and `pure' fields and move them after `count'.
* src/fns.c (make_hash_table): Change type of `rehash_threshold' and `pure'.
(Fmake_hash_table, Fhash_table_rehash_threshold):
* src/category.c (hash_get_category_set):
* src/xterm.c (syms_of_xterm):
* src/profiler.c (make_log):
* src/print.c (print_object):
* src/alloc.c (purecopy_hash_table, purecopy): Adjust accordingly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 8 | ||||
| -rw-r--r-- | src/category.c | 4 | ||||
| -rw-r--r-- | src/fns.c | 30 | ||||
| -rw-r--r-- | src/lisp.h | 22 | ||||
| -rw-r--r-- | src/print.c | 12 | ||||
| -rw-r--r-- | src/profiler.c | 4 | ||||
| -rw-r--r-- | src/xterm.c | 4 |
7 files changed, 42 insertions, 42 deletions
diff --git a/src/alloc.c b/src/alloc.c index deb1ca32500..b579e7ed1ae 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -5443,7 +5443,7 @@ static struct Lisp_Hash_Table * | |||
| 5443 | purecopy_hash_table (struct Lisp_Hash_Table *table) | 5443 | purecopy_hash_table (struct Lisp_Hash_Table *table) |
| 5444 | { | 5444 | { |
| 5445 | eassert (NILP (table->weak)); | 5445 | eassert (NILP (table->weak)); |
| 5446 | eassert (!NILP (table->pure)); | 5446 | eassert (table->pure); |
| 5447 | 5447 | ||
| 5448 | struct Lisp_Hash_Table *pure = pure_alloc (sizeof *pure, Lisp_Vectorlike); | 5448 | struct Lisp_Hash_Table *pure = pure_alloc (sizeof *pure, Lisp_Vectorlike); |
| 5449 | struct hash_table_test pure_test = table->test; | 5449 | struct hash_table_test pure_test = table->test; |
| @@ -5457,14 +5457,14 @@ purecopy_hash_table (struct Lisp_Hash_Table *table) | |||
| 5457 | pure->header = table->header; | 5457 | pure->header = table->header; |
| 5458 | pure->weak = purecopy (Qnil); | 5458 | pure->weak = purecopy (Qnil); |
| 5459 | pure->rehash_size = purecopy (table->rehash_size); | 5459 | pure->rehash_size = purecopy (table->rehash_size); |
| 5460 | pure->rehash_threshold = purecopy (table->rehash_threshold); | ||
| 5461 | pure->hash = purecopy (table->hash); | 5460 | pure->hash = purecopy (table->hash); |
| 5462 | pure->next = purecopy (table->next); | 5461 | pure->next = purecopy (table->next); |
| 5463 | pure->next_free = purecopy (table->next_free); | 5462 | pure->next_free = purecopy (table->next_free); |
| 5464 | pure->index = purecopy (table->index); | 5463 | pure->index = purecopy (table->index); |
| 5465 | pure->count = table->count; | 5464 | pure->count = table->count; |
| 5465 | pure->pure = table->pure; | ||
| 5466 | pure->rehash_threshold = table->rehash_threshold; | ||
| 5466 | pure->key_and_value = purecopy (table->key_and_value); | 5467 | pure->key_and_value = purecopy (table->key_and_value); |
| 5467 | pure->pure = purecopy (table->pure); | ||
| 5468 | 5468 | ||
| 5469 | return pure; | 5469 | return pure; |
| 5470 | } | 5470 | } |
| @@ -5524,7 +5524,7 @@ purecopy (Lisp_Object obj) | |||
| 5524 | /* Do not purify hash tables which haven't been defined with | 5524 | /* Do not purify hash tables which haven't been defined with |
| 5525 | :purecopy as non-nil or are weak - they aren't guaranteed to | 5525 | :purecopy as non-nil or are weak - they aren't guaranteed to |
| 5526 | not change. */ | 5526 | not change. */ |
| 5527 | if (!NILP (table->weak) || NILP (table->pure)) | 5527 | if (!NILP (table->weak) || !table->pure) |
| 5528 | { | 5528 | { |
| 5529 | /* Instead, add the hash table to the list of pinned objects, | 5529 | /* Instead, add the hash table to the list of pinned objects, |
| 5530 | so that it will be marked during GC. */ | 5530 | so that it will be marked during GC. */ |
diff --git a/src/category.c b/src/category.c index ff287a4af3d..f5edd20c8a3 100644 --- a/src/category.c +++ b/src/category.c | |||
| @@ -66,8 +66,8 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set) | |||
| 66 | (table, 1, | 66 | (table, 1, |
| 67 | make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE), | 67 | make_hash_table (hashtest_equal, make_number (DEFAULT_HASH_SIZE), |
| 68 | make_float (DEFAULT_REHASH_SIZE), | 68 | make_float (DEFAULT_REHASH_SIZE), |
| 69 | make_float (DEFAULT_REHASH_THRESHOLD), | 69 | DEFAULT_REHASH_THRESHOLD, |
| 70 | Qnil, Qnil)); | 70 | Qnil, false)); |
| 71 | h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); | 71 | h = XHASH_TABLE (XCHAR_TABLE (table)->extras[1]); |
| 72 | i = hash_lookup (h, category_set, &hash); | 72 | i = hash_lookup (h, category_set, &hash); |
| 73 | if (i >= 0) | 73 | if (i >= 0) |
| @@ -3676,8 +3676,8 @@ allocate_hash_table (void) | |||
| 3676 | Lisp_Object | 3676 | Lisp_Object |
| 3677 | make_hash_table (struct hash_table_test test, | 3677 | make_hash_table (struct hash_table_test test, |
| 3678 | Lisp_Object size, Lisp_Object rehash_size, | 3678 | Lisp_Object size, Lisp_Object rehash_size, |
| 3679 | Lisp_Object rehash_threshold, Lisp_Object weak, | 3679 | float rehash_threshold, Lisp_Object weak, |
| 3680 | Lisp_Object pure) | 3680 | bool pure) |
| 3681 | { | 3681 | { |
| 3682 | struct Lisp_Hash_Table *h; | 3682 | struct Lisp_Hash_Table *h; |
| 3683 | Lisp_Object table; | 3683 | Lisp_Object table; |
| @@ -3690,15 +3690,13 @@ make_hash_table (struct hash_table_test test, | |||
| 3690 | eassert (INTEGERP (size) && XINT (size) >= 0); | 3690 | eassert (INTEGERP (size) && XINT (size) >= 0); |
| 3691 | eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0) | 3691 | eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0) |
| 3692 | || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))); | 3692 | || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))); |
| 3693 | eassert (FLOATP (rehash_threshold) | 3693 | eassert (0 < rehash_threshold && rehash_threshold <= 1.0); |
| 3694 | && 0 < XFLOAT_DATA (rehash_threshold) | ||
| 3695 | && XFLOAT_DATA (rehash_threshold) <= 1.0); | ||
| 3696 | 3694 | ||
| 3697 | if (XFASTINT (size) == 0) | 3695 | if (XFASTINT (size) == 0) |
| 3698 | size = make_number (1); | 3696 | size = make_number (1); |
| 3699 | 3697 | ||
| 3700 | sz = XFASTINT (size); | 3698 | sz = XFASTINT (size); |
| 3701 | index_float = sz / XFLOAT_DATA (rehash_threshold); | 3699 | index_float = sz / rehash_threshold; |
| 3702 | index_size = (index_float < INDEX_SIZE_BOUND + 1 | 3700 | index_size = (index_float < INDEX_SIZE_BOUND + 1 |
| 3703 | ? next_almost_prime (index_float) | 3701 | ? next_almost_prime (index_float) |
| 3704 | : INDEX_SIZE_BOUND + 1); | 3702 | : INDEX_SIZE_BOUND + 1); |
| @@ -3797,7 +3795,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) | |||
| 3797 | else | 3795 | else |
| 3798 | new_size = INDEX_SIZE_BOUND + 1; | 3796 | new_size = INDEX_SIZE_BOUND + 1; |
| 3799 | } | 3797 | } |
| 3800 | index_float = new_size / XFLOAT_DATA (h->rehash_threshold); | 3798 | index_float = new_size / h->rehash_threshold; |
| 3801 | index_size = (index_float < INDEX_SIZE_BOUND + 1 | 3799 | index_size = (index_float < INDEX_SIZE_BOUND + 1 |
| 3802 | ? next_almost_prime (index_float) | 3800 | ? next_almost_prime (index_float) |
| 3803 | : INDEX_SIZE_BOUND + 1); | 3801 | : INDEX_SIZE_BOUND + 1); |
| @@ -4391,7 +4389,9 @@ in an error. | |||
| 4391 | usage: (make-hash-table &rest KEYWORD-ARGS) */) | 4389 | usage: (make-hash-table &rest KEYWORD-ARGS) */) |
| 4392 | (ptrdiff_t nargs, Lisp_Object *args) | 4390 | (ptrdiff_t nargs, Lisp_Object *args) |
| 4393 | { | 4391 | { |
| 4394 | Lisp_Object test, size, rehash_size, rehash_threshold, weak, pure; | 4392 | Lisp_Object test, size, rehash_size, weak; |
| 4393 | float rehash_threshold; | ||
| 4394 | bool pure; | ||
| 4395 | struct hash_table_test testdesc; | 4395 | struct hash_table_test testdesc; |
| 4396 | ptrdiff_t i; | 4396 | ptrdiff_t i; |
| 4397 | USE_SAFE_ALLOCA; | 4397 | USE_SAFE_ALLOCA; |
| @@ -4427,7 +4427,7 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */) | |||
| 4427 | 4427 | ||
| 4428 | /* See if there's a `:purecopy PURECOPY' argument. */ | 4428 | /* See if there's a `:purecopy PURECOPY' argument. */ |
| 4429 | i = get_key_arg (QCpurecopy, nargs, args, used); | 4429 | i = get_key_arg (QCpurecopy, nargs, args, used); |
| 4430 | pure = i ? args[i] : Qnil; | 4430 | pure = i && !NILP (args[i]); |
| 4431 | /* See if there's a `:size SIZE' argument. */ | 4431 | /* See if there's a `:size SIZE' argument. */ |
| 4432 | i = get_key_arg (QCsize, nargs, args, used); | 4432 | i = get_key_arg (QCsize, nargs, args, used); |
| 4433 | size = i ? args[i] : Qnil; | 4433 | size = i ? args[i] : Qnil; |
| @@ -4445,11 +4445,11 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */) | |||
| 4445 | 4445 | ||
| 4446 | /* Look for `:rehash-threshold THRESHOLD'. */ | 4446 | /* Look for `:rehash-threshold THRESHOLD'. */ |
| 4447 | i = get_key_arg (QCrehash_threshold, nargs, args, used); | 4447 | i = get_key_arg (QCrehash_threshold, nargs, args, used); |
| 4448 | rehash_threshold = i ? args[i] : make_float (DEFAULT_REHASH_THRESHOLD); | 4448 | rehash_threshold = |
| 4449 | if (! (FLOATP (rehash_threshold) | 4449 | i ? (FLOATP (args[i]) ? XFLOAT_DATA (args[i]) : -1.0) |
| 4450 | && 0 < XFLOAT_DATA (rehash_threshold) | 4450 | : DEFAULT_REHASH_THRESHOLD; |
| 4451 | && XFLOAT_DATA (rehash_threshold) <= 1)) | 4451 | if (! (0 < rehash_threshold && rehash_threshold <= 1)) |
| 4452 | signal_error ("Invalid hash table rehash threshold", rehash_threshold); | 4452 | signal_error ("Invalid hash table rehash threshold", args[i]); |
| 4453 | 4453 | ||
| 4454 | /* Look for `:weakness WEAK'. */ | 4454 | /* Look for `:weakness WEAK'. */ |
| 4455 | i = get_key_arg (QCweakness, nargs, args, used); | 4455 | i = get_key_arg (QCweakness, nargs, args, used); |
| @@ -4504,7 +4504,7 @@ DEFUN ("hash-table-rehash-threshold", Fhash_table_rehash_threshold, | |||
| 4504 | doc: /* Return the current rehash threshold of TABLE. */) | 4504 | doc: /* Return the current rehash threshold of TABLE. */) |
| 4505 | (Lisp_Object table) | 4505 | (Lisp_Object table) |
| 4506 | { | 4506 | { |
| 4507 | return check_hash_table (table)->rehash_threshold; | 4507 | return make_float (check_hash_table (table)->rehash_threshold); |
| 4508 | } | 4508 | } |
| 4509 | 4509 | ||
| 4510 | 4510 | ||
diff --git a/src/lisp.h b/src/lisp.h index 080bcf74ce6..985d54a0795 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1974,10 +1974,6 @@ struct Lisp_Hash_Table | |||
| 1974 | new size by multiplying the old size with this factor. */ | 1974 | new size by multiplying the old size with this factor. */ |
| 1975 | Lisp_Object rehash_size; | 1975 | Lisp_Object rehash_size; |
| 1976 | 1976 | ||
| 1977 | /* Resize hash table when number of entries/ table size is >= this | ||
| 1978 | ratio, a float. */ | ||
| 1979 | Lisp_Object rehash_threshold; | ||
| 1980 | |||
| 1981 | /* Vector of hash codes. If hash[I] is nil, this means that the | 1977 | /* Vector of hash codes. If hash[I] is nil, this means that the |
| 1982 | I-th entry is unused. */ | 1978 | I-th entry is unused. */ |
| 1983 | Lisp_Object hash; | 1979 | Lisp_Object hash; |
| @@ -1995,10 +1991,6 @@ struct Lisp_Hash_Table | |||
| 1995 | hash table size to reduce collisions. */ | 1991 | hash table size to reduce collisions. */ |
| 1996 | Lisp_Object index; | 1992 | Lisp_Object index; |
| 1997 | 1993 | ||
| 1998 | /* Non-nil if the table can be purecopied. The table cannot be | ||
| 1999 | changed afterwards. */ | ||
| 2000 | Lisp_Object pure; | ||
| 2001 | |||
| 2002 | /* Only the fields above are traced normally by the GC. The ones below | 1994 | /* Only the fields above are traced normally by the GC. The ones below |
| 2003 | `count' are special and are either ignored by the GC or traced in | 1995 | `count' are special and are either ignored by the GC or traced in |
| 2004 | a special way (e.g. because of weakness). */ | 1996 | a special way (e.g. because of weakness). */ |
| @@ -2006,6 +1998,14 @@ struct Lisp_Hash_Table | |||
| 2006 | /* Number of key/value entries in the table. */ | 1998 | /* Number of key/value entries in the table. */ |
| 2007 | ptrdiff_t count; | 1999 | ptrdiff_t count; |
| 2008 | 2000 | ||
| 2001 | /* Non-nil if the table can be purecopied. The table cannot be | ||
| 2002 | changed afterwards. */ | ||
| 2003 | bool_bf pure : 1; | ||
| 2004 | |||
| 2005 | /* Resize hash table when number of entries/ table size is >= this | ||
| 2006 | ratio, a float. */ | ||
| 2007 | float rehash_threshold; | ||
| 2008 | |||
| 2009 | /* Vector of keys and values. The key of item I is found at index | 2009 | /* Vector of keys and values. The key of item I is found at index |
| 2010 | 2 * I, the value is found at index 2 * I + 1. | 2010 | 2 * I, the value is found at index 2 * I + 1. |
| 2011 | This is gc_marked specially if the table is weak. */ | 2011 | This is gc_marked specially if the table is weak. */ |
| @@ -3361,8 +3361,10 @@ extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t); | |||
| 3361 | extern void sweep_weak_hash_tables (void); | 3361 | extern void sweep_weak_hash_tables (void); |
| 3362 | EMACS_UINT hash_string (char const *, ptrdiff_t); | 3362 | EMACS_UINT hash_string (char const *, ptrdiff_t); |
| 3363 | EMACS_UINT sxhash (Lisp_Object, int); | 3363 | EMACS_UINT sxhash (Lisp_Object, int); |
| 3364 | Lisp_Object make_hash_table (struct hash_table_test, Lisp_Object, Lisp_Object, | 3364 | Lisp_Object make_hash_table (struct hash_table_test test, |
| 3365 | Lisp_Object, Lisp_Object, Lisp_Object); | 3365 | Lisp_Object size, Lisp_Object rehash_size, |
| 3366 | float rehash_threshold, Lisp_Object weak, | ||
| 3367 | bool pure); | ||
| 3366 | ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); | 3368 | ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *); |
| 3367 | ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, | 3369 | ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object, |
| 3368 | EMACS_UINT); | 3370 | EMACS_UINT); |
diff --git a/src/print.c b/src/print.c index db3d00f51f2..3a36a4eb54d 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1812,16 +1812,14 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 1812 | print_object (h->rehash_size, printcharfun, escapeflag); | 1812 | print_object (h->rehash_size, printcharfun, escapeflag); |
| 1813 | } | 1813 | } |
| 1814 | 1814 | ||
| 1815 | if (!NILP (h->rehash_threshold)) | 1815 | print_c_string (" rehash-threshold ", printcharfun); |
| 1816 | { | 1816 | print_object (make_float (h->rehash_threshold), |
| 1817 | print_c_string (" rehash-threshold ", printcharfun); | 1817 | printcharfun, escapeflag); |
| 1818 | print_object (h->rehash_threshold, printcharfun, escapeflag); | ||
| 1819 | } | ||
| 1820 | 1818 | ||
| 1821 | if (!NILP (h->pure)) | 1819 | if (h->pure) |
| 1822 | { | 1820 | { |
| 1823 | print_c_string (" purecopy ", printcharfun); | 1821 | print_c_string (" purecopy ", printcharfun); |
| 1824 | print_object (h->pure, printcharfun, escapeflag); | 1822 | print_object (h->pure ? Qt : Qnil, printcharfun, escapeflag); |
| 1825 | } | 1823 | } |
| 1826 | 1824 | ||
| 1827 | print_c_string (" data ", printcharfun); | 1825 | print_c_string (" data ", printcharfun); |
diff --git a/src/profiler.c b/src/profiler.c index a223a7e7c07..edc28fc8427 100644 --- a/src/profiler.c +++ b/src/profiler.c | |||
| @@ -47,8 +47,8 @@ make_log (EMACS_INT heap_size, EMACS_INT max_stack_depth) | |||
| 47 | Lisp_Object log = make_hash_table (hashtest_profiler, | 47 | Lisp_Object log = make_hash_table (hashtest_profiler, |
| 48 | make_number (heap_size), | 48 | make_number (heap_size), |
| 49 | make_float (DEFAULT_REHASH_SIZE), | 49 | make_float (DEFAULT_REHASH_SIZE), |
| 50 | make_float (DEFAULT_REHASH_THRESHOLD), | 50 | DEFAULT_REHASH_THRESHOLD, |
| 51 | Qnil, Qnil); | 51 | Qnil, false); |
| 52 | struct Lisp_Hash_Table *h = XHASH_TABLE (log); | 52 | struct Lisp_Hash_Table *h = XHASH_TABLE (log); |
| 53 | 53 | ||
| 54 | /* What is special about our hash-tables is that the keys are pre-filled | 54 | /* What is special about our hash-tables is that the keys are pre-filled |
diff --git a/src/xterm.c b/src/xterm.c index 38229a5f31f..b04c6999b39 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -12876,8 +12876,8 @@ keysyms. The default is nil, which is the same as `super'. */); | |||
| 12876 | doc: /* Hash table of character codes indexed by X keysym codes. */); | 12876 | doc: /* Hash table of character codes indexed by X keysym codes. */); |
| 12877 | Vx_keysym_table = make_hash_table (hashtest_eql, make_number (900), | 12877 | Vx_keysym_table = make_hash_table (hashtest_eql, make_number (900), |
| 12878 | make_float (DEFAULT_REHASH_SIZE), | 12878 | make_float (DEFAULT_REHASH_SIZE), |
| 12879 | make_float (DEFAULT_REHASH_THRESHOLD), | 12879 | DEFAULT_REHASH_THRESHOLD, |
| 12880 | Qnil, Qnil); | 12880 | Qnil, false); |
| 12881 | 12881 | ||
| 12882 | DEFVAR_BOOL ("x-frame-normalize-before-maximize", | 12882 | DEFVAR_BOOL ("x-frame-normalize-before-maximize", |
| 12883 | x_frame_normalize_before_maximize, | 12883 | x_frame_normalize_before_maximize, |