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

40 commits

Author SHA1 Message Date
Andy Wingo
8bf83893c7 Rename DT_GUILE_VM_VERSION.
* libguile/objcodes.c (DT_GUILE_VM_VERSION, process_dynamic_segment):
* module/system/vm/elf.scm (DT_GUILE_VM_VERSION): Rename from
  DT_GUILE_RTL_VERSION.
* module/system/vm/assembler.scm (link-dynamic-section): Adapt.
2013-11-19 20:02:15 +01:00
Andy Wingo
e0755cd12a Rename scm_tc7_rtl_program to scm_tc7_program
* libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program.
* libguile/continuations.c:
* libguile/control.c:
* libguile/evalext.c:
* libguile/foreign.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/programs.h:
* libguile/vm-engine.c: Adapt users.

* module/system/vm/assembler.scm: Rename a tc7-rtl-program local to
  tc7-program.
* libguile/tags.h (scm_tc7_program): Rename from scm_tc7_rtl_program. * libguile/continuations.c: * libguile/control.c: * libguile/evalext.c: * libguile/foreign.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/print.c: * libguile/programs.c: * libguile/programs.h: * libguile/vm-engine.c: Adapt users.

* module/system/vm/assembler.scm: Rename a tc7-rtl-program local to
  tc7-program.
2013-11-19 18:24:54 +01:00
Andy Wingo
f8085163d6 Remove MVRA from VM frames
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump for frame layout
  change.

* libguile/frames.c: Update some static checks.
  (scm_frame_num_locals, scm_frame_local_ref, scm_frame_local_set_x):
  Update to not skip over uninitialized frames, as that's not a thing
  any more.

* libguile/frames.h: Update to remove MVRA.  Woo!

* libguile/vm-engine.c (ALLOC_FRAME, RETURN_ONE_VALUE):
  (rtl_vm_engine): Update for 3 words per frame instead of 4.

* libguile/vm.c (vm_return_to_continuation): Likewise.

* module/language/cps/slot-allocation.scm (allocate-slots): 3 words per
  frame, not 4.

* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.  Also
  remove a couple of tc7's that aren't around any more.
2013-11-15 17:13:27 +01:00
Andy Wingo
4c906ad5a5 Add specialize-primcalls pass; bump objcode version.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* libguile/objcodes.c (process_dynamic_segment): Expect the minor
  version to be present and, while we are still banging on the VM,
  exactly equal to SCM_OBJCODE_MINOR_VERSION.

* libguile/vm-engine.c: Renumber ops.  Remove the general make-vector.
  Rename constant-FOO to FOO/immediate.  Remove struct-ref and
  struct-set!, replace with struct-ref/immediate and
  struct-set!/immediate.

* module/Makefile.am:
* module/language/cps/specialize-primcalls.scm: New pass, inlines FOO to
  FOO/immediate -- e.g. vector-ref to vector-ref/immediate.

* module/language/cps/arities.scm: Remove struct-set! case, now that
  there is no struct-set! opcode.

* module/language/cps/compile-rtl.scm (compile-fun): Remove dispatch to
  constant-FOO versus FOO here -- that decision is made by
  specialize-primcalls.
  (optimize): Add specialize-primcalls pass.

* module/language/cps/dfg.scm (constant-needs-allocation?): Adapt to
  name changes.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*primitive-constructors*): Add allocate-struct.

* module/system/vm/assembler.scm (*bytecode-major-version*):
  (*bytecode-minor-version*, link-dynamic-section): Write minor version
  into resulting image.
2013-11-10 19:27:19 +01:00
Andy Wingo
463469cce7 Fix RTL linking of procedure properties.
* module/system/vm/assembler.scm (link-procprops): Fix procedure
  property embedding in bytecode.
2013-11-09 16:23:35 +01:00
Andy Wingo
d8595af555 Finding a procedure's arity uses binary search
* module/system/vm/assembler.scm (pack-arity-flags):
  (write-arity-headers): Add a flag to indicate that an arity is part of
  a case-lambda, so that we can use binary search to find arities.

