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

752 commits

Author SHA1 Message Date
Mark H Weaver
e0c211bb2e Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/posix.c
	module/ice-9/eval.scm
	test-suite/tests/cse.test
2013-01-07 17:23:26 -05:00
Ludovic Courtès
2c7b7e0f21 cse: Fix out-of-bounds access to the database.
Fixes <http://bugs.gnu.org/12883>.

* module/language/tree-il/cse.scm (cse)[find-dominating-lexical]: Fix
  computation of the last argument passed to `unroll'.
  Patch by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.
* test-suite/tests/cse.test ("cse")["http://bugs.gnu.org/12883"]: New
  test.
2012-11-21 23:51:16 +01:00
Mark H Weaver
fa980bcc0f Merge remote-tracking branch 'origin/stable-2.0'
Moved scm_i_struct_hash from struct.c to hash.c and made it static.

The port's alist is now a field of 'scm_t_port'.

Conflicts:
	libguile/arrays.c
	libguile/hash.c
	libguile/ports.c
	libguile/print.h
	libguile/read.c
2012-10-30 23:46:31 -04:00
Mark H Weaver
75a5de18a0 Simplify calls to 'eqv?' when one argument is an immediate constant.
* module/language/tree-il/primitives.scm (maybe-simplify-to-eq): New
  helper procedure shared by expanders for 'eqv?' and 'equal?'.
  (*primitive-expand-table*): Add expansion rule for 'eqv?'.

* test-suite/tests/tree-il.test ("primitives"): Add tests.
2012-10-08 11:56:10 -04:00
Mark H Weaver
bcf87e35e1 Don't simplify 'equal?' to 'not' or 'null?'.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Don't simplify 'equal?' to 'not' or 'null?', but only to 'eq?'.

* test-suite/tests/tree-il.test ("primitives"): Adjust tests.
2012-10-08 00:37:09 -04:00
Mark H Weaver
ebd363161e Don't simplify 'equal?' to 'eq?' when constant is an *inexact* small integer.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Refine test for fixnums to verify that the small integer is exact.

* test-suite/tests/tree-il.test ("primitives"): Add test.
2012-10-07 23:57:13 -04:00
Ludovic Courtès
2446f8e126 Simplify calls to `equal?' when one argument is a constant.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Add
  expansion rules for `equal?', when called with one constant and
  another argument.

* test-suite/tests/tree-il.test (pass-if-primitives-resolved): New
  macro.
  ("primitives"): New test prefix.
2012-10-06 22:34:00 +02:00
Andy Wingo
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Andy Wingo
13e3d3d95d fix `vector' instruction emission for big vectors
* module/language/glil/compile-assembly.scm (dump-constants): Only use
  the `vector' instruction for vectors whose length can fit in 16 bits.

  Fixes http://bugs.gnu.org/11087.
2012-07-05 23:26:38 +02:00
Andy Wingo
b8a5606b10 fix-letrec uses effects.scm for effects analysis
* module/language/tree-il/fix-letrec.scm: Use effects.scm for effects
  analysis, instead of primitives.scm.
  (simple-expression?, partition-vars): Adapt.
2012-07-05 20:40:56 +02:00
Andy Wingo
997ed30070 simplify one kind of degenerate prompt
* module/language/tree-il/peval.scm (<operand>): Instead of having a
  `residualize?' field, have it be a use count.
  (peval): Adapt to <operand> change.  Add function to kill uses of an
  operand.  Use it in the <prompt> inliner.  Add another kind of
  degenerate prompt to elide.  We should really switch to CPS though, as
  that will allow us to contify more aggressively.

