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

4091 commits

Author SHA1 Message Date
Shea Levy
2662cafd6a Recognize RISC-V compilation targets.
* module/system/base/target.scm (cpu-endianness): Add case for "riscv" variants.

Signed-off-by: Shea Levy <shea@shealevy.com>
Signed-off-by: Mark H Weaver <mhw@netris.org>
2018-08-07 11:40:46 +02:00
Ludovic Courtès
898d97d440 srfi-18: 'thread-sleep!' timeout-as-a-number is relative.
This is a followup to <https://bugs.gnu.org/29704>.

* module/srfi/srfi-18.scm (thread-sleep!): When TIMEOUT is a number,
keep it as-is.
* test-suite/tests/srfi-18.test ("thread sleep with number"): Pass 0 as
the timeout.
("thread sleeps fractions of a second"): Pass 0.5 as the timeout.
2018-08-07 11:40:40 +02:00
Ludovic Courtès
cac14ad34d srfi-18: When timeout is a number, it's a relative number of seconds.
Fixes <https://bugs.gnu.org/29704>.
Reported by David Beswick <dlbeswick@gmail.com>.

* module/srfi/srfi-18.scm (timeout->absolute-time): New procedure.
(mutex-lock!): Use it in 'thread:lock-mutex' call.
(mutex-unlock!): Use it.
* test-suite/tests/srfi-18.test ("mutex-lock! returns false on timeout")
("mutex-lock! returns true when lock obtained within timeout")
("recursive lock waits")
("mutex unlock is false when condition times out"): Adjust cases where
the 'timeout' parameter is a number so that it's a relative number.
2018-08-07 11:40:31 +02:00
Ludovic Courtès
2245c67c37 Revert "Honor '%fresh-auto-compile'."
This reverts commit 83d4c4d622,
which came from a misunderstanding.
2018-08-07 11:37:11 +02:00
Ludovic Courtès
c91e9e9220 compile: Load language modules upfront.
Fixes a bug whereby "guild compile --target=arm-linux-gnueabihf
--from=elisp ... language/elisp/boot.el" would fail with an exception
from 'load-thunk-from-memory' while trying to load (language elisp spec)
from the guile-being-compiled instead of using that of the
guile-for-build.

The problem did not manifest with --from=scheme because (language scheme
spec) happened to be already loaded before we had changed %load-path.

* module/scripts/compile.scm (compile): Add calls to 'lookup-language'.
2018-08-07 11:35:34 +02:00
Andy Wingo
0a01963d07 VM hooks take no values
* libguile/vm-engine.c (RUN_HOOK0, RUN_HOOK1): Remove.
  (RUN_HOOK): Take hook name.
  (APPLY_HOOK, RETURN_HOOK, NEXT_HOOK, ABORT_CONTINUATION_HOOK): Use
  RUN_HOOK.
* libguile/vm.c (vm_dispatch_hook): Remove value count arg; hooks no
  longer receive values (e.g. the return hook now uses
  frame-return-values).
  (vm_dispatch_abort_hook): Remove value count, which was bogus because
  the active frame was the continuation which might contain other
  locals, potentially unboxed, not the implicit return-values frame.  In
  the future we could push on an implicit return-values frame instead.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
  (trap-in-dynamic-extent, trap-calls-to-procedure): Adapt abort hooks
  to not take values.  They weren't being used anyway!
2018-08-07 11:05:56 +02:00
Andy Wingo
f4c50447dd Remove push continuation hook; return hook runs before FP pop
* libguile/frames.c (scm_frame_return_values): New function, for use
  when a frame is at "return-values".
  (scm_init_frames_builtins): Register frame-return-values.
* libguile/vm-engine.c (RETURN_HOOK): Rename from POP_CONTINUATION_HOOK.
  (call, call-label): Remove PUSH_CONTINUATION_HOOK; it's unneeded, as
  you can always check the FP from an apply hook.
  (return-values): Run return hook before popping frame.