* module/system/vm/debug.scm (is-in-case-lambda?)
  (arity-is-in-case-lambda?, find-first-arity): Use binary search.
2013-11-09 16:02:13 +01:00
Andy Wingo
4dfae1bf50 Move assemble-program to test cases.
* module/system/vm/assembler.scm (assemble-program): Remove.
* test-suite/tests/rtl.test (assemble-program): Move here.
2013-11-08 17:36:45 +01:00
Andy Wingo
b0ed216b6f Fix case-lambda* dispatching to agree with manual.
* module/system/vm/assembler.scm (kw-prelude): Emit br-if-npos-gt as
  appropriate.
2013-11-08 11:41:28 +01:00
Andy Wingo
0e3a59f750 Fix reading and writing arities into DWARF.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_call_ip):
* libguile/programs.c (scm_primitive_call_ip): Adapt to return an
  absolute address.

* module/system/vm/assembler.scm (write-arity-headers): Adapt to write
  byte addresses (relative to the text base).

* module/system/vm/debug.scm (arity-low-pc, arity-high-pc): Return
  absolute addresses, instead of word offsets relative to the text
  base.
  (find-first-arity): Adapt for absolute addresses.

* module/system/vm/program.scm (program-arguments-alist): Adapt for
  arity-low-pc / arity-high-pc absolute addresses.
2013-11-08 10:11:48 +01:00
Andy Wingo
31602aa04a Fix line advance DWARF opcodes when line advance is exactly 128
* module/system/vm/assembler.scm (link-debug): Fix off-by-one error in
  which forward jumps of 128 were mis-rendered.
2013-11-07 11:10:36 +01:00
Andy Wingo
32ca15d7d7 Write DWARF files list in correct order.
* module/system/vm/assembler.scm (link-debug): Fix order of writing the
  source files list; it was being written backwards.
2013-11-07 10:52:47 +01:00
Andy Wingo
0a1d52ac77 fix docstring assembly and fetching
* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as
  byte addresses.  Works better with native code.
* module/system/vm/debug.scm (find-program-docstring): Fix the linear
  search.  How embarassing!
2013-11-05 21:29:46 +01:00
Andy Wingo
3659ef543e asm-labels is a hash table
* module/system/vm/assembler.scm (make-assembler, label):
  (link-data, process-relocs, process-labels): Change labels to be a
  hash table.
2013-11-05 20:18:23 +01:00
Andy Wingo
d65514a2de RTL compiler supports static bitvectors
* libguile/arrays.c (scm_from_contiguous_typed_array):
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): For
  bitvectors, round up the length to 32-bit units, as they are stored
  internally.  Otherwise I think this probably does the wrong thing for
  the last word on big-endian systems.
* libguile/bitvectors.c (BITVECTOR_LENGTH, BITVECTOR_BITS):
  (scm_c_make_bitvector): Reorder the length and pointer words to match
  the layout of bytevectors.

* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/system/vm/assembler.scm (br-if-bitvector):
* module/system/vm/disassembler.scm (code-annotation): Add bitvector
  test support.

* module/system/vm/assembler.scm (<uniform-vector-backing-store>): Add
  an element-size field.
  (intern-constant): Adapt make-uniform-vector-backing-store call.  Use
  uniform-array->bytevector, as the old compiler did.
  (link-data): Add bitvector cases.
2013-11-03 21:48:48 +01:00
Andy Wingo
cb8054c7ac Better range checks in the assembler
* module/system/vm/assembler.scm (pack-u8-u24, pack-u8-s24):
  (pack-u1-u7-u24, pack-u8-u12-u12, pack-u8-u8-u16, pack-u8-u8-u8-u8):
  Prevent adjacent fields from stompling each other.
2013-10-31 22:57:06 +01:00
Andy Wingo
c7cb2bc200 static-patch! for pair and vector fields
* module/system/vm/assembler.scm (intern-constant): Use static-patch!
  for fields.