* test-suite/tests/peval.test ("partial evaluation"): Adapt (while #t
  #t) test, which was sensitive to how far the recursive inlining got.
  Add a test for the degenerate prompt elision.
2012-07-05 20:39:16 +02:00
Andy Wingo
37081d5d4b fix bugs in effects analysis of "effect+exception-free-primitives"
* module/language/tree-il/effects.scm (make-effects-analyzer): Be more
  precise regarding the effects of the so-called
  effect+exception-free-primitives: now we check their arities.

* test-suite/tests/cse.test ("cse"): Add a test that we don't
  elide (cons 1 2 3) in effect context.
2012-07-05 20:34:28 +02:00
Andy Wingo
3d2bcd2c35 optimize (apply foo 0 (list 1 2)) => (foo 0 1 2)
* module/language/tree-il/peval.scm (peval): Inline applications where
  we know the contents of the tail.

* test-suite/tests/peval.test ("partial evaluation"): Add tests.
2012-07-05 20:30:18 +02:00
Andy Wingo
c0cfa9ef07 compile ecmascript's `return' as an abort
* module/language/ecmascript/compile-tree-il.scm (current-return-tag):
  (with-return-prompt, comp): Compile `return' as an abort instead of a
  primcall to `return'.  Fixes beta-reduction by the optimizer -- it
  doesn't make sense for `return' to move from one function to another!
2012-07-05 11:06:29 +02:00
Andy Wingo
b8bc86bce1 instead of our custom .go format, use elf
* libguile/objcodes.c: Change to expect objcode on disk to be embedded
  in ELF instead of having the funky cookie.

  (to_native_order): Use already existing SCM_BYTE_ORDER style byte
  order instead of chars.
  (bytecode_to_objcode): No need for word_size arg.
  (scm_bytecode_to_objcode, scm_objcode_to_bytecode): Take optional
  endianness arg instead of sometimes using target-endianness.
  (scm_load_objcode, scm_write_objcode, scm_bytecode_to_native_objcode):
  Remove.

* libguile/objcodes.h: Adapt.

* libguile/vm.c (scm_load_compiled_with_vm): Use
  scm_load_thunk_from_file.
  (make_boot_program): Adapt to use scm_bytecode_to_objcode with
  endianness arg.

* module/Makefile.am (OBJCODE_LANG_SOURCES): Add (language objcode
  elf).
* module/language/objcode/elf.scm: New module, embeds objcode in ELF.

* module/language/bytecode/spec.scm (compile-objcode):
  (decompile-objcode): Use (target-endianness).

* module/language/objcode/spec.scm: use (language objcode elf) for
  write-objcode.

* module/scripts/disassemble.scm (disassemble):
* module/system/repl/command.scm (disassemble-file): Use
  load-thunk-from-file.

* module/system/vm/objcode.scm: Remove load-objcode and write-objcode.

* test-suite/tests/asm-to-bytecode.test (test-target): Adapt to the new
  ELF world.
2012-06-22 13:40:50 +02:00
Andy Wingo
0dd7c54075 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/deprecated.c
	libguile/ports.c
	libguile/ports.h
	libguile/strports.c
	test-suite/tests/cse.test
2012-06-22 13:18:02 +02:00
Andy Wingo
2874f66017 add char->integer, number->string etc to interesting primitives
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*): Add string->number, number->string,
  integer->char, and char->integer to allow for constant folding and
  better effects analysis.
2012-06-22 12:33:20 +02:00
Andy Wingo
4d1ae11279 cse: expressions evaluated for effect do not provide predicates
* module/language/tree-il/cse.scm (cse): When trying to fold
  conditionals, only look at entries in the database that were added in
  test context.

* test-suite/tests/cse.test ("cse"): Add a test case.
2012-06-22 12:33:20 +02:00
Sjoerd van Leent
6b5e918e4f Fix unbound variables and unbound values
* module/language/ecmascript/base.scm: fix two wrong variable names and a wrong
  number of arguments in a function call.
2012-06-08 21:21:08 -04:00
Andy Wingo
74bbb99457 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	module/language/tree-il/analyze.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/cse.test
	test-suite/tests/peval.test
2012-05-21 19:20:27 +02:00
Andy Wingo
15bb587f45 fix arity check for applicable structs
* module/language/tree-il/analyze.scm (validate-arity): Fix for
  applicable structs.  Applicable structs are procedures, but not every
  struct has a first slot, and not every struct with a procedure in its
  first slot is applicable.  Besides, the approach in this patch gives
  better errors.
2012-05-21 18:06:34 +02:00
Andy Wingo
63216d80de cse passes a lookup procedure to the effects analyzer
* module/language/tree-il/cse.scm (cse): Arrange to pass a lookup
  procedure to compute-effects, for better effects analysis.
