bpt/guile.git
10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Thu, 15 Aug 2013 08:09:04 +0000 (04:09 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoImprove run-time error reporting in (ice-9 match).
Mark H Weaver [Thu, 15 Aug 2013 07:59:15 +0000 (03:59 -0400)]
Improve run-time error reporting in (ice-9 match).

* module/Makefile.am: match.go depends on match.upstream.scm.

* module/ice-9/match.scm (error): Accept any number of arguments.

* module/ice-9/match.upstream.scm (match-next): Call 'error' in non-tail
  context, and include the value that failed to match in the call.

10 years agoAdapt peval.test to recent associativity fixes of numeric ops.
Mark H Weaver [Wed, 14 Aug 2013 03:34:32 +0000 (23:34 -0400)]
Adapt peval.test to recent associativity fixes of numeric ops.

* test-suite/tests/peval.test ("partial evaluation"): Adapt tests to the
  fact that arithmetic operators are now expanded into binary ops with
  left-to-right associativity.

10 years agoManual: clarify that 'append!' and 'reverse!' might not mutate.
Mark H Weaver [Wed, 14 Aug 2013 00:33:18 +0000 (20:33 -0400)]
Manual: clarify that 'append!' and 'reverse!' might not mutate.

* doc/ref/api-compound.texi (Append/Reverse): Clarify that 'append!' and
  'reverse!' are not required to modify anything.

10 years agoManual: don't promise that 'append!' will modify the existing lists.
Mark H Weaver [Tue, 13 Aug 2013 23:52:48 +0000 (19:52 -0400)]
Manual: don't promise that 'append!' will modify the existing lists.

* doc/ref/api-compound.texi (Append/Reverse): Say that 'append!' *may*
  modify the given lists, but don't promise that it will.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 13 Aug 2013 01:36:45 +0000 (21:36 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoCommon numeric operations are left-to-right associative.
Mark H Weaver [Mon, 12 Aug 2013 23:40:32 +0000 (19:40 -0400)]
Common numeric operations are left-to-right associative.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Use 'match-lambda*' instead of 'case-lambda' for pattern matching.
  (*primitive-expand-table*): In primitive expanders for '+', '*', '-',
  '/', 'logior', and 'logand', assume conventional left-to-right
  associativity.

10 years agoNumerical comparisons are not negatable.
Mark H Weaver [Mon, 12 Aug 2013 22:08:59 +0000 (18:08 -0400)]
Numerical comparisons are not negatable.

* module/language/tree-il/primitives.scm (*negatable-primitives*):
  Remove (< <= > >=) from the list of negatable primitives.

10 years agoRTL VM: Fix SCM_PACK_RTL_* macros.
Mark H Weaver [Mon, 12 Aug 2013 17:47:35 +0000 (13:47 -0400)]
RTL VM: Fix SCM_PACK_RTL_* macros.

* libguile/instructions.h (SCM_PACK_RTL_8_8_8): Fix typo.
  (SCM_PACK_RTL_16_8): Fix erroneous shift offset.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Mon, 12 Aug 2013 02:46:22 +0000 (22:46 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoBroken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.
Mark H Weaver [Mon, 12 Aug 2013 02:38:49 +0000 (22:38 -0400)]
Broken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.

* test-suite/tests/i18n.test (under-turkish-utf8-locale-or-unresolved):
  Disable tests of Turkish UTF-8 locale in FreeBSD 9.1.

10 years agoAdapt ecmascript compiler to tree-il prompt changes, again.
Mark H Weaver [Sun, 11 Aug 2013 21:18:09 +0000 (17:18 -0400)]
Adapt ecmascript compiler to tree-il prompt changes, again.

* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  The body of an escape-only prompt is no longer a thunk.  Adapt.

10 years agoVarious RTL VM and calling convention tweaks
Andy Wingo [Sun, 11 Aug 2013 14:42:06 +0000 (16:42 +0200)]
Various RTL VM and calling convention tweaks

* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Allow for
  five-word instructions, and for new instruction word types.

* libguile/vm-engine.c (RETURN_ONE_VALUE): Instead of returning the
  value in the fixed part of the call frame, return it in the same place
  multiple-value returns go: from slot 1.
  (BR_ARITHMETIC): Allow arithmetic tests to be negated.
  (rtl_vm_engine): Change calling convention to use the same location
  for single and multiple-value returns.  Renumber all instructions.

  (halt, halt/values): Fold into a single instruction (halt).
  (call): Take the location of the procedure instead of the location of
  the call frame.  Also take the number of args, and reset the sp before
  jumping to the procedure, so as to indicate the number of arguments.
  (call/values): Remove, as the new calling convention has RA == MVRA.
  (tail-call): Require the procedure to be shuffled down already, and
  take "nlocals" as an arg instead of "nargs".
  (receive, receive-values): New instructions, for receiving returned
  values from calls.
  (return-values): Rename from return/values.  Remove "values".
  (alloc-frame): Rename from reserve-locals.
  (reset-frame): New instruction.
  (drop-locals): Remove.
  (br-if-=, br-if-<, br-if-<=): Allow these instructions to be
  negatable.
  (br-if->, br-if->=): Remove.  Probably a bad idea, given NaN.
  (box-ref): Don't bother trying to do a reverse lookup -- the
  toplevel-box, module-box, and resolve instructions should handle
  that.
  (resolve): Add arg to check that the variable is bound.
  (toplevel-box, module-box): New instructions, replacing toplevel-ref,
  toplevel-set, module-ref, and module-set.

* libguile/vm.c (rtl_boot_continuation_code, rtl_values_code): Adapt to
  instruction set changes.

* module/Makefile.am: Make the assembler and disassembler dependent on
  vm-operations.h.

* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm: Adapt to instruction changes and
  new instruction word kinds.

* test-suite/tests/rtl.test: Adapt to instruction set changes.

10 years agoInline escape-only prompt bodies in the Tree-IL
Andy Wingo [Mon, 29 Jul 2013 19:55:39 +0000 (21:55 +0200)]
Inline escape-only prompt bodies in the Tree-IL

* module/language/scheme/decompile-tree-il.scm (do-decompile):
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/canonicalize.scm (canonicalize):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/peval.test ("partial evaluation"):  Partially revert
  178a40928, so that escape-only prompts explicitly inline their bodies.

10 years agoremove peval abort-in-tail-position optimization
Andy Wingo [Mon, 29 Jul 2013 19:30:49 +0000 (21:30 +0200)]
remove peval abort-in-tail-position optimization

* module/language/tree-il/peval.scm (peval): Remove abort optimization;
  the CPS compiler will do much better here, and it is complicating
  things in the meantime.

10 years agoFix inappropriate uses of scm_syserror in numbers.c.
Mark H Weaver [Sat, 10 Aug 2013 15:47:54 +0000 (11:47 -0400)]
Fix inappropriate uses of scm_syserror in numbers.c.

* libguile/numbers.c (mem2ureal, left_shift_exact_integer,
  floor_right_shift_exact_integer, round_right_shift_exact_integer):
  Use 'assert' instead of 'scm_syserror' to indicate a case that should
  never happen.

10 years agodereference-pointer: check for null pointer.
Mark H Weaver [Fri, 9 Aug 2013 22:23:56 +0000 (18:23 -0400)]
dereference-pointer: check for null pointer.

* libguile/foreign.c (scm_dereference_pointer): Check for attempts to
  dereference a null pointer.

* test-suite/tests/foreign.test ("null pointer"): Add test.

10 years agoFix numerator and denominator handling of signed zeroes and infinities.
Mark H Weaver [Fri, 9 Aug 2013 09:32:23 +0000 (05:32 -0400)]
Fix numerator and denominator handling of signed zeroes and infinities.

* libguile/numbers.c (scm_numerator, scm_denominator): Handle signed
  zeroes and infinities in accordance with the corresponding R6RS flonum
  procedures.

* module/rnrs/arithmetic/flonums.scm (flnumerator, fldenominator):
  Remove special handling of infinities.

* test-suite/tests/numbers.test (numerator, denominator): Add tests.
  Convert existing tests to use 'pass-if-equal'.

* test-suite/tests/r6rs-arithmetic-flonums.test (flnumerator): Fix
  broken test of (flnumerator -0.0).

10 years agoEliminate use of deprecated 'SCM_WTA_DISPATCH_2' in numbers.c.
Mark H Weaver [Thu, 8 Aug 2013 06:19:46 +0000 (02:19 -0400)]
Eliminate use of deprecated 'SCM_WTA_DISPATCH_2' in numbers.c.

* libguile/numbers.c (scm_gcd): Use 'scm_wta_dispatch_2' not
  'SCM_WTA_DISPATCH_2'.

10 years agoFix --without-threads and SCM_DEBUG_TYPING_STRICTNESS==2 builds.
Mark H Weaver [Thu, 8 Aug 2013 05:23:04 +0000 (01:23 -0400)]
Fix --without-threads and SCM_DEBUG_TYPING_STRICTNESS==2 builds.

* libguile/hashtab.c (scm_hashv_ref, scm_hashv_set_x,
  scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x, scm_hash_remove_x):
* libguile/strports.c (scm_mkstrport):
* libguile/weak-vector.c (weak_vector_ref): Add missing SCM_UNPACK.

* libguile/ports.c (lock_port, unlock_port): Cast MUTEX to the
  expected type.

10 years agoDecompiler: fix handling of empty 'case-lambda' expressions.
Mark H Weaver [Wed, 7 Aug 2013 09:54:15 +0000 (05:54 -0400)]
Decompiler: fix handling of empty 'case-lambda' expressions.

* module/language/scheme/decompile-tree-il.scm (choose-output-names):
  A <lambda> with no <lambda-case> decompiles into a 'case-lambda'
  primitive.  Ensure that 'case-lambda' is not shadowed by a lexical.

10 years agoAdapt ecmascript compiler to recent tree-il changes for prompts.
Mark H Weaver [Wed, 7 Aug 2013 07:13:11 +0000 (03:13 -0400)]
Adapt ecmascript compiler to recent tree-il changes for prompts.

* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  Adapt to the changes in 178a40928ab5221f6ce57c5af1067abe30a342b3.
  Prompt tree-il nodes now contain an explicit 'escape-only?' flag, and
  the body and handler are now both lambdas.

10 years agoString ports use UTF-8; ignore %default-port-encoding.
Mark H Weaver [Wed, 7 Aug 2013 04:46:34 +0000 (00:46 -0400)]
String ports use UTF-8; ignore %default-port-encoding.

* libguile/strports.c (scm_mkstrport): Use UTF-8; ignore
  %default-port-encoding.  Rename 'str_len' and 'c_pos' to
  'num_bytes' and 'c_byte_pos'.  Interpret 'pos' argument
  as a character index instead of a byte index.

* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-6 to the
  list of core features.

* module/srfi/srfi-6.scm (open-input-string, open-output-string): Simply
  re-export these, since the core versions are now compliant.

* doc/ref/api-io.texi (String Ports): Remove text that describes
  non-compliant behavior of string ports with regard to encoding.

* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-6 to the list of
  core features.
  (SRFI-6): Remove text that mentions non-compliant behavior of
  core string ports.

* module/ice-9/format.scm (format):
* module/ice-9/pretty-print.scm (truncated-print):
* module/rnrs/io/ports.scm (open-string-input-port,
  open-string-output-port):
* test-suite/test-suite/lib.scm (format-test-name):
* test-suite/tests/chars.test ("combining accent is pretty-printed",
  "combining X is pretty-printed"):
* test-suite/tests/ecmascript.test (eread, eread/1):
* test-suite/tests/rdelim.test:
* test-suite/tests/reader.test (read-string):
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-105.test (read-string): Don't set
  %default-port-encoding before creating string ports.

* benchmark-suite/benchmarks/ports.bm (%latin1-port): Use
  'set-port-encoding!' to set the string port encoding.
  (%utf8/ascii-port, %utf8/wide-port, "rdelim"): Don't set
  %default-port-encoding before creating string ports.

* test-suite/tests/r6rs-ports.test ("lookahead-u8 non-ASCII"): Don't set
  %default-port-encoding before creating string ports.
  ("put-bytevector with UTF-16 string port", "put-bytevector with
  wrong-encoding string port"): Use 'set-port-encoding!' to set the
  string port encoding.

* test-suite/tests/print.test (tprint): Use 'set-port-encoding!' to set
  the string port encoding.
  ("truncated-print"): Use 'pass-if-equal'.

* test-suite/tests/ports.test ("encoding failure leads to exception",
  "%default-port-encoding is honored", "peek-char [latin-1]", "peek-char
  [utf-8]", "peek-char [utf-16]"): Remove tests.
  ("%default-port-encoding is ignored", "peek-char"): Add tests.
  ("suitable encoding [latin-1]", "suitable encoding [latin-3]",
  "wrong encoding, error", "wrong encoding, substitute",
  "wrong encoding, escape"): Use 'set-port-encoding!' to set the
  string port encoding.
  ("%default-port-encoding, wrong encoding"): Rewrite to use
  a file port instead of a string port.

10 years agoFix display of symbols containing backslashes.
David Kastrup [Tue, 6 Aug 2013 22:01:54 +0000 (18:01 -0400)]
Fix display of symbols containing backslashes.

Fixes <http://bugs.gnu.org/15033>.

* libguile/print.c (print_extended_symbol): Double print backslashes.

Signed-off-by: Mark H Weaver <mhw@netris.org>
10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 6 Aug 2013 21:37:34 +0000 (17:37 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/numbers.c
libguile/vm-i-scheme.c

10 years agoAdd files from 'copysign' and 'isfinite' Gnulib modules.
Mark H Weaver [Tue, 6 Aug 2013 21:16:04 +0000 (17:16 -0400)]
Add files from 'copysign' and 'isfinite' Gnulib modules.

* lib/copysign.c:
* lib/isfinite.c:
* lib/isnanf-nolibm.h:
* lib/isnanl-nolibm.h:
* lib/signbitd.c:
* lib/signbitf.c:
* lib/signbitl.c:
* m4/copysign.m4:
* m4/isfinite.m4:
* m4/signbit.m4: New files.

10 years agoRTL VM: Avoid untagging inums in 'logand' and 'logior'.
Mark H Weaver [Tue, 6 Aug 2013 21:03:56 +0000 (17:03 -0400)]
RTL VM: Avoid untagging inums in 'logand' and 'logior'.

* libguile/vm-engine.c (logand, logior): Avoid untagging.

10 years agoRTL VM: Avoid signed overflows in 'add1' and 'sub1'.
Mark H Weaver [Tue, 6 Aug 2013 21:00:23 +0000 (17:00 -0400)]
RTL VM: Avoid signed overflows in 'add1' and 'sub1'.

* libguile/vm-engine.c (INUM_MIN, INUM_MAX): Redefine without making
  assumptions about the representation.
  (INUM_STEP): New macro.
  (add1, sub1): Avoid signed overflows, and use INUM_STEP.

10 years agoRTL VM: ash: Use SCM_SRS and fix large right shifts in fast path.
Mark H Weaver [Tue, 6 Aug 2013 20:51:41 +0000 (16:51 -0400)]
RTL VM: ash: Use SCM_SRS and fix large right shifts in fast path.

* libguile/vm-engine.c (ash): Use SCM_SRS, and handle large right
  shifts properly.

10 years agoVM: ash: Use SCM_SRS and handle large right shift in fast path.
Mark H Weaver [Tue, 6 Aug 2013 20:38:32 +0000 (16:38 -0400)]
VM: ash: Use SCM_SRS and handle large right shift in fast path.

* libguile/vm-i-scheme.c (ash): Use SCM_SRS.  Handle inum right shift by
  more than SCM_I_FIXNUM_BIT-1 bits in fast path.

10 years agoUse Gnulib's 'isfinite' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:26:46 +0000 (16:26 -0400)]
Use Gnulib's 'isfinite' in numbers.c.

* libguile/numbers.c (DOUBLE_IS_FINITE, DOUBLE_IS_POSITIVE_INFINITY,
  DOUBLE_IS_NEGATIVE_INFINITY): Remove.
  (scm_odd_p, scm_even_p, scm_finite_p, icmplx2str, scm_rational_p,
  scm_inexact_to_exact): Use 'isfinite' instead of 'DOUBLE_IS_FINITE'.

10 years agoUse Gnulib's 'copysign' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:21:26 +0000 (16:21 -0400)]
Use Gnulib's 'copysign' in numbers.c.

* libguile/numbers.c (double_is_non_negative_zero): Remove.
  (idbl2str, scm_max, scm_min, scm_angle, log_of_shifted_double,
  scm_log10): Use 'copysign' to check signs of zeroes,
  instead of 'double_is_non_negative_zero'.

10 years agoImport 'copysign' and 'isfinite' modules from Gnulib.
Mark H Weaver [Tue, 6 Aug 2013 19:56:32 +0000 (15:56 -0400)]
Import 'copysign' and 'isfinite' modules from Gnulib.

* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Add 'copysign' and 'isfinite' Gnulib modules.

10 years agoVM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".
Mark H Weaver [Sun, 4 Aug 2013 23:39:43 +0000 (19:39 -0400)]
VM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Clobber _CX not "rcx".

10 years agoVM: Define ASM_MUL on ARM only if SMULL instruction is supported.
Mark H Weaver [Sun, 4 Aug 2013 22:01:52 +0000 (18:01 -0400)]
VM: Define ASM_MUL on ARM only if SMULL instruction is supported.

* libguile/vm-i-scheme.c (ASM_MUL): Define only if the target
  architecture is known to implement the SMULL instruction.

10 years agoVM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.
Mark H Weaver [Fri, 2 Aug 2013 00:31:21 +0000 (20:31 -0400)]
VM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB, ASM_MUL): Implement for ARM.

10 years agoVM: Avoid untagging inums in 'logand' and 'logior'.
Mark H Weaver [Thu, 1 Aug 2013 19:31:39 +0000 (15:31 -0400)]
VM: Avoid untagging inums in 'logand' and 'logior'.

* libguile/vm-i-scheme.c (logand, logior): Avoid untagging.

10 years agoVM: Add ASM_MUL for x86.
Mark H Weaver [Sat, 3 Aug 2013 19:05:59 +0000 (15:05 -0400)]
VM: Add ASM_MUL for x86.

* libguile/vm-i-scheme.c (ASM_MUL): New macro.
  (mul): Use ASM_MUL if available.

10 years agoVM: Support 32-bit x86 in ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:58:28 +0000 (14:58 -0400)]
VM: Support 32-bit x86 in ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (_CX): New macro.
  (ASM_ADD, ASM_SUB): Replace references to "rcx" with _CX.

10 years agoVM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:59:54 +0000 (14:59 -0400)]
VM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Add "cc" to the clobber
  list.  Suggested by Göran Weinholt <goran@weinholt.se>.

10 years agoVM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.
Mark H Weaver [Sat, 3 Aug 2013 18:51:07 +0000 (14:51 -0400)]
VM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.

* libguile/vm-i-scheme.c (ASM_ADD): Remove the tag from one of the
  operands before adding, to avoid overflow when the result is the most
  positive fixnum.

10 years agoVM: Avoid signed overflows in 'add1' and 'sub1'.
Mark H Weaver [Sat, 3 Aug 2013 18:46:40 +0000 (14:46 -0400)]
VM: Avoid signed overflows in 'add1' and 'sub1'.

* libguile/vm-i-scheme.c (INUM_STEP): New macro.
  (add1, sub1): Avoid signed overflows, and use INUM_STEP.

10 years agoVM: Redefine INUM_MIN and INUM_MAX without assumptions.
Mark H Weaver [Thu, 1 Aug 2013 18:01:58 +0000 (14:01 -0400)]
VM: Redefine INUM_MIN and INUM_MAX without assumptions.

* libguile/vm-i-scheme.c (INUM_MIN, INUM_MAX): Redefine to avoid
  assumptions about the representation of inums.

10 years agoAdd 'scm_i_from_double' and use it.
Mark H Weaver [Thu, 1 Aug 2013 17:50:41 +0000 (13:50 -0400)]
Add 'scm_i_from_double' and use it.

* libguile/numbers.c (scm_i_from_double): New static function.
  (scm_from_double): Just call 'scm_i_from_double'.
  (scm_inf, scm_nan, scm_abs, scm_i_inexact_floor_quotient,
  scm_i_inexact_floor_remainder, scm_i_inexact_floor_divide,
  scm_i_inexact_ceiling_quotient, scm_i_inexact_ceiling_remainder,
  scm_i_inexact_ceiling_divide, scm_i_inexact_truncate_quotient,
  scm_i_inexact_truncate_remainder, scm_i_inexact_truncate_divide,
  scm_i_inexact_centered_quotient, scm_i_inexact_centered_remainder,
  scm_i_inexact_centered_divide, scm_i_inexact_round_quotient,
  scm_i_inexact_round_remainder, scm_i_inexact_round_divide,
  scm_max, scm_min, scm_sum, scm_difference, scm_product,
  scm_divide, scm_truncate_number, scm_round_number, scm_floor,
  scm_ceiling, scm_expt, scm_sin, scm_cos, scm_tan, scm_sinh,
  scm_cosh, scm_tanh, scm_asin, scm_acos, scm_atan, scm_sys_asinh,
  scm_sys_acosh, scm_sys_atanh, scm_real_part, scm_imag_part,
  scm_magnitude, scm_angle, scm_exact_to_inexact, log_of_shifted_double,
  log_of_fraction, scm_log10, scm_exp, scm_sqrt, scm_init_numbers):
  Use 'scm_i_from_double' instead of 'scm_from_double'.

10 years agoRTL instructions have no rest args
Andy Wingo [Sun, 21 Jul 2013 15:11:18 +0000 (17:11 +0200)]
RTL instructions have no rest args

* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE):
* module/system/vm/assembler.scm (assembler):
* module/system/vm/disassembler.scm (disassembler): Remove support for
  RTL instructions with rest args.

10 years agoUse allocate-struct in define-record-type implementations
Andy Wingo [Sun, 21 Jul 2013 15:06:41 +0000 (17:06 +0200)]
Use allocate-struct in define-record-type implementations

* module/ice-9/boot-9.scm (iota): Move up.
  (make-record-type, define-record-type): Use allocate-struct and
  struct-set!.

* module/srfi/srfi-9.scm (%%set-fields, %define-record-type): Use
  allocate-struct and struct-set!.

Note that this makes the stack VM slower, but it will make RTL
compilation faster.

10 years agoadd allocate-struct primitive and rtl opcode
Andy Wingo [Sun, 21 Jul 2013 14:17:59 +0000 (16:17 +0200)]
add allocate-struct primitive and rtl opcode

* libguile/struct.h:
* libguile/struct.c (scm_allocate_struct): New interface: allocates a
  struct.

* libguile/vm-engine.c (allocate_struct): Instead of make-struct with a
  rest arg, separate allocation from initialization.

10 years agoabort is no longer an op with rest args
Andy Wingo [Sun, 21 Jul 2013 10:54:36 +0000 (12:54 +0200)]
abort is no longer an op with rest args

* libguile/vm-engine.c (abort): No longer an op with rest args.

10 years agocall is no longer a vararg instruction
Andy Wingo [Sat, 20 Jul 2013 21:10:36 +0000 (23:10 +0200)]
call is no longer a vararg instruction

* libguile/vm-engine.c (push_frame, call): Separate out push_frame from
  call, and expect the caller to arrange the proc and arguments.

* test-suite/tests/rtl.test ("call"): Update tests.

10 years agoRTL: Local 0 is the procedure
Andy Wingo [Sat, 20 Jul 2013 18:05:13 +0000 (20:05 +0200)]
RTL: Local 0 is the procedure

* libguile/vm-engine.c: Change the RTL VM to number the procedure as
  local 0, and other locals from 1.  In the future we will want the FP
  to point to local 0 instead of local 1.  In the future also we can
  elide the procedure for well-known closures (closures in which all
  references are known call sites).
  (make_closure, free_set): Instead of taking rest arguments, we add a
  new free-set! op that initializes closures.
  (free_ref): Take the closure as an argument.

* libguile/vm.c (rtl_boot_continuation_code): Remove comments, which
  were out of date.
  (rtl_apply_code, rtl_values_code): Update comments.

* module/system/vm/assembler.scm (intern-constant, emit-init-constants):
  Adapt to locals numbering change.
  (begin-kw-arity): For assert-nargs-ee purposes, nreq includes the
  procedure.

* module/system/vm/disassembler.scm (code-annotation): Adapt annotation
  for assert-nargs-ee/locals.

* test-suite/tests/rtl.test: Adapt tests.

10 years agortl: propagate OP_DST to scheme
Andy Wingo [Fri, 19 Jul 2013 07:55:20 +0000 (09:55 +0200)]
rtl: propagate OP_DST to scheme

* libguile/instructions.c (scm_rtl_instruction_list): Add an element to
  the list to indicate that an instruction outputs to its first
  argument.

* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm: Adapt.

10 years agofree variable debugging access procedures for rtl
Andy Wingo [Fri, 19 Jul 2013 14:21:18 +0000 (16:21 +0200)]
free variable debugging access procedures for rtl

* libguile/programs.c (scm_program_num_free_variables)
  (scm_program_free_variable_ref, scm_program_free_variable_set_x): Add
  support for RTL programs.

10 years agofix rtl program arity functions
Andy Wingo [Fri, 19 Jul 2013 14:19:34 +0000 (16:19 +0200)]
fix rtl program arity functions

* libguile/programs.c (parse_arity): Lookup rtl-program-minimum-arity
  from (system vm debug).

* module/system/vm/debug.scm (find-first-arity): Fix the linear search.
  Whoops!

10 years agoOptimize R6RS bitwise operators.
Mark H Weaver [Sun, 21 Jul 2013 14:00:48 +0000 (10:00 -0400)]
Optimize R6RS bitwise operators.

* module/rnrs/arithmetic/bitwise.scm (bitwise-if, bitwise-length,
  bitwise-first-bit-set, bitwise-bit-field, bitwise-reverse-bit-field):
  Replace these with aliases to the identical SRFI-60 operators
  'bitwise-if', 'integer-length', 'first-set-bit', 'bit-field', and
  'reverse-bit-field'.

  (bitwise-copy-bit, bitwise-copy-bit-field, bitwise-rotate-bit-field):
  Reimplement these based upon the similar SRFI-60 operators 'copy-bit',
  'copy-bit-field', and 'rotate-bit-field'.

* test-suite/tests/r6rs-arithmetic-bitwise.test (bitwise-copy-bit): Fix
  test to conform to the specification, which requires the third
  argument to be either 0 or 1.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fxcopy-bit): Fix test
  to conform to the specification, which requires the third argument to
  be either 0 or 1.

