diff options
| author | Daniel Colascione | 2014-04-07 13:54:16 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2014-04-07 13:54:16 -0700 |
| commit | 7e31acf6b81fdce7258077645bc239767c484841 (patch) | |
| tree | 1f0d7b063a19b54982550797df063e0a9f87eaed /src | |
| parent | 608a4502b9fa8f5681368657fba5d5fd0fa46817 (diff) | |
| parent | e3b838807bf9fbbbec9826de6c1e4efdf72acb78 (diff) | |
| download | emacs-7e31acf6b81fdce7258077645bc239767c484841.tar.gz emacs-7e31acf6b81fdce7258077645bc239767c484841.zip | |
Merge from emacs-24; up to 2014-04-01T20:18:12Z!eggert@cs.ucla.edu
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 36 | ||||
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/alloc.c | 82 | ||||
| -rw-r--r-- | src/bidi.c | 190 | ||||
| -rw-r--r-- | src/buffer.h | 4 | ||||
| -rw-r--r-- | src/frame.h | 3 | ||||
| -rw-r--r-- | src/keyboard.c | 10 | ||||
| -rw-r--r-- | src/lisp.h | 3 |
8 files changed, 298 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b4722839fe3..d0d133c4989 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,37 @@ | |||
| 1 | 2014-04-07 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * lisp.h (struct Lisp_Symbol): New bitfield `pinned'. | ||
| 4 | |||
| 5 | * alloc.c: Keep track of symbols referenced from pure space (bug#17168). | ||
| 6 | (symbol_block_pinned): New var. | ||
| 7 | (Fmake_symbol): Initialize `pinned'. | ||
| 8 | (purecopy): New function, extracted from Fpurecopy. Mark symbols as | ||
| 9 | pinned and signal an error for un-purifiable objects. | ||
| 10 | (pure_cons): Use it. | ||
| 11 | (Fpurecopy): Use it, except for objects that can't be purified. | ||
| 12 | (mark_pinned_symbols): New function. | ||
| 13 | (Fgarbage_collect): Use it. | ||
| 14 | (gc_sweep): Remove hack made unnecessary. | ||
| 15 | |||
| 16 | 2014-04-05 Glenn Morris <rgm@gnu.org> | ||
| 17 | |||
| 18 | * keyboard.c (Fopen_dribble_file): Doc tweak. | ||
| 19 | |||
| 20 | 2014-04-04 Jan Djärv <jan.h.d@swipnet.se> | ||
| 21 | |||
| 22 | Backport from trunk. | ||
| 23 | * nsterm.m (updateFrameSize:): If waiting for the tool bar and tool | ||
| 24 | bar is zero height, just return (Bug#16976). | ||
| 25 | (initFrameFromEmacs:): Initialize wait_for_tool_bar. | ||
| 26 | * nsterm.h (EmacsView): Add wait_for_tool_bar. | ||
| 27 | * nsmenu.m (update_frame_tool_bar): Return early if view or toolbar | ||
| 28 | is nil. If waiting for toolbar to complete, force a redraw. | ||
| 29 | (free_frame_tool_bar): Set wait_for_tool_bar = NO (Bug#16976). | ||
| 30 | |||
| 31 | 2014-04-03 Ken Brown <kbrown@cornell.edu> | ||
| 32 | |||
| 33 | * Makefile.in (EMACS_MANIFEST): Update comment. (Bug#17176) | ||
| 34 | |||
| 1 | 2014-04-07 Paul Eggert <eggert@cs.ucla.edu> | 35 | 2014-04-07 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 36 | ||
| 3 | * alloc.c: Simplify by removing use of HAVE_EXECINFO_H. | 37 | * alloc.c: Simplify by removing use of HAVE_EXECINFO_H. |
| @@ -4490,7 +4524,7 @@ | |||
| 4490 | * frame.c (delete_frame): Block/unblock input to overcome race | 4524 | * frame.c (delete_frame): Block/unblock input to overcome race |
| 4491 | condition (Bug#15475). | 4525 | condition (Bug#15475). |
| 4492 | 4526 | ||
| 4493 | 2013-09-29 Andreas Politz <politza@hochschule-trier.de> (tiny change) | 4527 | 2013-09-29 Andreas Politz <politza@hochschule-trier.de> |
| 4494 | 4528 | ||
| 4495 | * frame.c (delete_frame): Record selected frame only after | 4529 | * frame.c (delete_frame): Record selected frame only after |
| 4496 | calling Qdelete_frame_functions (Bug#15477). | 4530 | calling Qdelete_frame_functions (Bug#15477). |
diff --git a/src/Makefile.in b/src/Makefile.in index 388923596c9..7e71d030279 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -259,7 +259,7 @@ W32_LIBS=@W32_LIBS@ | |||
| 259 | 259 | ||
| 260 | ## emacs.res if HAVE_W32 | 260 | ## emacs.res if HAVE_W32 |
| 261 | EMACSRES = @EMACSRES@ | 261 | EMACSRES = @EMACSRES@ |
| 262 | ## emacs-*.manifest if HAVE_W32 | 262 | ## emacs-*.manifest if WINDOWSNT |
| 263 | EMACS_MANIFEST = @EMACS_MANIFEST@ | 263 | EMACS_MANIFEST = @EMACS_MANIFEST@ |
| 264 | ## If HAVE_W32, compiler arguments for including | 264 | ## If HAVE_W32, compiler arguments for including |
| 265 | ## the resource file in the binary. | 265 | ## the resource file in the binary. |
diff --git a/src/alloc.c b/src/alloc.c index dbd1ece5d49..ea8d81648d7 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3357,6 +3357,13 @@ struct symbol_block | |||
| 3357 | 3357 | ||
| 3358 | static struct symbol_block *symbol_block; | 3358 | static struct symbol_block *symbol_block; |
| 3359 | static int symbol_block_index = SYMBOL_BLOCK_SIZE; | 3359 | static int symbol_block_index = SYMBOL_BLOCK_SIZE; |
| 3360 | /* Pointer to the first symbol_block that contains pinned symbols. | ||
| 3361 | Tests for 24.4 showed that at dump-time, Emacs contains about 15K symbols, | ||
| 3362 | 10K of which are pinned (and all but 250 of them are interned in obarray), | ||
| 3363 | whereas a "typical session" has in the order of 30K symbols. | ||
| 3364 | `symbol_block_pinned' lets mark_pinned_symbols scan only 15K symbols rather | ||
| 3365 | than 30K to find the 10K symbols we need to mark. */ | ||
| 3366 | static struct symbol_block *symbol_block_pinned; | ||
| 3360 | 3367 | ||
| 3361 | /* List of free symbols. */ | 3368 | /* List of free symbols. */ |
| 3362 | 3369 | ||
| @@ -3409,10 +3416,11 @@ Its value is void, and its function definition and property list are nil. */) | |||
| 3409 | SET_SYMBOL_VAL (p, Qunbound); | 3416 | SET_SYMBOL_VAL (p, Qunbound); |
| 3410 | set_symbol_function (val, Qnil); | 3417 | set_symbol_function (val, Qnil); |
| 3411 | set_symbol_next (val, NULL); | 3418 | set_symbol_next (val, NULL); |
| 3412 | p->gcmarkbit = 0; | 3419 | p->gcmarkbit = false; |
| 3413 | p->interned = SYMBOL_UNINTERNED; | 3420 | p->interned = SYMBOL_UNINTERNED; |
| 3414 | p->constant = 0; | 3421 | p->constant = 0; |
| 3415 | p->declared_special = 0; | 3422 | p->declared_special = false; |
| 3423 | p->pinned = false; | ||
| 3416 | consing_since_gc += sizeof (struct Lisp_Symbol); | 3424 | consing_since_gc += sizeof (struct Lisp_Symbol); |
| 3417 | symbols_consed++; | 3425 | symbols_consed++; |
| 3418 | total_free_symbols--; | 3426 | total_free_symbols--; |
| @@ -5214,6 +5222,8 @@ make_pure_c_string (const char *data, ptrdiff_t nchars) | |||
| 5214 | return string; | 5222 | return string; |
| 5215 | } | 5223 | } |
| 5216 | 5224 | ||
| 5225 | static Lisp_Object purecopy (Lisp_Object obj); | ||
| 5226 | |||
| 5217 | /* Return a cons allocated from pure space. Give it pure copies | 5227 | /* Return a cons allocated from pure space. Give it pure copies |
| 5218 | of CAR as car and CDR as cdr. */ | 5228 | of CAR as car and CDR as cdr. */ |
| 5219 | 5229 | ||
| @@ -5223,8 +5233,8 @@ pure_cons (Lisp_Object car, Lisp_Object cdr) | |||
| 5223 | Lisp_Object new; | 5233 | Lisp_Object new; |
| 5224 | struct Lisp_Cons *p = pure_alloc (sizeof *p, Lisp_Cons); | 5234 | struct Lisp_Cons *p = pure_alloc (sizeof *p, Lisp_Cons); |
| 5225 | XSETCONS (new, p); | 5235 | XSETCONS (new, p); |
| 5226 | XSETCAR (new, Fpurecopy (car)); | 5236 | XSETCAR (new, purecopy (car)); |
| 5227 | XSETCDR (new, Fpurecopy (cdr)); | 5237 | XSETCDR (new, purecopy (cdr)); |
| 5228 | return new; | 5238 | return new; |
| 5229 | } | 5239 | } |
| 5230 | 5240 | ||
| @@ -5265,9 +5275,19 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 5265 | { | 5275 | { |
| 5266 | if (NILP (Vpurify_flag)) | 5276 | if (NILP (Vpurify_flag)) |
| 5267 | return obj; | 5277 | return obj; |
| 5268 | 5278 | else if (MARKERP (obj) || OVERLAYP (obj) | |
| 5269 | if (PURE_POINTER_P (XPNTR (obj))) | 5279 | || HASH_TABLE_P (obj) || SYMBOLP (obj)) |
| 5280 | /* Can't purify those. */ | ||
| 5270 | return obj; | 5281 | return obj; |
| 5282 | else | ||
| 5283 | return purecopy (obj); | ||
| 5284 | } | ||
| 5285 | |||
| 5286 | static Lisp_Object | ||
| 5287 | purecopy (Lisp_Object obj) | ||
| 5288 | { | ||
| 5289 | if (PURE_POINTER_P (XPNTR (obj)) || INTEGERP (obj) || SUBRP (obj)) | ||
| 5290 | return obj; /* Already pure. */ | ||
| 5271 | 5291 | ||
| 5272 | if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ | 5292 | if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ |
| 5273 | { | 5293 | { |
| @@ -5295,7 +5315,7 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 5295 | size &= PSEUDOVECTOR_SIZE_MASK; | 5315 | size &= PSEUDOVECTOR_SIZE_MASK; |
| 5296 | vec = XVECTOR (make_pure_vector (size)); | 5316 | vec = XVECTOR (make_pure_vector (size)); |
| 5297 | for (i = 0; i < size; i++) | 5317 | for (i = 0; i < size; i++) |
| 5298 | vec->contents[i] = Fpurecopy (AREF (obj, i)); | 5318 | vec->contents[i] = purecopy (AREF (obj, i)); |
| 5299 | if (COMPILEDP (obj)) | 5319 | if (COMPILEDP (obj)) |
| 5300 | { | 5320 | { |
| 5301 | XSETPVECTYPE (vec, PVEC_COMPILED); | 5321 | XSETPVECTYPE (vec, PVEC_COMPILED); |
| @@ -5304,11 +5324,23 @@ Does not copy symbols. Copies strings without text properties. */) | |||
| 5304 | else | 5324 | else |
| 5305 | XSETVECTOR (obj, vec); | 5325 | XSETVECTOR (obj, vec); |
| 5306 | } | 5326 | } |
| 5307 | else if (MARKERP (obj)) | 5327 | else if (SYMBOLP (obj)) |
| 5308 | error ("Attempt to copy a marker to pure storage"); | 5328 | { |
| 5329 | if (!XSYMBOL (obj)->pinned) | ||
| 5330 | { /* We can't purify them, but they appear in many pure objects. | ||
| 5331 | Mark them as `pinned' so we know to mark them at every GC cycle. */ | ||
| 5332 | XSYMBOL (obj)->pinned = true; | ||
| 5333 | symbol_block_pinned = symbol_block; | ||
| 5334 | } | ||
| 5335 | return obj; | ||
| 5336 | } | ||
| 5309 | else | 5337 | else |
| 5310 | /* Not purified, don't hash-cons. */ | 5338 | { |
| 5311 | return obj; | 5339 | Lisp_Object args[2]; |
| 5340 | args[0] = build_pure_c_string ("Don't know how to purify: %S"); | ||
| 5341 | args[1] = obj; | ||
| 5342 | Fsignal (Qerror, (Fcons (Fformat (2, args), Qnil))); | ||
| 5343 | } | ||
| 5312 | 5344 | ||
| 5313 | if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ | 5345 | if (HASH_TABLE_P (Vpurify_flag)) /* Hash consing. */ |
| 5314 | Fputhash (obj, obj, Vpurify_flag); | 5346 | Fputhash (obj, obj, Vpurify_flag); |
| @@ -5471,6 +5503,24 @@ compact_undo_list (Lisp_Object list) | |||
| 5471 | return list; | 5503 | return list; |
| 5472 | } | 5504 | } |
| 5473 | 5505 | ||
| 5506 | static void | ||
| 5507 | mark_pinned_symbols (void) | ||
| 5508 | { | ||
| 5509 | struct symbol_block *sblk; | ||
| 5510 | int lim = (symbol_block_pinned == symbol_block | ||
| 5511 | ? symbol_block_index : SYMBOL_BLOCK_SIZE); | ||
| 5512 | |||
| 5513 | for (sblk = symbol_block_pinned; sblk; sblk = sblk->next) | ||
| 5514 | { | ||
| 5515 | union aligned_Lisp_Symbol *sym = sblk->symbols, *end = sym + lim; | ||
| 5516 | for (; sym < end; ++sym) | ||
| 5517 | if (sym->s.pinned) | ||
| 5518 | mark_object (make_lisp_ptr (&sym->s, Lisp_Symbol)); | ||
| 5519 | |||
| 5520 | lim = SYMBOL_BLOCK_SIZE; | ||
| 5521 | } | ||
| 5522 | } | ||
| 5523 | |||
| 5474 | DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", | 5524 | DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", |
| 5475 | doc: /* Reclaim storage for Lisp objects no longer needed. | 5525 | doc: /* Reclaim storage for Lisp objects no longer needed. |
| 5476 | Garbage collection happens automatically if you cons more than | 5526 | Garbage collection happens automatically if you cons more than |
| @@ -5573,6 +5623,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5573 | for (i = 0; i < staticidx; i++) | 5623 | for (i = 0; i < staticidx; i++) |
| 5574 | mark_object (*staticvec[i]); | 5624 | mark_object (*staticvec[i]); |
| 5575 | 5625 | ||
| 5626 | mark_pinned_symbols (); | ||
| 5576 | mark_specpdl (); | 5627 | mark_specpdl (); |
| 5577 | mark_terminals (); | 5628 | mark_terminals (); |
| 5578 | mark_kboards (); | 5629 | mark_kboards (); |
| @@ -6574,12 +6625,7 @@ sweep_symbols (void) | |||
| 6574 | 6625 | ||
| 6575 | for (; sym < end; ++sym) | 6626 | for (; sym < end; ++sym) |
| 6576 | { | 6627 | { |
| 6577 | /* Check if the symbol was created during loadup. In such a case | 6628 | if (!sym->s.gcmarkbit) |
| 6578 | it might be pointed to by pure bytecode which we don't trace, | ||
| 6579 | so we conservatively assume that it is live. */ | ||
| 6580 | bool pure_p = PURE_POINTER_P (XSTRING (sym->s.name)); | ||
| 6581 | |||
| 6582 | if (!sym->s.gcmarkbit && !pure_p) | ||
| 6583 | { | 6629 | { |
| 6584 | if (sym->s.redirect == SYMBOL_LOCALIZED) | 6630 | if (sym->s.redirect == SYMBOL_LOCALIZED) |
| 6585 | xfree (SYMBOL_BLV (&sym->s)); | 6631 | xfree (SYMBOL_BLV (&sym->s)); |
| @@ -6593,8 +6639,6 @@ sweep_symbols (void) | |||
| 6593 | else | 6639 | else |
| 6594 | { | 6640 | { |
| 6595 | ++num_used; | 6641 | ++num_used; |
| 6596 | if (!pure_p) | ||
| 6597 | eassert (!STRING_MARKED_P (XSTRING (sym->s.name))); | ||
| 6598 | sym->s.gcmarkbit = 0; | 6642 | sym->s.gcmarkbit = 0; |
| 6599 | } | 6643 | } |
| 6600 | } | 6644 | } |
diff --git a/src/bidi.c b/src/bidi.c index b96cc24bbd1..53c2dad1b6b 100644 --- a/src/bidi.c +++ b/src/bidi.c | |||
| @@ -22,9 +22,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 22 | A sequential implementation of the Unicode Bidirectional algorithm, | 22 | A sequential implementation of the Unicode Bidirectional algorithm, |
| 23 | (UBA) as per UAX#9, a part of the Unicode Standard. | 23 | (UBA) as per UAX#9, a part of the Unicode Standard. |
| 24 | 24 | ||
| 25 | Unlike the reference and most other implementations, this one is | 25 | Unlike the Reference Implementation and most other implementations, |
| 26 | designed to be called once for every character in the buffer or | 26 | this one is designed to be called once for every character in the |
| 27 | string. | 27 | buffer or string. That way, we can leave intact the design of the |
| 28 | Emacs display engine, whereby an iterator object is used to | ||
| 29 | traverse buffer or string text character by character, and generate | ||
| 30 | the necessary data for displaying each character in 'struct glyph' | ||
| 31 | objects. (See xdisp.c for the details of that iteration.) The | ||
| 32 | functions on this file replace the original linear iteration in the | ||
| 33 | logical order of the text with a non-linear iteration in the visual | ||
| 34 | order, i.e. in the order characters should be shown on display. | ||
| 28 | 35 | ||
| 29 | The main entry point is bidi_move_to_visually_next. Each time it | 36 | The main entry point is bidi_move_to_visually_next. Each time it |
| 30 | is called, it finds the next character in the visual order, and | 37 | is called, it finds the next character in the visual order, and |
| @@ -52,7 +59,182 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | A note about references to UAX#9 rules: if the reference says | 59 | A note about references to UAX#9 rules: if the reference says |
| 53 | something like "X9/Retaining", it means that you need to refer to | 60 | something like "X9/Retaining", it means that you need to refer to |
| 54 | rule X9 and to its modifications described in the "Implementation | 61 | rule X9 and to its modifications described in the "Implementation |
| 55 | Notes" section of UAX#9, under "Retaining Format Codes". */ | 62 | Notes" section of UAX#9, under "Retaining Format Codes". |
| 63 | |||
| 64 | Here's the overview of the design of the reordering engine | ||
| 65 | implemented by this file. | ||
| 66 | |||
| 67 | Basic implementation structure | ||
| 68 | ------------------------------ | ||
| 69 | |||
| 70 | The sequential processing steps described by UAX#9 are implemented | ||
| 71 | as recursive levels of processing, all of which examine the next | ||
| 72 | character in the logical order. This hierarchy of processing looks | ||
| 73 | as follows, from the innermost (deepest) to the outermost level, | ||
| 74 | omitting some subroutines used by each level: | ||
| 75 | |||
| 76 | bidi_fetch_char -- fetch next character | ||
| 77 | bidi_resolve_explicit -- resolve explicit levels and directions | ||
| 78 | bidi_resolve_weak -- resolve weak types | ||
| 79 | bidi_resolve_neutral -- resolve neutral types | ||
| 80 | bidi_level_of_next_char -- resolve implicit levels | ||
| 81 | |||
| 82 | Each level calls the level below it, and works on the result | ||
| 83 | returned by the lower level, including all of its sub-levels. | ||
| 84 | |||
| 85 | Unlike all the levels below it, bidi_level_of_next_char can return | ||
| 86 | the information about either the next or previous character in the | ||
| 87 | logical order, depending on the current direction of scanning the | ||
| 88 | buffer or string. For the next character, it calls all the levels | ||
| 89 | below it; for the previous character, it uses the cache, described | ||
| 90 | below. | ||
| 91 | |||
| 92 | Thus, the result of calling bidi_level_of_next_char is the resolved | ||
| 93 | level of the next or the previous character in the logical order. | ||
| 94 | Based on this information, the function bidi_move_to_visually_next | ||
| 95 | finds the next character in the visual order and updates the | ||
| 96 | direction in which the buffer is scanned, either forward or | ||
| 97 | backward, to find the next character to be displayed. (Text is | ||
| 98 | scanned backwards when it needs to be reversed for display, i.e. if | ||
| 99 | the visual order is the inverse of the logical order.) This | ||
| 100 | implements the last, reordering steps of the UBA, by successively | ||
| 101 | calling bidi_level_of_next_char until the character of the required | ||
| 102 | embedding level is found; the scan direction is dynamically updated | ||
| 103 | as a side effect. See the commentary before the 'while' loop in | ||
| 104 | bidi_move_to_visually_next, for the details. | ||
| 105 | |||
| 106 | Fetching characters | ||
| 107 | ------------------- | ||
| 108 | |||
| 109 | In a nutshell, fetching the next character boils down to calling | ||
| 110 | STRING_CHAR_AND_LENGTH, passing it the address of a buffer or | ||
| 111 | string position. See bidi_fetch_char. However, if the next | ||
| 112 | character is "covered" by a display property of some kind, | ||
| 113 | bidi_fetch_char returns the u+FFFC "object replacement character" | ||
| 114 | that represents the entire run of text covered by the display | ||
| 115 | property. (The ch_len and nchars members of 'struct bidi_it' | ||
| 116 | reflect the length in bytes and characters of that text.) This is | ||
| 117 | so we reorder text on both sides of the display property as | ||
| 118 | appropriate for an image or embedded string. Similarly, text | ||
| 119 | covered by a display spec of the form '(space ...)', is replaced | ||
| 120 | with the u+2029 paragraph separator character, so such display | ||
| 121 | specs produce the same effect as a TAB under UBA. Both these | ||
| 122 | special characters are not actually displayed -- the display | ||
| 123 | property is displayed instead -- but just used to compute the | ||
| 124 | embedding level of the surrounding text so as to produce the | ||
| 125 | required effect. | ||
| 126 | |||
| 127 | Bidi iterator states | ||
| 128 | -------------------- | ||
| 129 | |||
| 130 | The UBA is highly context dependent in some of its parts, | ||
| 131 | i.e. results of processing a character can generally depend on | ||
| 132 | characters very far away. The UAX#9 description of the UBA | ||
| 133 | prescribes a stateful processing of each character, whereby the | ||
| 134 | results of this processing depend on various state variables, such | ||
| 135 | as the current embedding level, level stack, and directional | ||
| 136 | override status. In addition, the UAX#9 description includes many | ||
| 137 | passages like this (from rule W2 in this case): | ||
| 138 | |||
| 139 | Search backward from each instance of a European number until the | ||
| 140 | first strong type (R, L, AL, or sos) is found. If an AL is found, | ||
| 141 | change the type of the European number to Arabic number. | ||
| 142 | |||
| 143 | To support this, we use a bidi iterator object, 'struct bidi_it', | ||
| 144 | which is a sub-structure of 'struct it' used by xdisp.c (see | ||
| 145 | dispextern.h for the definition of both of these structures). The | ||
| 146 | bidi iterator holds the entire state of the iteration required by | ||
| 147 | the UBA, and is updated as the text is traversed. In particular, | ||
| 148 | the embedding level of the current character being resolved is | ||
| 149 | recorded in the iterator state. To avoid costly searches backward | ||
| 150 | in support of rules like W2 above, the necessary character types | ||
| 151 | are also recorded in the iterator state as they are found during | ||
| 152 | the forward scan, and then used when such rules need to be applied. | ||
| 153 | (Forward scans cannot be avoided in this way; they need to be | ||
| 154 | performed at least once, and the results recorded in the iterator | ||
| 155 | state, to be reused until the forward scan oversteps the recorded | ||
| 156 | position.) | ||
| 157 | |||
| 158 | In this manner, the iterator state acts as a mini-cache of | ||
| 159 | contextual information required for resolving the level of the | ||
| 160 | current character by various UBA rules. | ||
| 161 | |||
| 162 | Caching of bidi iterator states | ||
| 163 | ------------------------------- | ||
| 164 | |||
| 165 | As described above, the reordering engine uses the information | ||
| 166 | recorded in the bidi iterator state in order to resolve the | ||
| 167 | embedding level of the current character. When the reordering | ||
| 168 | engine needs to process the next character in the logical order, it | ||
| 169 | fetches it and applies to it all the UBA levels, updating the | ||
| 170 | iterator state as it goes. But when the buffer or string is | ||
| 171 | scanned backwards, i.e. in the reverse order of buffer/string | ||
| 172 | positions, the scanned characters were already processed during the | ||
| 173 | preceding forward scan (see bidi_find_other_level_edge). To avoid | ||
| 174 | costly re-processing of characters that were already processed | ||
| 175 | during the forward scan, the iterator states computed while | ||
| 176 | scanning forward are cached. | ||
| 177 | |||
| 178 | The cache is just a linear array of 'struct bidi_it' objects, which | ||
| 179 | is dynamically allocated and reallocated as needed, since the size | ||
| 180 | of the cache depends on the text being processed. We only need the | ||
| 181 | cache while processing embedded levels higher than the base | ||
| 182 | paragraph embedding level, because these higher levels require | ||
| 183 | changes in scan direction. Therefore, as soon as we are back to | ||
| 184 | the base embedding level, we can free the cache; see the calls to | ||
| 185 | bidi_cache_reset and bidi_cache_shrink, for the conditions to do | ||
| 186 | this. | ||
| 187 | |||
| 188 | The cache maintains the index of the next unused cache slot -- this | ||
| 189 | is where the next iterator state will be cached. The function | ||
| 190 | bidi_cache_iterator_state saves an instance of the state in the | ||
| 191 | cache and increments the unused slot index. The companion function | ||
| 192 | bidi_cache_find looks up a cached state that corresponds to a given | ||
| 193 | buffer/string position. All of the cached states must correspond | ||
| 194 | 1:1 to the buffer or string region whose processing they reflect; | ||
| 195 | bidi.c will abort if it finds cache slots that violate this 1:1 | ||
| 196 | correspondence. | ||
| 197 | |||
| 198 | When the parent iterator 'struct it' is pushed (see push_it in | ||
| 199 | xdisp.c) to pause the current iteration and start iterating over a | ||
| 200 | different object (e.g., a 'display' string that covers some buffer | ||
| 201 | text), the bidi iterator cache needs to be "pushed" as well, so | ||
| 202 | that a new empty cache could be used while iterating over the new | ||
| 203 | object. Later, when the new object is exhausted, and xdisp.c calls | ||
| 204 | pop_it, we need to "pop" the bidi cache as well and return to the | ||
| 205 | original cache. See bidi_push_it and bidi_pop_it for how this is | ||
| 206 | done. | ||
| 207 | |||
| 208 | Some functions of the display engine save copies of 'struct it' in | ||
| 209 | local variables, and restore them later. For examples, see | ||
| 210 | pos_visible_p and move_it_in_display_line_to in xdisp.c, and | ||
| 211 | window_scroll_pixel_based in window.c. When this happens, we need | ||
| 212 | to save and restore the bidi cache as well, because conceptually | ||
| 213 | the cache is part of the 'struct it' state, and needs to be in | ||
| 214 | perfect sync with the portion of the buffer/string that is being | ||
| 215 | processed. This saving and restoring of the cache state is handled | ||
| 216 | by bidi_shelve_cache and bidi_unshelve_cache, and the helper macros | ||
| 217 | SAVE_IT and RESTORE_IT defined on xdisp.c. | ||
| 218 | |||
| 219 | Note that, because reordering is implemented below the level in | ||
| 220 | xdisp.c that breaks glyphs into screen lines, we are violating | ||
| 221 | paragraph 3.4 of UAX#9. which mandates that line breaking shall be | ||
| 222 | done before reordering each screen line separately. However, | ||
| 223 | following UAX#9 to the letter in this matter goes against the basic | ||
| 224 | design of the Emacs display engine, and so we choose here this | ||
| 225 | minor deviation from the UBA letter in preference to redesign of | ||
| 226 | the display engine. The effect of this is only seen in continued | ||
| 227 | lines that are broken into screen lines in the middle of a run | ||
| 228 | whose direction is opposite to the paragraph's base direction. | ||
| 229 | |||
| 230 | Important design and implementation note: when the code needs to | ||
| 231 | scan far ahead, be sure to avoid such scans as much as possible | ||
| 232 | when the buffer/string doesn't contain any RTL characters. Users | ||
| 233 | of left-to-right scripts will never forgive you if you introduce | ||
| 234 | some slow-down due to bidi in situations that don't involve any | ||
| 235 | bidirectional text. See the large comment near the beginning of | ||
| 236 | bidi_resolve_neutral, for one situation where such shortcut was | ||
| 237 | necessary. */ | ||
| 56 | 238 | ||
| 57 | #include <config.h> | 239 | #include <config.h> |
| 58 | #include <stdio.h> | 240 | #include <stdio.h> |
diff --git a/src/buffer.h b/src/buffer.h index d461415e036..de117eb9c61 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -847,8 +847,8 @@ struct buffer | |||
| 847 | struct region_cache *width_run_cache; | 847 | struct region_cache *width_run_cache; |
| 848 | struct region_cache *bidi_paragraph_cache; | 848 | struct region_cache *bidi_paragraph_cache; |
| 849 | 849 | ||
| 850 | /* Non-zero means don't use redisplay optimizations for | 850 | /* Non-zero means disable redisplay optimizations when rebuilding the glyph |
| 851 | displaying this buffer. */ | 851 | matrices (but not when redrawing). */ |
| 852 | bool_bf prevent_redisplay_optimizations_p : 1; | 852 | bool_bf prevent_redisplay_optimizations_p : 1; |
| 853 | 853 | ||
| 854 | /* Non-zero whenever the narrowing is changed in this buffer. */ | 854 | /* Non-zero whenever the narrowing is changed in this buffer. */ |
diff --git a/src/frame.h b/src/frame.h index 62dc33511b5..ff696df9eff 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -375,7 +375,8 @@ struct frame | |||
| 375 | set this directly, use SET_FRAME_ICONIFIED instead. */ | 375 | set this directly, use SET_FRAME_ICONIFIED instead. */ |
| 376 | bool_bf iconified : 1; | 376 | bool_bf iconified : 1; |
| 377 | 377 | ||
| 378 | /* True if this frame should be redrawn. */ | 378 | /* True if this frame should be fully redisplayed. Disables all |
| 379 | optimizations while rebuilding matrices and redrawing. */ | ||
| 379 | bool_bf garbaged : 1; | 380 | bool_bf garbaged : 1; |
| 380 | 381 | ||
| 381 | /* False means, if this frame has just one window, | 382 | /* False means, if this frame has just one window, |
diff --git a/src/keyboard.c b/src/keyboard.c index 277d4f1047c..87a2f91a17c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | /* Keyboard and mouse input; editor command loop. | 1 | /* Keyboard and mouse input; editor command loop. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1989, 1993-1997, 1999-2014 Free Software Foundation, | 3 | Copyright (C) 1985-1989, 1993-1997, 1999-2014 Free Software Foundation, Inc. |
| 4 | Inc. | ||
| 5 | 4 | ||
| 6 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 7 | 6 | ||
| @@ -2379,7 +2378,7 @@ read_decoded_event_from_main_queue (struct timespec *end_time, | |||
| 2379 | -2 means do neither. | 2378 | -2 means do neither. |
| 2380 | 1 means do both. */ | 2379 | 1 means do both. */ |
| 2381 | 2380 | ||
| 2382 | /* The arguments MAP is for menu prompting. MAP is a keymap. | 2381 | /* The argument MAP is a keymap for menu prompting. |
| 2383 | 2382 | ||
| 2384 | PREV_EVENT is the previous input event, or nil if we are reading | 2383 | PREV_EVENT is the previous input event, or nil if we are reading |
| 2385 | the first event of a key sequence (or not reading a key sequence). | 2384 | the first event of a key sequence (or not reading a key sequence). |
| @@ -10068,7 +10067,10 @@ DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, | |||
| 10068 | "FOpen dribble file: ", | 10067 | "FOpen dribble file: ", |
| 10069 | doc: /* Start writing all keyboard characters to a dribble file called FILE. | 10068 | doc: /* Start writing all keyboard characters to a dribble file called FILE. |
| 10070 | If FILE is nil, close any open dribble file. | 10069 | If FILE is nil, close any open dribble file. |
| 10071 | The file will be closed when Emacs exits. */) | 10070 | The file will be closed when Emacs exits. |
| 10071 | |||
| 10072 | Be aware that this records ALL characters you type! | ||
| 10073 | This may include sensitive information such as passwords. */) | ||
| 10072 | (Lisp_Object file) | 10074 | (Lisp_Object file) |
| 10073 | { | 10075 | { |
| 10074 | if (dribble) | 10076 | if (dribble) |
diff --git a/src/lisp.h b/src/lisp.h index 03c0d99fb27..264b8832092 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1572,6 +1572,9 @@ struct Lisp_Symbol | |||
| 1572 | special (with `defvar' etc), and shouldn't be lexically bound. */ | 1572 | special (with `defvar' etc), and shouldn't be lexically bound. */ |
| 1573 | bool_bf declared_special : 1; | 1573 | bool_bf declared_special : 1; |
| 1574 | 1574 | ||
| 1575 | /* True if pointed to from purespace and hence can't be GC'd. */ | ||
| 1576 | bool_bf pinned : 1; | ||
| 1577 | |||
| 1575 | /* The symbol's name, as a Lisp string. */ | 1578 | /* The symbol's name, as a Lisp string. */ |
| 1576 | Lisp_Object name; | 1579 | Lisp_Object name; |
| 1577 | 1580 | ||