This yields a 20% improvement on the "read-string" benchmark.
* module/ice-9/rdelim.scm (read-string): Rewrite as a 'case-lambda',
with a tight loop around 'read-char', and without using
'read-string!'.
* test-suite/tests/rdelim.test ("read-string")["longer than 100 chars,
with limit"]: New test.
* benchmark-suite/benchmarks/ports.bm ("rdelim")["read-string"]: New
benchmark.
Fixes <http://bugs.gnu.org/15368>.
* module/web/client.scm (open-socket-for-uri): Remove call to
'setsockopt'. Contrary to what the comment said, its effect was to
shrink the receive buffer from 124 KiB (the default size, per
/proc/sys/net/core/rmem_default on Linux-based systems) to 12 KiB.
* module/language/cps/effects-analysis.scm (define-enumeration): New
helper.
(&memory-kind-mask): Define as an enumeration, not a bitfield. Add
&unknown-memory-kinds.
(&all-effects, effect-clobbers?, make-prompt-tag, expression-effects):
Adapt.
Note that this change requires dce.go and cse.go to be recompiled.
* module/language/cps/dce.scm (elide-type-checks!, compute-live-code):
Replace old ad-hoc type check elision with one driven from type
analysis. Type check elision only operates on smallish functions, to
avoid n**2 explosion in type inference.
* module/language/cps/types.scm (infer-types): Add #:max-label-count
argument.
* module/language/cps/type-fold.scm (compute-folded, fold-constants*):
Disable for big functions. Perhaps we can relax this if we find an
O(n log n) way to represent types.
* module/Makefile.am (BOOT_SOURCES, BOOT_GOBJECTS): New variables.
(CLEANFILES, nobase_mod_DATA, nobase_ccache_DATA, EXTRA_DIST)
(ETAGS_ARGS): Use the new variables.
(CPS_LANG_SOURCES): Remove language/cps/types.scm, as it is a boot
file.
* module/language/cps/types.scm: New file, implementing type and range
inference over CPS.
* module/language/cps/type-fold.scm: New file, implementing abstract
constant folding for CPS.
* module/Makefile.am: Add the new files.
* module/language/cps/compile-bytecode.scm: Wire up type-fold, but
currently disabled.
* module/language/cps/effects-analysis.scm: Rewrite so that instead of
the depends/causes effects, there is just &type-check, &allocation,
&read, and &write. The object kind is a separate part of the
bitfield, and the field in the object (if appropriate) is another
field. Effects are still a fixnum. This enables precise effects for
vectors and structs on all architectures.
This kind of effects analysis was not possible in Tree-IL because
Tree-IL relied on logior-ing effects of subexpressions, whereas with
CPS we have no sub-expressions and we do flow analysis instead.
(effect-clobbers?): Replace effects-commute? with this inherently
directional and precise predicate.
* module/language/cps/cse.scm (compute-always-available-expressions):
(compute-equivalent-subexpressions): Adapt to effects analysis
change.
* module/language/cps/dce.scm (compute-live-code): Likewise.
* module/language/cps/cse.scm (compute-always-available-expressions):
Use constant? instead of zero?, to avoid punching through the effects
abstraction.
* module/language/cps/cse.scm (compute-available-expressions):
Simplify initialization.
(compute-equivalent-subexpressions): When synthesizing definitions,
use substed vars. Add synthetic definitions after processing an
expression, to take advantage of the substed vars.
* module/language/cps/effects-analysis.scm (synthesize-definition-effects!):
Fix a boneheaded thinko that caused all primcalls to be marked as
causing car, cdr, vector, struct, and box effects.
* module/system/vm/program.scm (print-program): New public interface --
the guts of write-program, but refactored to be able to work when only
given an addr.
(write-program): Use print-program.
* module/system/vm/frame.scm (frame-call-representation): Remove attempt
to abbreviate procedure representations; was confusing because the
result would write as a string, quotes and all.
* libguile/vm-engine.c (vm_engine): Always invoke the apply hook after
the ip has been reset. Avoids problems in frame-bindings, which
builds its bindings map based on the IP. Invoke push-continuation
before linking the new frame, so that more locals are available to the
frame inspector.
* module/system/vm/traps.scm (trap-in-procedure): No need for a
push-cont handler, as the apply handler will exit the frame.
* libguile/frames.c (scm_frame_address, scm_frame_stack_pointer): Return
offsets instead of absolute pointers. This is robust in the presence
of stack relocation.
* module/system/repl/debug.scm (print-registers): Adapt to print sp and
fp as integers.
* module/system/vm/frame.scm (frame-call-representation): Change
top-frame? argument to be a keyword instead of an optional argument.
* module/system/vm/trace.scm (print-application): Adapt caller.
* module/language/cps/dce.scm (constant-type, lookup-type)
(default-type-checker, *primcall-type-checkers*)
(define-primcall-type-checker, define-simple-primcall-types)
(check-primcall-arg-types): Define a really lame type analysis that
can elide some expressions causing &type-check.
(compute-live-code): Wire up the type checker.
* module/language/cps/effects-analysis.scm (effects-clobber): New
helper.
(length): Only depend on &cdr.
(synthesize-definition-effects!): New interface.
* module/language/cps/cse.scm (compute-available-expressions): Don't
count out constructors here -- we'll do that below.
(compute-defs): Add a comment.
(compute-equivalent-subexpressions): Synthesize getter calls at
constructor/setter sites, so that (set-car! x y) can cause a
future (car x) to just reference y. The equiv-labels set now stores
the defined vars, so there is no need for the defs vector.
(cse, apply-cse): Adapt to compute-equivalent-subexpressions change.
* module/ice-9/boot-9.scm (map): Rewrite to be recursive and pure
instead of iterative and effectful. At best this is faster; at worst
it is slower. In any case it resolves continuation-related issues.
* module/srfi/srfi-1.scm (fold): Specialize the two-arg case.
(map): Rewrite to be recursive.
* test-suite/tests/r5rs_pitfall.test (8.3): Update for new expected map
behavior.
* 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.
* libguile/goops.c (scm_sys_initialize_object): Refactor initialization
so that we don't ref uninitialized slots before initializing them.
This allows foreign slots, whose initial value is 0, to be initialized
via #:init-form.
* module/oop/goops.scm (@slot-ref, @slot-set!): Remove definitions.
Change callers to use struct-ref and struct-set!. slot-ref and
slot-set! were only marginally more efficient and were much more
dangerous. This change allows the standard accessors to work on
foreign slots; that was not the case before, as the 'u' fields of the
struct were read as if they were 'p' slots.
* module/language/tree-il/compile-glil.scm (lambda): Remove support for
compiling @slot-ref/@slot-set!. These were private to GOOPS.
* test-suite/tests/goops.test ("active-slot"): Update to not expect a
ref before initialization.
("foreign slots"): Add tests.
* module/language/cps/slot-allocation.scm (allocate-slots): Avoid
allocating locals in the range [253,255].
* module/system/vm/assembler.scm: List exports explicitly. For
operations with limited-range operands, export wrapper assemblers that
handle shuffling their operands into and out of their range.
(define-assembler): Get rid of enclosing begin.
(shuffling-assembler, define-shuffling-assembler): New helpers to
define shuffling wrapper assemblers.
(emit-mov*, emit-receive*): New functions.
(shuffle-up-args): New helper.
(standard-prelude, opt-prelude, kw-prelude): Call shuffle-up-args
after finishing.
* test-suite/tests/compiler.test ("limits"): Add test cases.
* module/system/vm/assembler.scm (define-inline): Change so that the
defined macro is only defined at expansion-time.
(u32-ref, u32-set!, s32-ref, s32-set!, pack-arity-flags): Use
define-inline.
(pack-flags, assert-match, *block-size*, id-append, assembler)
(define-assembler, visit-opcodes, define-macro-assembler): Wrap in
eval-when expand.
* libguile/vm-engine.c (make-array): Change to only have
restricted-width operands in the first word. This instruction is
currently unused, however.
* module/system/vm/assembler.scm (assembler):
* module/system/vm/disassembler.scm (disassembler): Disallow
restricted-width operands in tail words.
* 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/system/vm/frame.scm (available-bindings): Map indexes in such a
way that the first argument is index 1.
(frame-call-representation): Update to search the bindings for live
bindings.
* module/system/repl/debug.scm (print-locals): Update to work with new
interface.
(frame->module): Update. Still doesn't work due to lack of
`program-module', though.
* module/system/vm/program.scm (make-binding, binding:name)
(binding:definition-offset, program-arity-bindings-for-ip): Remove
these.
* module/system/vm/frame.scm (<binding>): New type.
(available-bindings): Return a list of <binding> instances.
(frame-lookup-binding, frame-binding-set!, frame-binding-ref):
(frame-environment, frame-object-name): Adapt.
* module/system/vm/frame.scm (parse-code, compute-predecessors):
(compute-genv, compute-defs-by-slot, compute-killv, available-bindings):
(frame-bindings): Add a bunch of hairy code to compute the set of
bindings that are live in a frame.
* module/system/vm/disassembler.scm (instruction-length):
(instruction-has-fallthrough?, instruction-relative-jump-targets):
(instruction-slot-clobbers): New interfaces; to be used when
determining the bindings available at a given point of a procedure.
* module/system/vm/debug.scm (arity-definitions): New interface.
* module/system/vm/program.scm (make-binding, binding:boxed?)
(binding:index, binding:start, binding:end): Remove.
(binding:definition-offset, binding:slot): Add.
(program-arity-bindings-for-ip): Rename from program-bindings-for-ip,
as it gives all definitions in an arity. The user will have to do
data-flow analysis to recover the set of variables that are actually
available at any given point.
(arity->arguments-alist): Remove crufty code.