10 years agoFix incorrect rationalize tests.
Mark H Weaver [Sun, 21 Jul 2013 12:09:46 +0000 (08:09 -0400)]
Fix incorrect rationalize tests.

* test-suite/tests/fractions.test (fractions): Fix rationalize tests.

10 years agoFix minor formatting error in 'rationalize'.
Mark H Weaver [Sun, 21 Jul 2013 11:20:03 +0000 (07:20 -0400)]
Fix minor formatting error in 'rationalize'.

* libguile/numbers.c (scm_rationalize): Fix formatting.

10 years agoRewrite 'rationalize' to fix bugs and improve efficiency.
Mark H Weaver [Sat, 20 Jul 2013 16:29:02 +0000 (12:29 -0400)]
Rewrite 'rationalize' to fix bugs and improve efficiency.

Fixes <http://bugs.gnu.org/14905>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_rationalize): Rewrite.  Previously an
  incorrect algorithm was used which failed in many cases.

* test-suite/tests/numbers.test (rationalize): Add tests.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Thu, 18 Jul 2013 19:31:34 +0000 (15:31 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoModify SCM_UNPACK type check to avoid warnings in clang.
Mark H Weaver [Thu, 18 Jul 2013 18:10:43 +0000 (14:10 -0400)]
Modify SCM_UNPACK type check to avoid warnings in clang.

* libguile/tags.h (SCM_UNPACK): Change (*(SCM*)0=(x)) to
  (*(volatile SCM *)0=(x)), to avoid null-dereference warnings
  from clang.  Reported by Shane Celis <shane.celis@gmail.com>.

10 years agoFix 'SCM_SYSCALL' to really swallow EINTR.
Ludovic Courtès [Wed, 17 Jul 2013 15:57:43 +0000 (17:57 +0200)]
Fix 'SCM_SYSCALL' to really swallow EINTR.

* libguile/_scm.h (SCM_SYSCALL): Keep looping upon EINTR.
  Reported at
  <http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.

10 years agobuild: Add `gdbinit' to the distribution.
Ludovic Courtès [Wed, 17 Jul 2013 13:11:51 +0000 (15:11 +0200)]
build: Add `gdbinit' to the distribution.

* Makefile.am (EXTRA_DIST): Add gdbinit.

10 years agoAdd support for HTTP proxies.
Mark H Weaver [Fri, 7 Jun 2013 04:47:33 +0000 (00:47 -0400)]
Add support for HTTP proxies.

* module/web/http.scm (http-proxy-port?, set-http-proxy-port?!): New
  exported procedures.
  (write-request-line): If we're using an http proxy, write an
  absolute-URI in the request line.

* module/web/client.scm: Import (web http).
  (current-http-proxy): New exported parameter.
  (open-socket-for-uri): If 'current-http-proxy' is not false,
  connect to the proxy instead of the URI host, and use
  'set-http-proxy-port?!' to make note of that fact.

* doc/ref/web.texi (Web Client): Document 'current-http-proxy'.

10 years agoFix R6RS 'fixnum-width'.
Mark H Weaver [Tue, 16 Jul 2013 21:38:14 +0000 (17:38 -0400)]
Fix R6RS 'fixnum-width'.

Fixes <http://bugs.gnu.org/14879>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Rewrite to avoid
  inexact arithmetic, and correct the off-by-one error.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fixnum-width): Add
  tests.

