bpt/guile.git
5 years agotemporarily disable elisp exception tests wip
Robin Templeton [Sun, 10 May 2015 21:41:27 +0000 (17:41 -0400)]
temporarily disable elisp exception tests

5 years agoignore 'expect-fail' forms in elisp tests
Robin Templeton [Sun, 10 May 2015 21:41:12 +0000 (17:41 -0400)]
ignore 'expect-fail' forms in elisp tests

5 years agoupdate cross-compilation test
Robin Templeton [Sun, 10 May 2015 21:11:40 +0000 (17:11 -0400)]
update cross-compilation test

5 years agouse standard evaluator
Robin Templeton [Sun, 10 May 2015 21:11:28 +0000 (17:11 -0400)]
use standard evaluator

5 years agoguile-backtrace function
Robin Templeton [Tue, 23 Sep 2014 04:58:22 +0000 (00:58 -0400)]
guile-backtrace function

* module/language/elisp/boot.el (guile-backtrace): New function
  extracted from `backtrace'.
  (backtrace): Use it.

5 years agouse guile eval for elisp tree-il
Robin Templeton [Mon, 18 Aug 2014 08:01:39 +0000 (04:01 -0400)]
use guile eval for elisp tree-il

5 years agodeprecated eval-when situations
Robin Templeton [Mon, 11 Aug 2014 10:55:11 +0000 (06:55 -0400)]
deprecated eval-when situations

5 years agoexecute top level require forms
Robin Templeton [Mon, 11 Aug 2014 10:05:45 +0000 (06:05 -0400)]
execute top level require forms

5 years agotop level fixes
Robin Templeton [Mon, 11 Aug 2014 10:05:26 +0000 (06:05 -0400)]
top level fixes

5 years agoonly evaluate top-level macro definitions
Robin Templeton [Mon, 11 Aug 2014 10:04:28 +0000 (06:04 -0400)]
only evaluate top-level macro definitions

5 years agodegenerate let forms
Robin Templeton [Tue, 5 Aug 2014 03:17:21 +0000 (23:17 -0400)]
degenerate let forms

5 years agoeval-when
Robin Templeton [Tue, 5 Aug 2014 03:16:09 +0000 (23:16 -0400)]
eval-when

5 years agofset macro
Robin Templeton [Tue, 5 Aug 2014 03:13:20 +0000 (23:13 -0400)]
fset macro

5 years agouse defsubst
Robin Templeton [Tue, 5 Aug 2014 03:13:03 +0000 (23:13 -0400)]
use defsubst

5 years agodefsubst
Robin Templeton [Tue, 5 Aug 2014 03:11:43 +0000 (23:11 -0400)]
defsubst

5 years agocompiler macros
Robin Templeton [Tue, 5 Aug 2014 03:11:29 +0000 (23:11 -0400)]
compiler macros

5 years agodefconst, defvar: proclaim special at compile-time
Robin Templeton [Tue, 5 Aug 2014 03:08:12 +0000 (23:08 -0400)]
defconst, defvar: proclaim special at compile-time

5 years agoelisp @@ macro
Robin Templeton [Tue, 5 Aug 2014 03:06:59 +0000 (23:06 -0400)]
elisp @@ macro

5 years agocompile-elisp fn
Robin Templeton [Tue, 5 Aug 2014 03:06:26 +0000 (23:06 -0400)]
compile-elisp fn

5 years agofix `nil?' type inference
Robin Templeton [Thu, 24 Jul 2014 22:58:38 +0000 (18:58 -0400)]
fix `nil?' type inference

5 years agofix symbol-function
Robin Templeton [Fri, 18 Jul 2014 21:43:20 +0000 (17:43 -0400)]
fix symbol-function

5 years agorestore special operator handling
Robin Templeton [Fri, 18 Jul 2014 21:42:59 +0000 (17:42 -0400)]
restore special operator handling

5 years agodefine-module for elisp special modules
Robin Templeton [Fri, 18 Jul 2014 21:42:07 +0000 (17:42 -0400)]
define-module for elisp special modules

5 years agoconstant-interning fix
Robin Templeton [Fri, 18 Jul 2014 21:41:48 +0000 (17:41 -0400)]
constant-interning fix

5 years agodefvar affects default value
Robin Templeton [Tue, 24 Jun 2014 04:10:10 +0000 (00:10 -0400)]
defvar affects default value

5 years agosymbol default value procedures
Robin Templeton [Tue, 24 Jun 2014 04:01:56 +0000 (00:01 -0400)]
symbol default value procedures

5 years agoread nil/t as #nil/#t
Robin Templeton [Fri, 20 Jun 2014 03:37:36 +0000 (23:37 -0400)]
read nil/t as #nil/#t

5 years agoelisp updates
Robin Templeton [Tue, 3 Jun 2014 00:01:55 +0000 (20:01 -0400)]
elisp updates

5 years agoguile-snarf fix
Robin Templeton [Sat, 14 Jun 2014 20:16:32 +0000 (16:16 -0400)]
guile-snarf fix

5 years agoprefer compilers earlier in list
Robin Templeton [Wed, 18 Jun 2014 02:41:45 +0000 (22:41 -0400)]
prefer compilers earlier in list

5 years agoallow arbitrary constants in cps
Robin Templeton [Sat, 14 Jun 2014 07:33:22 +0000 (03:33 -0400)]
allow arbitrary constants in cps

5 years agoguile-private-ref
BT Templeton [Fri, 23 Aug 2013 07:01:36 +0000 (03:01 -0400)]
guile-private-ref

* module/language/elisp/compile-tree-il.scm (compile-guile-private-ref):
  New special operator.

5 years agomultiple obarrays
BT Templeton [Wed, 31 Jul 2013 02:50:24 +0000 (22:50 -0400)]
multiple obarrays

* libguile/symbols.c (lookup_uninterned_symbol)
  (lookup_interned_latin1_symbol, lookup_interned_utf8_symbol)
  (scm_i_str2symbol): Take an `obarray' argument. All callers changed.

  (scm_make_obarray, scm_find_symbol, scm_intern, scm_unintern)
  (scm_obarray_for_each): New functions.