* libguile/vm.c (vm_dispatch_return_hook): Rename from
  vm_dispatch_pop_continuation_hook.  Remove push continuation hook.
  (scm_vm_return_hook):
* libguile/vm.h (SCM_VM_PUSH_CONTINUATION_HOOK): Remove.
  (SCM_VM_RETURN_HOOK): Rename from SCM_VM_POP_CONTINUATION_HOOK.
* module/system/vm/frame.scm (frame-return-values): Export.
* module/system/vm/trace.scm (print-return, trace-calls-to-procedure)
  (trace-calls-in-procedure): Adapt to not receiving values as
  arguments.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
  Adapt to return hook coming from returning frame.
  (program-sources-by-line): Update to use match instead of pmatch.
* module/system/vm/traps.scm (trap-in-dynamic-extent)
  (trap-calls-to-procedure): Adapt to return hook not receiving values.
* module/system/vm/vm.scm: Remove push continuation hook and rename
  return hook.
2018-08-06 17:00:45 +02:00
Andy Wingo
d145b57baf Minor updates for Scheme runtime (statprof, backtraces)
* module/system/vm/frame.scm: Add a comment about a case that we need to
  handle in the future.
* module/statprof.scm (statprof-proc-call-data): Always use the program
  code as the key, even for primitives.
2018-08-06 13:34:48 +02:00
Mark H Weaver
4c91de3e45 Fix R6RS call-with-{input,output}-file to open textual ports.
Fixes <https://bugs.gnu.org/32329>.
Reported and diagnosed by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/io/simple.scm (call-with-input-file)
(call-with-output-file): Use 'open-{input,output}-file' to open the port
in textual mode.  Previously 'open-file-{input,output}-port' was used,
which opened the port in binary mode.
2018-08-02 10:14:03 -04:00
Andy Wingo
b8a9a666f1 Rewrite subr implementation
* libguile/gsubr.c: Reimplement to store subr names and procedures in a
  side table, and to allocate fresh vcode for each subr.  This allows
  JIT of subrs, moves to a uniform all-code-starts-with-instrument-entry
  regime, and also allows statprof to distinguish between subrs based on
  IP.
* libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_NAME): Call out to functions,
  now that these are in a side table.
  (scm_subr_function, scm_subr_name): New exports.
  (scm_i_primitive_name): New internal function, for looking up a
  primitive name based on IP.
  (scm_apply_subr): Take the subr index.
* libguile/vm-engine.c (subr-call):
* libguile/jit.c (compile_subr_call): Adapt to take index as arg.
* module/statprof.scm (sample-stack-procs, count-call):
  (stack-samples->procedure-data): Update to always record IP in stack
  samples and call counts.
* module/system/vm/frame.scm (frame-procedure-name): Simplify.
  (frame-instruction-pointer-or-primitive-procedure-name): Removed.
* libguile/programs.h:
* libguile/programs.c (scm_primitive_code_name): New function.
* module/system/vm/program.scm (primitive-code-name): New export.
2018-07-29 15:47:07 +02:00
Andy Wingo
5c2e155fd7 Emit instrument-entry before programs
* module/system/vm/assembler.scm (<jit-data>, <meta>): Rework to have
  <meta> create the <jit-data> in the end-program, so that jit-data
  isn't mutable.  Record start and end PC values relative to '.rtl-text
  so that we don't need any more linker symbols.
  (emit-instrument-entry*, emit-instrument-loop*, begin-program):
  (end-program): Adapt.
  (begin-kw-arity): Include the initial instrument-entry in the first
  arity.
  (link-data, link-constants): Write the init routine before interning
  constants so that we correctly emit the jit-data for the init
  routine.
* libguile/programs.c (try_parse_arity): Skip over a
  scm_op_instrument_entry, if any.
