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

470 commits

Author SHA1 Message Date
Andy Wingo
7184c176b4 with-dynamic-state compiler and VM support
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_DYNAMIC_STATE):
* libguile/dynstack.c (DYNAMIC_STATE_WORDS, DYNAMIC_STATE_STATE_BOX):
  (scm_dynstack_push_dynamic_state):
  (scm_dynstack_unwind_dynamic_state): New definitions.
  (scm_dynstack_unwind_1, scm_dynstack_wind_1): Add with-dynamic-state
  cases.
* libguile/memoize.c (push_dynamic_state, pop_dynamic_state)
  (do_push_dynamic_state, do_pop_dynamic_state): New definitions.
  (memoize, scm_init_memoize): Handle push-dynamic-state and
  pop-dynamic-state.
* libguile/vm-engine.c (push-dynamic-state, pop-dynamic-state): New
  opcodes.
* module/ice-9/boot-9.scm (with-dynamic-state): New definition in Scheme
  so that the push-dynamic-state and pop-dynamic-state always run in the
  VM.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/types.scm:
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
* module/system/vm/assembler.scm: Add support for with-dynamic-state to
  the compiler.
* test-suite/tests/fluids.test ("dynamic states"): Add basic tests.
* doc/ref/vm.texi (Dynamic Environment Instructions): Update.
2016-12-05 22:57:29 +01:00
Andy Wingo
d74e0fed0d Move thread bindings to (ice-9 threads)
* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs.
* libguile/threads.c (scm_init_ice_9_threads): Rename from
  scm_init_thread_procs, make static.
  (scm_init_threads): Register scm_init_thread_procs extension.
* libguile/threads.h (scm_init_thread_procs): Remove decl.
* module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side
  effects occur early.
* module/ice-9/deprecated.scm (define-deprecated): Fix to allow
  deprecated bindings to appear in operator position.  Export deprecated
  bindings.
  (define-deprecated/threads, define-deprecated/threads*): Trampoline
  thread bindings to (ice-9 threads).
* module/ice-9/futures.scm: Use ice-9 threads.
* module/ice-9/threads.scm: Load scm_init_ice_9_threads extension.
  Reorder definitions and imports so that the module circularity
  with (ice-9 futures) continues to work.
* module/language/cps/intmap.scm:
* module/language/cps/intset.scm:
* module/language/tree-il/primitives.scm: Use (ice-9 threads).
* module/language/cps/reify-primitives.scm: Reify current-thread
  in (ice-9 threads) module.
* module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and
  adapt all users.  Use proper keywords in module definition form.
* test-suite/tests/filesys.test (test-suite):
* test-suite/tests/fluids.test (test-suite):
* test-suite/tests/srfi-18.test: Use ice-9 threads.
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Update.
* doc/ref/posix.texi (Processes): Move current-processor-count and
  total-processor-count docs to Threads.
2016-10-23 22:29:44 +02:00
Andy Wingo
32f309d5ce Compiler support for atomics
* doc/ref/vm.texi (Inlined Atomic Instructions): New section.
* libguile/vm-engine.c (VM_VALIDATE_ATOMIC_BOX, make-atomic-box)
  (atomic-box-ref, atomic-box-set!, atomic-box-swap!)
  (atomic-box-compare-and-swap!): New instructions.
* libguile/vm.c: Include atomic and atomics-internal.h.
  (vm_error_not_a_atomic_box): New function.
* module/ice-9/atomic.scm: Register primitives with the compiler.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  support for atomic ops.
* module/language/cps/effects-analysis.scm: Add comment about why no
  effects analysis needed.
* module/language/cps/reify-primitives.scm (primitive-module): Add case
  for (ice-9 atomic).
* module/language/tree-il/primitives.scm (*effect-free-primitives*):
  (*effect+exception-free-primitives*): Add atomic-box?.
* module/system/vm/assembler.scm: Add new instructions.

* test-suite/tests/atomic.test: Test with compilation and
  interpretation.
2016-09-06 12:18:35 +02:00
Andy Wingo
3b2cd09fe2 Better char<? compilation
* module/language/tree-il/primitives.scm
  (character-comparison-expander): Expand out char<? and friends to <,
  unboxing the char arguments.
* module/language/cps/types.scm:
* module/language/cps/effects-analysis.scm: Remove mention of char<? and
  friends as we won't see them any more.  Also fixes #24318.