5 years agocheck symbols constants uninterned
Robin Templeton [Wed, 11 Jun 2014 02:57:05 +0000 (22:57 -0400)]
check symbols constants uninterned

5 years agointern arbitrary constants
Robin Templeton [Tue, 10 Jun 2014 22:48:07 +0000 (18:48 -0400)]
intern arbitrary constants

5 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

5 years agoAdd "cps2" experiment
Andy Wingo [Sun, 15 Mar 2015 11:48:47 +0000 (12:48 +0100)]
Add "cps2" experiment

* module/Makefile.am: Add new file to makefile.
* module/language/cps/simplify2.scm: New file.

5 years agoTransient intsets
Andy Wingo [Wed, 1 Apr 2015 08:01:36 +0000 (10:01 +0200)]
Transient intsets

* module/language/cps/intset.scm (make-atomic-reference)
  (get-atomic-reference, set-atomic-reference!): New functions.
  (*branch-size-with-edit*, *edit-index*): New constants.
  (<transient-intset>): New data type.
  (new-branch, clone-branch-and-set): Adapt to set edit field.
  (transient-intset, persistent-intset): New exports.
  (intset-add!): New interface, supporting "transient" intsets.
  (intset-ref, intset-next, intset-prev, intset-fold, intset-fold2):
  Work with transients.

5 years agoAdd "transient" intmap interface
Andy Wingo [Wed, 1 Apr 2015 08:01:16 +0000 (10:01 +0200)]
Add "transient" intmap interface

* module/language/cps/intmap.scm (make-atomic-reference):
  (get-atomic-reference, set-atomic-reference!): New helpers.
  (*branch-size-with-edit*, *edit-index*): Branches now have a trailing
  field, an atomic reference to their owner.
  (<transient-intmap>): New record type.  A mutable intmap.
  (new-branch): Set the "edit" field on the branch.
  (clone-branch-and-set): No editor for this field.
  (assert-readable!, writable-branch): New helpers.
  (transient-intmap, persistent-intmap): New exported functions.
  (intmap-add!): New function.
  (intmap-next, intmap-prev, intmap-ref): Work on transient intmaps.
  (intmap-fold): Persist the intmap before folding over it.

5 years ago32-way branching in intmap.scm, not 16-way
Andy Wingo [Tue, 31 Mar 2015 10:21:47 +0000 (12:21 +0200)]
32-way branching in intmap.scm, not 16-way

* module/language/cps/intmap.scm (*branch-bits*): Switch to 32-way
  branching.  Marginally faster on lookup, and creation costs can be
  amortized via using the transient interface.  Marginal speedup for
  assembler.scm compilation.

5 years agoIntset-next micro-optimizations
Andy Wingo [Tue, 31 Mar 2015 10:11:22 +0000 (12:11 +0200)]
Intset-next micro-optimizations

* module/language/cps/intset.scm (intset-next): Micro-optimizations.

5 years agoAdd intset-fold, intset-fold2
Andy Wingo [Wed, 1 Apr 2015 08:45:53 +0000 (10:45 +0200)]
Add intset-fold, intset-fold2

* module/language/cps/intset.scm (intset-fold, intset-fold2): New
  functions.

5 years agoAdd intmap-fold.
Andy Wingo [Wed, 1 Apr 2015 08:45:31 +0000 (10:45 +0200)]
Add intmap-fold.

* module/language/cps/intmap.scm (intmap-fold): New function.

5 years agoAdd intmap-prev
Andy Wingo [Fri, 27 Mar 2015 09:34:40 +0000 (10:34 +0100)]
Add intmap-prev