2018-07-29 15:47:07 +02:00
Andy Wingo
a6b5049aa8 Emit instrument-loop in loops.
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES): Handle renamve of handle-interrupts.scm
  to loop-instrumentation.scm.
* libguile/jit.h (SCM_JIT_COUNTER_ENTRY_INCREMENT): Rename from
  SCM_JIT_COUNTER_CALL_INCREMENT.
* libguile/vm-engine.c (instrument-entry): Rename from instrument-call.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  handle-interrupts code before calls and returns.  Compile the
  "instrument-loop" primcall to an "instrument-loop" instruction and a
  "handle-interrupts" instruction.
  (lower-cps): Adapt to add-loop-instrumentation name change.
* module/language/cps/loop-instrumentation.scm: Rename from
  handle-interrupts.scm and just add "instrument-loop" primcalls in
  loops.  The compiler will add handle-interrupts primcalls as
  appropriate.
* module/system/vm/assembler.scm (<jit-data>): New data type, for
  emitting embedded JIT data.
  (<meta>): Add field for current JIT data.
  (make-meta): Initialize current JIT data.
  (emit-instrument-entry*, emit-instrument-loop*): New instruction
  emitters that reference the current JIT data.
  (end-program): Now that all labels are known, arrange to serialize the
  JIT data.
  (link-data): Reserve space for JIT data, and add relocs to initialize
  the "start" / "end" fields.
2018-07-29 15:47:07 +02:00
Andy Wingo
87da1c8d20 Add instrument-call, instrument-loop VM instructions
* libguile/jit.h (struct scm_jit_function_data)
  (enum scm_jit_counter_value): New data types.
* libguile/jit.c (scm_jit_compute_mcode, scm_jit_enter_mcode): New
  function stubs.  Adapt label/offset compilers to take pointers.
* libguile/vm-engine.c (instrument-call, instrument-loop): New
  instructions.
* libguile/vm.c: Add jit.h include.
* module/system/vm/assembler.scm (emit-instrument-call)
  (emit-instrument-loop): New exports.
2018-07-29 15:47:03 +02:00
Ludovic Courtès
71f536c3d8 srfi-19: Remove unused procedure.
* module/srfi/srfi-19.scm (date->broken-down-time): Remove.
2018-07-24 12:07:03 +02:00
Ludovic Courtès
bdcd0ba8a7 Add -Wshadowed-toplevel.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): New
variable.
* module/language/tree-il/compile-cps.scm (%warning-passes): Add it.
* module/system/base/message.scm (%warning-types): Add it.
* test-suite/tests/tree-il.test ("warnings")["shadowed-toplevel"]: New
test prefix.
* module/ice-9/boot-9.scm (%auto-compilation-options): Add it.
* doc/ref/api-evaluation.texi (Compilation): Add 'shadowed-toplevel' and
'macro-use-before-definition'.
2018-07-24 11:53:02 +02:00
Andy Wingo
950a762dc2 Multiple-value returns now start from slot 0, not slot 1
This should reduce frame sizes.

* libguile/vm-engine.c (halt): Adapt to multiple-values change.  Also
  adapt to not having the boot closure on the stack.
  (receive, receive-values, subr-call, foreign-call): Adapt to expect
  values one slot down.
  (prompt): Capture one less word for the values return.
* libguile/vm.c (vm_dispatch_pop_continuation_hook):
  (vm_dispatch_abort_hook): Adapt for where to expect values.
  (vm_builtin_values_code): Add a call to shuffle-down before
  returning.  This is more overhead than what existed before, but the
  hope is that the savings elsewhere pay off.
  (vm_builtin_values_code): Adapt to different values location.
  (reinstate_continuation_x, compose_continuation): Adapt to place
  resume args at right position.
  (capture_delimited_continuation): Remove unused sp and ip arguments.
  (abort_to_prompt): Adapt to capture_delimited_continuation change.
  (scm_call_n): Adapt to not reserve space for the boot closure.