2012-05-15 17:23:06 +02:00
Andy Wingo
83bd53abb6 better effects analysis for calls to lexically bound procedures
* module/language/tree-il/effects.scm (make-effects-analyzer): The
  analyzer will take an optional second argument, a lookup procedure of
  type sym -> exp.  This can let the analyzer dig into calls to
  lexically bound procedures.
2012-05-15 17:22:05 +02:00
Andy Wingo
86e4479abb fix-letrec tweak
* module/language/tree-il/fix-letrec.scm (make-sequence*, fix-letrec!):
  When turning unreferenced bindings into sequences, don't bother
  emitting trivially constant expressions in effect position.
2012-05-15 17:21:02 +02:00
Andy Wingo
dc1ee62046 CSE in tail position
* module/language/tree-il/cse.scm (singly-valued-expression?, cse):
  Allow CSE to propagate lexicals to tail positions, if the expression
  is singly-valued.
2012-05-15 17:20:01 +02:00
Andy Wingo
9b1750ed42 stronger conditional optimization
* module/language/tree-il/peval.scm (peval): If we can lift one common
  test, see if we can lift others as well.

* test-suite/tests/peval.test: Add a test.
2012-05-15 12:25:37 +02:00
Andy Wingo
f49fd9afd6 optimization for chain of if expressions with common tests
* module/language/tree-il/peval.scm (peval): Optimize common tests in
  chains of "if" expressions, like those generated by matchers.

* test-suite/tests/peval.test ("partial evaluation"): Add a test.
2012-05-15 12:25:37 +02:00
Andy Wingo
1fb39dc55f mvoe tree-il=? and tree-il-hash to tree-il.scm
* module/language/tree-il.scm (tree-il=?, tree-il-hash): Move these
  helpers here, from cse.scm.  Export them.

* module/language/tree-il/cse.scm (cse): Adapt accordingly.
2012-05-15 12:25:37 +02:00
Ludovic Courtès
8a74ffe88a Have -Wformat' remain quiet for any procedure called _' or `N_'.
* module/language/tree-il/analyze.scm (proc-ref?)[special?]: New
  procedure.
  Return #t for any toplevel-ref of `_'.

* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
  format string using gettext as top-level _"): New test.
