comparison src/extents.c @ 5146:88bd4f3ef8e4

make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-15 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (c_readonly): * alloc.c (deadbeef_memory): * alloc.c (make_compiled_function): * alloc.c (make_button_data): * alloc.c (make_motion_data): * alloc.c (make_process_data): * alloc.c (make_timeout_data): * alloc.c (make_magic_data): * alloc.c (make_magic_eval_data): * alloc.c (make_eval_data): * alloc.c (make_misc_user_data): * alloc.c (noseeum_make_marker): * alloc.c (ADDITIONAL_FREE_string): * alloc.c (common_init_alloc_early): * alloc.c (init_alloc_once_early): * bytecode.c (print_compiled_function): * bytecode.c (mark_compiled_function): * casetab.c: * casetab.c (print_case_table): * console.c: * console.c (print_console): * database.c (print_database): * database.c (finalize_database): * device-msw.c (sync_printer_with_devmode): * device-msw.c (print_devmode): * device-msw.c (finalize_devmode): * device.c: * device.c (print_device): * elhash.c: * elhash.c (print_hash_table): * eval.c (print_multiple_value): * eval.c (mark_multiple_value): * events.c (deinitialize_event): * events.c (print_event): * events.c (event_equal): * extents.c: * extents.c (soe_dump): * extents.c (soe_insert): * extents.c (soe_delete): * extents.c (soe_move): * extents.c (extent_fragment_update): * extents.c (print_extent_1): * extents.c (print_extent): * extents.c (vars_of_extents): * frame.c: * frame.c (print_frame): * free-hook.c: * free-hook.c (check_free): * glyphs.c: * glyphs.c (print_image_instance): * glyphs.c (print_glyph): * gui.c: * gui.c (copy_gui_item): * hash.c: * hash.c (NULL_ENTRY): * hash.c (KEYS_DIFFER_P): * keymap.c (print_keymap): * keymap.c (MARKED_SLOT): * lisp.h: * lrecord.h: * lrecord.h (LISP_OBJECT_UID): * lrecord.h (set_lheader_implementation): * lrecord.h (struct old_lcrecord_header): * lstream.c (print_lstream): * lstream.c (finalize_lstream): * marker.c (print_marker): * marker.c (marker_equal): * mc-alloc.c (visit_all_used_page_headers): * mule-charset.c: * mule-charset.c (print_charset): * objects.c (print_color_instance): * objects.c (print_font_instance): * objects.c (finalize_font_instance): * opaque.c (print_opaque): * opaque.c (print_opaque_ptr): * opaque.c (equal_opaque_ptr): * print.c (internal_object_printer): * print.c (enum printing_badness): * rangetab.c (print_range_table): * rangetab.c (range_table_equal): * specifier.c (print_specifier): * specifier.c (finalize_specifier): * symbols.c: * symbols.c (print_symbol_value_magic): * tooltalk.c: * tooltalk.c (print_tooltalk_message): * tooltalk.c (print_tooltalk_pattern): * window.c (print_window): * window.c (debug_print_window): (1) Make lrecord UID's have a separate UID space for each object. Otherwise, with 20-bit UID's, we rapidly wrap around, especially when common objects like conses and strings increment the UID value for every object created. (Originally I tried making two UID spaces, one for objects that always print readably and hence don't display the UID, and one for other objects. But certain objects like markers for which a UID is displayed are still generated rapidly enough that UID overflow is a serious issue.) This also has the advantage of making UID values smaller, hence easier to remember -- their main purpose is to make it easier to keep track of different objects of the same type when debugging code. Make sure we dump lrecord UID's so that we don't have problems with pdumped and non-dumped objects having the same UID. (2) Display UID's consistently whenever an object (a) doesn't consistently print readably (objects like cons and string, which always print readably, can't display a UID), and (b) doesn't otherwise have a unique property that makes objects of a particular type distinguishable. (E.g. buffers didn't and still don't print an ID, but the buffer name uniquely identifies the buffer.) Some types, such as event, extent, compiled-function, didn't always (or didn't ever) display an ID; others (such as marker, extent, lstream, opaque, opaque-ptr, any object using internal_object_printer()) used to display the actual machine pointer instead. (3) Rename NORMAL_LISP_OBJECT_UID to LISP_OBJECT_UID; make it work over all Lisp objects and take a Lisp object, not a struct pointer. (4) Some misc cleanups in alloc.c, elhash.c. (5) Change code in events.c that "deinitializes" an event so that it doesn't increment the event UID counter in the process. Also use deadbeef_memory() to overwrite memory instead of doing the same with custom code. In the process, make deadbeef_memory() in alloc.c always available, and delete extraneous copy in mc-alloc.c. Also capitalize all uses of 0xDEADBEEF. Similarly in elhash.c call deadbeef_memory(). (6) Resurrect "debug SOE" code in extents.c. Make it conditional on DEBUG_XEMACS and on a `debug-soe' variable, rather than on SOE_DEBUG. Make it output to stderr, not stdout. (7) Delete some custom print methods that were identical to external_object_printer().
author Ben Wing <ben@xemacs.org>
date Mon, 15 Mar 2010 16:35:38 -0500
parents f965e31a35f0
children b0ab9aa48977
comparison
equal deleted inserted replaced
5145:0b0241ae382f 5146:88bd4f3ef8e4
504 504
505 /* if true, we don't want to set any redisplay flags on modeline extent 505 /* if true, we don't want to set any redisplay flags on modeline extent
506 changes */ 506 changes */
507 int in_modeline_generation; 507 int in_modeline_generation;
508 508
509 int debug_soe;
510
509 511
510 /************************************************************************/ 512 /************************************************************************/
511 /* Generalized gap array */ 513 /* Generalized gap array */
512 /************************************************************************/ 514 /************************************************************************/
513 515
1527 if (!info->soe) 1529 if (!info->soe)
1528 info->soe = allocate_soe (); 1530 info->soe = allocate_soe ();
1529 return info->soe; 1531 return info->soe;
1530 } 1532 }
1531 1533
1532 /* #### don't even think of #define'ing this, the prototype of 1534 #ifdef DEBUG_XEMACS
1533 print_extent_1 has changed! */
1534 /* #define SOE_DEBUG */
1535
1536 #ifdef SOE_DEBUG
1537
1538 static void print_extent_1 (char *buf, Lisp_Object extent);
1539
1540 static void
1541 print_extent_2 (EXTENT e)
1542 {
1543 Lisp_Object extent;
1544 char buf[200];
1545
1546 extent = wrap_extent (e);
1547 print_extent_1 (buf, extent);
1548 fputs (buf, stdout);
1549 }
1550 1535
1551 static void 1536 static void
1552 soe_dump (Lisp_Object obj) 1537 soe_dump (Lisp_Object obj)
1553 { 1538 {
1554 int i; 1539 int i;
1556 Extent_List *sel; 1541 Extent_List *sel;
1557 int endp; 1542 int endp;
1558 1543
1559 if (!soe) 1544 if (!soe)
1560 { 1545 {
1561 printf ("No SOE"); 1546 stderr_out ("No SOE");
1562 return; 1547 return;
1563 } 1548 }
1564 sel = soe->extents; 1549 sel = soe->extents;
1565 printf ("SOE pos is %d (memxpos %d)\n", 1550 stderr_out ("SOE pos is %ld (memxpos %ld)\n",
1566 soe->pos < 0 ? soe->pos : 1551 soe->pos < 0 ? soe->pos :
1567 buffer_or_string_memxpos_to_bytexpos (obj, soe->pos), 1552 buffer_or_string_memxpos_to_bytexpos (obj, soe->pos),
1568 soe->pos); 1553 soe->pos);
1569 for (endp = 0; endp < 2; endp++) 1554 for (endp = 0; endp < 2; endp++)
1570 { 1555 {
1571 printf (endp ? "SOE end:" : "SOE start:"); 1556 stderr_out (endp ? "SOE end:" : "SOE start:");
1572 for (i = 0; i < extent_list_num_els (sel); i++) 1557 for (i = 0; i < extent_list_num_els (sel); i++)
1573 { 1558 {
1574 EXTENT e = extent_list_at (sel, i, endp); 1559 EXTENT e = extent_list_at (sel, i, endp);
1575 putchar ('\t'); 1560 stderr_out ("\t");
1576 print_extent_2 (e); 1561 debug_print (wrap_extent (e));
1577 } 1562 }
1578 putchar ('\n'); 1563 stderr_out ("\n");
1579 } 1564 }
1580 putchar ('\n'); 1565 stderr_out ("\n");
1581 } 1566 }
1582 1567
1583 #endif 1568 #endif /* DEBUG_XEMACS */
1584 1569
1585 /* Insert EXTENT into OBJ's stack of extents, if necessary. */ 1570 /* Insert EXTENT into OBJ's stack of extents, if necessary. */
1586 1571
1587 static void 1572 static void
1588 soe_insert (Lisp_Object obj, EXTENT extent) 1573 soe_insert (Lisp_Object obj, EXTENT extent)
1589 { 1574 {
1590 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj); 1575 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
1591 1576
1592 #ifdef SOE_DEBUG 1577 #ifdef DEBUG_XEMACS
1593 printf ("Inserting into SOE: "); 1578 if (debug_soe)
1594 print_extent_2 (extent); 1579 {
1595 putchar ('\n'); 1580 stderr_out ("Inserting into SOE: ");
1581 debug_print (wrap_extent (extent));
1582 stderr_out ("\n");
1583 }
1596 #endif 1584 #endif
1597 if (!soe || soe->pos < extent_start (extent) || 1585 if (!soe || soe->pos < extent_start (extent) ||
1598 soe->pos > extent_end (extent)) 1586 soe->pos > extent_end (extent))
1599 { 1587 {
1600 #ifdef SOE_DEBUG 1588 #ifdef DEBUG_XEMACS
1601 printf ("(not needed)\n\n"); 1589 if (debug_soe)
1590 stderr_out ("(not needed)\n\n");
1602 #endif 1591 #endif
1603 return; 1592 return;
1604 } 1593 }
1605 extent_list_insert (soe->extents, extent); 1594 extent_list_insert (soe->extents, extent);
1606 #ifdef SOE_DEBUG 1595 #ifdef DEBUG_XEMACS
1607 puts ("SOE afterwards is:"); 1596 if (debug_soe)
1608 soe_dump (obj); 1597 {
1598 stderr_out ("SOE afterwards is:\n");
1599 soe_dump (obj);
1600 }
1609 #endif 1601 #endif
1610 } 1602 }
1611 1603
1612 /* Delete EXTENT from OBJ's stack of extents, if necessary. */ 1604 /* Delete EXTENT from OBJ's stack of extents, if necessary. */
1613 1605
1614 static void 1606 static void
1615 soe_delete (Lisp_Object obj, EXTENT extent) 1607 soe_delete (Lisp_Object obj, EXTENT extent)
1616 { 1608 {
1617 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj); 1609 Stack_Of_Extents *soe = buffer_or_string_stack_of_extents (obj);
1618 1610
1619 #ifdef SOE_DEBUG 1611 #ifdef DEBUG_XEMACS
1620 printf ("Deleting from SOE: "); 1612 if (debug_soe)
1621 print_extent_2 (extent); 1613 {
1622 putchar ('\n'); 1614 stderr_out ("Deleting from SOE: ");
1615 debug_print (wrap_extent (extent));
1616 stderr_out ("\n");
1617 }
1623 #endif 1618 #endif
1624 if (!soe || soe->pos < extent_start (extent) || 1619 if (!soe || soe->pos < extent_start (extent) ||
1625 soe->pos > extent_end (extent)) 1620 soe->pos > extent_end (extent))
1626 { 1621 {
1627 #ifdef SOE_DEBUG 1622 #ifdef DEBUG_XEMACS
1628 puts ("(not needed)\n"); 1623 if (debug_soe)
1624 stderr_out ("(not needed)\n\n");
1629 #endif 1625 #endif
1630 return; 1626 return;
1631 } 1627 }
1632 extent_list_delete (soe->extents, extent); 1628 extent_list_delete (soe->extents, extent);
1633 #ifdef SOE_DEBUG 1629 #ifdef DEBUG_XEMACS
1634 puts ("SOE afterwards is:"); 1630 if (debug_soe)
1635 soe_dump (obj); 1631 {
1632 stderr_out ("SOE afterwards is:\n");
1633 soe_dump (obj);
1634 }
1636 #endif 1635 #endif
1637 } 1636 }
1638 1637
1639 /* Move OBJ's stack of extents to lie over the specified position. */ 1638 /* Move OBJ's stack of extents to lie over the specified position. */
1640 1639
1650 1649
1651 #ifdef ERROR_CHECK_EXTENTS 1650 #ifdef ERROR_CHECK_EXTENTS
1652 assert (bel); 1651 assert (bel);
1653 #endif 1652 #endif
1654 1653
1655 #ifdef SOE_DEBUG 1654 #ifdef DEBUG_XEMACS
1656 printf ("Moving SOE from %d (memxpos %d) to %d (memxpos %d)\n", 1655 if (debug_soe)
1657 soe->pos < 0 ? soe->pos : 1656 stderr_out ("Moving SOE from %ld (memxpos %ld) to %ld (memxpos %ld)\n",
1658 buffer_or_string_memxpos_to_bytexpos (obj, soe->pos), soe->pos, 1657 soe->pos < 0 ? soe->pos :
1659 buffer_or_string_memxpos_to_bytexpos (obj, pos), pos); 1658 buffer_or_string_memxpos_to_bytexpos (obj, soe->pos), soe->pos,
1659 buffer_or_string_memxpos_to_bytexpos (obj, pos), pos);
1660 #endif 1660 #endif
1661 if (soe->pos < pos) 1661 if (soe->pos < pos)
1662 { 1662 {
1663 direction = 1; 1663 direction = 1;
1664 endp = 0; 1664 endp = 0;
1668 direction = -1; 1668 direction = -1;
1669 endp = 1; 1669 endp = 1;
1670 } 1670 }
1671 else 1671 else
1672 { 1672 {
1673 #ifdef SOE_DEBUG 1673 #ifdef DEBUG_XEMACS
1674 puts ("(not needed)\n"); 1674 if (debug_soe)
1675 stderr_out ("(not needed)\n\n");
1675 #endif 1676 #endif
1676 return; 1677 return;
1677 } 1678 }
1678 1679
1679 /* For DIRECTION = 1: Any extent that overlaps POS is either in the 1680 /* For DIRECTION = 1: Any extent that overlaps POS is either in the
1754 extent_list_insert (sel, e); 1755 extent_list_insert (sel, e);
1755 } 1756 }
1756 } 1757 }
1757 1758
1758 soe->pos = pos; 1759 soe->pos = pos;
1759 #ifdef SOE_DEBUG 1760 #ifdef DEBUG_XEMACS
1760 puts ("SOE afterwards is:"); 1761 if (debug_soe)
1761 soe_dump (obj); 1762 {
1763 stderr_out ("SOE afterwards is:\n");
1764 soe_dump (obj);
1765 }
1762 #endif 1766 #endif
1763 } 1767 }
1764 1768
1765 static void 1769 static void
1766 soe_invalidate (Lisp_Object obj) 1770 soe_invalidate (Lisp_Object obj)
3198 !extent_in_red_event_p(e)) 3202 !extent_in_red_event_p(e))
3199 { 3203 {
3200 Lisp_Object function = extent_initial_redisplay_function (e); 3204 Lisp_Object function = extent_initial_redisplay_function (e);
3201 Lisp_Object obj; 3205 Lisp_Object obj;
3202 3206
3203 /* printf ("initial redisplay function called!\n "); */ 3207 /* stderr_out ("initial redisplay function called!\n "); */
3204 3208
3205 /* print_extent_2 (e); 3209 /* debug_print (wrap_extent (e));
3206 printf ("\n"); */ 3210 stderr_out ("\n"); */
3207 3211
3208 /* FIXME: One should probably inhibit the displaying of 3212 /* FIXME: One should probably inhibit the displaying of
3209 this extent to reduce flicker */ 3213 this extent to reduce flicker */
3210 extent_in_red_event_p (e) = 1; 3214 extent_in_red_event_p (e) = 1;
3211 3215
3286 { 3290 {
3287 Lisp_Object v = XCAR (XCDR (tail)); 3291 Lisp_Object v = XCAR (XCDR (tail));
3288 if (NILP (v)) continue; 3292 if (NILP (v)) continue;
3289 write_fmt_string_lisp (printcharfun, "%S ", 1, XCAR (tail)); 3293 write_fmt_string_lisp (printcharfun, "%S ", 1, XCAR (tail));
3290 } 3294 }
3291
3292 write_fmt_string (printcharfun, "0x%lx", (long) ext);
3293 } 3295 }
3294 3296
3295 static void 3297 static void
3296 print_extent (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 3298 print_extent (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
3297 { 3299 {
3331 } 3333 }
3332 3334
3333 if (print_readably) 3335 if (print_readably)
3334 { 3336 {
3335 if (!EXTENT_LIVE_P (XEXTENT (obj))) 3337 if (!EXTENT_LIVE_P (XEXTENT (obj)))
3336 printing_unreadable_object_fmt ("#<destroyed extent>"); 3338 printing_unreadable_object_fmt ("#<destroyed extent 0x%x>",
3339 LISP_OBJECT_UID (obj));
3337 else 3340 else
3338 printing_unreadable_object_fmt ("#<extent 0x%lx>", 3341 printing_unreadable_object_fmt ("#<extent 0x%x>",
3339 (long) XEXTENT (obj)); 3342 LISP_OBJECT_UID (obj));
3340 } 3343 }
3341 3344
3342 if (!EXTENT_LIVE_P (XEXTENT (obj))) 3345 if (!EXTENT_LIVE_P (XEXTENT (obj)))
3343 write_ascstring (printcharfun, "#<destroyed extent"); 3346 write_ascstring (printcharfun, "#<destroyed extent");
3344 else 3347 else
3345 { 3348 {
3346 write_ascstring (printcharfun, "#<extent "); 3349 write_ascstring (printcharfun, "#<extent ");
3347 print_extent_1 (obj, printcharfun, escapeflag); 3350 print_extent_1 (obj, printcharfun, escapeflag);
3348 write_ascstring (printcharfun, extent_detached_p (XEXTENT (obj)) 3351 write_ascstring (printcharfun, extent_detached_p (XEXTENT (obj))
3349 ? " from " : " in "); 3352 ? "from " : "in ");
3350 write_fmt_string (printcharfun, "%s%s%s", title, name, posttitle); 3353 write_fmt_string (printcharfun, "%s%s%s", title, name, posttitle);
3351 } 3354 }
3352 } 3355 }
3353 else 3356 else
3354 { 3357 {
3355 if (print_readably) 3358 if (print_readably)
3356 printing_unreadable_object_fmt ("#<extent>"); 3359 printing_unreadable_object_fmt ("#<extent 0x%x>",
3360 LISP_OBJECT_UID (obj));
3357 write_ascstring (printcharfun, "#<extent"); 3361 write_ascstring (printcharfun, "#<extent");
3358 } 3362 }
3359 write_ascstring (printcharfun, ">"); 3363
3364 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
3360 } 3365 }
3361 3366
3362 static int 3367 static int
3363 properties_equal (EXTENT e1, EXTENT e2, int depth) 3368 properties_equal (EXTENT e1, EXTENT e2, int depth)
3364 { 3369 {
7558 } 7563 }
7559 7564
7560 void 7565 void
7561 vars_of_extents (void) 7566 vars_of_extents (void)
7562 { 7567 {
7568 #ifdef DEBUG_XEMACS
7569 DEFVAR_BOOL ("debug-soe", &debug_soe /*
7570 If non-nil, display debugging information about the SOE ("stack of extents").
7571 The SOE is a cache of extents overlapping a specified region, used to
7572 speed up `map-extents' and certain other functions.
7573 */ );
7574 debug_soe = 0;
7575 #endif /* DEBUG_XEMACS */
7576
7563 DEFVAR_INT ("mouse-highlight-priority", &mouse_highlight_priority /* 7577 DEFVAR_INT ("mouse-highlight-priority", &mouse_highlight_priority /*
7564 The priority to use for the mouse-highlighting pseudo-extent 7578 The priority to use for the mouse-highlighting pseudo-extent
7565 that is used to highlight extents with the `mouse-face' attribute set. 7579 that is used to highlight extents with the `mouse-face' attribute set.
7566 See `set-extent-priority'. 7580 See `set-extent-priority'.
7567 */ ); 7581 */ );