10 years agoUpdate copyright dates of recently-changed R6RS bitwise/flonums files.
Mark H Weaver [Tue, 16 Jul 2013 16:12:25 +0000 (12:12 -0400)]
Update copyright dates of recently-changed R6RS bitwise/flonums files.

* module/rnrs/arithmetic/bitwise.scm:
  module/rnrs/arithmetic/flonums.scm:
  test-suite/tests/r6rs-arithmetic-bitwise.test:
  test-suite/tests/r6rs-arithmetic-flonums.test: Add 2013 to the
  copyright dates.

10 years agoFix 'fxbit-count' for negative arguments.
Mark H Weaver [Tue, 16 Jul 2013 16:06:45 +0000 (12:06 -0400)]
Fix 'fxbit-count' for negative arguments.

Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/fixnums.scm (fxbit-count): If the argument is
  negative, return the 'bitwise-not' of the result of 'logcount', as per
  R6RS.  Previously, 'fxbit-count' was identical to 'logcount'.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fxbit-count): Add test.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 16 Jul 2013 10:49:20 +0000 (06:49 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/numbers.c

10 years agogcd and lcm support inexact integer arguments.
Mark H Weaver [Tue, 16 Jul 2013 10:38:38 +0000 (06:38 -0400)]
gcd and lcm support inexact integer arguments.

Fixes <http://bugs.gnu.org/14870>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_gcd, scm_lcm): Support inexact integers.

* test-suite/tests/numbers.test (gcd, lcm): Add tests.

10 years agomin and max: NaNs beat infinities, per R6RS errata.
Mark H Weaver [Tue, 16 Jul 2013 09:18:15 +0000 (05:18 -0400)]
min and max: NaNs beat infinities, per R6RS errata.

Fixes <http://bugs.gnu.org/14865>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
  the R6RS errata.

* test-suite/tests/numbers.test (min, max): Update tests.

10 years agoFlonum operations always return flonums.
Mark H Weaver [Tue, 16 Jul 2013 08:43:07 +0000 (04:43 -0400)]
Flonum operations always return flonums.

Fixes <http://bugs.gnu.org/14871>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (ensure-flonum): New procedure.
  (fllog): Rewrite using case-lambda.  Handle negative zeroes.  Use
  'ensure-flonum'.
  (flatan): Rewrite using case-lambda.
  (flasin, flacos, flsqrt, flexpt): Use 'ensure-flonum'.

* test-suite/tests/r6rs-arithmetic-flonums.test
  (fllog, flasin, flacos, flsqrt, flexpt): Add tests.

10 years agoflfinite? applied to a NaN returns false.
Mark H Weaver [Tue, 16 Jul 2013 07:42:52 +0000 (03:42 -0400)]
flfinite? applied to a NaN returns false.

Fixes <http://bugs.gnu.org/14868>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (flfinite?): If the argument is a
  NaN, return false.

* test-suite/tests/r6rs-arithmetic-flonums.test (flfinite?): Add test.

10 years agoflonum? returns false for complex number objects.
Mark H Weaver [Tue, 16 Jul 2013 07:38:27 +0000 (03:38 -0400)]
flonum? returns false for complex number objects.

Fixes <http://bugs.gnu.org/14866>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (flonum?): Use 'real?' instead of
  'number?'.

* test-suite/tests/r6rs-arithmetic-flonums.test (flonum?): Add tests.

10 years agoAllow fl+ and fl* to accept zero arguments.
Mark H Weaver [Tue, 16 Jul 2013 07:33:02 +0000 (03:33 -0400)]
Allow fl+ and fl* to accept zero arguments.

Fixes <http://bugs.gnu.org/14869>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (fl+, fl*): Accept zero arguments.

* test-suite/tests/r6rs-arithmetic-flonums.test (fl+, fl*): Add tests.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 16 Jul 2013 05:48:19 +0000 (01:48 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agonumbers.test: Fix inum/flonum comparison test on 32-bit machines.
Mark H Weaver [Tue, 16 Jul 2013 05:46:05 +0000 (01:46 -0400)]
numbers.test: Fix inum/flonum comparison test on 32-bit machines.

* test-suite/tests/numbers.test (<): Fix inum/flonum test.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 16 Jul 2013 05:33:27 +0000 (01:33 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/keywords.c
libguile/vm.c

10 years agoAvoid lossy conversion from inum to double in numerical comparisons.
Mark H Weaver [Tue, 16 Jul 2013 04:26:11 +0000 (00:26 -0400)]
Avoid lossy conversion from inum to double in numerical comparisons.

* libguile/numbers.c (scm_less_p): Avoid converting inums to doubles.

* test-suite/tests/numbers.test (<): Add tests.

10 years agonumbers.test: Avoid inexact arithmetic in computation of fixnum-bit.
Mark H Weaver [Tue, 16 Jul 2013 04:22:10 +0000 (00:22 -0400)]
numbers.test: Avoid inexact arithmetic in computation of fixnum-bit.

* test-suite/tests/numbers.test (fixnum-bit): Rewrite to avoid
  inexact arithmetic.

10 years agoFix bugs in numerical equality predicate.
Mark H Weaver [Tue, 16 Jul 2013 04:18:40 +0000 (00:18 -0400)]
Fix bugs in numerical equality predicate.

* libguile/numbers.c (scm_num_eq_p): Fix bug comparing fractions to
  infinities (reported by Göran Weinholt <goran@weinholt.se>).  Fix
  erroneous comment describing the logic behind inum/flonum comparison.
  Use similar logic for inum/complex comparison to avoid rounding
  errors.  Make minor indentation fixes and simplifications.

* test-suite/tests/numbers.test (=): Add tests.

10 years agoFix rounding in scm_i_divide2double for negative arguments.
Mark H Weaver [Tue, 16 Jul 2013 04:00:23 +0000 (00:00 -0400)]
Fix rounding in scm_i_divide2double for negative arguments.

* libguile/numbers.c (INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE):
  New macro.
  (scm_i_divide2double): Use INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE to
  determine if our fast path is safe.  Previously, negative arguments
  were not checked properly.

* test-suite/tests/numbers.test (exact->inexact): Add tests.

10 years agoFix VM 'ash' for right shifts by large amounts.
Mark H Weaver [Sun, 14 Jul 2013 18:47:10 +0000 (14:47 -0400)]
Fix VM 'ash' for right shifts by large amounts.

Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/vm-i-scheme.c (ash): Fallback to 'scm_ash' for right shifts
  with counts >= SCM_I_FIXNUM_BIT, since '>>' is not guaranteed to work
  correctly for large counts.

10 years agoFix 'bitwise-bit-count' for negative arguments.
Mark H Weaver [Sun, 14 Jul 2013 18:08:33 +0000 (14:08 -0400)]
Fix 'bitwise-bit-count' for negative arguments.

Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/bitwise.scm (bitwise-bit-count): If the
  argument is negative, return the 'bitwise-not' of the result of
  'logcount', as per R6RS.  Previously, 'bitwise-bit-count' was
  identical to 'logcount'.

10 years ago<prompt> body and handler are lambdas; add escape-only? field
Andy Wingo [Sat, 6 Jul 2013 11:06:02 +0000 (20:06 +0900)]
<prompt> body and handler are lambdas; add escape-only? field

* module/language/tree-il.scm (<prompt>): Change to have the body and
  handler be lambdas, and add an "escape-only?" field.  This will make
  generic prompts work better in CPS or ANF with the RTL VM, as it
  doesn't make sense in that context to capture only part of a frame.
  Escape-only prompts can still be fully inlined.
  (parse-tree-il, unparse-tree-il): Add escape-only? to the
  serialization.
  (make-tree-il-folder, pre-post-order): Deal with escape-only?.

* module/language/tree-il/analyze.scm (analyze-lexicals): Handle
  escape-only?, and the new expectations for the body and handler.

* module/language/tree-il/canonicalize.scm (canonicalize): Ensure that
  the body of an escape-only continuation is a thunk, and that the
  handler is always a lambda.
* module/language/tree-il/debug.scm (verify-tree-il): Assert that
  escape-only? is a boolean.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
* test-suite/tests/peval.test ("partial evaluation"):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Adapt
  to <prompt> change.

10 years agoSimplify dynstack API to only wind one fluid at a time
Andy Wingo [Fri, 28 Jun 2013 18:01:35 +0000 (20:01 +0200)]
Simplify dynstack API to only wind one fluid at a time

* libguile/dynstack.h (SCM_DYNSTACK_TYPE_WITH_FLUID): Rename from
  with-fluids.
* libguile/dynstack.c (scm_dynstack_push_fluid):
  (scm_dynstack_unwind_fluid): Change API to only wind/unwind one
  fluid binding.
  (WITH_FLUID_WORDS): New define, always 2 words (fluid and value box).
  (WITH_FLUID_FLUID, WITH_FLUID_VALUE_BOX): New macros to get offsets of
  fluid and value box.
  (scm_dynstack_push_rewinder, scm_dynstack_push_unwinder): Use
  WINDER_WORDS.
  (scm_dynstack_push_dynwind): Use DYNWIND_WORDS.
  (scm_dynstack_wind_1): Update for scm_swap_fluid API change.

* libguile/fluids.h:
* libguile/fluids.c (scm_prepare_fluids): Remove; no longer needed.
  (scm_swap_fluid): Update to just swap one fluid binding.
  (scm_c_with_fluids, scm_c_with_fluid): Update to use
  scm_dynstack_push_fluid.

* libguile/memoize.c (do_push_fluid, do_pop_fluid): Adapt to API
  change.
* libguile/vm-engine.c (rtl_vm_engine): Change wind-fluids / unwind-fluids
  to push-fluid / pop-fluid, and actually enable.  Woo!

* libguile/vm-i-system.c (push-fluid, pop-fluid): Update to new API.

10 years agoRemove with-fluids; replaced by with-fluid* and inlined push-fluid primops
Andy Wingo [Fri, 28 Jun 2013 17:47:03 +0000 (19:47 +0200)]
Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops

* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
  to push-fluid, and unwind-fluids to pop-fluid.  They now only work on
  one fluid binding at a time.

* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
  primcalls to push-fluid and pop-fluid.
  (custom-throw-handler, catch, with-throw-handler): Use with-fluid*
  instead of with-fluids, as with-fluids is no longer available before
  psyntax is loaded.
  (with-fluids): Define in Scheme in terms of with-fluid*.

* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
  don't expose to Scheme.

* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
  (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
  helpers, like wind and unwind.
  (memoize): Memoize wind and unwind primcalls.  Don't memoize dynlet to
  with-fluids.
  (scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.

* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
  with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.

* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>.  Add cases for
  primcalls to push-fluid and pop-fluid in compile-glil.scm and
  effects.scm.

* module/language/tree-il/peval.scm (peval): Factor out
  with-temporaries; probably a bad idea, but works for now.  Factor out
  make-begin0 (a better idea).  Inline primcalls to with-fluid*, and
  remove dynlet cases.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Add with-fluid*.

10 years agoreplace <dynset> with primcalls to fluid-set!
Andy Wingo [Thu, 27 Jun 2013 17:38:32 +0000 (19:38 +0200)]
replace <dynset> with primcalls to fluid-set!

* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynset>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynset.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynset>.

* module/language/tree-il/analyze.scm (analyze-lexicals):

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-set!.
  (flatten-lambda-case): Remove <dynset> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynset>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynset> case.  Add a primcall fluid-set! case.

* module/language/tree-il/peval.scm (peval): Remove dynset cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-set! -> dynset transformation.

10 years agoreplace <dynref> with primcalls to fluid-ref
Andy Wingo [Thu, 27 Jun 2013 17:28:42 +0000 (19:28 +0200)]
replace <dynref> with primcalls to fluid-ref

* doc/ref/compiler.texi (Tree-IL): Remove mention of <dynref>.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynref.
* module/language/tree-il.scm (<tree-il>, parse-tree-il):
  (unparse-tree-il, make-tree-il-folder, pre-post-order): Remove
  <dynref>.

* module/language/tree-il/analyze.scm (analyze-lexicals):

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add
  fluid-ref.
  (flatten-lambda-case): Remove <dynref> case.

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il): Remove <dynref>
  cases.

* module/language/tree-il/effects.scm (make-effects-analyzer): Remove
  <dynref> case.  Add a primcall fluid-ref case.

* module/language/tree-il/peval.scm (peval): Remove dynref cases.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove fluid-ref -> dynref transformation.

10 years agodynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind
Andy Wingo [Thu, 27 Jun 2013 16:49:21 +0000 (18:49 +0200)]
dynamic-wind in terms of wind and unwind; remove <dynwind>, @dynamic-wind

* doc/ref/compiler.texi: Remove mention of <dynwind>.
* libguile/eval.c (eval): Remove SCM_M_DYNWIND case.
* libguile/expand.c: Remove scm_sym_at_dynamic_wind.
* libguile/memoize.c (do_wind, do_unwind): A couple of hacky subrs.  If
  we see a wind or unwind primcall, we expand to a call of a quoted subr
  value.  It works and removes a kind of memoized value from the
  interpreter.  For the compiler,primcalls to wind and unwind are
  handled specially.
  (MAKMEMO_DYNWIND): Remove.
  (scm_tc16_memoizer): Remove.  Yay!
  (memoize): Remove speculative lookup for toplevels to see if they are
  memoizers: there are no more memoizers.  Memoize calls to the wind and
  unwind primitives.
  (m_dynamic_wind): Remove.
  (unmemoize): Remove dynwind case.
  (scm_init_memoize): Add wind and unwind local definitions.

* module/ice-9/boot-9.scm (dynamic-wind): Reimplement in terms of "wind"
  and "unwind" primitives.  These primitives are not exposed to other
  modules.

* module/ice-9/eval.scm (primitive-eval): Remove dynwind case.
* module/language/scheme/decompile-tree-il.scm (do-decompile):
  (choose-output-names): Remove dynwind cases.

* module/language/tree-il.scm: Remove <dynwind>.  Yaaay!

* module/language/tree-il/analyze.scm (analyze-lexicals): Remove dynwind
  cases.

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add wind
  and unwind.
  (flatten-lambda-case): Remove dynwind case.  Yay!

* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (singly-valued-expression?, peval):
  Remove <dywind> cases.  Inline primcalls to dynamic-wind.  Add
  constant folding for thunk?.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Remove @dynamic-wind, and add procedure? and thunk?.
  (*effect+exception-free-primitives*): Add procedure? and thunk?.
  (*multiply-valued-primitives*): Remove @dynamic-wind.
  Remove @dynamic-wind expander.

* test-suite/tests/peval.test ("partial evaluation"): Update tests for
  dynwind desugaring.

10 years agoremove @call-with-values memoizer
Andy Wingo [Thu, 27 Jun 2013 10:20:36 +0000 (12:20 +0200)]
remove @call-with-values memoizer

* libguile/memoize.h:
* libguile/expand.c (scm_sym_at_call_with_values): Remove.

* libguile/memoize.c (memoize, m_call_values, unmemoize): Adapt to
  memoize call-with-values primcalls.

* module/ice-9/boot-9.scm (call-with-values): Expand to a
  call-with-values primcall.

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Expect
  call-with-values primcall, without the @, and fall back to a normal
  call.

* module/language/tree-il/peval.scm (peval): Match bare
  call-with-values.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*multiply-valued-primitives*): Remove @call-with-values.

10 years agoremove @call-with-current-continuation memoizer
Andy Wingo [Thu, 27 Jun 2013 10:10:37 +0000 (12:10 +0200)]
remove @call-with-current-continuation memoizer

* module/ice-9/boot-9.scm (call-with-current-continuation): Change to
  primcall call-with-current-continuation.

* libguile/memoize.h:
* libguile/expand.c (scm_sym_atcall_cc): Remove.

* libguile/memoize.c (memoize): Memoize call/cc primcalls to
  SCM_M_CONT.
  (m_call_cc): Remove.
  (unmemoize): Unmemoize to call-with-current-continuation.

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
  to call-with-current-continuation without @ prefix, and fix fallback
  case.

* module/language/tree-il/primitives.scm (*multiply-valued-primitives*):
  (*interesting-primitive-names*): Remove
  @call-with-current-continuation.
  (call/cc): Expand to call-with-current-continuation.

* test-suite/tests/tree-il.test ("call/cc"): Update to use and expect
  call-with-current-continuation primcalls / toplevel refs.

10 years agoremove apply:nconc2last
Andy Wingo [Thu, 27 Jun 2013 09:26:11 +0000 (11:26 +0200)]
remove apply:nconc2last

* libguile/eval.c (scm_nconc2last): Remove, now unused.
* doc/ref/api-evaluation.texi (Fly Evaluation): Remove docs.

10 years agoremove @apply memoizer
Andy Wingo [Thu, 27 Jun 2013 09:25:34 +0000 (11:25 +0200)]
remove @apply memoizer

* libguile/memoize.c (memoize): Recognize a primcall to 'apply as
  SCM_M_APPLY.
  (@apply): Remove @apply memoizer.
  (unmemoize): Unmemoize using "apply", not "@apply".

* libguile/memoize.h:
* libguile/expand.c (scm_sym_atapply): Remove.

* module/ice-9/boot-9.scm (apply): Re-implement using apply primcall.
  Use case-lambda, so as to give an appropriate minimum arity.

* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
  Compile a primcall of "apply" specially, not "@apply".

* module/language/tree-il/peval.scm (peval): Match primcalls to "apply",
  not "@apply".  Residualize "apply" primcalls.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*multiply-valued-primitives*): Remove @apply, and apply primitive
  expander.

* test-suite/tests/peval.test:
* test-suite/tests/tree-il.test: Update tests to expect residualized
  "apply".

* test-suite/tests/procprop.test ("procedure-arity"): Update test for
  better apply arity.

* test-suite/tests/strings.test ("string"): Update expected error.

10 years agoRemove @prompt memoizer
Andy Wingo [Tue, 25 Jun 2013 20:36:08 +0000 (22:36 +0200)]
Remove @prompt memoizer

* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_CALL_WITH_PROMPT, memoize, unmemoize):
  Remove the @prompt memoizer in favor of recognizing call-with-prompt
  primcalls.  Rename SCM_M_PROMPT to SCM_M_CALL_WITH_PROMPT, and pass a
  thunk instead of an expression so that it has normal applicative
  order.

* libguile/expand.c (PRIMITIVE_REF, PRIMCALL, expand): Produce primcalls
  from forms whose car is a primitive.
  (expand_atat): Recognize (@@ primitive FOO) as being a primitive-ref.

* module/ice-9/boot-9.scm (call-with-prompt): Instead of dispatching to
  the wonky @prompt memoizer, residualize a primcall to
  call-with-prompt.  The memoizer will DTRT to allow call-with-prompt to
  be interpreted correctly without needing an additional binding.

* module/ice-9/eval.scm (primitive-eval): Change the 'prompt clause to a
  call to call-with-prompt.

* module/language/tree-il/primitives.scm: No more need to recognize
  @prompt.

* libguile/eval.c (eval): Adapt to SCM_M_PROMPT renaming to
  SCM_M_CALL_WITH_PROMPT, and apply the thunk.

* libguile/throw.c (pre_init_throw): Adapt to scm_abort_to_prompt_star
  rename.

10 years agoabort-to-prompt* instead of @abort
Andy Wingo [Tue, 25 Jun 2013 19:53:52 +0000 (21:53 +0200)]
abort-to-prompt* instead of @abort

* libguile/control.h:
* libguile/control.c (scm_abort_to_prompt_star): Rename from
  scm_at_abort.

* module/ice-9/boot-9.scm (abort-to-prompt): Use abort-to-prompt*.

* module/language/tree-il/primitives.scm: Handle abort-to-prompt*
  instead of @abort.

10 years agopsyntax: ((@@ primitive NAME) ARG ...) in (guile) module is a primcall
Andy Wingo [Sun, 23 Jun 2013 19:36:08 +0000 (21:36 +0200)]
psyntax: ((@@ primitive NAME) ARG ...) in (guile) module is a primcall

* ice-9/psyntax.scm (@@): Recognize new form, (@@ primitive NAME), which
  in operator position expands to a primcall.  This expansion is only
  available for forms in the (guile) module.  Added an argument to @@
  and @ procedures, the module, for use by expanded syntax objects;
  adapted callers.
  (analyze-variable): Error when accessing a primitive for value.
  (get-global-definition-hook): Primitives are not macros.
  (syntax-type): A form with a primitive in the car is a
  primitive-call.
  (expand-expr): Residualize primitive calls as primcalls.
  (syntax-local-binding): Return 'primitive as the type for primitives.

10 years agoFix bug in remqueue in threads.c when removing last element.
Mark H Weaver [Mon, 17 Jun 2013 18:43:58 +0000 (14:43 -0400)]
Fix bug in remqueue in threads.c when removing last element.

Reported and debugged by Andrew Gaylard <ag@computer.org>.

* libguile/threads.c (remqueue): When removing the last element from a
  queue with more than one element, set (car q) to the previous element.

* THANKS: Thank Andrew Gaylard.

10 years agoFix #ifdefery for `setegid'.
Ludovic Courtès [Sun, 16 Jun 2013 19:47:39 +0000 (21:47 +0200)]
Fix #ifdefery for `setegid'.

* libguile/posix.c (scm_setegid): Change to #ifdef HAVE_SETEGID.

10 years agotests: Don't rely on `scm_call_2' being visible.
Ludovic Courtès [Sun, 16 Jun 2013 18:58:10 +0000 (20:58 +0200)]
tests: Don't rely on `scm_call_2' being visible.

* test-suite/tests/coverage.test ("procedure-execution-count")["called
  from C"]: Throw 'unresolved when `scm_call_2' cannot be resolved.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agoAugment `.dir-locals.el'.
Ludovic Courtès [Sun, 16 Jun 2013 18:56:31 +0000 (20:56 +0200)]
Augment `.dir-locals.el'.

10 years agotests: Remove symlink only when it exists.
Ludovic Courtès [Sun, 16 Jun 2013 14:54:12 +0000 (16:54 +0200)]
tests: Remove symlink only when it exists.

* test-suite/tests/filesys.test: Delete (test-symlink) only if it
  exists---i.e., not on Windows.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agotests: Skip FFI tests that use `qsort' when it's not accessible.
Ludovic Courtès [Sun, 16 Jun 2013 14:52:38 +0000 (16:52 +0200)]
tests: Skip FFI tests that use `qsort' when it's not accessible.

* test-suite/tests/foreign.test ("procedure->pointer")[qsort]: Wrap in
  `false-if-exception'.
  ["qsort", "qsort, wrong return type", "qsort, wrong arity"]: Throw
  'unresolved when QSORT if #f.
  Reported by Eli Zaretskii <eliz@gnu.org>.