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

20647 commits

Author SHA1 Message Date
Robin Templeton
ece0f4e782 remove uses of define-inlinable
* module/language/elisp/runtime.scm (ensure-present!, ensure-desc!)
(schemify): Remove use of `define-inlinable'.
2024-12-13 22:32:16 -05:00
Ricardo Wurmus
4b9b827773
elisp: boot: Replace removed FRAME-PROCEDURE with FRAME-PROCEDURE-NAME.
This is a follow-up to commit e139accb530c970c989b3d53d5a8a22fd75437fc.

* module/language/elisp/boot.el (backtrace-frame, guile-backtrace): Use
FRAME-PROCEDURE-NAME instead of FRAME-PROCEDURE.

(cherry picked from commit 3d7db7c2175d91629d4133ae0b79f3c9c2ce6191)
2021-10-19 18:10:05 -04:00
Ricardo Wurmus
726f34b35d
loader: Handle interned constants as well as plain bytevectors.
This is a follow-up to commit b04e79283ada9a6af05552dda6446a0934c0fbe2.

* libguile/loader.c (scm_load_thunk_from_memory): Extract constants only
if the object is a pair.

(cherry picked from commit c536c297683178e6eadc0a60d1e53f8c510db3c9)
2021-10-19 18:10:05 -04:00
Robin Templeton
e38f6377e3
temporarily disable elisp exception tests
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* test-suite/tests/elisp-compiler.test ("catch without exception" test)
  ("catch and throw" test, "unwind-protect" test): Switch from pass-if
  to expect-fail.
2021-10-19 18:10:05 -04:00
Robin Templeton
d5246bebe7
ignore 'expect-fail' forms in elisp tests
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* test-suite/tests/elisp-compiler.test (compile-test): Update to support
  expect-fail.
2021-10-19 18:10:05 -04:00
Robin Templeton
8ce962192f
update cross-compilation test
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* test-suite/tests/cross-compilation.test (test-target): Update it.
2021-10-19 18:10:05 -04:00
Robin Templeton
c53e9d0ac1
use standard evaluator
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm: Remove import of
  "(language tree-il eval)".
  (defmacro): Use standard "eval".
* module/language/elisp/runtime.scm: Remove import of "(language tree-il eval)".
2021-10-19 18:10:05 -04:00
Robin Templeton
6dba232fd9
guile-backtrace function
* module/language/elisp/boot.el (guile-backtrace): New function
  extracted from `backtrace'.
  (backtrace): Use it.
2021-10-19 18:10:05 -04:00
Robin Templeton
1de0e2a1d4
use guile eval for elisp tree-il
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (eval): Update with simplified definition.
* module/language/elisp/compile-tree-il.scm: Import "(language tree-il eval)".
  (eval-when-compile): Use eval-elisp.
  (defmacro): Use eval-tree-il.
* module/language/elisp/runtime.scm: Import "(language tree-il eval)".
  (eval-elisp): Use "eval" to evaluate compiled form within current-module.
2021-10-19 18:10:05 -04:00
Robin Templeton
f4a154f9df
deprecated eval-when situations
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (eval-when): Update.
2021-10-19 18:10:05 -04:00
Robin Templeton
4b92314676
execute top level require forms
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (require): New compiler macro.
2021-10-19 18:10:05 -04:00
Robin Templeton
49c845c912
top level fixes
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (compile-pair): Use
  compile-expr-1 instead of compile-expr.
2021-10-19 18:10:05 -04:00
Robin Templeton
31761a6221
only evaluate top-level macro definitions
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (defmacro): Check to see
  whether toplevel? is true before compiling a macro.
2021-10-19 18:10:05 -04:00
Robin Templeton
05ea13e910
degenerate let forms
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (let): Conditionally invoke
  make-body within make-dynlet or just on its own depending on whether
  or not dynamic? is null?.