* module/language/cps/compile-bytecode.scm (compile-function): When
  returning values, adapt reset-frame call for return calling convention
  change.  Adapt truncating or rest returns to expect values in the
  right place.
* module/language/cps/slot-allocation.scm (compute-shuffles):
  (allocate-lazy-vars, allocate-slots): Allocate values from the "proc
  slot", not proc-slot + 1.
* module/system/vm/assembler.scm (emit-init-constants): Reset the frame
  before returning so that the return value is in the right place.
* test-suite/tests/rtl.test: Update for return convention change.
* libguile/foreign.c (get_foreign_stub_code): Update for return calling
  convention change.
2018-07-20 11:42:30 +02:00
Andy Wingo
c2a8224a63 Rework VM approach to shuffling unknown numbers of args
* libguile/vm-engine.c (shuffle-down, expand-apply-argument): New
  instructions.
  (tail-call, tail-call-label, return-values): Don't reset the frame.
  The compiler should reset the frame appropriately.
  (tail-call/shuffle, tail-apply): Remove unused instructions.
* libguile/vm.c (vm_builtin_apply_code): Use new shuffle-down and
  expand-apply-argument opcodes.
  (vm_builtin_call_with_values_code): Replace tail-call/shuffle with
  shuffle-down then tail-call.
* libguile/jit.c (compile_shuffle_down, compile_expand_apply_argument):
  Add compiler stubs
  (COMPILE_X8_F12_F12): New definition.
  (compile_tail_call_shuffle, compile_tail_apply): Remove unused
  compilers.
* module/language/cps/compile-bytecode.scm (compile-function): Emit
  reset-frame before tail calls and returns.
* module/system/vm/assembler.scm (system): Remove unbound "emit-return"
  export.
* module/system/vm/disassembler.scm (code-annotation)
  (instruction-has-fallthrough?, define-stack-effect-parser): Adapt for
  opcode changes.
2018-07-20 11:42:30 +02:00
Andy Wingo
043432fd57 Reserve frame word for machine return address
* libguile/frames.h: Add machine return address to diagram.
  (SCM_FRAME_MACHINE_RETURN_ADDRESS):
  (SCM_FRAME_SET_MACHINE_RETURN_ADDRESS): New macros.
  (SCM_FRAME_PREVIOUS_SP):
  (SCM_FRAME_DYNAMIC_LINK):
  (SCM_FRAME_SET_DYNAMIC_LINK): Adapt for new frame size.
* libguile/vm-engine.c (halt): Set frame size to 3.
  (call, call-label): Set mRA to 0.
* libguile/vm.c (push_interrupt_frame, reinstate_continuation_x):
  (scm_call_n): Set frame size to 3.  In push_interrupt_frame, init the
  mRA of the frame.
  (vm_builtin_call_with_values_code, vm_handle_interrupt_code): Allocate
  larger frames.
* module/language/cps/slot-allocation.scm (allocate-slots): Frame size
  is 3.
* module/system/vm/disassembler.scm (define-clobber-parser): Bump frame
  size.
2018-07-20 11:42:30 +02:00
Andy Wingo
b1705bd0f0 Prepare for frames having separate virtual and machine return addrs
* libguile/frames.c (scm_frame_return_address): Use
  SCM_FRAME_VIRTUAL_RETURN_ADDRESS.
  (scm_c_frame_previous): Likewise.
* libguile/frames.h: Update diagram for new names.
  (union scm_vm_stack_element): Rename "as_ip" to "as_vcode", and
  add "as_mcode" for machine code pointers.
  (SCM_FRAME_VIRTUAL_RETURN_ADDRESS)
  (SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS): Rename to these, from
  SCM_FRAME_RETURN_ADDRESS and SCM_FRAME_SET_RETURN_ADDRESS.
* libguile/vm-engine.c (halt, call, call-label, return-values)
  (return-from-interrupt): Adapt to renamings.  Make "halt" have frame
  size as a parameter.
