diff options
| author | Paul Eggert | 2015-01-19 16:49:11 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-01-19 17:17:30 -0800 |
| commit | 347e01447194e511daaeee8835bcb86d2505e642 (patch) | |
| tree | a075b2c51308d56221833b5e7d9e8e48e18e472d /src | |
| parent | fb6462f056f616f3da8ae18037c7c2137fecb6fd (diff) | |
| download | emacs-347e01447194e511daaeee8835bcb86d2505e642.tar.gz emacs-347e01447194e511daaeee8835bcb86d2505e642.zip | |
Port to hypothetical case where Qnil is nonzero
* alloc.c (allocate_pseudovector):
* callint.c (Fcall_interactively):
* coding.c (syms_of_coding):
* dispnew.c (realloc_glyph_pool):
* fringe.c (init_fringe):
* lisp.h (memsetnil):
* xdisp.c (init_iterator):
Port to the currently-hypothetical case where Qnil is nonzero.
* dispnew.c (adjust_glyph_matrix): Remove unnecessary verification,
as there are no Lisp_Object values in the data here.
* lisp.h (NIL_IS_NONZERO): New symbol, replacing NIL_IS_ZERO.
All uses changed. Define only if not already defined, so that one
can debug with -DNIL_IS_NONZERO.
* xdisp.c (init_iterator): Remove unnecessary initializations to 0.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 18 | ||||
| -rw-r--r-- | src/alloc.c | 7 | ||||
| -rw-r--r-- | src/callint.c | 3 | ||||
| -rw-r--r-- | src/coding.c | 4 | ||||
| -rw-r--r-- | src/dispnew.c | 14 | ||||
| -rw-r--r-- | src/fringe.c | 3 | ||||
| -rw-r--r-- | src/lisp.h | 22 | ||||
| -rw-r--r-- | src/xdisp.c | 44 |
8 files changed, 68 insertions, 47 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f6a5f3837a3..b77f00c21c5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | 2015-01-20 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Port to hypothetical case where Qnil is nonzero | ||
| 4 | * alloc.c (allocate_pseudovector): | ||
| 5 | * callint.c (Fcall_interactively): | ||
| 6 | * coding.c (syms_of_coding): | ||
| 7 | * dispnew.c (realloc_glyph_pool): | ||
| 8 | * fringe.c (init_fringe): | ||
| 9 | * lisp.h (memsetnil): | ||
| 10 | * xdisp.c (init_iterator): | ||
| 11 | Port to the currently-hypothetical case where Qnil is nonzero. | ||
| 12 | * dispnew.c (adjust_glyph_matrix): Remove unnecessary verification, | ||
| 13 | as there are no Lisp_Object values in the data here. | ||
| 14 | * lisp.h (NIL_IS_NONZERO): New symbol, replacing NIL_IS_ZERO. | ||
| 15 | All uses changed. Define only if not already defined, so that one | ||
| 16 | can debug with -DNIL_IS_NONZERO. | ||
| 17 | * xdisp.c (init_iterator): Remove unnecessary initializations to 0. | ||
| 18 | |||
| 1 | 2015-01-19 Eli Zaretskii <eliz@gnu.org> | 19 | 2015-01-19 Eli Zaretskii <eliz@gnu.org> |
| 2 | 20 | ||
| 3 | * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that | 21 | * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that |
diff --git a/src/alloc.c b/src/alloc.c index 2c7b02f1158..d758ca18a7b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3175,9 +3175,10 @@ allocate_pseudovector (int memlen, int lisplen, | |||
| 3175 | eassert (lisplen <= (1 << PSEUDOVECTOR_SIZE_BITS) - 1); | 3175 | eassert (lisplen <= (1 << PSEUDOVECTOR_SIZE_BITS) - 1); |
| 3176 | 3176 | ||
| 3177 | /* Only the first LISPLEN slots will be traced normally by the GC. | 3177 | /* Only the first LISPLEN slots will be traced normally by the GC. |
| 3178 | But since Qnil == 0, we can memset Lisp_Object slots as well. */ | 3178 | If Qnil is nonzero, clear the non-Lisp data separately. */ |
| 3179 | verify (NIL_IS_ZERO); | 3179 | memsetnil (v->contents, zerolen); |
| 3180 | memset (v->contents, 0, zerolen * word_size); | 3180 | if (NIL_IS_NONZERO) |
| 3181 | memset (v->contents + lisplen, 0, (zerolen - lisplen) * word_size); | ||
| 3181 | 3182 | ||
| 3182 | XSETPVECTYPESIZE (v, tag, lisplen, memlen - lisplen); | 3183 | XSETPVECTYPESIZE (v, tag, lisplen, memlen - lisplen); |
| 3183 | return v; | 3184 | return v; |
diff --git a/src/callint.c b/src/callint.c index 3a595b57d77..43566acfbe9 100644 --- a/src/callint.c +++ b/src/callint.c | |||
| @@ -509,8 +509,9 @@ invoke it. If KEYS is omitted or nil, the return value of | |||
| 509 | visargs = args + nargs; | 509 | visargs = args + nargs; |
| 510 | varies = (signed char *) (visargs + nargs); | 510 | varies = (signed char *) (visargs + nargs); |
| 511 | 511 | ||
| 512 | verify (NIL_IS_ZERO); | ||
| 513 | memset (args, 0, nargs * (2 * word_size + 1)); | 512 | memset (args, 0, nargs * (2 * word_size + 1)); |
| 513 | if (NIL_IS_NONZERO) | ||
| 514 | memsetnil (args, nargs * 2); | ||
| 514 | 515 | ||
| 515 | GCPRO5 (prefix_arg, function, *args, *visargs, up_event); | 516 | GCPRO5 (prefix_arg, function, *args, *visargs, up_event); |
| 516 | gcpro3.nvars = nargs; | 517 | gcpro3.nvars = nargs; |
diff --git a/src/coding.c b/src/coding.c index 77cea77cef5..b95c0a5f825 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -11272,8 +11272,8 @@ internal character representation. */); | |||
| 11272 | Vtranslation_table_for_input = Qnil; | 11272 | Vtranslation_table_for_input = Qnil; |
| 11273 | 11273 | ||
| 11274 | { | 11274 | { |
| 11275 | verify (NIL_IS_ZERO); | 11275 | Lisp_Object args[coding_arg_undecided_max]; |
| 11276 | Lisp_Object args[coding_arg_undecided_max] = { LISP_INITIALLY_ZERO, }; | 11276 | memsetnil (args, ARRAYELTS (args)); |
| 11277 | 11277 | ||
| 11278 | Lisp_Object plist[16]; | 11278 | Lisp_Object plist[16]; |
| 11279 | plist[0] = intern_c_string (":name"); | 11279 | plist[0] = intern_c_string (":name"); |
diff --git a/src/dispnew.c b/src/dispnew.c index 4aaf6db3a86..e76be21dcdc 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -418,7 +418,6 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y | |||
| 418 | relies on the object of special glyphs (truncation and | 418 | relies on the object of special glyphs (truncation and |
| 419 | continuation glyps and also blanks used to extend each line | 419 | continuation glyps and also blanks used to extend each line |
| 420 | on a TTY) to be nil. */ | 420 | on a TTY) to be nil. */ |
| 421 | verify (NIL_IS_ZERO); | ||
| 422 | memset (matrix->rows + old_alloc, 0, | 421 | memset (matrix->rows + old_alloc, 0, |
| 423 | (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); | 422 | (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows); |
| 424 | } | 423 | } |
| @@ -1345,14 +1344,15 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim matrix_dim) | |||
| 1345 | ptrdiff_t old_nglyphs = pool->nglyphs; | 1344 | ptrdiff_t old_nglyphs = pool->nglyphs; |
| 1346 | pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, | 1345 | pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs, |
| 1347 | needed - old_nglyphs, -1, sizeof *pool->glyphs); | 1346 | needed - old_nglyphs, -1, sizeof *pool->glyphs); |
| 1348 | /* As a side effect, this sets the object of each glyph to nil, | ||
| 1349 | so verify we will indeed get that. Redisplay relies on the | ||
| 1350 | object of special glyphs (truncation and continuation glyps | ||
| 1351 | and also blanks used to extend each line on a TTY) to be | ||
| 1352 | nil. */ | ||
| 1353 | verify (NIL_IS_ZERO); | ||
| 1354 | memset (pool->glyphs + old_nglyphs, 0, | 1347 | memset (pool->glyphs + old_nglyphs, 0, |
| 1355 | (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); | 1348 | (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs); |
| 1349 | |||
| 1350 | /* Set the object of each glyph to nil. Redisplay relies on | ||
| 1351 | this for objects of special glyphs (truncation and continuation | ||
| 1352 | glyphs and also blanks used to extend each line on a TTY). */ | ||
| 1353 | if (NIL_IS_NONZERO) | ||
| 1354 | for (ptrdiff_t i = old_nglyphs; i < pool->nglyphs; i++) | ||
| 1355 | pool->glyphs[i].object = Qnil; | ||
| 1356 | } | 1356 | } |
| 1357 | 1357 | ||
| 1358 | /* Remember the number of rows and columns because (a) we use them | 1358 | /* Remember the number of rows and columns because (a) we use them |
diff --git a/src/fringe.c b/src/fringe.c index 464379d0cd0..a494f681cd7 100644 --- a/src/fringe.c +++ b/src/fringe.c | |||
| @@ -1727,8 +1727,9 @@ init_fringe (void) | |||
| 1727 | 1727 | ||
| 1728 | fringe_bitmaps = xzalloc (max_fringe_bitmaps * sizeof *fringe_bitmaps); | 1728 | fringe_bitmaps = xzalloc (max_fringe_bitmaps * sizeof *fringe_bitmaps); |
| 1729 | 1729 | ||
| 1730 | verify (NIL_IS_ZERO); | ||
| 1731 | fringe_faces = xzalloc (max_fringe_bitmaps * sizeof *fringe_faces); | 1730 | fringe_faces = xzalloc (max_fringe_bitmaps * sizeof *fringe_faces); |
| 1731 | if (NIL_IS_NONZERO) | ||
| 1732 | memsetnil (fringe_faces, max_fringe_bitmaps); | ||
| 1732 | } | 1733 | } |
| 1733 | 1734 | ||
| 1734 | #ifdef HAVE_NTGUI | 1735 | #ifdef HAVE_NTGUI |
diff --git a/src/lisp.h b/src/lisp.h index a1ea35574c3..119257bc4b9 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1503,18 +1503,22 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) | |||
| 1503 | XVECTOR (array)->contents[idx] = val; | 1503 | XVECTOR (array)->contents[idx] = val; |
| 1504 | } | 1504 | } |
| 1505 | 1505 | ||
| 1506 | /* True, since Qnil's representation is zero. Every place in the code | 1506 | /* True if Qnil's representation is nonzero. This is always false currently, |
| 1507 | that assumes Qnil is zero should verify (NIL_IS_ZERO), to make it easy | 1507 | but there is fallback code for hypothetical alternative implementations. |
| 1508 | to find such assumptions later if we change Qnil to be nonzero. */ | 1508 | Compile with -DNIL_IS_NONZERO to test the fallback code. */ |
| 1509 | enum { NIL_IS_ZERO = XLI_BUILTIN_LISPSYM (iQnil) == 0 }; | 1509 | #ifndef NIL_IS_NONZERO |
| 1510 | enum { NIL_IS_NONZERO = XLI_BUILTIN_LISPSYM (iQnil) != 0 }; | ||
| 1511 | #endif | ||
| 1510 | 1512 | ||
| 1511 | /* Set a Lisp_Object array V's SIZE entries to nil. */ | 1513 | /* Set a Lisp_Object array V's N entries to nil. */ |
| 1512 | INLINE void | 1514 | INLINE void |
| 1513 | memsetnil (Lisp_Object *v, ptrdiff_t size) | 1515 | memsetnil (Lisp_Object *v, ptrdiff_t n) |
| 1514 | { | 1516 | { |
| 1515 | eassert (0 <= size); | 1517 | eassert (0 <= n); |
| 1516 | verify (NIL_IS_ZERO); | 1518 | memset (v, 0, n * sizeof *v); |
| 1517 | memset (v, 0, size * sizeof *v); | 1519 | if (NIL_IS_NONZERO) |
| 1520 | for (ptrdiff_t i = 0; i < n; i++) | ||
| 1521 | v[i] = Qnil; | ||
| 1518 | } | 1522 | } |
| 1519 | 1523 | ||
| 1520 | /* If a struct is made to look like a vector, this macro returns the length | 1524 | /* If a struct is made to look like a vector, this macro returns the length |
diff --git a/src/xdisp.c b/src/xdisp.c index 2442367d3b5..8d53274fd7b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2747,19 +2747,22 @@ init_iterator (struct it *it, struct window *w, | |||
| 2747 | } | 2747 | } |
| 2748 | 2748 | ||
| 2749 | /* Clear IT. */ | 2749 | /* Clear IT. */ |
| 2750 | /* As a side effect, this sets it->object to nil, so verify we will | ||
| 2751 | indeed get that. */ | ||
| 2752 | verify (NIL_IS_ZERO); | ||
| 2753 | memset (it, 0, sizeof *it); | 2750 | memset (it, 0, sizeof *it); |
| 2751 | if (NIL_IS_NONZERO) | ||
| 2752 | { | ||
| 2753 | it->string = Qnil; | ||
| 2754 | it->from_overlay = Qnil; | ||
| 2755 | it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil; | ||
| 2756 | it->space_width = Qnil; | ||
| 2757 | it->font_height = Qnil; | ||
| 2758 | it->object = Qnil; | ||
| 2759 | it->bidi_it.string.lstring = Qnil; | ||
| 2760 | } | ||
| 2754 | it->current.overlay_string_index = -1; | 2761 | it->current.overlay_string_index = -1; |
| 2755 | it->current.dpvec_index = -1; | 2762 | it->current.dpvec_index = -1; |
| 2756 | it->base_face_id = remapped_base_face_id; | 2763 | it->base_face_id = remapped_base_face_id; |
| 2757 | it->string = Qnil; | ||
| 2758 | IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1; | 2764 | IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1; |
| 2759 | it->paragraph_embedding = L2R; | 2765 | it->paragraph_embedding = L2R; |
| 2760 | it->bidi_it.string.lstring = Qnil; | ||
| 2761 | it->bidi_it.string.s = NULL; | ||
| 2762 | it->bidi_it.string.bufpos = 0; | ||
| 2763 | it->bidi_it.w = w; | 2766 | it->bidi_it.w = w; |
| 2764 | 2767 | ||
| 2765 | /* The window in which we iterate over current_buffer: */ | 2768 | /* The window in which we iterate over current_buffer: */ |
| @@ -2780,7 +2783,6 @@ init_iterator (struct it *it, struct window *w, | |||
| 2780 | * FRAME_LINE_HEIGHT (it->f)); | 2783 | * FRAME_LINE_HEIGHT (it->f)); |
| 2781 | else if (it->f->extra_line_spacing > 0) | 2784 | else if (it->f->extra_line_spacing > 0) |
| 2782 | it->extra_line_spacing = it->f->extra_line_spacing; | 2785 | it->extra_line_spacing = it->f->extra_line_spacing; |
| 2783 | it->max_extra_line_spacing = 0; | ||
| 2784 | } | 2786 | } |
| 2785 | 2787 | ||
| 2786 | /* If realized faces have been removed, e.g. because of face | 2788 | /* If realized faces have been removed, e.g. because of face |
| @@ -2792,10 +2794,6 @@ init_iterator (struct it *it, struct window *w, | |||
| 2792 | if (FRAME_FACE_CACHE (it->f)->used == 0) | 2794 | if (FRAME_FACE_CACHE (it->f)->used == 0) |
| 2793 | recompute_basic_faces (it->f); | 2795 | recompute_basic_faces (it->f); |
| 2794 | 2796 | ||
| 2795 | /* Current value of the `slice', `space-width', and 'height' properties. */ | ||
| 2796 | it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil; | ||
| 2797 | it->space_width = Qnil; | ||
| 2798 | it->font_height = Qnil; | ||
| 2799 | it->override_ascent = -1; | 2797 | it->override_ascent = -1; |
| 2800 | 2798 | ||
| 2801 | /* Are control characters displayed as `^C'? */ | 2799 | /* Are control characters displayed as `^C'? */ |
| @@ -2833,21 +2831,19 @@ init_iterator (struct it *it, struct window *w, | |||
| 2833 | it->tab_width = SANE_TAB_WIDTH (current_buffer); | 2831 | it->tab_width = SANE_TAB_WIDTH (current_buffer); |
| 2834 | 2832 | ||
| 2835 | /* Are lines in the display truncated? */ | 2833 | /* Are lines in the display truncated? */ |
| 2836 | if (base_face_id != DEFAULT_FACE_ID | 2834 | if (TRUNCATE != 0) |
| 2837 | || it->w->hscroll | ||
| 2838 | || (! WINDOW_FULL_WIDTH_P (it->w) | ||
| 2839 | && ((!NILP (Vtruncate_partial_width_windows) | ||
| 2840 | && !INTEGERP (Vtruncate_partial_width_windows)) | ||
| 2841 | || (INTEGERP (Vtruncate_partial_width_windows) | ||
| 2842 | /* PXW: Shall we do something about this? */ | ||
| 2843 | && (WINDOW_TOTAL_COLS (it->w) | ||
| 2844 | < XINT (Vtruncate_partial_width_windows)))))) | ||
| 2845 | it->line_wrap = TRUNCATE; | 2835 | it->line_wrap = TRUNCATE; |
| 2846 | else if (NILP (BVAR (current_buffer, truncate_lines))) | 2836 | if (base_face_id == DEFAULT_FACE_ID |
| 2837 | && !it->w->hscroll | ||
| 2838 | && (WINDOW_FULL_WIDTH_P (it->w) | ||
| 2839 | || NILP (Vtruncate_partial_width_windows) | ||
| 2840 | || (INTEGERP (Vtruncate_partial_width_windows) | ||
| 2841 | /* PXW: Shall we do something about this? */ | ||
| 2842 | && (XINT (Vtruncate_partial_width_windows) | ||
| 2843 | <= WINDOW_TOTAL_COLS (it->w)))) | ||
| 2844 | && NILP (BVAR (current_buffer, truncate_lines))) | ||
| 2847 | it->line_wrap = NILP (BVAR (current_buffer, word_wrap)) | 2845 | it->line_wrap = NILP (BVAR (current_buffer, word_wrap)) |
| 2848 | ? WINDOW_WRAP : WORD_WRAP; | 2846 | ? WINDOW_WRAP : WORD_WRAP; |
| 2849 | else | ||
| 2850 | it->line_wrap = TRUNCATE; | ||
| 2851 | 2847 | ||
| 2852 | /* Get dimensions of truncation and continuation glyphs. These are | 2848 | /* Get dimensions of truncation and continuation glyphs. These are |
| 2853 | displayed as fringe bitmaps under X, but we need them for such | 2849 | displayed as fringe bitmaps under X, but we need them for such |