2012-05-12 16:11:51 +02:00
Ludovic Courtès
2c5f0bdb0e Have `-Warity-mismatch' handle applicable structs.
* module/language/tree-il/analyze.scm (arity-analysis): Honor applicable
  structs.

* test-suite/tests/tree-il.test ("warnings")["arity
  mismatch"]("top-level applicable struct", "top-level applicable struct
  with wrong arguments"): New tests.
2012-05-12 15:58:23 +02:00
Ludovic Courtès
4c98474782 Improve special-casing of _' in -Wformat'.
* module/language/tree-il/analyze.scm (proc-ref?): Check for
  SPECIAL-NAME in the <module-ref> and <lexical-ref> cases too.

* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
  format string using gettext as module-ref _", "non-literal format
  string using gettext as lexical _"): New tests.
2012-05-12 15:31:28 +02:00
Andy Wingo
9d8a10a94c Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	test-suite/tests/cse.test
2012-04-26 23:40:57 +02:00
Andy Wingo
0ea5ba9ab9 Merge commit 'f66cbb99ee' 2012-04-26 23:36:02 +02:00
Andy Wingo
79d29f96c7 Merge commit '1cd63115be'
Conflicts:
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-04-26 23:08:14 +02:00
Andy Wingo
c46e0a8a59 Merge commit 'de1eb420a5'
Conflicts:
	module/language/tree-il/primitives.scm
	test-suite/tests/tree-il.test
2012-04-26 22:56:45 +02:00
Andy Wingo
985702f713 avoid emitting degenerate aliases in peval
* module/language/tree-il/peval.scm (<operand>, make-operand)
  (make-bound-operands, peval): Avoid emitting needless aliases in
  degenerate cases of let.
  (visit-operand): If we visit an operand with a fresh counter and have
  to abort, record that fact.

* test-suite/tests/peval.test ("partial evaluation"): Add a test.
2012-04-23 21:52:25 +02:00
Andy Wingo
f66cbb99ee new pass: cse
* module/language/tree-il/cse.scm: New pass, some simple common
  subexpression elimination with effects analysis.

* test-suite/tests/cse.test: New test.

* test-suite/Makefile.am:
* module/Makefile.am: Adapt.
2012-04-23 21:52:24 +02:00
Andy Wingo
73001b06f6 fix replacement of CSE with lexical-ref
* module/language/tree-il/cse.scm (cse): Fix dominator unrolling for
  lexical propagation.

* test-suite/tests/cse.test ("cse"): Add test.
2012-04-23 21:52:24 +02:00
Andy Wingo
a36e7870c3 peval uses effects analysis
* module/language/tree-il/peval.scm: Use effects analysis from (language
  tree-il effects) instead of our own constant-expression?.  Eagerly
  mark assigned lexicals as non-copyable.
2012-04-23 21:52:24 +02:00
Andy Wingo
3db8f60977 cse hashing tweak
* module/language/tree-il/cse.scm (cse): Minor tweak to hash depth based
  on time profile of compiling peval.scm.
2012-04-23 21:52:24 +02:00
Andy Wingo
036c366dc2 more inlining in effects.scm
* module/language/tree-il/effects.scm (define-effects)
  (&no-effects, &all-effects-but-bailout):
  (cause, &depends-on, &causes, depends-on-effects?)
  (causes-effects?, effects-commute?): Add ham-fisted inlining.
2012-04-23 21:52:24 +02:00
Andy Wingo
b3f25e6269 better primitives support for bit operations
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add lognot.
  (*effect-free-primitives*): Add ash, logand, logior, logxor, and
  lognot.
  (logior, logand): Define associative expanders.
2012-04-23 21:52:24 +02:00
Andy Wingo
9068f4f527 enable cse
* module/language/tree-il/optimize.scm: Enable CSE unless #:cse? #f is
  passed.

* test-suite/tests/tree-il.test: Disable CSE for one test.
2012-04-23 21:52:24 +02:00
Andy Wingo
da9b2b71f7 add effects
* module/language/tree-il/effects.scm: New module, for effects
  analysis.
* module/Makefile.am: Adapt.
2012-04-23 21:52:23 +02:00
Andy Wingo
5deea34d0e add more primitives and predicates to (language tree-il primitives)
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*): Add number? and char?.  Add more
  numeric predicates.  Add character comparators.  Add throw, error, and
  scm-error.
  (*primitive-accessors*): Remove struct-vtable.  Though the vtable's
  contents may change (through redefinition), its identity does not
  change.
  (*effect-free-primitives*): Put struct-vtable, number?, and char?
  here.
  (*multiply-valued-primitives*): Instead of listing singly-valued
  primitives, list multiply-valued primitives.
  (*bailout-primitives*): New list.
  (*negatable-primitives*): New alist.
  (*bailout-primitive-table*, *multiply-valued-primitive-table*)
  (*negatable-primitive-table*): New tables.
  (singly-valued-primitive?): Adapt to
  use *multiply-valued-primitive-table*.
  (bailout-primitive?, negate-primitive): New exported procedures.
2012-04-23 21:52:02 +02:00
BT Templeton
ebc30e3fde length's argument is a sequence
* module/language/elisp/boot.el (length): Use `length' if the argument
  is a list or `generalized-vector-length' otherwise.
2012-04-01 15:59:42 -04:00
Andy Wingo
c8ab29ac8e Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/procprop.c
	libguile/smob.c
	libguile/smob.h
	libguile/vm.c
	module/language/tree-il/primitives.scm
2012-03-26 00:56:29 +02:00
BT Templeton
a8004dcb4d primitive resolution for public refs
* module/language/tree-il/primitives.scm (resolve-primitives!): Resolve
  public module-refs to primitives.

* test-suite/tests/tree-il.test: New tests for primitive resolution.
2012-03-23 19:05:58 -04:00
BT Templeton
52d2472441 elisp rng
* module/language/elisp/boot.el (random): New function.
2012-03-08 17:08:30 -05:00
BT Templeton
43ff6804d6 elisp i/o
* module/language/elisp/boot.el (send-string-to-terminal)
  (read-from-minibuffer, prin1-to-string): New functions.
2012-03-08 17:08:30 -05:00