2016-09-02 10:02:54 +02:00
Andy Wingo
3e719e0a35 Add -Wmacro-use-before-definition
* module/ice-9/boot-9.scm (%auto-compilation-options):
* am/guilec (GUILE_WARNINGS): Add -Wmacro-use-before-definition.
* module/language/tree-il/analyze.scm (unbound-variable-analysis): Use
  match-lambda.
  (<macro-use-info>, macro-use-before-definition-analysis): New
  analysis.
* module/system/base/message.scm (%warning-types): Add
  macro-use-before-definition warning type.
* module/language/tree-il/compile-cps.scm (%warning-passes): Add
  support for macro-use-before-definition.
2016-06-25 18:08:28 +02:00
Andy Wingo
31c76f16c6 Fix duplicate case in peval
* module/language/tree-il/peval.scm (singly-valued-expression?): Fix
  duplicate case.  Spotted by "mejja" on IRC.
2016-06-25 15:34:11 +02:00
Andy Wingo
229d062f83 Constant-folding eq? and eqv? uses deduplication
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
* module/language/tree-il/peval.scm (peval): Constant-fold eq? and eqv?
  using equal?, anticipating deduplication.
2016-06-24 17:37:51 +02:00
Andy Wingo
0472af4c58 Fix (< 'foo) compilation
* module/language/tree-il/primitives.scm (expand-chained-comparisons):
  Fix (< 'foo) compilation.
* test-suite/tests/compiler.test ("regression tests"): Add test case.
2016-06-21 23:17:25 +02:00
Andy Wingo
f1c0434403 `define!' instruction returns the variable
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
  documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
  define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
  effects.  Incidentally here was the bug: in Guile 2.2 you can't have
  effects on different object kinds in one instruction, without
  reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
2016-06-21 22:40:31 +02:00
Andy Wingo
fff013215f Fix peval on (call-with-values foo (lambda (x) x))
* module/language/tree-il/peval.scm (peval): Don't
  inline (call-with-values foo (lambda (x) exp)) to (let ((x (foo)))
  exp).  The idea is that call-with-values sets up an explicit context
  in which we are requesting an explicit return arity, and that dropping
  extra values when there's not a rest argument is the wrong thing.
  Fixes #13966.
* test-suite/tests/peval.test ("partial evaluation"): Update test.
2016-06-20 22:04:45 +02:00
Andy Wingo
f5b9a53bd0 Add integer->char and char->integer opcodes
* libguile/vm-engine.c (integer_to_char, char_to_integer): New opcodes.
* libguile/vm.c (vm_error_not_a_char): New error case.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm:
* module/language/tree-il/compile-cps.scm (convert):
* doc/ref/vm.texi (Inlined Scheme Instructions):
* module/system/vm/assembler.scm: Add support for new opcodes.
2016-05-04 12:36:41 +02:00
Andy Wingo
fb2f7b4e5f Better CPS conversion for tests in tests
* module/language/tree-il/compile-cps.scm (convert): Tests in tests have
  their consequents and alternates also converted in test context.
2016-01-03 18:18:51 +01:00
Andy Wingo
166703c5ce Better partial evaluation of tests in tests
* module/language/tree-il/peval.scm (peval): In test context,
  fold (let ((x EXP)) (if x x ALT)) to (if EXP #t ALT).  This reduces
  the number of boolean literals that the compiler has to reify, by
  causing EXP to evaluate in test context instead of value context.
  Also, rotate `let' out of the test part of conditionals, for the same
  reason.
2016-01-03 18:15:20 +01:00
Andy Wingo
82085252ec Add logsub op.
* libguile/vm-engine.c (logsub): New op.
* module/language/cps/effects-analysis.scm (logsub):
* module/language/cps/types.scm (logsub):
* module/system/vm/assembler.scm (system): Add support for the new op.

* module/language/tree-il/compile-cps.scm (canonicalize):
  Rewrite (logand x (lognot y)) to (logsub x y).
2015-12-01 15:42:24 +01:00
Andy Wingo
8c75a5eb1b Add current-thread VM op
* libguile/vm-engine.c (current-thread): New op.
* module/language/cps/effects-analysis.scm (&thread): New memory kind.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (current-thread):
* module/language/cps/types.scm (current-thread):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
* module/system/vm/assembler.scm (emit-current-thread): Wire up the new
  op.
2015-12-01 15:42:24 +01:00
Andy Wingo
c3240d09b2 Unbox indexes of vectors, strings, and structs
* libguile/vm-engine.c (string-length, string-ref)
  (make-vector, vector-ref, vector-set!)
  (allocate-struct, struct-ref, struct-set!): Take indexes and return
  lengths as untagged u64 values.

* libguile/vm.c (vm_error_not_a_string): New helper.

* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/constructors.scm (inline-vector):
* module/language/cps/closure-conversion.scm (convert-one): Untag
  arguments to {string,vector,struct}-{ref,set!}, make-vector, and
  allocate-struct.  Tag return values from {string,vector}-length.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  vector-length and string-length define u64 slots.

* module/language/cps/effects-analysis.scm: make-vector no longer causes
  a &type-check effect.

* module/language/cps/types.scm: Update to expect &u64 values for
  lengths and indexes.
2015-12-01 15:42:24 +01:00
Andy Wingo
a08b3d40f8 Untag values and indexes for all bytevector instructions
* libguile/vm-engine.c (bv-s8-ref, bv-s16-ref, bv-s32-ref, bv-s64-ref):
  Unbox index and return unboxed S32 value.
  (bv-s8-set!, bv-s16-set!, bv-s32-set!, bv-s64-set!): Unbox index and
  take unboxed S32 value.
  (bv-u8-ref, bv-u16-ref, bv-u32-ref, bv-u64-ref)
  (bv-s8-set!, bv-s16-set!, bv-s32-set!, bv-s64-set!): Likewise, but
  with unsigned values.
  (bv-f32-ref, bv-f32-set!, bv-f64-ref, bv-f64-set!): Use memcpy to
  access the value so we don't have to think about alignment.  GCC will
  inline this to a single instruction on architectures that support
  unaligned access.
* libguile/vm.c (vm_error_out_of_range_uint64)
  (vm_error_out_of_range_int64): New helpers.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  All bytevector ref operations produce untagged values.

* module/language/cps/types.scm (define-bytevector-accessors): Update
  for bytevector untagged indices and values.

* module/language/cps/utils.scm (compute-constant-values): Fix s64
  case.

* module/language/tree-il/compile-cps.scm (convert): Box results of all
  bytevector accesses, and unbox incoming indices and values.
2015-12-01 15:42:24 +01:00
Andy Wingo
8f18b71b7a Remove add1 and sub1
* libguile/vm-engine.c: Remove add1 and sub1 instructions.  Will replace
  with add/immediate and sub/immediate.
* module/language/tree-il/peval.scm (peval): If we reify a new
  <primcall>, expand it.  Removes 1- and similar primcalls.
* module/language/tree-il/primitives.scm: Don't specialize (+ x 1) to 1+.
  (expand-primcall): New export, does a single primcall expansion.
  (expand-primitives): Use the new helper.
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/types.scm:
* module/system/vm/assembler.scm: Remove support for add1 and sub1 CPS
  primitives.
* test-suite/tests/peval.test ("partial evaluation"): Adapt tests that
  expect 1+/1- to expect +/-.
2015-12-01 11:30:55 +01:00
Andy Wingo
87cc8b0f97 bv-f{32,64}-{ref,set!} take unboxed u64 index
* module/language/tree-il/compile-cps.scm (convert): bv-f32-ref,
  bv-f32-set!, bv-f64-ref, and bv-f64-set! take the index as an untagged
  u64 value.
* module/language/cps/types.scm (define-bytevector-uaccessors): New
  helper, used while migrating bytevectors to take unboxed indexes.
  Adapt f32/f64 accessors to use this definition helper.
* libguile/vm-engine.c (BV_FLOAT_REF, BV_FLOAT_SET): The index is
  unboxed.
2015-12-01 11:30:54 +01:00
Andy Wingo
8464cc576c Add bv-length instruction
* libguile/vm-engine.c (bv-length): New instruction.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm (bv-length):
* module/language/cps/primitives.scm (*instruction-aliases*):
* module/language/cps/slot-allocation.scm (compute-var-representations):
* module/language/cps/types.scm (bv-length):
* module/language/tree-il/compile-cps.scm (convert): Add support for
  bv-length.
* module/system/vm/assembler.scm: Export emit-bv-length.
2015-12-01 11:30:54 +01:00
Andy Wingo
3e5d4131d2 Don't compile equal? to br-if-equal
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (equal?):
* module/language/cps/types.scm (equal?):
* module/language/tree-il/compile-cps.scm (convert): `equal?' is no
  longer a branching primcall, because it isn't inline.  The
  implementation could lead to bad backtraces also, as it didn't save
  the IP, and actually could lead to segfaults as it didn't reload the
  SP after the return.  There is an eqv? fast-path, though.
* module/system/vm/assembler.scm (br-if-equal): Remove interface.
* module/system/vm/disassembler.scm (code-annotation):
  (compute-labels): No need to handle br-if-equal.
2015-11-12 21:22:19 +01:00
Andy Wingo
b1ac8d68b5 bv-{f32,f64}-{ref,set!} operate on raw f64 values
* module/language/tree-il/compile-cps.scm (convert): Box results of
  bv-f32-ref and bv-f64-ref.  Unbox the argument to bv-f32-set! and
  bv-f64-set!.

* libguile/vm-engine.c (bv-f32-ref, bv-f64-ref): Results are raw.
  (bv-f32-set!, bv-f64-set!): Take unboxed arguments.

* module/system/vm/assembler.scm (emit-scm->f64, emit-f64->scm):
  Export.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm: Add support for scm->f64 and
  f64->scm.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  Add cases for primops returning raw values.

* module/language/cps/types.scm (bv-f32-ref, bv-f32-set!)
  (bv-f64-ref, bv-f64-set!): Deal in &f64 values instead of reals.
2015-11-11 10:20:12 +01:00
Andy Wingo
2f08838cd6 Replace return primcalls with $values
* module/language/cps/compile-bytecode.scm:
* module/language/cps/contification.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Never generate a return
  primcall.  Instead use $values.
2015-10-28 11:11:23 +00:00
Andy Wingo
f169be9fc8 Wire up `guild compile -O0 foo.scm'
* module/scripts/compile.scm (%options): Resurrect -O option and make it
  follow GCC, more or less.  The default is equivalent to -O2.

* module/language/cps/compile-bytecode.scm (lower-cps):
* module/language/cps/optimize.scm (optimize-higher-order-cps): Move
  split-rec to run unconditionally for now, as closure conversion fails
  without it.
  (define-optimizer): Only verify the result if we are debugging, to
  save time.
  (cps-default-optimization-options): New exported procedure.

* module/language/tree-il/optimize.scm
  (tree-il-default-optimization-options): New exported procedure.
2015-10-22 17:44:17 +00:00
Mark H Weaver
315adb6347 Fix typo in CPS conversion.
Fixes <http://bugs.gnu.org/21614>.
Reported by tantalum <sph@posteo.eu>.

* module/language/tree-il/compile-cps.scm (convert): Add missing 'cps'
  argument to the continuation passed to 'convert-arg'.
2015-10-06 10:09:12 -04:00
Andy Wingo
78fdc3e673 Remove unused (language tree-il inline) module.
* module/language/tree-il/inline.scm: Remove.
* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove inline.scm.
2015-09-17 12:45:36 +02:00
Andy Wingo
aa7f0e25ac Rename CPS2 to CPS 2015-07-22 17:19:04 +02:00
Andy Wingo
bac96c10f5 Factor with-cps out to separate module
* module/language/cps2/with-cps.scm: New file.
* module/language/tree-il/compile-cps2.scm: Use (language cps2 with-cps).
* module/Makefile.am: Add language/cps2/with-cps.scm.

* .dir-locals.el: Add indentation rules for with-cps.
2015-06-02 11:06:37 +02:00
Andy Wingo
23379467ae Add intmap-replace!.
* module/language/cps/intmap.scm (intmap-replace!): New interface.

* module/language/cps2/dce.scm (elide-type-checks):
* module/language/cps2/simplify.scm (transform-conts):
* module/language/cps2/utils.scm (intmap-map):
* module/language/tree-il/compile-cps2.scm (cps-convert/thunk): Use intmap-replace!.
2015-06-02 10:05:09 +02:00
Andy Wingo
2b06e90ca4 Intmaps do not treat #f specially as a value
* module/language/cps/intmap.scm: Intmaps can now contain any value;
  #f does not indicate the absence of a value.  Instead we use a unique
  private sentinel to mark absent values or branches.
  (*absent*, absent?, present?): New helpers.
  (new-branch): Initialize empty elements to *absent*.
  (clone-branch-with-edit): New helper.
  (clone-branch-and-set): Use clone-branch-with-edit.
  (writable-branch): Use clone-branch-with-edit
  (empty-intmap): Initialize value to *absent*.
  (add-level): clone-branch-and-set doesn't take #f as a branch any
  more; use new-branch.
  (branch-empty?, make-intmap/prune, intmap-add!):
  (intmap-add, intmap-remove, intmap-next, intmap-prev):
  (intmap-fold, intmap-union, intmap-intersect): Use absent? to detect
  absent branches / values.
  (intmap-ref): Likewise.  Instead of returning #f if the value is not
  found, call the optional not-found procedure.  By default this will
  signal an error.

* module/language/cps/types.scm:
* module/language/cps2/renumber.scm:
* module/language/cps2/simplify.scm: Adapt to intmap-ref signalling an
  error by default if the value is not found.

* module/language/tree-il/compile-cps2.scm: Adapt to intmap-add
  signalling an error if #f was in the intmap as a value.
2015-05-20 19:18:45 +02:00
Andy Wingo
4632f3d998 Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.  Fix construction of rest bindings
  as well.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2015-05-20 19:18:45 +02:00
Andy Wingo
fa7df5ed3a Fix sub/- primcall bug
* module/language/tree-il/compile-cps2.scm (convert): Fix bug
  in (apply - ...), because the instruction for "-" is "sub", and
  "sub" lookup was failing.  Caught by numbers.test.  Really I would
  like to get rid of $prim, somehow.
2015-05-20 19:18:45 +02:00
Andy Wingo
b31af02faf Consolidate CPS2 above CPS in the compiler
This is an intermediate step.  We'll replace CPS bit by bit.  If it
turns out to be a terrible idea we can just revert.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove compile-cps.scm.
  (CPS_LANG_SOURCES): Remove arities.scm.

* module/language/cps/arities.scm: Remove.
* module/language/tree-il/compile-cps.scm: Remove.

* module/language/tree-il/spec.scm: Remove use of compile-cps.scm.

* module/language/cps/compile-bytecode.scm: Remove use of arities.scm.
  Instead, incoming terms are expected to call their continuations
  with the correct number of arguments.
2015-05-11 22:43:25 +02:00
Andy Wingo
9833c545cc Adapt return arities in Tree-IL -> CPS2 conversion
* module/language/tree-il/compile-cps2.scm (adapt-arity): New
  procedure.  This is equivalent to (language cps arities), but as it
  is a necessary pass and not an optimization it's more proper to put
  it in the converter itself.  Unlike with the nested CPS
  representation, it's possible to look up continuations without
  making a DFG.
  (convert): Adapt arities as necessary.
2015-05-11 22:43:20 +02:00
Andy Wingo
3ab3cdecda Build CPS2 with transient intmaps
* module/language/tree-il/compile-cps2.scm (with-cps)
  (cps-convert/thunk): Use transient intmaps.
2015-05-11 22:43:19 +02:00
Andy Wingo
5928d16a8e Tree-IL -> CPS2 -> CPS
* module/language/tree-il/spec.scm (tree-il): Compile to CPS2 instead of CPS.
2015-05-09 16:52:09 +02:00
Andy Wingo
d99fedc5fd Fix convert-cps2 for "not" primcalls
* module/language/tree-il/compile-cps2.scm (convert): Fix typo in "not"
  compilation.
2015-05-08 15:44:50 +02:00
Andy Wingo
09869e781b Register up cps2 compiler with language tower
* module/language/tree-il/compile-cps2.scm (compile-cps2): Rename from compile-cps.
* module/language/cps2/spec.scm: New file.
* module/Makefile.am (CPS2_LANG_SOURCES): Add spec.scm.
* module/language/tree-il/spec.scm (tree-il): Declare compiler to cps2.
2015-05-08 13:35:08 +02:00
Andy Wingo
773595f0db Add compiler from tree-il to cps2
* module/language/tree-il/compile-cps2.scm: New file.
* module/Makefile.am: Add the file to the build.
2015-05-08 11:46:46 +02:00
Andy Wingo
50fcdfece3 Remove "free" field of $fun
* module/language/cps.scm ($fun): Remove unused "free" field.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all callers.
2015-04-01 10:10:10 +02:00
Andy Wingo
34ff3af9f0 Replace $letrec with $rec
* module/language/cps.scm ($rec): Replace $letrec with $rec, which is an
  expression, not a term.  This means that the names bound by the letrec
  appear twice: once in the $rec term, and once in the continuation.
  This is not very elegant, but the situation is better than it was
  before.  Adapt all callers.

* doc/ref/compiler.texi (CPS in Guile): Incomplete documentation
  updates.  I'll update these later when the IL settles down.
2015-04-01 10:10:10 +02:00
Andy Wingo
a9ec16f9c5 Remove $void CPS expression type
* module/language/cps.scm: Remove the $void expression type, replaced by
  $const of the unspecified value.
* 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/reify-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/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update callers.
2015-03-11 21:51:33 +01:00
Andy Wingo
e2fafeb901 Keywords have a tc7
* libguile/tags.h (scm_tc7_keyword): Allocate a tc7, so that the VM can
  have cheap keyword? tests.

* libguile/keywords.c:
* libguile/keywords.h: Adapt.

* libguile/goops.c (scm_class_of, scm_sys_goops_early_init): Capture
  <keyword>.

* libguile/print.c (iprin1): Inline keyword printer.

* libguile/evalext.c (scm_self_evaluating_p): Add keywords here.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_tc16_keyword): Deprecate.

* module/language/cps/compile-bytecode.scm (compile-fun): Add keyword?
  case, and bitvector? case while we're at it.
* module/language/cps/effects-analysis.scm (define-primitive-effects):
  Add bytevector?, keyword?, and bitvector? cases.

* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
  keyword?.

* module/language/cps/types.scm (bitvector?, keyword?, bytevector?): Add
  branch inferrers.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*):
  (*effect+exception-free-primitives*): Add bytevector?, keyword?, and
  bitvector?.

