comparison src/extents.c @ 1292:f3437b56874d

[xemacs-hg @ 2003-02-13 09:57:04 by ben] profile updates profile.c: Major reworking. Keep track of new information -- total function timing (includes descendants), GC usage, total GC usage (includes descendants). New functions to be called appropriately from eval.c, alloc.c to keep track of this information. Keep track of when we're actually in a function vs. in its profile, for more accurate timing counts. Track profile overhead separately. Create new mechanism for specifying "internal sections" that are tracked just like regular Lisp functions and even appear in the backtrace if `backtrace-with-internal-sections' is non-nil (t by default for error-checking builds). Add some KKCC information for the straight (non-Elisp) hash table used by profile, which contains Lisp objects in its keys -- but not used yet. Remove old ad-hoc methods for tracking garbage collection, redisplay (which was incorrect anyway when Lisp was called within these sections). Don't record any tick info when blocking under MS Windows, since the timer there is in real time rather than in process time. Make `start-profiling', `stop-profiling' interactive. Be consistent wrt. recursive functions and functions currently on the stack when starting or stopping -- together these make implementing the `total' values extremely difficult. When we start profiling, we act as if we just entered all the functions currently on the stack. Likewise when exiting. Create vars in_profile for tracking time spent inside of profiling, and profiling_lock for setting exclusive access to the main hash table when reading from it or modifying it. (protects against getting screwed up by the signal handle going off at the same time. profile.h: New file. Create macros for declaring internal profiling sections. lisp.h: Move profile-related stuff to profile.h. alloc.c: Keep track of total consing, for profile. Tell profile when we are consing. Use new profile-section method for noting garbage-collection. alloc.c: Abort if we attempt to call the allocator reentrantly. backtrace.h, eval.c: Add info for use by profile in the backtrace frame and transfer PUSH_BACKTRACE/POP_BACKTRACE from eval.c, for use with profile. elhash.c: Author comment. eval.c, lisp.h: New Lisp var `backtrace-with-internal-sections'. Set to t when error-checking is on. eval.c: When unwinding, eval.c: Report to profile when we are about-to-call and just-called wrt. a function. alloc.c, eval.c: Allow for "fake" backtrace frames, for internal sections (used by profile and `backtrace-with-internal-sections'. event-Xt.c, event-gtk.c, event-msw.c, event-tty.c: Record when we are actually blocking on an event, for profile's sake. event-stream.c: Record internal profiling sections for getting, dispatching events. extents.c: Record internal profiling sections for map_extents. hash.c, hash.h: Add pregrow_hash_table_if_necessary(). (Used in profile code since the signal handler is the main grower but can't allow a realloc(). We make sure, at critical points, that the table is large enough.) lread.c: Create internal profiling sections for `load' (which may be triggered internally by autoload, etc.). redisplay.c: Remove old profile_redisplay_flag. Use new macros to declare internal profiling section for redisplay. text.c: Use new macros to declare internal profiling sections for char-byte conversion and internal-external conversion. SEMI-UNRELATED CHANGES: ----------------------- text.c: Update the long comments.
author ben
date Thu, 13 Feb 2003 09:57:08 +0000
parents e22b0213b713
children a8d8f419b459
comparison
equal deleted inserted replaced
1291:3d99b5e6c6ec 1292:f3437b56874d
1 /* Copyright (c) 1994, 1995 Free Software Foundation, Inc. 1 /* Copyright (c) 1994, 1995 Free Software Foundation, Inc.
2 Copyright (c) 1995 Sun Microsystems, Inc. 2 Copyright (c) 1995 Sun Microsystems, Inc.
3 Copyright (c) 1995, 1996, 2000, 2002 Ben Wing. 3 Copyright (c) 1995, 1996, 2000, 2002, 2003 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
224 #include "glyphs.h" 224 #include "glyphs.h"
225 #include "insdel.h" 225 #include "insdel.h"
226 #include "keymap.h" 226 #include "keymap.h"
227 #include "opaque.h" 227 #include "opaque.h"
228 #include "process.h" 228 #include "process.h"
229 #include "profile.h"
229 #include "redisplay.h" 230 #include "redisplay.h"
230 #include "gutter.h" 231 #include "gutter.h"
231 232
232 /* ------------------------------- */ 233 /* ------------------------------- */
233 /* gap array */ 234 /* gap array */
427 /* flags for decode_extent() */ 428 /* flags for decode_extent() */
428 #define DE_MUST_HAVE_BUFFER 1 429 #define DE_MUST_HAVE_BUFFER 1
429 #define DE_MUST_BE_ATTACHED 2 430 #define DE_MUST_BE_ATTACHED 2
430 431
431 Lisp_Object Vlast_highlighted_extent; 432 Lisp_Object Vlast_highlighted_extent;
433
434 Lisp_Object QSin_map_extents_internal;
435
432 Fixnum mouse_highlight_priority; 436 Fixnum mouse_highlight_priority;
433 437
434 Lisp_Object Qextentp; 438 Lisp_Object Qextentp;
435 Lisp_Object Qextent_live_p; 439 Lisp_Object Qextent_live_p;
436 440
2119 EXTENT range = 0; /* extent for this, if ME_MIGHT_MODIFY_TEXT */ 2123 EXTENT range = 0; /* extent for this, if ME_MIGHT_MODIFY_TEXT */
2120 Extent_List *el = 0; /* extent list we're iterating over */ 2124 Extent_List *el = 0; /* extent list we're iterating over */
2121 Extent_List_Marker *posm = 0; /* marker for extent list, 2125 Extent_List_Marker *posm = 0; /* marker for extent list,
2122 if ME_MIGHT_MODIFY_EXTENTS */ 2126 if ME_MIGHT_MODIFY_EXTENTS */
2123 /* count and struct for unwind-protect, if ME_MIGHT_THROW */ 2127 /* count and struct for unwind-protect, if ME_MIGHT_THROW */
2124 int count = 0; 2128 int count = specpdl_depth ();
2125 struct map_extents_struct closure; 2129 struct map_extents_struct closure;
2130 PROFILE_DECLARE ();
2126 2131
2127 #ifdef ERROR_CHECK_EXTENTS 2132 #ifdef ERROR_CHECK_EXTENTS
2128 assert (from <= to); 2133 assert (from <= to);
2129 assert (from >= buffer_or_string_absolute_begin_byte (obj) && 2134 assert (from >= buffer_or_string_absolute_begin_byte (obj) &&
2130 from <= buffer_or_string_absolute_end_byte (obj) && 2135 from <= buffer_or_string_absolute_end_byte (obj) &&
2137 assert (EQ (obj, extent_object (after))); 2142 assert (EQ (obj, extent_object (after)));
2138 assert (!extent_detached_p (after)); 2143 assert (!extent_detached_p (after));
2139 } 2144 }
2140 2145
2141 el = buffer_or_string_extent_list (obj); 2146 el = buffer_or_string_extent_list (obj);
2142 if (!el || !extent_list_num_els(el)) 2147 if (!el || !extent_list_num_els (el))
2143 return; 2148 return;
2144 el = 0; 2149 el = 0;
2150
2151 PROFILE_RECORD_ENTERING_SECTION (QSin_map_extents_internal);
2145 2152
2146 st = buffer_or_string_bytexpos_to_memxpos (obj, from); 2153 st = buffer_or_string_bytexpos_to_memxpos (obj, from);
2147 en = buffer_or_string_bytexpos_to_memxpos (obj, to); 2154 en = buffer_or_string_bytexpos_to_memxpos (obj, to);
2148 2155
2149 if (flags & ME_MIGHT_MODIFY_TEXT) 2156 if (flags & ME_MIGHT_MODIFY_TEXT)
2164 if (flags & ME_MIGHT_THROW) 2171 if (flags & ME_MIGHT_THROW)
2165 { 2172 {
2166 /* The mapping function might throw past us so we need to use an 2173 /* The mapping function might throw past us so we need to use an
2167 unwind_protect() to eliminate the internal extent and range 2174 unwind_protect() to eliminate the internal extent and range
2168 that we use. */ 2175 that we use. */
2169 count = specpdl_depth ();
2170 closure.range = range; 2176 closure.range = range;
2171 closure.mkr = 0; 2177 closure.mkr = 0;
2172 record_unwind_protect (map_extents_unwind, 2178 record_unwind_protect (map_extents_unwind,
2173 make_opaque_ptr (&closure)); 2179 make_opaque_ptr (&closure));
2174 } 2180 }
2429 } 2435 }
2430 } 2436 }
2431 /* ---------- Finished looping. ---------- */ 2437 /* ---------- Finished looping. ---------- */
2432 } 2438 }
2433 2439
2434 if (flags & ME_MIGHT_THROW) 2440 if (!(flags & ME_MIGHT_THROW))
2435 /* This deletes the range extent and frees the marker. */
2436 unbind_to (count);
2437 else
2438 { 2441 {
2439 /* Delete them ourselves */ 2442 /* Delete them ourselves */
2440 if (range) 2443 if (range)
2441 extent_detach (range); 2444 extent_detach (range);
2442 if (posm) 2445 if (posm)
2443 extent_list_delete_marker (el, posm); 2446 extent_list_delete_marker (el, posm);
2444 } 2447 }
2448
2449 /* This deletes the range extent and frees the marker, if ME_MIGHT_THROW. */
2450 unbind_to (count);
2451
2452 PROFILE_RECORD_EXITING_SECTION (QSin_map_extents_internal);
2445 } 2453 }
2446 2454
2447 /* ------------------------------- */ 2455 /* ------------------------------- */
2448 /* adjust_extents() */ 2456 /* adjust_extents() */
2449 /* ------------------------------- */ 2457 /* ------------------------------- */
7419 Vextent_face_memoize_hash_table = 7427 Vextent_face_memoize_hash_table =
7420 make_lisp_hash_table (100, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL); 7428 make_lisp_hash_table (100, HASH_TABLE_VALUE_WEAK, HASH_TABLE_EQUAL);
7421 staticpro (&Vextent_face_reverse_memoize_hash_table); 7429 staticpro (&Vextent_face_reverse_memoize_hash_table);
7422 Vextent_face_reverse_memoize_hash_table = 7430 Vextent_face_reverse_memoize_hash_table =
7423 make_lisp_hash_table (100, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ); 7431 make_lisp_hash_table (100, HASH_TABLE_KEY_WEAK, HASH_TABLE_EQ);
7424 } 7432
7433 QSin_map_extents_internal = build_msg_string ("(in map-extents-internal)");
7434 staticpro (&QSin_map_extents_internal);
7435 }