2013-10-31 19:21:31 +01:00
Andy Wingo
becce37b58 Better compiler support for bytevector ops
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add emitters
  for bytevector ops.  Add br-if-bytevector emitter.
* module/language/cps/primitives.scm (*branching-primcall-arities*):
  Mark bytevector? as a branching primitive.
* module/system/vm/assembler.scm (br-if-bytevector): New instruction
* module/system/vm/disassembler.scm (code-annotation): Add support for
  bytevector?.
2013-10-31 12:55:24 +01:00
Andy Wingo
7bfbc7b1c5 Support serialization of uniform vector literals
* libguile/uniform.h:
* libguile/uniform.c (scm_uniform_vector_element_type_code): New
  interface, returns a type code as an integer.

* module/system/vm/assembler.scm (<uniform-vector-backing-store>)
  (simple-vector?, uniform-array?, statically-allocatable?)
  (intern-constant, link-data, link-constants): Support uniform arrays,
  and punt on vectors aren't contiguous from 0.  Support for general
  arrays will come later.

* test-suite/tests/rtl.test ("load-constant"): Add tests.
2013-10-31 12:55:23 +01:00
Andy Wingo
2ab2a10d50 static-patch! replaces link-procedure!
* libguile/vm-engine.c (static-patch!): Replace link-procedure! with
  this more versatile primitive.
* module/system/vm/assembler.scm (intern-constant): Emit static-patch!
  for static procedures and for strings.
* module/system/vm/disassembler.scm (code-annotation): Remove annotation
  for link-procedure!.  There can be no annotation for static-patch!, as
  neither operand is guaranteed to be a SCM value.
2013-10-31 09:47:48 +01:00
Andy Wingo
be8b62ca7f RTL compiler: Compile TC7 branches.
* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm (code-annotation):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/compile-rtl.scm (emit-rtl-sequence): Add support
  for compiling symbol?, variable?, vector?, and string? branches.
2013-10-26 15:16:09 +02:00
Andy Wingo
8695854a7d Fix assembler for keyword args
* module/system/vm/assembler.scm (begin-kw-arity, kw-prelude): Fix
  functions with keywords.
2013-10-22 22:31:26 +02:00
Andy Wingo
6b71a76713 A couple of fixes when no source info is available
* module/system/vm/assembler.scm (link-debug): If there was no debugging
  info, reset the file register to 0 from its default value of 1 before
  adding the final row.

* module/system/vm/dwarf.scm (line-prog-scan-to-pc): If we rescanned
  from the beginning and still found no source info for this pc, return
  #f instead of the default value of the file register (1).
2013-10-10 12:22:20 +02:00
Andy Wingo
d56ab5a913 Serialize source positions into .debug_line
* module/system/vm/assembler.scm (link-debug): Generate a correct DWARF2
  line program.  Tests come next.
2013-10-03 16:14:20 +02:00
Andy Wingo
0a7340ac98 Emit a placeholder .debug_line section.
* module/system/vm/assembler.scm (link-debug): Emit a .debug_line
  section also.
  (link-objects): Expect .debug_line.
2013-09-30 21:49:12 +02:00
Andy Wingo
e675e9bd39 Add new "source" macro instruction; compile-rtl emits it.
* module/system/vm/assembler.scm (<asm>): Add "sources" field.
  (make-assembler): Adapt to make-asm change.
  (source): New macro assembler.

* module/language/cps/compile-rtl.scm (emit-rtl-sequence):
  (compile-fun): Emit source instructions as appropriate.
2013-09-30 21:48:07 +02:00
Andy Wingo
6371e368e6 DWARF linker: encode strings using the correct form
* module/system/vm/assembler.scm (link-debug): Encode strings using the
  strp form.
2013-09-28 18:15:50 +02:00
Andy Wingo
a862d8c138 Emit minimal DWARF information
* module/system/vm/assembler.scm (link-debug): New function, creates the
  necessary DWARF debugging sections.
  (link-objects): Emit debugging sections.