* module/oop/goops.scm (<keyword>): New class.

* module/system/base/types.scm (%tc7-keyword, cell->object): Add cases.

* module/system/vm/assembler.scm (br-if-keyword): New definition.
* module/system/vm/disassembler.scm (code-annotation): Add br-if-tc7
  case for keywords.

* test-suite/tests/types.test ("clonable objects"): Update now that
  keywords are cloneable.
2015-01-22 13:03:11 +01:00
Mark H Weaver
856d318a9f Merge branch 'stable-2.0'
Conflicts:
	benchmark-suite/benchmarks/ports.bm
	libguile/async.h
	libguile/bytevectors.c
	libguile/foreign.c
	libguile/gsubr.c
	libguile/srfi-1.c
	libguile/vm-engine.h
	libguile/vm-i-scheme.c
	module/Makefile.am
	module/language/tree-il/analyze.scm
	module/language/tree-il/peval.scm
	module/scripts/compile.scm
	module/scripts/disassemble.scm
	test-suite/tests/asm-to-bytecode.test
	test-suite/tests/peval.test
	test-suite/tests/rdelim.test
2014-09-30 03:50:47 -04:00
Mark H Weaver
7a71a45cfd peval: Handle optional argument inits that refer to previous arguments.
Fixes <http://bugs.gnu.org/17634>.
Reported by Josep Portella Florit <jpf@primfilat.com>.