* libguile/vm.c (scm_i_vm_mark_stack): Adapt to renaming.
  (push_interrupt_frame): Take mRA as additional argument.  In future we
  will set it as frame mRA.
  (capture_continuation): Adapt to renaming.
  (scm_call_n): Adapt to renaming and make frame size adjustable.
  (push_interrupt_frame, reinstate_continuation_x): Make frame size
  adjustable.
* module/language/cps/slot-allocation.scm (allocate-slots): Make frame
  size adjustable.
* libguile/intrinsics.h (scm_t_thread_mra_intrinsic): New type; use for
  push_interrupt_frame.
  (scm_t_thread_u8_scm_sp_vra_intrinsic): Rename from the same but was
  "ra" instead of "vra", and change type to uint32_t*.
* module/system/vm/disassembler.scm (define-clobber-parser):
  Parameterize clobber set for calls by frame size.
2018-07-20 11:42:30 +02:00
Ludovic Courtès
e45a33ce58 compile: Update copyright year.
* module/scripts/compile.scm (show-version): Update copyright year.
2018-07-19 18:00:19 +02:00
Ludovic Courtès
85c5bae4fd compile: Improve error message.
* module/scripts/compile.scm (parse-args): Add missing newline in
"unrecognized option" message.
2018-07-19 18:00:19 +02:00
Ludovic Courtès
887e495c6b compile: Add '-x' flag.
* module/scripts/compile.scm (%options, compile): Add '-x'.
* doc/ref/api-evaluation.texi (Compilation): Document it.
2018-07-19 18:00:19 +02:00
Mark H Weaver
59a06d8392
Make srfi-71 visible through 'cond-expand'.
This is a followup to commit eb90831ce8.

* module/srfi/srfi-71.scm: Add missing 'cond-expand-provide'.
2018-07-04 20:42:07 -04:00
Ludovic Courtès
d571009370 build: Really build srfi/srfi-71.scm.
Commit eb90831ce8 added it to the wrong
makefile.

* module/Makefile.am (SOURCES): Add srfi/srfi-71.scm.
* module/srfi/Makefile.am: Remove.  It's a leftover from the 2009 build
system rework in commit 3bb299b3f0.
2018-07-01 23:33:46 +02:00
Ludovic Courtès
be1e6e6ab0 Update copyright years in '--version' and the manual.
* module/ice-9/command-line.scm (version-etc): Change #:copyright-year
to 2018.
* doc/ref/guile.texi: Add 2017 and 2018 to the copyright years.
* configure.ac (GUILE_CONFIGURE_COPYRIGHT): Add 2018.
2018-07-01 23:33:26 +02:00
Ludovic Courtès
533e3ff170 Serialize accesses to submodule hash tables.
Fixes <https://bugs.gnu.org/30602>.

Previously, when compiling files in parallel like Guix does, threads
would be concurrently inserting, rehashing, and reading the submodule
hash table of module ().  Thus, some threads would sometimes see an
inconsistent state, leading to errors such as:

  Module named (system repl debug) does not exist

* module/ice-9/boot-9.scm (call-with-module-autoload-lock): Move higher
in the file.
(module-name): Use it around call to 'nested-define-module!'.
(resolve-module): Wrap the whole thing in 'call-with-module-autoload-lock'.
2018-07-01 18:37:59 +02:00
Ludovic Courtès
b87068eee7 linker: Don't rely on out-of-range bv-ref exceptions.
* module/system/vm/linker.scm (find-shstrndx): Check whether NAME is
lower than the length of BV; remove 'false-if-exception' around
'string-table-ref' call.
2018-06-28 17:14:08 +02:00
Andy Wingo
8918165c40 Compile current-module as intrinsic call
* libguile/fluids.c (scm_i_fluid_ref): New internal function.
  (scm_fluid_ref): Use scm_i_fluid_ref.