* module/language/cps/intmap.scm (intmap-next): Starting index is
  optional.
  (intmap-prev): New function.

5 years agoDefault "meet" operator is meet-error for intmap
Andy Wingo [Thu, 26 Mar 2015 12:32:46 +0000 (13:32 +0100)]
Default "meet" operator is meet-error for intmap

* module/language/cps/intmap.scm (meet-error): New helper.
  (intmap-add, intmap-union, intmap-intersect): The "meet" argument is
  optional and defaults to meet-error.

5 years agoRemove "free" field of $fun
Andy Wingo [Thu, 26 Mar 2015 13:10:09 +0000 (14:10 +0100)]
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.

5 years agoReplace $letrec with $rec
Andy Wingo [Wed, 1 Apr 2015 07:51:13 +0000 (09:51 +0200)]
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.

5 years agoPrecise range inference on <, <=, >=, > branches
Andy Wingo [Tue, 31 Mar 2015 09:13:01 +0000 (11:13 +0200)]
Precise range inference on <, <=, >=, > branches

* module/language/cps/types.scm (restricted-comparison-ranges): New
  helper.
  (define-comparison-inferrer): New helper.
  (<, <=, >=, >): Infer ranges precisely.

5 years agoFix intmap bug for maps with only one element
Andy Wingo [Fri, 27 Mar 2015 12:40:23 +0000 (13:40 +0100)]
Fix intmap bug for maps with only one element

* module/language/cps/intmap.scm (intmap-ref): Fix bug referencing
  values when there is only one value in the map.

5 years agoelf: Add missing argument in 'elf-segment'.
Ludovic Courtès [Mon, 30 Mar 2015 13:19:58 +0000 (15:19 +0200)]
elf: Add missing argument in 'elf-segment'.

* module/system/vm/elf.scm (elf-segment): Add missing argument N.

5 years agoOnly lazily compile where profitable
Andy Wingo [Thu, 12 Mar 2015 13:48:03 +0000 (14:48 +0100)]
Only lazily compile where profitable

* module/ice-9/eval.scm (primitive-eval): Only lazily compile box-ref on
  toplevel variables; otherwise compile eagerly to avoid the
  indirection.

5 years agoOptimize branches in the evaluator
Andy Wingo [Thu, 12 Mar 2015 13:26:24 +0000 (14:26 +0100)]
Optimize branches in the evaluator

* module/ice-9/eval.scm (primitive-eval): Factor out primitive=?
  helper.  Simplify compile-top-call.  Add compile-top-branch for
  primcall branches, so the compiler can see the specialized branch
  operator.

5 years agoPrimcall inlining in eval.scm, lazy function body compilation
Andy Wingo [Thu, 12 Mar 2015 13:06:15 +0000 (14:06 +0100)]
Primcall inlining in eval.scm, lazy function body compilation

* module/ice-9/eval.scm (primitive-eval): Lazily compile lambda bodies.
  Special-case calls to top-level or module variables, and recognize
  some of those calls as primcalls.  In that case, emit closures with
  the primcalls.

5 years agoRemove unused "nargs" field of memoized call expressions
Andy Wingo [Thu, 12 Mar 2015 07:37:04 +0000 (08:37 +0100)]
Remove unused "nargs" field of memoized call expressions

* libguile/eval.c (eval):
* libguile/memoize.c (MAKMEMO_CALL, memoize, unmemoize):
* module/ice-9/eval.scm (primitive-eval): Remove "nargs" field from
  memoized call expressions, and adapt callers.

5 years agoMarginal bootstrap memory improvements
Andy Wingo [Thu, 12 Mar 2015 07:20:58 +0000 (08:20 +0100)]
Marginal bootstrap memory improvements

* module/language/cps/compile-bytecode.scm (optimize, compile-bytecode):
  Marginally improve bootstrap memory usage by not retaining stale
  copies of already-rewritten terms.

5 years agoRemove $void CPS expression type
Andy Wingo [Wed, 11 Mar 2015 20:51:33 +0000 (21:51 +0100)]
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.

5 years agoAdapt GDB integration to newest patches
Andy Wingo [Mon, 9 Mar 2015 12:45:24 +0000 (13:45 +0100)]
Adapt GDB integration to newest patches

* libguile/libguile-2.2-gdb.scm (vm-frame-function-name): Don't default
  to the address, as we will have better identifying info via the file
  name.
  (vm-frame-source): New helper.
  (compile-time-cond): For some reason "else" matching wasn't working;
  punt and use expressions.
  (snarfy-frame-decorator): Rename from decorator, and adapt to new
  version of Guile frame filter patch.
  (vm-frame-filter): Adapt to frame filter changes, and fill in source
  info.

5 years agoRe-implement (ice-9 streams) in terms of (srfi srfi-41)
Andy Wingo [Thu, 5 Mar 2015 08:44:53 +0000 (09:44 +0100)]
Re-implement (ice-9 streams) in terms of (srfi srfi-41)