* module/language/tree-il/peval.scm (inlined-application): When inlining
  an application whose operator is a lambda expression with optional
  arguments that rely on default initializers, expand into a series of
  nested let expressions, to ensure that previous arguments are in scope
  when the default initializers are evaluated.

* test-suite/tests/peval.test ("partial evaluation"): Add tests.
2014-09-28 23:51:20 -04:00
Ludovic Courtès
8ac39b38d1 Handle ~p in 'format' warnings.
Fixes <http://bugs.gnu.org/18299>.
Reported by Frank Terbeck <ft@bewatermyfriend.org>.

* module/language/tree-il/analyze.scm (format-string-argument-count):
  Add case for ~p.
* test-suite/tests/tree-il.test ("warnings")["format"]("~p", "~p, too
  few arguments", "~:p", "~:@p, too many arguments", "~:@p, too few
  arguments"): New tests.
2014-08-26 23:41:33 +02:00
Andy Wingo
ae67b159bb 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.
2014-07-22 12:18:07 +02:00
Andy Wingo
8006d2d6eb 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?.
2014-07-03 14:45:12 +02:00
Andy Wingo
803a1ee7c7 Constant folding for (list) and (vector) in peval
* module/language/tree-il/peval.scm (peval): Add cases for (list) -> '()
  and (vector) -> #().
2014-06-19 08:47:25 +02: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