* libguile/intrinsics.h:
* libguile/intrinsics.c (current_module): New intrinsic.
* libguile/modules.c (scm_i_current_module): New internal function.
  (scm_current_module): Use new internal function.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add current-module as an intrinsic primitive.
* module/system/vm/assembler.scm (define-scm<-thread-intrinsic):
  (current-module): Arrange to compile to intrinsic call.
2018-06-27 14:57:51 +02:00
Ludovic Courtès
c009bfdcc8 types: Recognize 'scm_t_port_type' and decode port type name.
* module/system/base/types.scm (read-c-string, inferior-port-type): New
procedures.
(inferior-port): Use 'inferior-port-type' to determine the port type.
(cell->object): Rename 'flags+type' to 'flags' in the '%tc7-port' case.
* test-suite/tests/types.test ("opaque objects"): Adjust port testse.
(test-inferior-ports): New macro.
("ports"): New test prefix.
2018-06-24 15:31:05 +02:00
Arun Isaac
919979ac39 web: Export http-request.
* module/web/client.scm (request): Rename to http-request, add a
docstring, and export it.
(http-get, http-head, http-post, http-put, http-delete, http-trace,
http-options): Update docstring.
* doc/ref/web.texi (Web Client): Document http-request.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2018-06-23 23:32:13 +02:00
Ludovic Courtès
761cf0fb8c Make module autoloading thread-safe.
Fixes <https://bugs.gnu.org/31878>.

* module/ice-9/boot-9.scm (call-with-module-autoload-lock): New procedure.
(try-module-autoload): Wrap body in 'call-with-module-autoload-lock'.
* module/ice-9/threads.scm: Set (@ (guile) call-with-module-autoload-lock).
2018-06-18 14:14:47 +02:00
Christopher Allan Webber
eb90831ce8 Add SRFI 71: Extended LET-syntax for multiple values.
* module/srfi/srfi-71.scm: New file.
* module/srfi/Makefile.am: Add it.
* doc/ref/srfi-modules.texi: Document it.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2018-06-18 14:14:47 +02:00
Mark H Weaver
ac9f0831c1
Add copyright header for (language elisp falias), and fix typo.
* module/language/elisp/falias.scm: Add copyright header.
* module/language/elisp/spec.scm: Fix typo in header.
2018-06-11 10:14:28 -04:00
Mark H Weaver
bff75635e5
elisp: Fix cross-compilation support.
* module/system/base/target.scm (with-native-target): New exported
procedure.
* module/language/elisp/spec.scm: In the top-level body expression, call
'compile-and-load' within 'with-native-target' to compile native code.
* module/language/elisp/compile-tree-il.scm
(eval-when-compile, defmacro): Compile native code.
2018-06-11 10:12:54 -04:00
Mark H Weaver
ff2adb04cb
goops: Fix 'instance?' to work on objects that aren't structs.
Fixes <https://bugs.gnu.org/31606>
Reported by Tommi Höynälänmaa <tommi.hoynalanmaa@gmail.com>

* module/oop/goops.scm (instance?): Check that OBJ is a struct
before applying 'struct-vtable' to it.
2018-06-11 10:12:50 -04:00
Mark H Weaver
e1dffd3504
Avoid inexact arithmetic in the type inferrer for 'sqrt'.
* module/language/cps/types.scm: Use 'exact-integer-sqrt' and avoid
inexact arithmetic in the range analysis of the type inferrer for
'sqrt'.
2018-06-11 10:12:47 -04:00
Mark H Weaver
2733e97395
Fix type inference for bitwise logical operators.
Fixes <https://bugs.gnu.org/31474> and related bugs.
Reported by Jan Nieuwenhuizen <janneke@gnu.org>.