* module/ice-9/streams.scm: Re-implement in terms of SRFI-41.  Passes
  tests.

5 years agobuild: Use pipe symbol instead of comma for substitutions.
Mark H Weaver [Sat, 7 Mar 2015 04:56:14 +0000 (23:56 -0500)]
build: Use pipe symbol instead of comma for substitutions.

* meta/Makefile.am (substitute): Use pipe symbol instead of comma for
  substitutions.

5 years agoNon-vector 1D arrays print as #1()
Daniel Llorens [Wed, 18 Feb 2015 08:32:30 +0000 (09:32 +0100)]
Non-vector 1D arrays print as #1()

* libguile/arrays.c (scm_i_print_array): Print the dimension whenever
  the array is a true scm_tc7_array.

* test-suite/tests/arrays.test: Check that non-vector 1D arrays print as
  expected.

5 years agoStruct and array GDB pretty printers hint as arrays
Andy Wingo [Tue, 17 Feb 2015 10:53:03 +0000 (11:53 +0100)]
Struct and array GDB pretty printers hint as arrays

* libguile/libguile-2.2-gdb.scm (make-scm-pretty-printer-worker):
  (%scm-pretty-printer): Refactor to avoid printing all struct / array
  fields by hinting these as arrays.  The resulting print is not as
  faithful to the original data, but that's probably OK.

5 years agoGDB support: add frame annotators and filters
Andy Wingo [Tue, 17 Feb 2015 10:02:52 +0000 (11:02 +0100)]
GDB support: add frame annotators and filters

These features depend on a patch to GDB that has not been merged yet.
If GDB doesn't support the annotator/filter interface, the code have no
effect.

* libguile/libguile-2.2-gdb.scm (compile-time-cond): New helper.
  (snarfy-frame-annotator): Simple annotator that gives subr names for
  snarfed gsubrs.
  (vm-frame-filter): New filter that interleaves Scheme frames with C
  frames on the stack when the user asks for a backtrace.

5 years agoDe-bitrot libguile-2.2-gdb.scm
Andy Wingo [Tue, 17 Feb 2015 10:00:21 +0000 (11:00 +0100)]
De-bitrot libguile-2.2-gdb.scm

* libguile/libguile-2.2-gdb.scm: Update to work with Guile 2.2 stacks.
  Represent the VM stack as a SRFI-41 stream, which will work better
  with the frame filter interface.  Add support for getting the vm
  frame's function name, if possible.

5 years ago(system base types) knows about variables
Andy Wingo [Tue, 17 Feb 2015 09:58:29 +0000 (10:58 +0100)]
(system base types) knows about variables

* module/system/base/types.scm (%tc7-variable): New tc7.
  (cell->object): Handle tc7-variable.

* test-suite/tests/types.test ("opaque objects"): Add a test.

5 years agoFix infinite loop in expander
Andy Wingo [Fri, 13 Feb 2015 15:40:46 +0000 (16:40 +0100)]
Fix infinite loop in expander

* module/ice-9/psyntax.scm (resolve-identifier): There is a case where a
  syntax object can resolve to itself.  Prevent an infinite loop in that
  case by continuing to resolve by name.

* module/ice-9/psyntax-pp.scm: Regenerate.

* test-suite/tests/syncase.test ("infinite loop bug"): Add a test.

5 years agoAdd `scm_smob_type_class()'.
Andy Wingo [Tue, 10 Feb 2015 13:35:35 +0000 (14:35 +0100)]
Add `scm_smob_type_class()'.

* libguile/smob.h:
* libguile/smob.c (scm_smob_type_class): New function, to access the
  GOOPS class for a SMOB type.

5 years agoNEWS and doc updates
Andy Wingo [Mon, 9 Feb 2015 21:43:20 +0000 (22:43 +0100)]
NEWS and doc updates

* doc/ref/vm.texi: Update for new instructions.
* doc/ref/web.texi: Update for URI-reference support.
* NEWS: Update.

5 years agoDocument support for URI references.
Andy Wingo [Sun, 8 Feb 2015 12:12:27 +0000 (13:12 +0100)]
Document support for URI references.

* doc/ref/web.texi (URIs): Update for URI reference changes.

5 years agoReify bytevector? in the correct module
Andy Wingo [Fri, 6 Feb 2015 14:13:32 +0000 (15:13 +0100)]
Reify bytevector? in the correct module

* module/language/cps/reify-primitives.scm (primitive-module): Reify
  bytevector? in the correct module.  Thanks to Nala Ginrut for the
  report.

5 years agoAdd #:static-slot-allocation?
Andy Wingo [Fri, 6 Feb 2015 12:25:17 +0000 (13:25 +0100)]
Add #:static-slot-allocation?

* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC): Reserve the fourth
  GOOPS flag to indicate that a class has static slot allocation.