2021-10-19 18:10:05 -04:00
Robin Templeton
cd630c1f38
eval-when
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (progn): Use compile-expr-1
  instead of compile-expr.
  (toplevel?, compile-time-too?): New fluids.
  (eval-when): New special form.
  (compile-expr, compile-expr-1): compile-expr is renamed to
  compile-expr-1, and compile-expr  is now a procedure which, if
  fulid-ref of toplevel? is true, will call compile-expr-1 with
  toplevel? fulid bound to #f.  Otherwise, continue with compile-expr-1.
  (compile-tree-il): Set toplevel? and compile-time-too? fluids to #t
  during evaluation.
2021-10-19 18:10:05 -04:00
Robin Templeton
e07e9a0962
fset macro
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (fset): Update to handle macros.
2021-10-19 18:10:05 -04:00
Robin Templeton
dcb55d3895
use defsubst
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (null, consp, listp, car, cdr): Update
  to use defsubst.
  (atom): New variable, using defsubst.
2021-10-19 18:10:04 -04:00
Robin Templeton
cfbf37d917
defsubst
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (defsubst): New macro.
2021-10-19 18:10:04 -04:00
Robin Templeton
8dcb633909
compiler macros
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (%define-compiler-macro): New macro.
* module/language/elisp/compile-tree-il.scm: New function.
  (compile-pair): Update to handle %compiler-macro condition.
2021-10-19 18:10:04 -04:00
Robin Templeton
c8f94d3917
defconst, defvar: proclaim special at compile-time
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (defconst, defvar): Use
  proclaim-special!.
2021-10-19 18:10:04 -04:00
Robin Templeton
de52c1b0a1
elisp @@ macro
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el (@@): New macro.
2021-10-19 18:10:04 -04:00
Robin Templeton
9ef10e8c75
compile-elisp fn
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/runtime.scm (compile-elisp): New procedure.
2021-10-19 18:10:04 -04:00
Robin Templeton
361db0dca8
fix symbol-function
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/runtime.scm (symbol-function): Adjust function.
2021-10-19 18:10:04 -04:00
Robin Templeton
8a4905f2cb
restore special operator handling
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/boot.el
  (progn, eval-when-compile, if, defconst, defvar, setq, let, flet)
  (labels, let*, function, defmacro, quote): Removed.

* module/language/elisp/compile-tree-il.scm (special-operators): Removed.
  (compound-pair): Use find-operator to check if a 'special-operator
  rather than checking the now removed special-operators table.

* module/language/elisp/runtime.scm (defspecial): Update to use
  set-symbol-function!
2021-10-19 18:10:04 -04:00
Robin Templeton
08380a632b
define-module for elisp special modules
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/runtime.scm (value-slot-module)
  (function-slot-module, plist-slot-module): Update to set #:pure to #t.
2021-10-19 18:10:04 -04:00
Robin Templeton
8351f21d6d
constant-interning fix
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/system/vm/assembler.scm (intern-constant): Switch from using
  vector-ref/immediate to make-short-immediate.
2021-10-19 18:10:04 -04:00
Robin Templeton
c25539c9dc
defvar affects default value
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/compile-tree-il.scm (defvar): Refactor appropriately.
2021-10-19 18:10:04 -04:00
Robin Templeton
534211afac
symbol default value procedures
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/runtime.scm:
  (symbol-default-bound?, symbol-default-value, set-symbol-default-value!):
  New procedure aliases.  Export their symbols.
  (emacs!): Update to accept new parameters dref, dset, dboundp.
2021-10-19 18:10:04 -04:00
Robin Templeton
1099c7c6b6
read nil/t as #nil/#t
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/lexer.scm (lex): Update to handle #nil / #t.
2021-10-19 18:10:04 -04:00
Robin Templeton
cf5e02f1a6
elisp updates
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/elisp/bindings.scm (get-lexical-binding)
  (get-function-binding): Use cadr instead of fluid-ref on slot.
  (with-fluids**): New procedure.
  (with-symbol-bindings, with-function-bindings): Use with-fluids**.
  Also stop using "make-fluid", use "(list #f #f)" instead as default
  lexical-bindings hashtable value.
  (with-lexical-bindings): Drop the error checking for invalid targets.

