Mercurial > hg > xemacs-beta
comparison src/lread.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 | 57b76886836d |
children | 21549d437f09 |
comparison
equal
deleted
inserted
replaced
1291:3d99b5e6c6ec | 1292:f3437b56874d |
---|---|
28 #include "lisp.h" | 28 #include "lisp.h" |
29 | 29 |
30 #include "buffer.h" | 30 #include "buffer.h" |
31 #include "bytecode.h" | 31 #include "bytecode.h" |
32 #include "elhash.h" | 32 #include "elhash.h" |
33 #include "file-coding.h" | |
33 #include "lstream.h" | 34 #include "lstream.h" |
34 #include "opaque.h" | 35 #include "opaque.h" |
35 #include "file-coding.h" | 36 #include "profile.h" |
36 | 37 |
37 #include "sysfile.h" | 38 #include "sysfile.h" |
38 #include "sysfloat.h" | 39 #include "sysfloat.h" |
39 #ifdef WIN32_NATIVE | 40 #ifdef WIN32_NATIVE |
40 #include "syswindows.h" | 41 #include "syswindows.h" |
57 Lisp_Object Qbackquote, Qbacktick, Qcomma, Qcomma_at, Qcomma_dot; | 58 Lisp_Object Qbackquote, Qbacktick, Qcomma, Qcomma_at, Qcomma_dot; |
58 #endif | 59 #endif |
59 Lisp_Object Qvariable_domain; /* I18N3 */ | 60 Lisp_Object Qvariable_domain; /* I18N3 */ |
60 Lisp_Object Vvalues, Vstandard_input, Vafter_load_alist; | 61 Lisp_Object Vvalues, Vstandard_input, Vafter_load_alist; |
61 Lisp_Object Qcurrent_load_list; | 62 Lisp_Object Qcurrent_load_list; |
62 Lisp_Object Qload, Qload_file_name; | 63 Lisp_Object Qload, Qload_file_name, Qload_internal, Qfset; |
63 Lisp_Object Qfset; | |
64 | 64 |
65 /* Hash-table that maps directory names to hashes of their contents. */ | 65 /* Hash-table that maps directory names to hashes of their contents. */ |
66 static Lisp_Object Vlocate_file_hash_table; | 66 static Lisp_Object Vlocate_file_hash_table; |
67 | 67 |
68 Lisp_Object Qexists, Qreadable, Qwritable, Qexecutable; | 68 Lisp_Object Qexists, Qreadable, Qwritable, Qexecutable; |
495 to e.g. warn of newer .el files when the .elc is being loaded. */ | 495 to e.g. warn of newer .el files when the .elc is being loaded. */ |
496 Lisp_Object newer = Qnil; | 496 Lisp_Object newer = Qnil; |
497 Lisp_Object older = Qnil; | 497 Lisp_Object older = Qnil; |
498 Lisp_Object handler = Qnil; | 498 Lisp_Object handler = Qnil; |
499 Lisp_Object found = Qnil; | 499 Lisp_Object found = Qnil; |
500 Lisp_Object retval; | |
500 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 501 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
501 int reading_elc = 0; | 502 int reading_elc = 0; |
502 int from_require = EQ (nomessage, Qrequire); | 503 int from_require = EQ (nomessage, Qrequire); |
503 int message_p = NILP (nomessage) || load_always_display_messages; | 504 int message_p = NILP (nomessage) || load_always_display_messages; |
504 struct stat s1, s2; | 505 struct stat s1, s2; |
505 Ibyte *spaces = alloca_ibytes (load_in_progress * 2 + 10); | 506 Ibyte *spaces = alloca_ibytes (load_in_progress * 2 + 10); |
506 int i; | 507 int i; |
508 PROFILE_DECLARE (); | |
507 | 509 |
508 GCPRO4 (file, newer, older, found); | 510 GCPRO4 (file, newer, older, found); |
509 CHECK_STRING (file); | 511 CHECK_STRING (file); |
512 | |
513 PROFILE_RECORD_ENTERING_SECTION (Qload_internal); | |
510 | 514 |
511 /* If file name is magic, call the handler. */ | 515 /* If file name is magic, call the handler. */ |
512 handler = Ffind_file_name_handler (file, Qload); | 516 handler = Ffind_file_name_handler (file, Qload); |
513 if (!NILP (handler)) | 517 if (!NILP (handler)) |
514 RETURN_UNGCPRO (call5 (handler, Qload, file, noerror, | 518 { |
515 nomessage, nosuffix)); | 519 retval = call5 (handler, Qload, file, noerror, nomessage, nosuffix); |
520 goto done; | |
521 } | |
516 | 522 |
517 /* Do this after the handler to avoid | 523 /* Do this after the handler to avoid |
518 the need to gcpro noerror, nomessage and nosuffix. | 524 the need to gcpro noerror, nomessage and nosuffix. |
519 (Below here, we care only whether they are nil or not.) */ | 525 (Below here, we care only whether they are nil or not.) */ |
520 file = Fsubstitute_in_file_name (file); | 526 file = Fsubstitute_in_file_name (file); |
549 { | 555 { |
550 if (NILP (noerror)) | 556 if (NILP (noerror)) |
551 signal_error (Qfile_error, "Cannot open load file", file); | 557 signal_error (Qfile_error, "Cannot open load file", file); |
552 else | 558 else |
553 { | 559 { |
554 UNGCPRO; | 560 retval = Qnil; |
555 return Qnil; | 561 goto done; |
556 } | 562 } |
557 } | 563 } |
558 | 564 |
559 foundstr = (Ibyte *) ALLOCA (XSTRING_LENGTH (found) + 1); | 565 foundstr = (Ibyte *) ALLOCA (XSTRING_LENGTH (found) + 1); |
560 qxestrcpy (foundstr, XSTRING_DATA (found)); | 566 qxestrcpy (foundstr, XSTRING_DATA (found)); |
749 } | 755 } |
750 | 756 |
751 if (!noninteractive) | 757 if (!noninteractive) |
752 PRINT_LOADING_MESSAGE ("done"); | 758 PRINT_LOADING_MESSAGE ("done"); |
753 | 759 |
760 retval = Qt; | |
761 done: | |
762 PROFILE_RECORD_EXITING_SECTION (Qload_internal); | |
754 UNGCPRO; | 763 UNGCPRO; |
755 return Qt; | 764 return retval; |
756 } | 765 } |
757 | 766 |
758 | 767 |
759 /* ------------------------------- */ | 768 /* ------------------------------- */ |
760 /* locate_file */ | 769 /* locate_file */ |
3014 DEFSYMBOL (Qstandard_input); | 3023 DEFSYMBOL (Qstandard_input); |
3015 DEFSYMBOL (Qread_char); | 3024 DEFSYMBOL (Qread_char); |
3016 DEFSYMBOL (Qcurrent_load_list); | 3025 DEFSYMBOL (Qcurrent_load_list); |
3017 DEFSYMBOL (Qload); | 3026 DEFSYMBOL (Qload); |
3018 DEFSYMBOL (Qload_file_name); | 3027 DEFSYMBOL (Qload_file_name); |
3028 DEFSYMBOL (Qload_internal); | |
3019 DEFSYMBOL (Qfset); | 3029 DEFSYMBOL (Qfset); |
3020 | 3030 |
3021 #ifdef LISP_BACKQUOTES | 3031 #ifdef LISP_BACKQUOTES |
3022 DEFSYMBOL (Qbackquote); | 3032 DEFSYMBOL (Qbackquote); |
3023 defsymbol (&Qbacktick, "`"); | 3033 defsymbol (&Qbacktick, "`"); |
3204 Vcurrent_compiled_function_annotation = Qnil; | 3214 Vcurrent_compiled_function_annotation = Qnil; |
3205 staticpro (&Vcurrent_compiled_function_annotation); | 3215 staticpro (&Vcurrent_compiled_function_annotation); |
3206 #endif | 3216 #endif |
3207 | 3217 |
3208 /* So that early-early stuff will work */ | 3218 /* So that early-early stuff will work */ |
3209 Ffset (Qload, intern ("load-internal")); | 3219 Ffset (Qload, Qload_internal); |
3210 | 3220 |
3211 #ifdef FEATUREP_SYNTAX | 3221 #ifdef FEATUREP_SYNTAX |
3212 DEFSYMBOL (Qfeaturep); | 3222 DEFSYMBOL (Qfeaturep); |
3213 Fprovide (intern ("xemacs")); | 3223 Fprovide (intern ("xemacs")); |
3214 #ifdef INFODOCK | 3224 #ifdef INFODOCK |