* libguile/goops.c (scm_init_goops_builtins): Define
  vtable-flag-goops-static for goops.scm.

* module/oop/goops.scm (class-has-statically-allocated-slots?): New
  helper.
  (build-slots-list): Instead of the ad-hoc checks for <class> or
  <slot>, use the new helper.
  (initialize): Accept #:static-slot-allocation? keyword.

* module/system/foreign-object.scm (make-foreign-object-type): Declare
  foreign object classes as having static slot allocation.

* test-suite/tests/goops.test ("static slot allocation"): Add tests.

5 years agoFix foreign objects for getter method change
Andy Wingo [Fri, 6 Feb 2015 11:27:56 +0000 (12:27 +0100)]
Fix foreign objects for getter method change

* module/system/foreign-object.scm: Fix getters after change to make
  <accessor-method> instances only apply to their precise specializer
  types.

5 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Mon, 26 Jan 2015 17:13:38 +0000 (18:13 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/goops.c
libguile/vm-engine.h
module/oop/goops.scm
module/oop/goops/compile.scm
module/oop/goops/dispatch.scm
test-suite/tests/goops.test

5 years agoAccessor methods only apply to subclasses with their slot
Andy Wingo [Mon, 26 Jan 2015 16:54:26 +0000 (17:54 +0100)]
Accessor methods only apply to subclasses with their slot

* libguile/goops.c (is_accessor_method, scm_compute_applicable_methods):
  Fix regression from 51f66c912078a25ab0380c8fc070abb73d178d98 (2009).
  Accessor methods are added on each subclass on which the slot is
  present; therefore if a subclass doesn't have a method, then the
  methods doesn't apply.  Truly fixes #17355, unlike
  583a23bf104c84d9617222856e188f3f3af4934d.

* module/oop/goops.scm (compute-cmethod, compute-getter-method)
  (compute-setter-method): Revert earlier changes.

* test-suite/tests/goops.test ("accessor slots"): Update for new
  expectations, in agreement with Guile 1.8.

5 years agoFix verify-cps
Andy Wingo [Sun, 25 Jan 2015 10:39:42 +0000 (11:39 +0100)]
Fix verify-cps

* module/language/cps/verify.scm (verify-cps): Fix.  Thanks to Steven
  H. Margolis for the note.  Fixes bug #19389.

5 years agoFix accessor struct field inlining
Andy Wingo [Sat, 24 Jan 2015 18:22:47 +0000 (19:22 +0100)]
Fix accessor struct field inlining

* module/oop/goops/compile.scm: Inline into goops.scm, leaving a
  compatible interface stub behind.

* module/oop/goops/dispatch.scm: Don't import (oop goops compile), to
  break circularities.

* module/oop/goops.scm: Move (oop goops util) include up to the top, and
  import (ice-9 match).
  (compute-cmethod): Move here from compile.scm.  Add a special case for
  accessor methods, so as to fix bug #17355.
  (compute-getter-method, compute-setter-method): #:procedure slot is
  now generic.

* test-suite/tests/goops.test ("accessor slots"): New test.

5 years agoFix accessor struct inlining in GOOPS
Andy Wingo [Sat, 24 Jan 2015 17:59:15 +0000 (18:59 +0100)]
Fix accessor struct inlining in GOOPS

Fixes bug #17355.

* module/oop/goops.scm (memoize-effective-method!): Adapt to
  compute-effective-method change.
  (compute-effective-method, %compute-effective-method): Renamed from
  compute-cmethod; now a generic protocol.
  (compute-specialized-effective-method)
  (%compute-specialized-effective-method): New sub-protocol.
  (memoize-generic-function-application!): Adapt to call the hard-wired
  compute-applicable-methods based on the concrete arguments types --
  the semantics is that %compute-applicable-methods is the
  implementation for <generic> functions.  Perhaps we should do the same
  for sort-applicable-methods and method-more-specific?.
  (compute-getter-method, compute-setter-method): The standard
  #:procedure is now a generic slot-ref.  It wasn't valid to inline
  field access here, because subtypes could have different field
  layouts.
  (compute-applicable-methods): Refactor generic definition to use
  lexical scoping.
  (compute-specialized-effective-method): New method for
  <accessor-method>, which does field access inlining based on the
  concrete types being applied.

* test-suite/tests/goops.test ("accessor slots"): New test.

5 years agoSimplify and optimize slot access
Andy Wingo [Fri, 23 Jan 2015 13:55:35 +0000 (14:55 +0100)]
Simplify and optimize slot access

* module/oop/goops.scm (fold-slot-slots): Add `slot-ref/raw' slot, which
  is what the slot-ref slot was.  Now the slot-ref slot checks that the
  slot is bound, if needed.
  (slot-definition-slot-ref/raw): Define.
  (make-slot): Adapt.  Also, effective slot definition slots have no
  initargs.
  (define-standard-accessor-method, bound-check-get, standard-get)
  (standard-set): Move definitions up.
  (allocate-slots): Adapt.  If the slot has an init thunk, we don't need
  to check that it's bound.
  (slot-ref, slot-set!, slot-bound?): Simplify.
  (class-slot-ref): Use the raw getter so that we can call
  `slot-unbound' with just the class.
  (compute-getter-method, compute-setter-method): Simplify to just use
  the slot-ref / slot-set! functions from the slot.
  (%initialize-object): Simplify.

5 years agoExport <slot> from GOOPS
Andy Wingo [Fri, 23 Jan 2015 13:51:22 +0000 (14:51 +0100)]
Export <slot> from GOOPS

* module/oop/goops.scm (<slot>): Export.  This is the way to tell if you
  have new GOOPS or not: whether <slot> is defined.

5 years agoSimplify GOOPS effective method cache format
Andy Wingo [Wed, 21 Jan 2015 14:53:53 +0000 (15:53 +0100)]
Simplify GOOPS effective method cache format

* module/oop/goops.scm (single-arity-cache-dispatch)
  (compute-generic-function-dispatch-procedure)
  (memoize-effective-method!): Simplify format of effective method
  cache.

5 years agoFast generic function dispatch without calling `compile' at runtime
Andy Wingo [Wed, 21 Jan 2015 14:16:56 +0000 (15:16 +0100)]
Fast generic function dispatch without calling `compile' at runtime

* module/oop/goops.scm: Rewrite generic function dispatch to use chained
  closures instead of compiling specific dispatch procedures.  The big
  speed win before was not allocating rest arguments, which we gain by
  simply pre-generating dispatchers for arities of up to 20 arguments.
  Also now a tail call without reshuffling arguments -- which is what
  dispatch now is -- is just a (mov 0 new-procedure) and (tail-call),
  which is pretty cheap.

  (%invalidate-method-cache!): Use the new
  recompute-generic-function-dispatch-procedure!.
  (arity-case, multiple-arity-dispatcher, single-arity-dispatcher)
  (single-arity-cache-dispatch)
  (compute-generic-function-dispatch-procedure)
  (recompute-generic-function-dispatch-procedure!): New internal
  interfaces.
  (memoize-effective-method!): Update for new interfaces.
  (memoize-generic-function-application!): Rename from `memoize-method!'.

5 years agoGOOPS cosmetics
Andy Wingo [Mon, 19 Jan 2015 21:41:57 +0000 (22:41 +0100)]
GOOPS cosmetics

* module/oop/goops.scm: More commenting.  Move around <keyword> in the
  export section.

5 years agoUpdate (oop goops save) for <slot> objects
Andy Wingo [Mon, 19 Jan 2015 16:11:21 +0000 (17:11 +0100)]
Update (oop goops save) for <slot> objects

* module/oop/goops/describe.scm (describe): Remove commented code.
* module/oop/goops/save.scm (get-set-for-each, access-for-each): Update
  these hoary routines for the new <slot> universe.

5 years agoFix foreign objects for removal of getters-n-setters
Andy Wingo [Mon, 19 Jan 2015 15:58:14 +0000 (16:58 +0100)]
Fix foreign objects for removal of getters-n-setters

* module/system/foreign-object.scm (getter-method): Fix for removal of
  getters-n-setters property.

5 years agoMinor GOOPS cleanups
Andy Wingo [Mon, 19 Jan 2015 14:57:23 +0000 (15:57 +0100)]
Minor GOOPS cleanups

* module/oop/goops.scm: Minor commenting fixes.

5 years agoOptimize %initialize-object
Andy Wingo [Mon, 19 Jan 2015 12:06:44 +0000 (13:06 +0100)]
Optimize %initialize-object

* module/oop/goops.scm (%initialize-object): Optimize by inlining the
  slot initialization, and by avoiding multiple checks for initargs
  validity.

5 years agoInline internal slot accessors
Andy Wingo [Mon, 19 Jan 2015 11:20:50 +0000 (12:20 +0100)]
Inline internal slot accessors

* module/oop/goops.scm (define-slot-accessor): Also define internal
  accessors without the type check for when we know that the object is a
  slot.  Adapt struct-ref users to use these variants.

5 years agoInline helpers into slot-ref, slot-set!, etc
Andy Wingo [Sun, 18 Jan 2015 20:02:51 +0000 (21:02 +0100)]
Inline helpers into slot-ref, slot-set!, etc

* module/oop/goops.scm (%class-slot-definition): New helper.
  (class-slot-definition): Use the new helper.
  (get-slot-value-using-name, set-slot-value-using-name!)
  (test-slot-existence): Remove helpers.
  (slot-ref, slot-set!, slot-bound?, slot-exists?): Inline helpers for
  speed.

5 years agoUse a vtable bit to mark <slot> instances
Andy Wingo [Sun, 18 Jan 2015 20:01:31 +0000 (21:01 +0100)]
Use a vtable bit to mark <slot> instances

* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_SLOT): Allocate another vtable
  flag to indicate that instances of this vtable are slots.
* libguile/goops.c (scm_init_goops_builtins): Export
  vtable-flag-goops-slot to Scheme.

* module/oop/goops.scm (<slot>, slot?, make-standard-class, initialize):
  Arrange for <slot> classes to have the vtable-flag-goops.slot.
  (build-slots-list): Ensure that <slot> slots are statically laid out.

5 years agoIntroduce <slot> objects in GOOPS
Andy Wingo [Sun, 18 Jan 2015 19:53:19 +0000 (20:53 +0100)]
Introduce <slot> objects in GOOPS

* module/oop/goops.scm (fold-class-slots): Change format to use proper
  slot specifications.
  (fold-slot-slots): Flesh out with all needed slots.
  (<class>): Update cons-layout to deal with new fold-class-slots form.
  Don't create slots; we do that later.
  (is-a?, get-keyword, *unbound, unbound?, %allocate-instance): Move
  definitions up.
  (<slot>, slot?): New definitions.
  (slot-definition-name, slot-definition-allocation)
  (slot-definition-init-keyword, slot-definition-init-form)
  (slot-definition-init-value, slot-definition-init-thunk)
  (slot-definition-options, slot-definition-getter)
  (slot-definition-setter, slot-definition-accessor)
  (slot-definition-slot-ref, slot-definition-slot-set!)
  (slot-definition-index, slot-definition-size): New definitions as
  accessors on <slot> objects.
  (class-slot-definition): Adapt to class-slots change.
  (direct-slot-definition-class, make-slot): New definitions.
  (make): Define a boot version that can allocate <slot> instances.
  (compute-direct-slot-definition)
  (compute-direct-slot-definition-initargs)
  (effective-slot-definition-class, compute-effective-slot-definition):
  New definitions.
  (build-slots-list): Adapt to slots being <slot> objects.
  (compute-get-n-set): New boot definition.
  (allocate-slots): New definition.  Replaces
  compute-getters-n-setters.
  (%compute-layout, %prep-layout): Adapt to changes.
  (make-standard-class): Make <slot> objects for direct-slots, and
  handle the allocate-slots protocol.
  (<foreign-slot>): Inherit from <slot>.
  (get-slot-value-using-name, set-slot-value-using-name!)
  (test-slot-existence): Adapt to using slot definition objects.
  (make-class): Allow slot specs or <slot> objects as the `slots'
  argument.
  (write): New method on <slot>.
  (class-slot-ref, class-slot-set!): Reimplement.
  (compute-slot-accessors, compute-getter-method)
  (compute-setter-method): Adapt to changes.
  (compute-getters-n-setters): Remove.  Yay!
  (compute-get-n-set): Adapt to use effective slot definitions instead
  of the getters-n-setters for #:class / #:each-subclass allocation.
  (%initialize-object): Adapt.
  (initialize): New method for <slot>.  Adapt method for <class>.

* module/oop/goops/active-slot.scm (compute-get-n-set):
* module/oop/goops/composite-slot.scm (compute-propagated-get-n-set):
  Use slot-definition-options to access options of slot.

* test-suite/tests/goops.test ("bad init-thunk"): Fix to be a "pass-if"
  instead of an "expect-fail".

5 years agoBeginnings of <slot> slot definition class
Andy Wingo [Fri, 16 Jan 2015 14:44:48 +0000 (15:44 +0100)]
Beginnings of <slot> slot definition class

* module/oop/goops.scm (define-macro-folder): Factor out this helper.
  (fold-class-slots): Implement using define-macro-folder.
  (fold-slot-slots): New definition, for slots of <slot-definition>.
  (define-slot-indexer): New helper.  Use to define indexes for slots of
  <class> and of <slot>.

5 years agoThe GOOPS "unbound" value is a unique pair
Andy Wingo [Fri, 16 Jan 2015 12:50:21 +0000 (13:50 +0100)]
The GOOPS "unbound" value is a unique pair

* libguile/goops.c (SCM_GOOPS_UNBOUND, SCM_GOOPS_UNBOUNDP): Remove
  internal macros.
  (scm_make_unbound, scm_unbound_p): Remove internal functions.
  (scm_sys_clear_fields_x): Add "unbound" parameter, for the init
  value.

* module/oop/goops.scm (*unbound*): Define in Scheme as a simple
  heap-allocated value.
  (unbound?): New definition.
  (%allocate-instance): Pass *unbound* to %clear-fields!.
  (make-class, slot-definition-init-value)
  (slot-definition-init-form, make-closure-variable): Use *unbound*
  instead of (make-unbound), which is now gone.

* module/oop/goops/active-slot.scm (compute-get-n-set): Use *unbound*
  instead of make-unbound.  This module uses the GOOPS internals module;
  perhaps we should export make-unbound or something...

* module/oop/goops/save.scm (make-unbound): Export our own make-unbound
  definition, for use by residualized save code.

* module/language/ecmascript/base.scm (<undefined>, *undefined*): Use a
  unique object kind and instance for the undefined value.

* libguile/vm.c (scm_i_vm_mark_stack): Fill the stack with
  SCM_UNSPECIFIED instead of SCM_UNBOUND.

5 years agoGOOPS: Deprecate "using-class" procs like slot-ref-using-class
Andy Wingo [Fri, 16 Jan 2015 12:18:05 +0000 (13:18 +0100)]
GOOPS: Deprecate "using-class" procs like slot-ref-using-class

* libguile/deprecated.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/deprecated.c (scm_slot_ref_using_class):
  (scm_slot_set_using_class_x):
  (scm_slot_bound_using_class_p):
  (scm_slot_exists_using_class_p): Deprecate.

* module/oop/goops.scm (slot-ref-using-class, slot-set-using-class!)
  (slot-bound-using-class?, slot-exists-using-class?): Deprecate.
  Change to check that `class' is indeed the class of `obj', as
  required, and then dispatch to slot-ref et al.

5 years agochange-object-class refactor
Andy Wingo [Fri, 16 Jan 2015 12:02:31 +0000 (13:02 +0100)]
change-object-class refactor

* module/oop/goops.scm (change-object-class): Refactor to use slot-ref,
  slot-bound?, and slot-set! instead of the using-class? variants.

5 years agoslot-ref, slot-set! et al bypass "using-class" variants
Andy Wingo [Fri, 16 Jan 2015 11:55:48 +0000 (12:55 +0100)]
slot-ref, slot-set! et al bypass "using-class" variants

* module/oop/goops.scm (slot-ref, slot-set!, slot-bound?, slot-exists?):
  Bypass slot-ref-using-class, slot-set-using-class!, and so on.  Those
  interfaces are public and have to check that the class is indeed a
  class, they should check that the object is an instance of the class,
  and so on, whereas if we get the class via class-of we know that the
  invariant holds.

5 years agoManipulate GOOPS vtable flags from Scheme, for speed
Andy Wingo [Fri, 16 Jan 2015 10:26:25 +0000 (11:26 +0100)]
Manipulate GOOPS vtable flags from Scheme, for speed

* libguile/goops.h: Remove unimplemented declarations of
  scm_make_next_method, scm_sys_invalidate_method_cache_x, and
  stklos_version.
  (scm_sys_invalidate_class_x): Remove helper definition.  This was
  exported in the past but shouldn't have been.

* libguile/goops.c (scm_sys_make_vtable_vtable): Rename from
  scm_sys_make_root_class, and don't do anything about flags.
  (scm_sys_bless_applicable_struct_vtables_x, scm_class_p)
  (scm_sys_invalidate_class_x): Remove; we do these in Scheme now.
  (scm_init_goops_builtins): Define Scheme values for vtable flags.

* module/oop/goops.scm (vtable-flag-goops-metaclass)
  (class-add-flags!, class-clear-flags!, class-has-flags?)
  (class?, instance?): New definitions.
  (<class>): Add GOOPS metaclass flags from Scheme.
  (<applicable-struct-class>, <applicable-struct-with-setter-class>):
  Add flags from Scheme.
  (make, initialize): Add class flags as appropriate.
  (class-redefinition): Clear the "valid" flag on the old class.
  (check-slot-args): Use instance? instead of a CPL check.

5 years agoGOOPS class slot indices defined as inline values
Andy Wingo [Fri, 16 Jan 2015 09:20:17 +0000 (10:20 +0100)]
GOOPS class slot indices defined as inline values

* module/oop/goops.scm (define-class-index): Define as inline values.

5 years ago`match' refactor in goops.scm
Andy Wingo [Fri, 16 Jan 2015 09:19:47 +0000 (10:19 +0100)]
`match' refactor in goops.scm

* module/oop/goops.scm (compute-dispatch-procedure): Use `match'.

5 years agoConvert emit-linear-dispatch to use match
Andy Wingo [Wed, 14 Jan 2015 19:43:35 +0000 (20:43 +0100)]
Convert emit-linear-dispatch to use match

* module/oop/goops.scm (emit-linear-dispatch): Convert to use `match'.

5 years agoMore GOOPS cleanups
Andy Wingo [Wed, 14 Jan 2015 19:15:53 +0000 (20:15 +0100)]
More GOOPS cleanups

* module/oop/goops.scm (build-slots-list): Use `match'.
  (make-standard-class): Formatting fixes.

5 years agowhen and unless for one-armed ifs in goops.scm
Andy Wingo [Wed, 14 Jan 2015 19:06:35 +0000 (20:06 +0100)]
when and unless for one-armed ifs in goops.scm

* module/oop/goops.scm: Consistently use when or unless for one-armed
  ifs.