* module/language/cps/types.scm (next-power-of-two): Remove procedure.
(non-negative?, lognot*, saturate+, saturate-, logand-bounds)
(logsub-bounds, logior-bounds, logxor-bounds): New procedures.  Use them
to improve and fix bugs in the range analysis of the type inferrers for
'logand', 'logsub', 'logior', 'ulogior', 'logxor', 'ulogxor', and
'lognot'.
2018-06-11 10:12:45 -04:00
Mark H Weaver
df93752479
Revert "Minor CSE run-time optimization"
Fixes <https://bugs.gnu.org/30020>.
Reported by David Thompson <dthompson2@worcester.edu>.

This reverts commit d4883307ca.
2018-06-11 10:12:43 -04:00
Andy Wingo
76eac85084 Use intrinsics for top-level refs outside captured scopes
* module/language/tree-il/compile-cps.scm (toplevel-box): Reify
  intrinsic calls for top-level references outside captured scopes.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Update set of macro-instructions.
2018-05-14 16:25:50 +02:00
Andy Wingo
ceffb5e990 Compile "define!" via intrinsic
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new define!
  intrinsic.
* module/language/cps/compile-bytecode.scm (compile-function): Adapt
  compilation for define! to take two arguments.
* module/language/cps/effects-analysis.scm (current-module): Update
  define! for two arguments.
* module/language/tree-il/compile-cps.scm (convert): When reifying
  "define", grab the current module.
* module/system/vm/assembler.scm (define!): Define assembler as
  intrinsic.
2018-05-14 15:15:22 +02:00
Andy Wingo
77e7bea4c2 Remove backend support for cached-module-box et al.
* module/language/cps/compile-bytecode.scm (compile-function): Remove
  unused assemblers for cached-module-box, cached-toplevel-box, and
  cache-current-module!.
* module/language/cps/effects-analysis.scm (&cache): New memory kind.
  (cache-current-module!): Set &cache memory, not &box.
  (resolve-module, lookup-module, cache-ref, cache-set!): Add effect
  annotations.
* module/system/vm/assembler.scm (emit-cache-current-module!)
  (emit-cached-toplevel-box, emit-cached-module-box): Remove
  assemblers.
* module/system/vm/disassembler.scm (code-annotation, fold-code-range):
  Remove special cases for toplevel-box and module-box.
* module/system/xref.scm (program-callee-rev-vars): Add a FIXME for the
  future.
2018-05-14 14:04:59 +02:00
Andy Wingo
667d808f58 Instruction explosion for cache-current-module, cached-toplevel-box
* module/language/cps/reify-primitives.scm (primitive-ref): When
  reifying xoprimitives, explode cached-module-box references.
  (cache-current-module!, cached-toplevel-box): Do instruction
  explosion.
2018-05-14 14:04:59 +02:00
Andy Wingo
3edf02cbe5 Instruction explosion for cached-module-box
* module/language/cps/reify-primitives.scm (reify-lookup):
  (reify-resolve-module): New helpers.
  (cached-module-box): Explode.
2018-05-14 14:04:59 +02:00
Andy Wingo
f6de1b0620 Add cache-ref, cache-set! macro-instructions
* module/system/vm/assembler.scm (<cache-cell>): Remove "scope" member.
  Just be an opaque key comparable with equal?.
  (intern-cache-cell): Remove scope arg.
  (intern-module-cache-cell): Remove; callers use intern-cache-cell now.
  (cache-current-module!, cached-toplevel-box, cached-module-box): Create
  cache keys that by construction won't collide between types.
  (cache-ref, cache-set!): Add new macro assemblers.
* module/language/cps/reify-primitives.scm:
* module/language/cps/compile-bytecode.scm: Add cases for new macro
  instructions.
