VM has "builtins": primitives addressable by emitted RTL code
authorAndy Wingo <wingo@pobox.com>
Sun, 20 Oct 2013 13:49:22 +0000 (15:49 +0200)
committerAndy Wingo <wingo@pobox.com>
Sun, 27 Oct 2013 19:09:01 +0000 (20:09 +0100)
commit486013d67c2db6b454c4b684f0317ff948bd6eb1
tree3a8c5efe797cf4890e3564a85b097aca9734c7ca
parentd76de8716d36e1fe419224119111fdb594a5d1b9
VM has "builtins": primitives addressable by emitted RTL code

* libguile/Makefile.am:
* libguile/vm-builtins.h: New header, declaring stubs needed by the
  compiler like values, apply, and abort-to-prompt.

* libguile/vm.c: Adapt the apply and values stubs to conform to a
  standard interface.  Add an abort-to-prompt stub.  Add call/cc and
  call-with-values stubs.
  (scm_vm_builtin_ref): New helper, for the builtin-ref opcode.
  (scm_vm_builtin_name_to_index)
  (scm_vm_builtin_index_to_name): New helpers, for the compiler and
  disassembler, respectively.
  (scm_init_vm_builtins, scm_bootstrap_vm): Allow the compiler helpers
  to be loaded later into a module.
* module/language/rtl.scm: Export builtin-index->name and
  builtin-name->index.

* libguile/vm-engine.c (RETURN_VALUE_LIST): Update to use new names of
  "apply" and "values".
  (tail-call/shuffle): New opcode.
  (abort): Update to be a tail VM op, and reorder and renumber other
  ops.
  (builtin-ref): New opcode.

* libguile/continuations.h:
* libguile/continuations.c (scm_i_call_with_current_continuation):
  Move this to vm.[ch], implemented as a builtin.

* module/language/tree-il/compile-cps.scm (convert): Convert to
  'abort-to-prompt calls, possibly with 'apply, effectively undoing the
  tree-il transformation.

* module/language/cps/reify-primitives.scm (builtin-ref): New helper.
  (reify-primitives): Convert builtin primitives to builtin-ref.

* module/language/cps/dfg.scm (constant-needs-allocation?):
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support
  for compiling builtin-ref.

* module/system/vm/disassembler.scm (code-annotation): Add annotation
  for builtin-ref.
13 files changed:
libguile/Makefile.am
libguile/continuations.c
libguile/continuations.h
libguile/vm-builtins.h [new file with mode: 0644]
libguile/vm-engine.c
libguile/vm.c
libguile/vm.h
module/language/cps/compile-rtl.scm
module/language/cps/dfg.scm
module/language/cps/reify-primitives.scm
module/language/rtl.scm
module/language/tree-il/compile-cps.scm
module/system/vm/disassembler.scm