Andy Wingo [Thu, 3 Jul 2014 08:37:20 +0000 (10:37 +0200)]
Add bitvector->intset.
* module/language/cps/intset.scm (bitvector->intset): New interface.
Andy Wingo [Thu, 3 Jul 2014 07:37:30 +0000 (09:37 +0200)]
Restrict intsets and maps to non-negative integers
* module/language/cps/intmap.scm (intmap-add):
* module/language/cps/intset.scm (intset-add): Restrict to only hold
non-negative integers.
Andy Wingo [Thu, 3 Jul 2014 07:20:11 +0000 (09:20 +0200)]
Adapt visit-prompt-control-flow to use intsets.
* module/language/cps/dfg.scm (compute-reachable): Use intsets.
(compute-interval): Adapt.
(visit-prompt-control-flow): Adapt.
Andy Wingo [Thu, 3 Jul 2014 07:03:45 +0000 (09:03 +0200)]
CSE comments
* module/language/cps/cse.scm (compute-available-expressions): Add
clarifying comment.
Andy Wingo [Thu, 3 Jul 2014 07:02:31 +0000 (09:02 +0200)]
Add intset-subtract.
* module/language/cps/intset.scm (intset-subtract): New interface.
Andy Wingo [Tue, 1 Jul 2014 09:30:29 +0000 (11:30 +0200)]
Fix intset on 32-bit machines
* module/language/cps/intset.scm (*leaf-bits*): Define to 4 on 32-bit
machines, to stay in fixnum range.
Andy Wingo [Mon, 30 Jun 2014 13:30:39 +0000 (15:30 +0200)]
Remove size limit in elide-type-checks
* module/language/cps/dce.scm (elide-type-checks!): Remove limit on
label-count, now that complexity is under control.
Andy Wingo [Sun, 29 Jun 2014 17:49:41 +0000 (19:49 +0200)]
Fix intmap-intersect corner case
* module/language/cps/intmap.scm (intmap-intersect): Fix a corner case,
as was recently fixed for intsets.
Andy Wingo [Sun, 29 Jun 2014 17:25:54 +0000 (19:25 +0200)]
CSE truth inference pass uses intsets
* module/language/cps/cse.scm (compute-truthy-expressions): Rewrite to
use intsets instead of bitvectors.
(apply-cse): Adapt.
Andy Wingo [Sun, 29 Jun 2014 17:47:25 +0000 (19:47 +0200)]
Result of intsect-intersect will share structure with A if it can
* module/language/cps/intset.scm (intset-intersect): Ensure that the
result shares structure with A if possible, as intmaps do.
Andy Wingo [Sun, 29 Jun 2014 17:40:43 +0000 (19:40 +0200)]
Fix an intset-intersect corner case
* module/language/cps/intset.scm (intset-intersect): Avoid creating
invalid intsets when lowering an intset with a higher shift.
Andy Wingo [Sun, 29 Jun 2014 17:31:27 +0000 (19:31 +0200)]
Fix intset pruning for empty intsets
* module/language/cps/intset.scm (make-intset/prune): Fix empty intset
case.
Andy Wingo [Sun, 29 Jun 2014 12:29:20 +0000 (14:29 +0200)]
Remove namesets.
This was a failed experiment. It had good space complexity but terrible
time complexity.
* module/Makefile.am: Update.
* module/language/cps/nameset.scm: Remove.
Andy Wingo [Sun, 29 Jun 2014 12:20:52 +0000 (14:20 +0200)]
Rewrite type inference to use intmaps
* module/language/cps/types.scm: Rewrite to use intmaps instead of
namesets.
Andy Wingo [Sun, 29 Jun 2014 08:41:57 +0000 (10:41 +0200)]
New module (language cps intmap)
* module/language/cps/intmap.scm: New file.
* module/Makefile.am: Add to build.
Andy Wingo [Sun, 29 Jun 2014 12:20:26 +0000 (14:20 +0200)]
Rewrite CSE to use intsets.
* module/language/cps/cse.scm: Rewrite using intsets.
Andy Wingo [Sun, 29 Jun 2014 12:09:04 +0000 (14:09 +0200)]
New module: (language cps intset)
* module/Makefile.am: Add to build.
* module/language/cps/intset.scm: New file.
Andy Wingo [Sat, 28 Jun 2014 13:24:29 +0000 (15:24 +0200)]
Fix bit-count* bug
* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
2005 refactor (!) in which the second arg was erroneously taken from
the first arg.
* test-suite/tests/bitvectors.test: Add test.
* doc/ref/api-compound.texi: Fix doc example for u32vector selector.
Andy Wingo [Thu, 19 Jun 2014 06:49:05 +0000 (08:49 +0200)]
Rewrite type inference pass to use namesets
* module/Makefile.am: Build types.scm early, but don't block the rest of
the build on it.
* module/language/cps/types.scm: Rewrite to use namesets.
* module/language/cps/dce.scm:
* module/language/cps/type-fold.scm: Adapt to interface changes.
Andy Wingo [Sun, 8 Jun 2014 16:50:07 +0000 (18:50 +0200)]
New module: (language cps nameset)
* module/language/cps/nameset.scm: New file.
* module/Makefile.am: Add new file.
Andy Wingo [Sun, 15 Jun 2014 20:02:29 +0000 (22:02 +0200)]
Refactor dominator computation
* module/language/cps/cse.scm:
* module/language/cps/dfg.scm (compute-idoms, compute-dom-edges): Move
these procedures from cse.scm to dfg.scm.
Remove loop-detection code; that can come back later but it is
bitrotten for now.
Andy Wingo [Sun, 8 Jun 2014 12:46:18 +0000 (14:46 +0200)]
Constant folding for (list) and (vector) in peval
* module/language/tree-il/peval.scm (peval): Add cases for (list) -> '()
and (vector) -> #().
Ludovic Courtès [Mon, 9 Jun 2014 17:26:38 +0000 (19:26 +0200)]
Use the right GC version macros.
Reported by Doug Evans <xdje42@gmail.com>.
* libguile/gc.c (scm_storage_prehistory): Use GC_VERSION_MICRO, not
GC_ALPHA_VERSION.
Andy Wingo [Sun, 1 Jun 2014 01:43:12 +0000 (21:43 -0400)]
Remove $kif
* module/language/cps.scm: Remove $kif.
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt.
Andy Wingo [Sun, 1 Jun 2014 01:13:33 +0000 (21:13 -0400)]
CPS conversion produces $branch nodes, not $kif
* module/language/tree-il/compile-cps.scm (unbound?, convert): Create
$branch nodes instead of $kif nodes.
Andy Wingo [Tue, 27 May 2014 15:49:42 +0000 (11:49 -0400)]
Add $branch expression type
* module/language/cps.scm ($branch): New expression type; will replace
$kif.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt to $branch expression type.
Andy Wingo [Fri, 30 May 2014 15:54:56 +0000 (11:54 -0400)]
Fix source-line-for-user for unknown line
* module/system/vm/debug.scm (source-line-for-user): Fix to allow for
unknown lines.
Andy Wingo [Wed, 28 May 2014 16:50:15 +0000 (12:50 -0400)]
Fix off-by-one in dump-dfg
* module/language/cps/dfg.scm (dump-dfg): Fix bug where the last
continuation wasn't printed.
Andy Wingo [Wed, 28 May 2014 14:46:19 +0000 (10:46 -0400)]
Fix compute-predecessors bug in frame.scm
* module/system/vm/frame.scm (compute-predecessors): Fix bug in
resolving targets of backwards branches.
Andy Wingo [Fri, 16 May 2014 14:57:58 +0000 (16:57 +0200)]
Update effects-analysis docstring.
* module/language/cps/effects-analysis.scm: Update docs.
Andy Wingo [Fri, 16 May 2014 14:17:53 +0000 (16:17 +0200)]
Redefine memory kind part of effects to be enumeration, not flags
* 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.
Andy Wingo [Wed, 14 May 2014 14:59:08 +0000 (16:59 +0200)]
DCE uses type analysis to elide type checks
* 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.
Andy Wingo [Wed, 14 May 2014 19:42:09 +0000 (21:42 +0200)]
Limit impact of O(n^2) type analysis by imposing limit
* 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.
Andy Wingo [Wed, 14 May 2014 14:15:15 +0000 (16:15 +0200)]
Compile language/cps/types.scm early
* 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.
Andy Wingo [Wed, 14 May 2014 14:02:08 +0000 (16:02 +0200)]
Enable type folding
* module/language/cps/compile-bytecode.scm (optimize): Enable type
folding.
Andy Wingo [Tue, 13 May 2014 14:14:35 +0000 (16:14 +0200)]
Type and range inference for CPS
* 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.
Andy Wingo [Mon, 12 May 2014 07:41:58 +0000 (09:41 +0200)]
Add syntax-parameterize indentation to .dir-locals.el.
* .dir-locals.el: Add syntax-parameterize indentation.
Andy Wingo [Thu, 8 May 2014 08:39:49 +0000 (10:39 +0200)]
Rewrite effects analysis to be precise for fields.
* 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.
Andy Wingo [Wed, 7 May 2014 15:10:15 +0000 (17:10 +0200)]
CSE effects analysis cleanup
* module/language/cps/cse.scm (compute-always-available-expressions):
Use constant? instead of zero?, to avoid punching through the effects
abstraction.
Andy Wingo [Wed, 7 May 2014 13:28:50 +0000 (15:28 +0200)]
Add dump-dfg pretty-printer
* module/language/cps/dfg.scm (dump-dfg): New pretty-printer. Under
construction.
Andy Wingo [Wed, 7 May 2014 13:28:12 +0000 (15:28 +0200)]
Synthetic definitions take advantage of CSE'd vars
* 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.
Andy Wingo [Wed, 7 May 2014 13:25:13 +0000 (15:25 +0200)]
Fix thinko in synthesize-definition-effects!
* 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.
Andy Wingo [Sun, 4 May 2014 20:51:34 +0000 (22:51 +0200)]
Fix frame-call-representation for frames from apply-hook
* module/system/vm/frame.scm (frame-call-representation): Fix when
called on frames that are created from the apply hook.
Andy Wingo [Sun, 4 May 2014 20:41:48 +0000 (22:41 +0200)]
Program printing tweaks
* 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.
Andy Wingo [Sun, 4 May 2014 12:09:42 +0000 (14:09 +0200)]
Refactorings to apply-hook and push-continuation-hook
* 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.
Andy Wingo [Sun, 4 May 2014 09:46:18 +0000 (11:46 +0200)]
frame-address, frame-stack-pointer return offsets
* 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.
Andy Wingo [Sun, 4 May 2014 09:18:54 +0000 (11:18 +0200)]
frame-call-representation has #:top-frame? as keyword argument
* 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.
Andy Wingo [Fri, 2 May 2014 18:06:30 +0000 (20:06 +0200)]
Set-car! on a dead pair does not force the pair to be live
* 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.
Andy Wingo [Sat, 3 May 2014 10:21:20 +0000 (12:21 +0200)]
Add auxiliary definitions for boxes
* module/language/cps/cse.scm (compute-equivalent-subexpressions): Add
auxiliary definitions for boxes.
Andy Wingo [Fri, 2 May 2014 15:47:20 +0000 (17:47 +0200)]
CSE does scalar replacement of aggregates
* 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.
Andy Wingo [Fri, 2 May 2014 15:29:39 +0000 (17:29 +0200)]
More inlinable effects-analysis procedures
* module/language/cps/effects-analysis.scm (exclude-effects)
(effect-free?, constant?): Define to be inlinable.
(allocate-struct/immediate): Add effects.
Andy Wingo [Fri, 2 May 2014 09:13:34 +0000 (11:13 +0200)]
Update NEWS
* NEWS: Update.
Andy Wingo [Thu, 1 May 2014 19:14:42 +0000 (21:14 +0200)]
Rewrite boot-9 map to be recursive and pure
* 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.
Andy Wingo [Thu, 1 May 2014 12:26:20 +0000 (14:26 +0200)]
Fix inner and outer stack cuts to match on procedure code
* 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.
Andy Wingo [Mon, 28 Apr 2014 16:51:21 +0000 (18:51 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
.gitignore
doc/example-smob/Makefile
doc/ref/api-smobs.texi
doc/ref/libguile-concepts.texi
doc/ref/libguile-smobs.texi
libguile.h
libguile/finalizers.c
libguile/finalizers.h
libguile/goops.c
module/language/tree-il/compile-glil.scm
module/oop/goops.scm
Andy Wingo [Mon, 28 Apr 2014 16:00:05 +0000 (18:00 +0200)]
Prefer foreign objects over smobs in manual
* doc/ref/api-memory.texi (Memory Blocks): Recommend against
scm_gc_free. Refer to foreign objects instead of smobs. Remove
discussion of scm_must_malloc et al.
* doc/ref/guile.texi (API Reference): Rename SMOB menu item.
* doc/ref/libguile-snarf.texi (Function Snarfing): Update example to not
refer to smobs.
* doc/ref/tools.texi (How guile-snarf works): Likewise.
Andy Wingo [Mon, 28 Apr 2014 15:47:54 +0000 (17:47 +0200)]
Add new standalone tests to gitignore
* .gitignore: Add entries.
Andy Wingo [Mon, 28 Apr 2014 15:46:59 +0000 (17:46 +0200)]
Remove doc/example-smob/
* doc/example-smob/: Remove example. It's smaller than it used to be in
Guile 1.8, and with foreign objects there's practically nothing
interesting to test.
* doc/oldfmt.c: Remove this hoary thing.
* doc/README:
* doc/Makefile.am: Update.
Andy Wingo [Mon, 28 Apr 2014 15:45:07 +0000 (17:45 +0200)]
Remove SMOB tutorial; update manual.
* doc/ref/libguile-smobs.texi: Remove; this tutorial is superseded by
libguile-foreign-objects.
* doc/ref/libguile-foreign-objects.texi: Proofreading.
* doc/ref/libguile-program.texi: Update Dia examples to refer to foreign
objects.
* doc/ref/libguile-concepts.texi (Garbage Collection): Update to
accurately describe the BDW-GC, and to avoid reference to mark
functions.
* doc/ref/guile.texi: Remove libguile-smobs, and reword API menu.
* doc/ref/api-utility.texi (Equality): Mention GOOPS instead of SMOBs.
* doc/ref/api-smobs.texi (Smobs): Describe as a legacy interface.
Exhort readers against the writing of mark functions.
* doc/ref/api-foreign-objects.texi (Foreign Objects): Proofreading.
* doc/ref/api-control.texi (Catch): Fix ref to point to foreign
objects.
* doc/ref/Makefile.am: Remove libguile-smobs.texi.
Andy Wingo [Mon, 28 Apr 2014 14:27:09 +0000 (16:27 +0200)]
Add foreign object documentation
* doc/ref/api-foreign-objects.texi:
* doc/ref/libguile-foreign-objects.texi: New files.
* doc/ref/guile.texi:
* doc/ref/Makefile.am: Link new files into docs.
Andy Wingo [Mon, 28 Apr 2014 09:27:31 +0000 (11:27 +0200)]
Add more foreign object interfaces
* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_make_foreign_object_1)
(scm_make_foreign_object_2, scm_make_foreign_object_3)
(scm_make_foreign_object_n): Change to take void * arguments, and to
add a comment to the header indicating that these are convenience
constructors.
* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_unsigned_ref)
(scm_foreign_object_unsigned_set_x): New functions, equivalent to the
old scm_foreign_object_ref and scm_foreign_object_set_x.
* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_signed_ref)
(scm_foreign_object_signed_set_x): New functions taking
scm_t_signed_bits.
* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_ref)
(scm_foreign_object_set_x): New functions that take void*.
Andy Wingo [Mon, 28 Apr 2014 09:01:44 +0000 (11:01 +0200)]
Avoid non-constant struct initializers
* libguile/foreign-object.c (scm_make_foreign_object_2):
(scm_make_foreign_object_3): Avoid non-constant struct initializers.
Andy Wingo [Mon, 28 Apr 2014 08:55:26 +0000 (10:55 +0200)]
Add scm_make_foreign_object_0; optimize scm_make_foreign_object_n.
* libguile/foreign-object.c (scm_make_foreign_object_0): New function.
(scm_make_foreign_object_n): Pre-fetch layout_chars.
* libguile/foreign-object.h: Add scm_make_foreign_object_0.
Andy Wingo [Sun, 27 Apr 2014 12:47:40 +0000 (14:47 +0200)]
New foreign object facility, to replace SMOBs
* libguile/foreign-object.c:
* libguile/foreign-object.h:
* module/system/foreign-object.scm:
* test-suite/standalone/test-foreign-object-c.c:
* test-suite/standalone/test-foreign-object-scm: New files.
* test-suite/standalone/Makefile.am:
* module/Makefile.am:
* libguile/Makefile.am: Add new files.
* libguile.h: Add foreign-object.h.
* libguile/init.c (scm_i_init_guile): Call scm_register_foreign_object.
Andy Wingo [Sun, 27 Apr 2014 09:02:35 +0000 (11:02 +0200)]
Fix foreign slot initialization and access
* 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.
Andy Wingo [Thu, 17 Apr 2014 13:29:13 +0000 (15:29 +0200)]
Add interface to disable automatic finalization
* libguile/finalizers.h:
* libguile/finalizers.c (run_finalizers_async_thunk): Call the new
scm_run_finalizers helper.
(scm_set_automatic_finalization_enabled, scm_run_finalizers): New
functions.
(scm_init_finalizers): Only set a finalizer notifier if automatic
finalization is enabled.
* doc/ref/libguile-smobs.texi (Garbage Collecting Smobs): Add discussion
of concurrency.
* doc/ref/api-smobs.texi (Smobs): Document new functions.
Mark H Weaver [Fri, 25 Apr 2014 06:06:01 +0000 (02:06 -0400)]
Merge branch 'stable-2.0'
Conflicts:
GUILE-VERSION
NEWS
guile-readline/ice-9/readline.scm
libguile/async.c
libguile/backtrace.c
libguile/deprecated.h
libguile/gc-malloc.c
libguile/gdbint.c
libguile/init.c
libguile/ioext.c
libguile/mallocs.c
libguile/print.c
libguile/rw.c
libguile/scmsigs.c
libguile/script.c
libguile/simpos.c
libguile/snarf.h
libguile/strports.c
libguile/threads.c
libguile/vm-i-scheme.c
libguile/vm-i-system.c
module/srfi/srfi-18.scm
test-suite/Makefile.am
test-suite/standalone/test-num2integral.c
Mark H Weaver [Fri, 25 Apr 2014 05:39:59 +0000 (01:39 -0400)]
print: Fix printing of weak vectors.
* libguile/print.c (print_vector_or_weak_vector): New static function.
(iprin1): Use 'print_vector_or_weak_vector' in the vector and weak
vector cases.
Mark H Weaver [Thu, 24 Apr 2014 21:57:19 +0000 (17:57 -0400)]
Support weak vectors, arrays, and bitvectors in (system base types).
* module/system/base/types.scm (%tc7-wvect, %tc7-array, %tc7-bitvector):
New variables.
(cell->object): Add cases for weak vectors, arrays, and bitvectors.
Mark H Weaver [Thu, 24 Apr 2014 21:55:47 +0000 (17:55 -0400)]
print: avoid triggering deprecation warnings when printing weak vectors.
* libguile/print.c (iprin1): Use 'scm_c_weak_vector_ref' to access
elements of weak vectors.
Ludovic Courtès [Thu, 24 Apr 2014 21:46:20 +0000 (23:46 +0200)]
build: Clean up rules for meta/{guild,guile-config}.
* meta/Makefile.am (guile-config, guild): Avoid useless 'cat'
invocation'. Quote all occurrences of '@'.
Suggested by Eric Blake <eblake@redhat.com>.
Ludovic Courtès [Thu, 24 Apr 2014 21:46:20 +0000 (23:46 +0200)]
build: Clean up rules for meta/{guild,guile-config}.
* meta/Makefile.am (guile-config, guild): Avoid useless 'cat'
invocation'. Quote all occurrences of '@'.
Suggested by Eric Blake <eblake@redhat.com>.
Ludovic Courtès [Thu, 24 Apr 2014 09:16:21 +0000 (11:16 +0200)]
build: Honor program name transformation in 'guild'.
* configure.ac: Remove erroneous 'guile_program_name' substitute; see
<https://lists.gnu.org/archive/html/autoconf/2014-04/msg00010.html>
for details. Remove 'meta/guild' config file.
* meta/Makefile.am (guild): New target.
(CLEANFILES): Add 'guild'.
* meta/guild.in: Remove 'prefix' and 'exec_prefix' definitions; use
@installed_guile@.
Ludovic Courtès [Thu, 24 Apr 2014 09:16:21 +0000 (11:16 +0200)]
build: Honor program name transformation in 'guild'.
* configure.ac: Remove erroneous 'guile_program_name' substitute; see
<https://lists.gnu.org/archive/html/autoconf/2014-04/msg00010.html>
for details. Remove 'meta/guild' config file.
* meta/Makefile.am (guild): New target.
(CLEANFILES): Add 'guild'.
* meta/guild.in: Remove 'prefix' and 'exec_prefix' definitions; use
@installed_guile@.
Ludovic Courtès [Wed, 23 Apr 2014 16:12:26 +0000 (18:12 +0200)]
Set $GC_MARKERS to 1 when libgc 7.4.0 is used.
* libguile/gc.c (scm_storage_prehistory) [GC_VERSION == 7.4.0]: Add
'setenv' call.
Dmitry Bogatov [Thu, 10 Apr 2014 05:23:28 +0000 (09:23 +0400)]
Fix memory leak on `realloc' failure
* libguile/script.c (realloc0): New helper.
(script_read_arg, scm_get_meta_args): Use realloc0, not realloc.
Signed-off-by: Dmitry Bogatov <KAction@gnu.org>
Andy Wingo [Mon, 21 Apr 2014 19:48:39 +0000 (21:48 +0200)]
Add make-vector opcode
* libguile/vm-engine.c (make-vector): New opcode.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Support the new opcode.
(*bytecode-minor-version*): Bump.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* test-suite/tests/compiler.test ("limits"): Add vector test.
Andy Wingo [Mon, 21 Apr 2014 17:28:06 +0000 (19:28 +0200)]
Operations on 8-bit and 12-bit operands shuffle args into range
* 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.
Andy Wingo [Mon, 21 Apr 2014 10:13:54 +0000 (12:13 +0200)]
More expansion-time-only definitions in assembler.scm
* 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.
Andy Wingo [Mon, 21 Apr 2014 10:01:46 +0000 (12:01 +0200)]
define-inline in assembler.scm
* module/system/vm/assembler.scm (define-inline): New local helper.
Update local users of define-inlinable to use it.
Andy Wingo [Sun, 20 Apr 2014 09:52:14 +0000 (11:52 +0200)]
VM opcodes only have <24-bit slot operands in the first word
* 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.
Andy Wingo [Thu, 17 Apr 2014 13:29:13 +0000 (15:29 +0200)]
Add interface to disable automatic finalization
* libguile/finalizers.h:
* libguile/finalizers.c (run_finalizers_async_thunk)
(finalization_thread_proc): Call the new scm_run_finalizers helper.
(scm_i_finalizer_pre_fork): Only spawn the thread if automatic
finalization is enabled.
(scm_set_automatic_finalization_enabled, scm_run_finalizers): New
functions.
(scm_init_finalizers, scm_init_finalizer_thread): Only set a finalizer
notifier if automatic finalization is enabled.
* doc/ref/libguile-smobs.texi (Garbage Collecting Smobs): Add discussion
of concurrency.
* doc/ref/api-smobs.texi (Smobs): Document new functions.
Andy Wingo [Wed, 16 Apr 2014 17:21:50 +0000 (19:21 +0200)]
Slot allocation can re-use closure and argument slots
* module/language/cps/slot-allocation.scm (allocate-slots): Allow slot
allocation to re-use the closure and argument slots.
Andy Wingo [Wed, 16 Apr 2014 17:20:42 +0000 (19:20 +0200)]
Remove SCM_FRAME_PROGRAM
* libguile/frames.h: Remove SCM_FRAME_PROGRAM, now unused.
Andy Wingo [Wed, 16 Apr 2014 17:20:23 +0000 (19:20 +0200)]
VM robustness for optimized closures
* libguile/vm.c (vm_error_unbound, vm_error_unbound_fluid): Remove proc
argument. The value in slot 0 is not necessarily the procedure being
applied, after the prelude is done.
* libguile/vm-engine.c (vm_engine): Use LOCAL_REF (0) instead of
SCM_FRAME_PROGRAM, and adapt to above changes.
Andy Wingo [Wed, 16 Apr 2014 17:18:29 +0000 (19:18 +0200)]
Fix rewinding continuations when outermost frame has zero locals
* libguile/vm.c (vm_reinstate_partial_continuation_inner): Fix boundary
condition when the outermost frame has zero locals.
Andy Wingo [Wed, 16 Apr 2014 17:17:38 +0000 (19:17 +0200)]
frame-previous, frame-procedure robustness
* libguile/frames.c (scm_c_frame_closure): Don't use SCM_FRAME_PROGRAM,
as we don't know if the frame actually has any locals.
(scm_c_frame_previous): More robustly detect end-of-stack. Allows
scm_c_frame_previous to work on partial continuations.
Andy Wingo [Wed, 16 Apr 2014 17:16:10 +0000 (19:16 +0200)]
make-stack works on delimited continuations
* libguile/stacks.c (scm_make_stack, scm_stack_id):
* libguile/vm.c (scm_i_vm_cont_to_frame): Allow delimited continuations
as the argument to make-stack.
Andy Wingo [Wed, 16 Apr 2014 17:13:49 +0000 (19:13 +0200)]
More robust coverage tests
* test-suite/tests/coverage.test ("line-execution-counts"): Allow zero
or one count on the loop head.
Andy Wingo [Wed, 16 Apr 2014 17:13:09 +0000 (19:13 +0200)]
Change some make-stack tests to use frame-call-representation
* test-suite/tests/eval.test ("stacks"): Use frame-call-representation.
Andy Wingo [Wed, 16 Apr 2014 17:12:43 +0000 (19:12 +0200)]
Fix statprof for optimizations
* 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.
Andy Wingo [Wed, 16 Apr 2014 12:54:46 +0000 (14:54 +0200)]
Fix a frame-call-representation bug
* module/system/vm/frame.scm (frame-call-representation): Fix logic for
displaying names of non-procedures and procedures out of arities.
Andy Wingo [Wed, 16 Apr 2014 12:33:20 +0000 (14:33 +0200)]
Better backtraces from C, especially for optimized closures
* libguile/frames.h:
* libguile/frames.c (scm_frame_call_representation): New interface;
dispatches to Scheme.
* libguile/backtrace.c (display_application): Use
scm_frame_call_representation. This should be monotonically better,
given that scm_frame_arguments (which was previously called) also
dispatched to Scheme and actually ended up calling
frame-call-representation.
Andy Wingo [Wed, 16 Apr 2014 12:19:18 +0000 (14:19 +0200)]
frame-call-representation checks available-bindings, as appropriate
* 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.
Andy Wingo [Wed, 16 Apr 2014 11:58:17 +0000 (13:58 +0200)]
Update frame-bindings interface
* 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.
Andy Wingo [Wed, 16 Apr 2014 10:59:45 +0000 (12:59 +0200)]
Implement frame-bindings
* 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.
Andy Wingo [Wed, 16 Apr 2014 10:58:35 +0000 (12:58 +0200)]
Add arity-code
* module/system/vm/debug.scm (arity-code): New interface.
Andy Wingo [Wed, 16 Apr 2014 10:58:20 +0000 (12:58 +0200)]
Add parsing interfaces to the disassembler
* 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.
Andy Wingo [Wed, 16 Apr 2014 10:51:34 +0000 (12:51 +0200)]
Fix up some opcode metadata
* libguile/vm-engine.c (make-long-immediate, static-ref): Mark as "dst"
instructions.
Mark H Weaver [Wed, 16 Apr 2014 04:49:40 +0000 (00:49 -0400)]
Update libgc URL in README.
* README: Update libgc URL. Suggested by Ian Grant
<ian.a.n.grant@googlemail.com>.