1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

3117 commits

Author SHA1 Message Date
Andy Wingo
59258f7cad 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.
2014-05-31 21:43:12 -04:00
Andy Wingo
fd61004764 CPS conversion produces $branch nodes, not $kif
* module/language/tree-il/compile-cps.scm (unbound?, convert): Create
  $branch nodes instead of $kif nodes.
2014-05-31 21:15:13 -04:00
Andy Wingo
92805e2197 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.
2014-05-31 21:15:06 -04:00
Andy Wingo
c90e2c6087 Fix source-line-for-user for unknown line
* module/system/vm/debug.scm (source-line-for-user): Fix to allow for
  unknown lines.
2014-05-31 21:15:06 -04:00
Andy Wingo
51177f3515 Fix off-by-one in dump-dfg
* module/language/cps/dfg.scm (dump-dfg): Fix bug where the last
  continuation wasn't printed.
2014-05-31 21:15:06 -04:00
Andy Wingo
5062a56df0 Fix compute-predecessors bug in frame.scm
* module/system/vm/frame.scm (compute-predecessors): Fix bug in
  resolving targets of backwards branches.
2014-05-31 21:15:05 -04:00
Ludovic Courtès
a41b07a34f rdelim: Speed up 'read-string' (aka. 'get-string-all'.)
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.
2014-05-28 23:00:20 +02:00
Ludovic Courtès
0bb3f946e9 web: Keep the default size for the client's in-kernel receive buffer.
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.
2014-05-23 22:02:30 +02:00
Andy Wingo
146c8e72a9 Update effects-analysis docstring.
* module/language/cps/effects-analysis.scm: Update docs.
2014-05-16 16:57:58 +02:00
Andy Wingo
e7f2fe1bb7 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.
2014-05-16 16:17:53 +02:00
Andy Wingo
3be43fb782 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.
2014-05-15 17:39:24 +02:00
Andy Wingo
a7ee377dbe 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.
2014-05-15 17:39:24 +02:00
Andy Wingo
a77e3a7c8a 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.
2014-05-15 17:39:24 +02:00
Andy Wingo
6129faa0f5 Enable type folding
* module/language/cps/compile-bytecode.scm (optimize): Enable type
  folding.
2014-05-15 17:39:24 +02:00
Andy Wingo
8bc65d2d64 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.
2014-05-15 17:39:19 +02:00
Andy Wingo
5d25fdae37 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.
2014-05-08 10:39:49 +02:00
Andy Wingo
466bdf7ee3 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.
2014-05-07 17:10:15 +02:00
Andy Wingo
fb512cac6e Add dump-dfg pretty-printer
* module/language/cps/dfg.scm (dump-dfg): New pretty-printer.  Under
  construction.
2014-05-07 15:28:50 +02:00
Andy Wingo
c8d87b4745 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.
2014-05-07 15:28:12 +02:00
Andy Wingo
aa980ce0dc 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.
2014-05-07 15:25:13 +02:00
Andy Wingo
7af8115675 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.
2014-05-04 22:51:34 +02:00
Andy Wingo
423164efa6 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.
2014-05-04 22:41:48 +02:00
Andy Wingo
f5cb70e94a 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.
2014-05-04 14:09:42 +02:00
Andy Wingo
7c080187bc 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.
2014-05-04 11:46:18 +02:00
Andy Wingo
18f8fd0211 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.
2014-05-04 11:18:54 +02:00
Andy Wingo
40b36bbf94 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.
2014-05-03 12:42:12 +02:00
Andy Wingo
41812daa78 Add auxiliary definitions for boxes
* module/language/cps/cse.scm (compute-equivalent-subexpressions): Add
  auxiliary definitions for boxes.
2014-05-03 12:21:43 +02:00
Andy Wingo
6119a90595 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.
2014-05-02 17:47:20 +02:00
Andy Wingo
cfb42b4c8a 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.
2014-05-02 17:30:10 +02:00
Andy Wingo
9de674e6e6 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.
2014-05-01 21:17:28 +02:00
Andy Wingo
de0233af17 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.
2014-05-01 14:26:20 +02:00
Andy Wingo
d7a67c3e91 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
2014-04-28 18:51:21 +02:00
Andy Wingo
a7ee7f7cbf 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.
2014-04-28 10:59:11 +02:00
Andy Wingo
48ad85fb56 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.
2014-04-27 11:02:35 +02:00
Mark H Weaver
475772ea57 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
2014-04-25 02:06:01 -04:00
Mark H Weaver
e0da53b4fe 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.
2014-04-24 18:22:04 -04:00
Andy Wingo
d38ca16e2c 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.
2014-04-21 22:47:33 +02:00
Andy Wingo
d4b3a36d42 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.
2014-04-21 22:47:28 +02:00
Andy Wingo
28e12ea0c4 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.
2014-04-21 12:13:54 +02:00
Andy Wingo
dece041203 define-inline in assembler.scm
* module/system/vm/assembler.scm (define-inline): New local helper.
  Update local users of define-inlinable to use it.
2014-04-21 12:01:50 +02:00
Andy Wingo
c09708f985 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.
2014-04-20 11:52:14 +02:00
Andy Wingo
f5765cc25e 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.
2014-04-16 19:21:50 +02:00
Andy Wingo
3f71590f20 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.
2014-04-16 19:12:43 +02:00
Andy Wingo
6eae3141bf 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.
2014-04-16 17:16:10 +02:00
Andy Wingo
d856931d8d 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.
2014-04-16 14:19:18 +02:00
Andy Wingo
1a2711a848 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.
2014-04-16 13:58:17 +02:00
Andy Wingo
c4c9bfffd7 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.
2014-04-16 13:56:08 +02:00
Andy Wingo
bc5bcf6637 Add arity-code
* module/system/vm/debug.scm (arity-code): New interface.
2014-04-16 12:58:35 +02:00
Andy Wingo
20d7d68284 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.
2014-04-16 12:58:20 +02:00
Andy Wingo
f9425c8000 Add ability to query local definitions for 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.
2014-04-15 22:24:48 +02:00