bpt/guile.git
9 years agointern arbitrary constants
Robin Templeton [Tue, 10 Jun 2014 22:48:07 +0000 (18:48 -0400)]
intern arbitrary constants

9 years agolibguile/Makefile.am (snarfcppopts): Remove CFLAGS
Robin Templeton [Tue, 10 Jun 2014 20:03:17 +0000 (16:03 -0400)]
libguile/Makefile.am (snarfcppopts): Remove CFLAGS

9 years agoBetter simplification of literal constants that continue to branches
Andy Wingo [Sun, 20 Jul 2014 18:52:06 +0000 (20:52 +0200)]
Better simplification of literal constants that continue to branches

* module/language/cps/simplify.scm (eta-reduce): Constants that continue
  to branches eta-reduce to the true or false branch.

9 years agoCPS will not see "not" primcalls
Andy Wingo [Sun, 20 Jul 2014 18:19:01 +0000 (20:19 +0200)]
CPS will not see "not" primcalls

* module/language/tree-il/compile-cps.scm (convert): Remove "not"
  primcalls.

* module/language/cps/effects-analysis.scm (values):
* module/language/cps/types.scm: Remove special cases for the "not"
  primcall.

9 years agoSimplify pass rewrite scope tree to reflect dominator tree
Andy Wingo [Sun, 6 Jul 2014 10:38:26 +0000 (12:38 +0200)]
Simplify pass rewrite scope tree to reflect dominator tree

* module/language/cps/simplify.scm (redominate): Add micropass to
  rewrite the scope tree to reflect the dominator tree.  Will enable
  better eta reduction.

9 years agoRemove dead case in CSE
Andy Wingo [Sun, 6 Jul 2014 10:17:58 +0000 (12:17 +0200)]
Remove dead case in CSE

* module/language/cps/cse.scm (apply-cse): Remove a case that couldn't
  occur.

9 years agoCSE allocate-struct fix
Andy Wingo [Mon, 21 Jul 2014 15:30:16 +0000 (17:30 +0200)]
CSE allocate-struct fix

* module/language/cps/cse.scm (compute-equivalent-subexpressions):
  Fix handling of allocate-struct in tail position.

9 years agoFix typo in arities.scm
Andy Wingo [Mon, 21 Jul 2014 15:03:51 +0000 (17:03 +0200)]
Fix typo in arities.scm

* module/language/cps/arities.scm (fix-arities*): Fix typo.

9 years agoStabilize renumber.scm:sort-conts.
Andy Wingo [Mon, 21 Jul 2014 10:19:33 +0000 (12:19 +0200)]
Stabilize renumber.scm:sort-conts.

* module/language/cps/renumber.scm (sort-conts): Prevent spurious
  continuation reordering.

9 years agomaybe_annotate_source does not annotate negative positions
Andy Wingo [Mon, 21 Jul 2014 19:37:20 +0000 (21:37 +0200)]
maybe_annotate_source does not annotate negative positions

* libguile/read.c (maybe_annotate_source): Don't annotate with negative
  lines or columns.

9 years agoSoft port fill-input doesn't alter line or column
Andy Wingo [Mon, 21 Jul 2014 19:36:30 +0000 (21:36 +0200)]
Soft port fill-input doesn't alter line or column

* libguile/vports.c (sf_fill_input): Save and restore the line/column
  info around the ungetc.

9 years agoscm_ungetc_unlocked should not result in negative columns
Andy Wingo [Mon, 21 Jul 2014 19:35:49 +0000 (21:35 +0200)]
scm_ungetc_unlocked should not result in negative columns

* libguile/ports.c (scm_ungetc_unlocked): Use DECCOL in all cases, to
  avoid negative columns.

9 years agoFix allocate-slots for $kreceive with multiple predecessors
Andy Wingo [Mon, 21 Jul 2014 09:47:43 +0000 (11:47 +0200)]
Fix allocate-slots for $kreceive with multiple predecessors

* module/language/cps/slot-allocation.scm (allocate-slots): For
  continuations of $call, $callk, and $values with multiple
  predecessors, recalculate the set of live slots.  Fixes miscompilation
  of ice-9/futures.scm:process-future!, broken since the previous patch,
  now that $kreceive continuations can have multiple predecessors.

9 years agoBlock sorting to keep loop bodies together
Andy Wingo [Sat, 5 Jul 2014 13:46:48 +0000 (15:46 +0200)]
Block sorting to keep loop bodies together