2013-09-28 14:50:48 +02:00
Andy Wingo
c96933fd54 Export the assembler procedures
* module/system/vm/assembler.scm (define-assembler):
  (define-macro-assembler): Export the assemblers.
2013-08-24 15:41:09 +02:00
Andy Wingo
8fa7288928 assembler: give proper permissions to .data section
* module/system/vm/assembler.scm (link-data): Give stringbufs the
  "shared" flag already, so we don't attempt to set it at runtime.  Give
  .data sections the SHF_WRITE flag.
2013-08-24 15:28:03 +02:00
Andy Wingo
af95414f1d 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.
2013-08-11 16:45:31 +02:00
Andy Wingo
78ff784784 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.
2013-07-21 17:12:23 +02:00
Andy Wingo
7396d21670 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.
2013-07-21 17:12:22 +02:00
Andy Wingo
2a294c7cd3 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.
2013-07-21 17:12:22 +02:00
Andy Wingo
c4c098e355 procedure-properties for RTL functions
* module/system/vm/assembler.scm (link-procprops, link-objects): Arrange
  to write procedure property links out to a separate section.

* libguile/procprop.c (scm_procedure_properties):
* libguile/programs.h:
* libguile/programs.c (scm_i_rtl_program_properties):
* module/system/vm/debug.scm (find-program-properties): Wire up
  procedure-properties for RTL procedures.  Yeah!  Fistpumps!  :)

* module/system/vm/debug.scm (find-program-debug-info): Return #f if the
  string is "", as it is if we don't have a name.  Perhaps
  elf-symbol-name should return #f in that case...

* test-suite/tests/rtl.test: Add some tests.
2013-06-09 23:59:19 +02:00
Andy Wingo
9128b1a19f Write docstrings into RTL ELF images
* module/system/vm/assembler.scm (link-docstrs): Write docstrings.
  (link-objects): Link docstrings into the ELF.
2013-06-09 23:48:39 +02:00
Andy Wingo
b2006c19af RTL assembler writes arities information into separate section.
* module/system/vm/assembler.scm: Write arities into a .guile.arities
  section and associated .guile.arities.strtab.
2013-06-09 23:42:52 +02:00
Andy Wingo
3185c9071c Beginnings of tracking of procedure arities in assembler
* module/system/vm/assembler.scm (<meta>, <arity>): Assembler now tracks
  arities of a function.
  (begin-standard-arity, begin-opt-arity, begin-kw-arity, end-arity):
  New macro-assemblers.

* test-suite/tests/rtl.test: Adapt all tests to use begin-standard-arity
  and end-arity.
2013-06-09 23:37:46 +02:00
Andy Wingo
07c052796d add procedure prelude macro-instructions
* module/system/vm/assembler.scm (pack-flags): New helper.
  (standard-prelude, opt-prelude, kw-prelude): New macro-instructions.

* test-suite/tests/rtl.test: Update tests to use standard-prelude.
2013-06-09 23:36:46 +02:00
Andy Wingo
2a4daafd30 begin-program takes properties alist
* module/system/vm/assembler.scm (assert-match): New helper macro to
  check argument types.
  (<meta>): Add properties field.  Rename name field to "label" to
  indicate that it should be unique.
  (make-meta, meta-name): New helpers.
  (begin-program): Take additional properties argument.
  (emit-init-constants): Adapt to begin-program change.
  (link-symtab): Allow for anonymous procedures.

* test-suite/tests/rtl.test: Adapt tests.
2013-06-09 23:36:45 +02:00
Andy Wingo
e78991aa36 Add RTL assembler
* module/Makefile.am:
* module/system/vm/assembler.scm: New module, implementing an assembler
  for RTL.

* test-suite/Makefile.am:
* test-suite/tests/rtl.test: New test suite.

* module/system/vm/elf.scm (make-elf-symbol*): Add constructor; export
  as make-elf-symbol.
  (elf-symbol-len): New export.
  (write-elf32-symbol, write-elf64-symbol): New helpers.
  (write-elf-symbol): New export.
2013-06-09 17:28:25 +02:00