* module/language/elisp/boot.el (defun, save-excursion)
  (save-current-buffer, save-restriction, track-mouse, setq-default)
  (catch, condition-case): New macros.
  (omega, eval, gensym, interactive, autoload-do-load, fset, prin1)
  (backtrace-frame, backtrace, %set-eager-macroexpansion-mode): New functions.
  (null, consp, listp, car, cdr, make-symbol, signal): Wrap in eval-and-compile.
  (prog1, cond, or, while): Update to make use of gensym.
  (unwind-protect): Switch from funcall to %funcall.
  (%functionp): Rename from functionp.
  (%indirect-function): Update to use %functionp instead of functionp.
  Add check for if object is null, signaling void-function.  Instead of
  calling symbol-function directly, call via %funcall from the module
  "(language elisp runtime)".
  (fset): Significant additions and refactoring.
  (gload): Renamed from fload.
  (defvaralias, nthcdr, nth, eq): Move functions to a different location.
  (eq): Also stop using null.
  (dolist): Remove quasiquoting, build list manually.
  (random): Fix indentation.
  (progn, eval-when-compile, if, defconst, defvar, setq, let, flet)
  (labels, let*, function, defmacro, quote): Protect as special
  operators by raising error if invoked as a function.

* module/language/elisp/compile-tree-il.scm: Import "(ice-9 format)".
  Export compile-%function.
  (lexical-binding, handle-var-def, defun, valid-symbol-list-arg?)
  (process-options!): Remove.
  (reference-variable): Adjust functions passed to access-variable.
  (global?): Drop module parameter, use value-slot instead.
  (ensure-globals!, set-variable!, parse-body-1, parse-lambda-list)
  (compile-lambda, defconst, defvar, let, let*, compile-pair): Refactor.
  (reference-function): Use '(elisp-functions) instead of function-slot.
  (bind-lexically?): Drop module parameter, simplify.
  (make-dynlet): Switch from using make-primcall to make-call.
  (find-operator): Switch from using resolve-interface/resolve-module
  to using function-slot.
  (if, defconst, defvar, let, let*, flet, labels, guile-ref)
  (guile-private-ref, guile-primitive, defmacro, `, quote, %funcall)
  (%set-lexical-binding-mode): Add error checking.
  (setq): Pass in args to report-error.
  (function): Simplified, now calling %function.
  (%function): New function, based on prior "function".  Refactor, including
  adding support for matching against a closure.
  (%set-lexical-binding-mode): Switch from using fluid-set! to
  set-lexical-binding-mode.
  (special-operators): New variable.  Build from following for-each
  statement.
  (compile-tree-il): Drop call to "process-options!"

* module/language/elisp/lexer.scm: Import "(language elisp runtime)".
  (lex): Switch from using "list->string" to "make-lisp-string".

* module/language/elisp/runtime.scm: Use modules "(ice-9 format)",
  "(system base compile)".
  Remove from export list list, removing ensure-fluid!, symbol-fluid!,
  set-symbol-fluid!.  Add to export list ensure-dynamic!, symbol-name,
  symbol-plist, set-symbol-plist!, bind-symbol, symbol-desc, proclaim-symbol!
  special? emacs! unbound, lexical-binding?, set-lexical-binding-mode,
  log!, eval-elisp, local-eval-elisp, make-lisp-string, lisp-string?
  (make-list-string, lisp-string?) New function aliases.
  (value-slot-module, function-slot-module): Adjust module resolution.
  (nil_, t_): New variables.
  (ensure-fluid!, symbol-fluid, set-symbol-fluid!): Removed.
  (lexical-binding, unbound): New variables.
  (lexical-binding?, set-lexical-binding-mode, unbound, dynamic?)
  (make-dynamic, dynamic-ref, dynamic-set!, dynamic-unset!)
  (dynamic-bound?, dynamic-bind, ensure-present!, ensure-desc!)
  (schemify, symbol-name, symbol-desc, ensure-dynamic!, symbol-dynamic)
  (set-symbol-plist!, special?, proclaim-special!, emacs!, eval-elisp)
  (make-string): New procedures.
  (symbol-value): Use dynamic-ref! instead of fluid-ref!.
  (set-symbol-value!): Use dynamic-set! instead of fluid-set!.
  (symbol-function, set-symbol-function!, symbol-bound?)
  (symbol-fbound?, makunbound!, fmakunbound!): Refactor, including
  adjusting how module resolution is being done.

* module/language/elisp/spec.scm: Import module "(system vm vm)".
  Setup elisp-symbols, elisp-functions, elisp-plists.
  Use "set-default-vm-engine!" and "set-vm-engine!" to be set to
  'debug.
  (elisp): Comment out joiner.
2021-10-19 18:10:04 -04:00
Robin Templeton
ad3d498d31
guile-snarf fix
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* libguile/guile-snarf.in (modern_snarf): Adjusted.
2021-10-19 18:10:04 -04:00
Robin Templeton
c7fe0eb420
allow arbitrary constants in cps
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/language/cps/types.scm (constant-type): No longer error
  if type not determined.  Return &all-types instead.
2021-10-19 18:10:04 -04:00
Robin Templeton
12a9311f17
guile-private-ref
* module/language/elisp/compile-tree-il.scm (compile-guile-private-ref):
  New special operator.
2021-10-19 18:10:02 -04:00
Robin Templeton
433fc448dd
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.
2021-10-19 18:09:59 -04:00
Robin Templeton
51bd3086db
check symbols constants uninterned
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* module/system/vm/assembler.scm (intern-constant, link-data):
  Update to check "symbol-interned?".
2021-10-19 18:02:52 -04:00
Robin Templeton
4e96211eb6
intern arbitrary constants
(Best-ability ChangeLog annotation added by Christine Lemmer-Webber.)

* libguile/loader.c (load_thunk_from_memory): Refactor, adding
  "constants" argument and passing to "init" if appropriate.
  (load_thunk_from_file): Call "load-thunk-from-memory" with
  "constants" set to #f.
  (scm_load_thunk_from_memory): Instead of a bytevector, accept
  a cons of "(bytevector . constants)", where constants is either
  a vector or #f.  Pass this into "load_thunk_from_memory".
* module/language/bytecode/spec.scm: Adapt printer.
* module/language/cps/compile-bytecode.scm (compile-bytecode):
  New variable.
* module/system/repl/command.scm (disassemble):
  Adapt to expect pair which includes bytevector as its car.
* module/system/vm/assembler.scm <asm>: Add "to-file?" slot.
  (fresh-block): New variable.
  (make-assembler): Adapt to expect "to-file?" keyword argument.
  (intern-constant): Support "asm-to-file?" in checks.
  (emit-init-constants, link-data): Likewise.
  (link-assembly): Update logic for handling "(bytevector . constants)"
  pair, as well as the expectations of its invocation by compile-bytecode.
2021-10-19 18:02:31 -04:00
Robin Templeton
1ba3d7854c Remove CFLAGS from snarfcppopts.
libguile/Makefile.am (snarfcppopts): Remove CFLAGS
2021-10-07 11:36:48 -04:00
Andy Wingo
e60469c8b6 Add primitive alias analysis to CSE
* module/language/cps/effects-analysis.scm (compute-known-allocations):
(compute-clobber-map): Add "conts" parameter, and use it to compute
primcalls that access known allocations.  A write to a known allocation
only clobbers a read to a known allocation if they are the same.
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
Pass conts also to compute-clobber-map.
2021-10-03 21:39:46 +02:00
Andy Wingo
71e201d5c4 Use more logtest in cse.scm
* module/language/cps/effects-analysis.scm (causes-effect?):
(effect-clobbers?): Use logtest.
2021-10-03 21:09:41 +02:00
Andy Wingo
c9c16db694 Allow primcalls with multiple defs
* module/language/cps/types.scm (infer-types): Allow multiple defs.
2021-10-01 11:33:13 +02:00
Andy Wingo
c803566a17 Add ,optimize-cps REPL meta-command
* module/system/repl/command.scm (*command-table*): Add optimize-cps /
optx.
(optimize-cps): Define meta-command.
* module/system/repl/common.scm (optimize*): New helper.
(repl-optimize): Use helper.
(repl-optimize-cps): New public function.
2021-10-01 11:33:13 +02:00
Andy Wingo
426867ac7d Add CPS pretty-printer
* module/language/cps/dump.scm: New file.
* module/Makefile.am (SOURCES): Add to build.
2021-10-01 11:33:10 +02:00
Andy Wingo
c8c35c6987 Allow unchecked functions to have unboxed arguments
* module/language/cps/utils.scm (compute-var-representations): Use
'arg-representations from metadata for arg representations.
* module/language/tree-il/compile-cps.scm (sanitize-meta):
(convert): Make sure incoming terms have no arg representations.
2021-10-01 11:28:22 +02:00
Andy Wingo
8fab68f8b1 Move live variable computation routines to utils and graphs.
* module/language/cps/graphs.scm (rename-keys, rename-intset)
(rename-graph, compute-reverse-control-flow-order)
(compute-live-variables): Move here from slot-allocation.
* module/language/cps/utils.scm: Remove duplicate compute-idoms
definition.
(compute-defs-and-uses, compute-var-representations): Move here from
slot-allocation.
* module/language/cps/slot-allocation.scm: Move routines out to utils
and graphs.
2021-10-01 11:28:22 +02:00
Andy Wingo
745b67c04a Add frame-local-ref / frame-local-set! support for type 'ptr
* libguile/frames.c (enum stack_item_representation):
(scm_to_stack_item_representation):
(scm_frame_local_ref):
(scm_frame_local_set_x): Add support for "ptr" representations.
2021-10-01 11:28:22 +02:00
Andy Wingo
d4d4336ede Hotfix to unify (x ...) patterns in match
* module/ice-9/match.upstream.scm (match-gen-ellipsis): Instead of just
binding the identifier when matching (x ...), go through match-one so
that if the id is already bound, we unify instead.
* test-suite/tests/match.test ("unify in list patterns"): Add test.
* test-suite/tests/match.test.upstream: Add additional tests from
upstream.

See commit 05c546e38 in Chibi Scheme.  Thanks to Alex Shinn for help
here!
2021-09-30 15:47:41 +02:00
Ludovic Courtès
74abae04aa Baseline compiler no longer swaps rsh/lsh when transforming ash calls.
Reported by Marius Bakke <marius@gnu.org>
at <https://issues.guix.gnu.org/50696>.

Previously, the baseline compiler would incorrectly emit a right shift
when for, say, (ash x 2), and a left shift for (ash x -2).

* module/language/tree-il/compile-bytecode.scm (canonicalize): When Y is
negative, emit 'rsh', not 'lsh'.
* test-suite/tests/numbers.test ("ash at -O1"): New test.
2021-09-20 23:27:39 +02:00
Ludovic Courtès
330c6ea83f Fix 'ash' primcall match clause in baseline compiler.
Previously the pattern would only match when the two 'src' values were
the same, which is not the case for example when running on the
interpreter.

* module/language/tree-il/compile-bytecode.scm (canonicalize): In 'ash
primcall pattern, rename second 'src' to 'src*'.
2021-09-20 23:24:24 +02:00
Ludovic Courtès
136417990c doc: Fix wrong @uref argument order.
* doc/ref/sxml.texi (SXML): Fix @uref argument order.
2021-09-20 17:00:19 +02:00
Ludovic Courtès
e304773416 srfi-1: 'find-tail' passes 'check-arg' the right procedure name.
* module/srfi/srfi-1.scm (find-tail): Pass 'find-tail' as the 3rd
argument to 'check-arg'.
2021-09-20 17:00:19 +02:00