2018-05-14 14:04:59 +02:00
Andy Wingo
fb344a25d5 Add intrinsics for module operations
* libguile/intrinsics.c (scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* module/system/vm/assembler.scm (resolve-module, lookup): New intrinsics.
* module/language/cps/compile-bytecode: Add cases for primcalls
  corresponding to new intrinsics.
2018-05-14 14:04:54 +02:00
Andy Wingo
1532b570e5 lsh, rsh etc are intrinsics
* libguile/intrinsics.c (lsh, rsh, lsh_immediate, rsh_immediate): New
  intrinsics.
  (scm_bootstrap_intrinsics): Wire up the intrinsics.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new
  intrinsics.
* libguile/vm-engine.c (call-scm<-scm-u64): New intrinsic caller.
  (lsh, rsh, lsh/immediate, rsh/immediate): Disable.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm: Adapt assemblers for new intrinsics.
2018-05-01 07:02:45 +02:00
Andy Wingo
89fda6da60 push and pop dynamic state via intrinsics
* libguile/intrinsics.c (push_dynamic_state, pop_dynamic_state): New
  intrinsics.
  (scm_bootstrap_intrinsics): Add new intrinsics.
* libguile/intrinsics.h: Declare new intrinsics.
* libguile/vm-engine.c (call-thread-scm): New intrinsic caller.
  (push-dynamic-state, pop-dynamic-state): Disable.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm (push-dynamic-state)
  (pop-dynamic-state): Emit as intrinsics.
2018-04-29 10:41:24 +02:00
Andy Wingo
2eb9c755d1 Intrinsics for dynamic state instructions
* libguile/intrinsics.c (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): New intrinsics.
  (scm_bootstrap_intrinsics): Wire them up.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Declare new
  intrinsics.
* libguile/vm-engine.c (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): Disable these instructions.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add new intrinsics.
* module/system/vm/assembler.scm (wind, unwind, push_fluid, pop_fluid)
  (fluid_ref): Assemble as intrinsics.
2018-04-29 10:22:30 +02:00
Andy Wingo
4779a10223 Add support for dynamic-state-related intrinsics
* libguile/vm-engine.c (call-thread, call-thread-scm-scm)
  (call-scm<-thread-scm): New intrinsics.
* module/system/vm/assembler.scm (define-thread-scm-scm-intrinsic)
  (define-thread-intrinsic, define-scm<-thread-scm-intrinsic): New
  helpers.
  (encode-X8_S12_S12-C32!/shuffle): New shuffler.
* libguile/intrinsics.h: Add new intrinsic types.
2018-04-29 10:13:50 +02:00
Andy Wingo
dff85f6f9f Explode atomic box ops to new atomic instructions
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add C8_S24
  word type.
* libguile/vm-engine.c (UNPACK_8_24): New helper.
  (atomic-scm-ref/immediate, atomic-scm-set!/immediate)
  (atomic-swap-scm!/immediate, atomic-scm-compare-and-swap!/immediate):
  New instructions.
  (make-atomic-box, atomic-box-ref, atomic-box-set!, atomic-box-swap!)
  (atomic-box-compare-and-swap!): Disable these ops.
* module/language/bytecode.scm (compute-instruction-arity): Add C8_S24
  support.
* module/system/vm/assembler.scm: Add C8_S24 support.  Export assemblers
  for new opcodes.
* module/system/vm/disassembler.scm (disassembler): Support C8_S24.
* module/language/cps/compile-bytecode.scm (compile-function): Replace
  old atomic-box assemblers with the new instructions.
* module/language/cps/effects-analysis.scm (annotation->memory-kind):
* module/language/cps/types.scm (annotation->type): Add cases for atomic
  boxes.  Mark as all memory kinds because atomic ops serialize memory
  accesses.
* module/language/tree-il/compile-cps.scm (make-atomic-box):
  (ensure-atomic-box, atomic-box-ref, atomic-box-set!):
  (atomic-box-swap!, atomic-box-compare-and-swap!): Explode these ops to
  more basic instructions.
* module/system/base/types/internal.scm (%tc7-atomic-box): Add forgotten
  export.
2018-04-13 10:09:56 +02:00