* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs.
* libguile/programs.h:
* libguile/programs.c (scm_program_address_range): New internal
procedure.
* libguile/stacks.c (narrow_stack): Interpret a pair of integers as an
address range. If a cut is a procedure, attempt to resolve it to an
address range.
(scm_make_stack): Update docstring.
* module/system/vm/program.scm (program-address-range): New exported
procedure.
* module/statprof.scm (statprof, gcprof): Use program-address-range to
get the outer-cut, for efficiency.
* module/statprof.scm (profile-signal-handler): Bind in a letrec.
Otherwise the compiler may see the closure slot as dead, and the inner
stack cut won't work.
* module/statprof.scm (statprof-start, statprof-stop): Don't futz the vm
trace level when we aren't counting calls. With this change, statprof
now imposes no overhead on the measured program.
* module/statprof.scm (statprof-fold-call-data)
(statprof-proc-call-data): Add optional state arg.
(gcprof): Add optional port arg, and pass state arg explicitly.
(statprof-display-anomalies, statprof-display)
(statprof-call-data->stats): Pass state explicitly.
* module/statprof.scm (<state>): Add outer-cut member.
(fresh-profiler-state): Add outer-cut kwarg.
(sample-stack-procs): Stop when the stack-length is zero, which will
be before the frames run out if there is an outer cut.
(profile-signal-handler): Use the outer cut when capturing the stack.
(call-thunk): New helper, for use as an outer cut.
(statprof, gcprof): Call the thunk within call-thunk, and use
call-thunk as an outer cut.
* module/statprof.scm: Add a big ol' comment.
(sample-stack-procs): If slot 0 isn't a primitive, use the IP to
mark. In the future we will see more non-procedures in slot 0 as we
start to use call-label and tail-call-label.
* module/statprof.scm (call-data): Source is after printable.
(addr->printable): Just produce a name, without source. Anonymous
printables get "anon " prefixed.
(stack-samples->procedure-data): Adapt to call-data change.
(stats): Add "proc-source" element.
(statprof-call-data->stats): Give a source to the call-data.
(statprof-display): Print source also.
* module/statprof.scm (call-data): Add source member.
(stack-samples->procedure-data): Populate source member
(stats): Convert to record from vector.
(statprof-call-data->stats): Adapt to produce a record.
* module/statprof.scm (<state>): Remove record-full-stacks? and stacks
members. The stack trace buffer is sufficient.
(fresh-profiler-state): Adapt.
(sample-stack-procs): Don't save stacks.
(statprof-reset): Deprecate the full-stacks? argument.
(stack-samples->procedure-data): Remove a needless vector-ref.
(stack-samples->callee-lists): New helper.
(statprof-fetch-stacks): Use stack-samples->callee-lists.
(statprof-fetch-call-tree): Use stack-samples->callee-lists, and
implement our own callee->string helper.
(statprof, with-statprof, gcprof): Deprecate full-stacks? argument.
* module/statprof.scm (<state>): Instead of a boolean count-calls?,
treat the presence of a call-counts hash table as indicating a need to
count calls. That hash table maps callees to call counts. A "callee"
is either the IP of the entry of a program, the symbolic name of a
primitive, or the identity of a non-program.
New members "buffer" and "buffer-pos" replace "procedure-data".
We try to avoid analyzing things at runtime, instead just recording
the stack traces into a buffer. This will let us do smarter things
when post-processing.
(fresh-buffer, expand-buffer): New helpers.
(fresh-profiler-state): Adapt to <state> changes.
(sample-stack-procs): Instead of updating the procedure-data
table (which no longer exists), instead trace the stack into the
buffer.
(count-call): Update to update the call-counts table instead of the
procedure-data table.
(statprof-start, statprof-start): Adapt to call-counts change.
(call-data): Move lower in the file. Add "name" and "printable"
members, and no longer store a proc.
(source->string, program-debug-info-printable, addr->pdi)
(addr->printable): New helpers.
(stack-samples->procedure-data): New procedure to process stack trace
buffer into a hash table of the same format as the old procedure-data
table.
(statprof-fold-call-data, statprof-proc-call-data): Use
stack-samples->procedure-data instead of procedure-data.
(statprof-call-data->stats): Adapt to count-calls change.
(statprof-display, statprof-display-anomalies): Adapt.
* module/statprof.scm (statprof-start, statprof-stop): Take optional
state arg.
(statprof-reset): Return no values.
(statprof): Take port keyword arg. Since statprof-reset is now the
same as parameterizing profiler-state, there's no need to call
statprof-reset. Pass the state argument explicitly to statprof-start,
statprof-stop, and statprof-display.
* module/statprof.scm (<state>): Add field for the previous SIGPROF
handler.
(statprof-start, statprof-stop, statprof-reset): Instead of setting
the SIGPROF handler in statprof-reset, set it when the profiler
becomes active, and actually restore it when the profiler becomes
inactive.
* module/statprof.scm (statprof-display, statprof-display-anomalies)
(statprof-accumulated-time, statprof-sample-count)
(statprof-fetch-stacks, statprof-fetch-call-tree): Take optional state
argument.
(statprof-display-anomolies): Deprecate this mis-spelling.
(statprof): Just compute usecs for the period.
* module/statprof.scm (gcprof): No need to reset in gcprof; the fresh
profiler state and the parameterize handle that. Fix mistaken
set-vm-trace-level! as well.
* module/statprof.scm (<state>): The sampling frequency is actually a
period; label it as such, and express in microseconds instead of as a
pair. Likewise for remaining-prof-time.
(fresh-profiler-state): Adapt.
(reset-sigprof-timer): New helper.
(profile-signal-handler): Use the new helper.
(statprof-start): Use the new helper.
(statprof-stop): Here too.
(statprof-reset): Adapt to <state> change.
(gcprof): Set remaining prof time to 0.
* module/statprof.scm (profile-signal-handler): Don't bother detecting
if we were in a count-call call or not; it doesn't matter, and we
should accumulate time in any case.
* module/statprof.scm (fresh-profiler-state): accumulated-time and
gc-time-taken are in jiffies, not seconds, so they are exact.
(statprof-accumulated-time): Divide by 1.0 so that we get a flonum.
Also refactor use of assq to get the gc-time-taken.
* module/statprof.scm (get-call-data, sample-stack-procs): Take the
state as an argument.
(profile-signal-handler, count-call, statprof-proc-call-data)
(gcprof): Adapt.
* module/statprof.scm (statprof-reset, statprof-fold-call-data):
(statprof-proc-call-data, statprof-accumulated-time):
(statprof-sample-count): Refactor some things to use statprof-active?
instead of checking the profile level manually.
* module/statprof.scm (fresh-profiler-state): New helper.
(ensure-profiler-state): Use it.
(accumulate-time): No need to add 0.0 here.
(statprof-reset): Create a new state instead of mutating the existing
one.
* module/statprof.scm (existing-profiler-state): New helper, gets the
profiler state or fails if there is no state.
(sample-stack-procs, profile-signal-handler, count-call)
(statprof-fold-call-data, statprof-proc-call-data)
(statprof-call-data->stats, statprof-display)
(statprof-display-anomolies, statprof-accumulated-time)
(statprof-sample-count, statprof-fetch-stacks)
(statprof-fetch-call-tree): Use the new helper.
(statprof-active?): Don't create a state if there isn't one already.
* module/statprof.scm (<state>, profiler-state, ensure-profiler-state):
A mostly-mechanical refactor to encapsulate profiler state in a
parameter and a record instead of global variables.
* libguile/vm.h:
* libguile/vm.c:
(scm_vm_apply_hook, scm_vm_push_continuation_hook,
scm_vm_pop_continuation_hook, scm_vm_abort_continuation_hook,
scm_vm_restore_continuation_hook, scm_vm_next_hook,
scm_vm_trace_level, scm_set_vm_trace_level_x, scm_vm_engine,
scm_set_vm_engine_x, scm_c_set_vm_engine_x): The VM argument is now
implicit: the VM for the current thread.
* doc/ref/api-debug.texi (VM Hooks): Try to adapt.
* module/ice-9/command-line.scm:
* module/statprof.scm:
* module/system/vm/coverage.scm:
* module/system/vm/trace.scm:
* module/system/vm/trap-state.scm:
* module/system/vm/traps.scm:
* test-suite/tests/control.test:
* test-suite/tests/eval.test: Adapt users that set hooks or ensure that
we have a debug engine.
* libguile/Makefile.am:
* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Remove the old VM files, and the rules to
build the .i files.
* libguile/vm-engine.c:
* libguile/vm.c: Remove the old VM. Woot!
* libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET)
(SCM_OBJCODE_WORD_SIZE_OFFSET): Remove.
* libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program
cases.
* libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove
program cases.
* libguile/gc.c (scm_i_tag_name): Remove objcode case.
* libguile/goops.c (scm_class_of, create_standard_classes): Remove
objcode and program cases.
* libguile/instructions.h:
* libguile/instructions.c (scm_instruction_list, scm_instruction_p)
(scm_instruction_length, scm_instruction_pops, scm_instruction_pushes)
(scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM
code.
* libguile/objcodes.h:
* libguile/objcodes.c: Remove the objcode data type, and handling for
objcode files.
* libguile/print.c: Remove objcode and program printers.
* libguile/procprop.c: Remove program cases.
* libguile/procs.c:
* libguile/programs.h:
* libguile/programs.c: Remove old program code.
* libguile/smob.c: Remove objcodes include.
* libguile/snarf.h: Remove static program defines.
* libguile/stacks.c: Remove program case.
* libguile/tags.h: Remove program and objcode tc7s.
* module/ice-9/session.scm (procedure-arguments)
* module/language/tree-il/analyze.scm (validate-arity)
* module/statprof.scm (get-call-data, procedure=?)
* module/system/vm/frame.scm (frame-bindings)
(frame-call-representation): Remove old program cases.
* module/system/repl/debug.scm (frame->module): Add a FIXME.
* module/system/vm/instruction.scm: Remove old exports.
* module/system/vm/program.scm: Remove old program code.
* module/statprof.scm (statprof-reset): Make full-stacks? into an
optional arg instead of doing the rest arg dance.
(statprof-display): Format gc-time-taken appropriately.
* module/statprof.scm (get-call-data): For closures, get call data by
the program's objcode.
(statprof-start, statprof-stop): Fix bug in which all statprof runs
were enabling the apply hook regardless of the setting of
#:count-calls?. The result was distorted timings, where procedure
calls were unfairly penalized.
(procedure=?): Streamline.
* module/statprof.scm: Use VM modules, instead of using @ hacks.
(statprof): New public export, a functional interface to the profiler.
(profile-signal-handler, count-call, statprof-start, statprof-stop):
Fix call counting with the VM.
(statprof-call-data->stats): Hack around a case in which a call could
be sampled but not counted, if you get my drift.
(procedure=?): Update for current API.
(with-statprof): Use `statprof'.
* module/system/repl/command.scm (profile): Use the `statprof'
procedural interface.
* module/statprof.scm (make-call-data): Change so that call-data holds
the proc, not its name. Remove set-call-data-name!.
(get-call-data): Adapt caller.
(sample-stack-procs): Always sample procedures on the stack, even
anonymous ones.
(profile-signal-handler): Fix stack cutting to work with compiled
statprof.scm.
(count-call): Always count calls, even to anonymous procedures.
(statprof-call-data->stats): Use call-data-printable for printing the
call data.
(statprof-display-anomolies): Fix a couple longstanding bugs caught by
compiler warnings.
* module/Makefile.am (LIB_SOURCES): Add statprof, sxml, and texinfo to
the build.
(NOCOMP_SOURCES): Reindent, and add the upstream SSAX files.
* module/statprof.scm:
* module/sxml/apply-templates.scm:
* module/sxml/fold.scm:
* module/sxml/simple.scm:
* module/sxml/ssax.scm:
* module/sxml/ssax/input-parse.scm:
* module/sxml/transform.scm:
* module/sxml/upstream/COPYING.SSAX:
* module/sxml/upstream/SSAX.scm:
* module/sxml/upstream/SXML-tree-trans.scm:
* module/sxml/upstream/SXPath-old.scm:
* module/sxml/upstream/assert.scm:
* module/sxml/upstream/input-parse.scm:
* module/sxml/xpath.scm:
* module/texinfo.scm:
* module/texinfo/docbook.scm:
* module/texinfo/html.scm:
* module/texinfo/indexing.scm:
* module/texinfo/plain-text.scm:
* module/texinfo/reflection.scm:
* module/texinfo/serialize.scm:
* module/texinfo/string-utils.scm: Add files from guile-lib to Guile.
It's only Richard, Andreas, Rob, and myself that have copyright on
these, and we have all assigned to the FSF. SSAX itself is in the
public domain.