* module/language/cps/renumber.scm (compute-new-labels-and-vars):
  (compute-tail-path-lengths, sort-conts): Arrange to visit successors
  in such a way that if branches are unsorted, the longest path length
  will appear first.  This keeps loop bodies together.

9 years agologbit? strength reduction
Andy Wingo [Fri, 4 Jul 2014 10:05:31 +0000 (12:05 +0200)]
logbit? strength reduction

* module/language/cps/type-fold.scm (fold-and-reduce): Don't require
  types to check out; it could be that the reduced expression can
  exhibit the same type-check effects.  Reduce for all continuations,
  even $kreceive.  Pass dfg to reducer.
  (mul): Check types.
  (logbit?): New reducer.

9 years agoFix logand range analysis.
Andy Wingo [Fri, 4 Jul 2014 09:54:03 +0000 (11:54 +0200)]
Fix logand range analysis.

* module/language/cps/types.scm (logand): Fix range analysis.

9 years agoFix range analysis for mul and div
Andy Wingo [Fri, 4 Jul 2014 09:14:16 +0000 (11:14 +0200)]
Fix range analysis for mul and div

* module/language/cps/types.scm (mul): Avoid producing nans in the
  resulting range.
  (div): Fix range analysis.

9 years agoType-driven strength reduction
Andy Wingo [Fri, 4 Jul 2014 08:46:31 +0000 (10:46 +0200)]
Type-driven strength reduction

* module/language/cps/type-fold.scm (*primcall-reducers*):
  (define-primcall-reducer, define-unary-primcall-reducer):
  (define-binary-primcall-reducer, mul): Beginnings of strength
  reduction.
  (fold-and-reduce): Rename from compute-folded.
  (fold-constants*): Adapt.

9 years agoSmall type-fold cleanup
Andy Wingo [Fri, 4 Jul 2014 07:18:36 +0000 (09:18 +0200)]
Small type-fold cleanup

* module/language/cps/type-fold.scm (fold-constants*): Remove stale
  branches that were there when we only type folded on limited-size
  branches.

9 years agoCompiler emits br-if-logtest
Andy Wingo [Thu, 3 Jul 2014 13:03:40 +0000 (15:03 +0200)]
Compiler emits br-if-logtest

* module/language/cps/compile-bytecode.scm (compile-fun):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (logtest):
* module/language/cps/types.scm (logtest):
* module/system/vm/assembler.scm (system):
* module/system/vm/disassembler.scm (compute-labels): Add backend
  support for the logtest instruction.

9 years agoAdd br-if-logtest opcode
Andy Wingo [Thu, 3 Jul 2014 12:50:50 +0000 (14:50 +0200)]
Add br-if-logtest opcode

* libguile/vm-engine.c (br-if-logtest): New opcode.
* module/system/vm/disassembler.scm (code-annotation): Add branch
  annotation support.

9 years agoOptimizer support for logtest and logbit?
Andy Wingo [Thu, 3 Jul 2014 12:45:12 +0000 (14:45 +0200)]
Optimizer support for logtest and logbit?

* module/language/cps/effects-analysis.scm: Add entries for logtest and
  logbit?.
* module/language/cps/types.scm (logtest, logbit?): New checkers and
  inferrers.
* module/language/tree-il/peval.scm (peval): Convert (zero? (logand a
  b)) to (logtest a b), in anticipation of opcode support for logtest.
*
  module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*): Add logtest and logbit?.

9 years agoConvert slot allocation to use intsets
Andy Wingo [Thu, 3 Jul 2014 09:24:37 +0000 (11:24 +0200)]
Convert slot allocation to use intsets

* module/language/cps/dfg.scm (compute-live-variables): Convert to use
  intsets, and fold in compute-maximum-fixed-point.
  (print-dfa): Update.

* module/language/cps/slot-allocation.scm (dead-after-def?)
  (dead-after-use?, allocate-slots): Convert to use intsets.

9 years agoAdd bitvector->intset.
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.

9 years agoRestrict intsets and maps to non-negative integers
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.

9 years agoAdapt visit-prompt-control-flow to use intsets.
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.

9 years agoCSE comments
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.

9 years agoAdd intset-subtract.
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.

9 years agoFix intset on 32-bit machines
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.

9 years agoRemove size limit in elide-type-checks
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.

9 years agoFix intmap-intersect corner case
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.

9 years agoCSE truth inference pass uses 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.

9 years agoResult of intsect-intersect will share structure with A if it can
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.

9 years agoFix an intset-intersect corner case
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.

9 years agoFix intset pruning for empty intsets
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.

9 years agoRemove namesets.
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.

9 years agoRewrite type inference to use intmaps
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.

9 years agoNew module (language cps intmap)
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.

9 years agoRewrite CSE to use intsets.
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.

9 years agoNew module: (language cps intset)
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.

9 years agoFix bit-count* bug
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.

9 years agoRewrite type inference pass to use namesets
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.

9 years agoNew module: (language cps nameset)
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.

9 years agoRefactor dominator computation
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.

9 years agoConstant folding for (list) and (vector) in peval
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) -> #().

9 years agoUse the right GC version macros.
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.

9 years agoRemove $kif
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.

9 years agoCPS conversion produces $branch nodes, not $kif
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.

9 years agoAdd $branch expression type
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.

9 years agoFix source-line-for-user for unknown line
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.

9 years agoFix off-by-one in dump-dfg
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.

9 years agoFix compute-predecessors bug in frame.scm
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.

10 years agoUpdate effects-analysis docstring.
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.

10 years agoRedefine memory kind part of effects to be enumeration, not flags
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.

10 years agoDCE uses type analysis to elide type checks
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.

10 years agoLimit impact of O(n^2) type analysis by imposing limit
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.

10 years agoCompile language/cps/types.scm early
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.

10 years agoEnable type folding
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.

10 years agoType and range inference for CPS
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.

10 years agoAdd syntax-parameterize indentation to .dir-locals.el.
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.

10 years agoRewrite effects analysis to be precise for fields.
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.

10 years agoCSE effects analysis cleanup
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.

10 years agoAdd dump-dfg pretty-printer
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.

10 years agoSynthetic definitions take advantage of CSE'd vars
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.

10 years agoFix thinko in synthesize-definition-effects!
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.

10 years agoFix frame-call-representation for frames from apply-hook
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.

10 years agoProgram printing tweaks
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.

10 years agoRefactorings to apply-hook and push-continuation-hook
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.

10 years agoframe-address, frame-stack-pointer return offsets
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.

10 years agoframe-call-representation has #:top-frame? as keyword argument
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.

10 years agoSet-car! on a dead pair does not force the pair to be live
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.

10 years agoAdd auxiliary definitions for boxes
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.

10 years agoCSE does scalar replacement of aggregates
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.

10 years agoMore inlinable effects-analysis procedures
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.

10 years agoUpdate NEWS
Andy Wingo [Fri, 2 May 2014 09:13:34 +0000 (11:13 +0200)]
Update NEWS

* NEWS: Update.

10 years agoRewrite boot-9 map to be recursive and pure
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.

10 years agoFix inner and outer stack cuts to match on procedure code
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.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
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

10 years agoPrefer foreign objects over smobs in manual
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.

10 years agoAdd new standalone tests to gitignore
Andy Wingo [Mon, 28 Apr 2014 15:47:54 +0000 (17:47 +0200)]
Add new standalone tests to gitignore

* .gitignore: Add entries.

10 years agoRemove doc/example-smob/
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.

10 years agoRemove SMOB tutorial; update manual.
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.

10 years agoAdd foreign object documentation
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.

10 years agoAdd more foreign object interfaces
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*.

10 years agoAvoid non-constant struct initializers
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.

10 years agoAdd scm_make_foreign_object_0; optimize scm_make_foreign_object_n.
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.

10 years agoNew foreign object facility, to replace SMOBs
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.

10 years agoFix foreign slot initialization and access
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.

10 years agoAdd interface to disable automatic finalization
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.

10 years agoMerge branch 'stable-2.0'
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

10 years agoprint: Fix printing of weak vectors.
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.

10 years agoSupport weak vectors, arrays, and bitvectors in (system base types).
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.

10 years agoprint: avoid triggering deprecation warnings when printing weak vectors.
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.

10 years agobuild: Clean up rules for meta/{guild,guile-config}.
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>.

10 years agobuild: Clean up rules for meta/{guild,guile-config}.
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>.

10 years agobuild: Honor program name transformation in 'guild'.
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@.

10 years agobuild: Honor program name transformation in 'guild'.
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@.

10 years agoSet $GC_MARKERS to 1 when libgc 7.4.0 is used.
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.

10 years agoFix memory leak on `realloc' failure
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>
10 years agoAdd make-vector opcode
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.