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

852 commits

Author SHA1 Message Date
Rob Browning
136c3a4c4a Recognize m68k, s390x, and sh4 as compilation targets
* module/system/base/target.scm (cpu-endianness, triplet-pointer-size):
  Add cases for "m68k", "sh4", and "s390x".

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2014-11-19 14:07:10 +01:00
Daniel Llorens
0f259045e1 Intern general arrays
* module/system/vm/assembler.scm (intern-constant, link-data): handle
  the array case.
2014-09-30 11:35:08 +02:00
Mark H Weaver
856d318a9f Merge branch 'stable-2.0'
Conflicts:
	benchmark-suite/benchmarks/ports.bm
	libguile/async.h
	libguile/bytevectors.c
	libguile/foreign.c
	libguile/gsubr.c
	libguile/srfi-1.c
	libguile/vm-engine.h
	libguile/vm-i-scheme.c
	module/Makefile.am
	module/language/tree-il/analyze.scm
	module/language/tree-il/peval.scm
	module/scripts/compile.scm
	module/scripts/disassemble.scm
	test-suite/tests/asm-to-bytecode.test
	test-suite/tests/peval.test
	test-suite/tests/rdelim.test
2014-09-30 03:50:47 -04:00
Ludovic Courtès
ffd3e55cfd Recognize more ARM targets.
Suggested by Dale P. Smith.

* module/system/base/target.scm (cpu-endianness): Add cases for
  "arm.*eb", "^aarch64.*be", and "aarch64".  Change "arm" case to
  "arm.*".
  (triplet-pointer-size): Allow underscore as in 'aarch64_be'.
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["armeb-unknown-linux-gnu",
  "aarch64-linux-gnu", "aarch64_be-linux-gnu"]: New tests.
2014-07-04 17:26:41 +02:00
Ludovic Courtès
df8c52e93d Recognize arm-* target triplets.
Reported by Sylvain Beucler <beuc@beuc.net>.

* module/system/base/target.scm (cpu-endianness): Add case where CPU is
  "arm".
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["arm-unknown-linux-androideabi"]:
  New test.
2014-07-04 15:35:55 +02:00
Andy Wingo
d613ccaaa0 Compiler emits br-if-logtest
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (logtest):
* module/language/cps/types.scm (logtest):
* module/system/vm/assembler.scm (system):
* module/system/vm/disassembler.scm (compute-labels): Add backend
  support for the logtest instruction.
2014-07-03 15:03:40 +02:00
Andy Wingo
8c6206f319 Add br-if-logtest opcode
* libguile/vm-engine.c (br-if-logtest): New opcode.
* module/system/vm/disassembler.scm (code-annotation): Add branch
  annotation support.
2014-07-03 14:50:50 +02:00
Andy Wingo
c90e2c6087 Fix source-line-for-user for unknown line
* module/system/vm/debug.scm (source-line-for-user): Fix to allow for
  unknown lines.
2014-05-31 21:15:06 -04:00
Andy Wingo
5062a56df0 Fix compute-predecessors bug in frame.scm
* module/system/vm/frame.scm (compute-predecessors): Fix bug in
  resolving targets of backwards branches.
2014-05-31 21:15:05 -04:00
Andy Wingo
7af8115675 Fix frame-call-representation for frames from apply-hook
* module/system/vm/frame.scm (frame-call-representation): Fix when
  called on frames that are created from the apply hook.
2014-05-04 22:51:34 +02:00
Andy Wingo
423164efa6 Program printing tweaks
* module/system/vm/program.scm (print-program): New public interface --
  the guts of write-program, but refactored to be able to work when only
  given an addr.
  (write-program): Use print-program.

* module/system/vm/frame.scm (frame-call-representation): Remove attempt
  to abbreviate procedure representations; was confusing because the
  result would write as a string, quotes and all.
2014-05-04 22:41:48 +02:00
Andy Wingo
f5cb70e94a Refactorings to apply-hook and push-continuation-hook
* libguile/vm-engine.c (vm_engine): Always invoke the apply hook after
  the ip has been reset.  Avoids problems in frame-bindings, which
  builds its bindings map based on the IP.  Invoke push-continuation
  before linking the new frame, so that more locals are available to the
  frame inspector.

* module/system/vm/traps.scm (trap-in-procedure): No need for a
  push-cont handler, as the apply handler will exit the frame.
2014-05-04 14:09:42 +02:00
Andy Wingo
7c080187bc frame-address, frame-stack-pointer return offsets
* libguile/frames.c (scm_frame_address, scm_frame_stack_pointer): Return
  offsets instead of absolute pointers.  This is robust in the presence
  of stack relocation.

* module/system/repl/debug.scm (print-registers): Adapt to print sp and
  fp as integers.
2014-05-04 11:46:18 +02:00
Andy Wingo
18f8fd0211 frame-call-representation has #:top-frame? as keyword argument
* module/system/vm/frame.scm (frame-call-representation): Change
  top-frame? argument to be a keyword instead of an optional argument.

* module/system/vm/trace.scm (print-application): Adapt caller.
2014-05-04 11:18:54 +02:00
Andy Wingo
de0233af17 Fix inner and outer stack cuts to match on procedure code
* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs.

* libguile/programs.h:
* libguile/programs.c (scm_program_address_range): New internal
  procedure.

* libguile/stacks.c (narrow_stack): Interpret a pair of integers as an
  address range.  If a cut is a procedure, attempt to resolve it to an
  address range.
  (scm_make_stack): Update docstring.

* module/system/vm/program.scm (program-address-range): New exported
  procedure.

* module/statprof.scm (statprof, gcprof): Use program-address-range to
  get the outer-cut, for efficiency.
2014-05-01 14:26:20 +02:00
Andy Wingo
d7a67c3e91 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	.gitignore
	doc/example-smob/Makefile
	doc/ref/api-smobs.texi
	doc/ref/libguile-concepts.texi
	doc/ref/libguile-smobs.texi
	libguile.h
	libguile/finalizers.c
	libguile/finalizers.h
	libguile/goops.c
	module/language/tree-il/compile-glil.scm
	module/oop/goops.scm
2014-04-28 18:51:21 +02:00
Andy Wingo
a7ee7f7cbf New foreign object facility, to replace SMOBs
* libguile/foreign-object.c:
* libguile/foreign-object.h:
* module/system/foreign-object.scm:
* test-suite/standalone/test-foreign-object-c.c:
* test-suite/standalone/test-foreign-object-scm: New files.

* test-suite/standalone/Makefile.am:
* module/Makefile.am:
* libguile/Makefile.am: Add new files.

* libguile.h: Add foreign-object.h.
* libguile/init.c (scm_i_init_guile): Call scm_register_foreign_object.
2014-04-28 10:59:11 +02:00
Mark H Weaver
475772ea57 Merge branch 'stable-2.0'
Conflicts:
	GUILE-VERSION
	NEWS
	guile-readline/ice-9/readline.scm
	libguile/async.c
	libguile/backtrace.c
	libguile/deprecated.h
	libguile/gc-malloc.c
	libguile/gdbint.c
	libguile/init.c
	libguile/ioext.c
	libguile/mallocs.c
	libguile/print.c
	libguile/rw.c
	libguile/scmsigs.c
	libguile/script.c
	libguile/simpos.c
	libguile/snarf.h
	libguile/strports.c
	libguile/threads.c
	libguile/vm-i-scheme.c
	libguile/vm-i-system.c
	module/srfi/srfi-18.scm
	test-suite/Makefile.am
	test-suite/standalone/test-num2integral.c
2014-04-25 02:06:01 -04:00
Mark H Weaver
e0da53b4fe Support weak vectors, arrays, and bitvectors in (system base types).
* module/system/base/types.scm (%tc7-wvect, %tc7-array, %tc7-bitvector):
  New variables.
  (cell->object): Add cases for weak vectors, arrays, and bitvectors.
2014-04-24 18:22:04 -04:00
Andy Wingo
d38ca16e2c Add make-vector opcode
* libguile/vm-engine.c (make-vector): New opcode.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Support the new opcode.
  (*bytecode-minor-version*): Bump.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* test-suite/tests/compiler.test ("limits"): Add vector test.
2014-04-21 22:47:33 +02:00
Andy Wingo
d4b3a36d42 Operations on 8-bit and 12-bit operands shuffle args into range
* module/language/cps/slot-allocation.scm (allocate-slots): Avoid
  allocating locals in the range [253,255].

* module/system/vm/assembler.scm: List exports explicitly.  For
  operations with limited-range operands, export wrapper assemblers that
  handle shuffling their operands into and out of their range.
  (define-assembler): Get rid of enclosing begin.
  (shuffling-assembler, define-shuffling-assembler): New helpers to
  define shuffling wrapper assemblers.
  (emit-mov*, emit-receive*): New functions.
  (shuffle-up-args): New helper.
  (standard-prelude, opt-prelude, kw-prelude): Call shuffle-up-args
  after finishing.

* test-suite/tests/compiler.test ("limits"): Add test cases.
2014-04-21 22:47:28 +02:00
Andy Wingo
28e12ea0c4 More expansion-time-only definitions in assembler.scm
* module/system/vm/assembler.scm (define-inline): Change so that the
  defined macro is only defined at expansion-time.
  (u32-ref, u32-set!, s32-ref, s32-set!, pack-arity-flags): Use
  define-inline.
  (pack-flags, assert-match, *block-size*, id-append, assembler)
  (define-assembler, visit-opcodes, define-macro-assembler): Wrap in
  eval-when expand.
2014-04-21 12:13:54 +02:00
Andy Wingo
dece041203 define-inline in assembler.scm
* module/system/vm/assembler.scm (define-inline): New local helper.
  Update local users of define-inlinable to use it.
2014-04-21 12:01:50 +02:00
Andy Wingo
c09708f985 VM opcodes only have <24-bit slot operands in the first word
* libguile/vm-engine.c (make-array): Change to only have
  restricted-width operands in the first word.  This instruction is
  currently unused, however.

* module/system/vm/assembler.scm (assembler):
* module/system/vm/disassembler.scm (disassembler): Disallow
  restricted-width operands in tail words.
2014-04-20 11:52:14 +02:00
Andy Wingo
6eae3141bf Fix a frame-call-representation bug
* module/system/vm/frame.scm (frame-call-representation): Fix logic for
  displaying names of non-procedures and procedures out of arities.
2014-04-16 17:16:10 +02:00
Andy Wingo
d856931d8d frame-call-representation checks available-bindings, as appropriate
* module/system/vm/frame.scm (available-bindings): Map indexes in such a
  way that the first argument is index 1.
  (frame-call-representation): Update to search the bindings for live
  bindings.
2014-04-16 14:19:18 +02:00
Andy Wingo
1a2711a848 Update frame-bindings interface
* module/system/repl/debug.scm (print-locals): Update to work with new
  interface.
  (frame->module): Update.  Still doesn't work due to lack of
  `program-module', though.

* module/system/vm/program.scm (make-binding, binding:name)
  (binding:definition-offset, program-arity-bindings-for-ip): Remove
  these.

* module/system/vm/frame.scm (<binding>): New type.
  (available-bindings): Return a list of <binding> instances.
  (frame-lookup-binding, frame-binding-set!, frame-binding-ref):
  (frame-environment, frame-object-name): Adapt.
2014-04-16 13:58:17 +02:00
Andy Wingo
c4c9bfffd7 Implement frame-bindings
* module/system/vm/frame.scm (parse-code, compute-predecessors):
  (compute-genv, compute-defs-by-slot, compute-killv, available-bindings):
  (frame-bindings): Add a bunch of hairy code to compute the set of
  bindings that are live in a frame.
2014-04-16 13:56:08 +02:00
Andy Wingo
bc5bcf6637 Add arity-code
* module/system/vm/debug.scm (arity-code): New interface.
2014-04-16 12:58:35 +02:00
Andy Wingo
20d7d68284 Add parsing interfaces to the disassembler
* module/system/vm/disassembler.scm (instruction-length):
  (instruction-has-fallthrough?, instruction-relative-jump-targets):
  (instruction-slot-clobbers): New interfaces; to be used when
  determining the bindings available at a given point of a procedure.
2014-04-16 12:58:20 +02:00
Andy Wingo
f9425c8000 Add ability to query local definitions for a procedure
* module/system/vm/debug.scm (arity-definitions): New interface.

* module/system/vm/program.scm (make-binding, binding:boxed?)
  (binding:index, binding:start, binding:end): Remove.
  (binding:definition-offset, binding:slot): Add.
  (program-arity-bindings-for-ip): Rename from program-bindings-for-ip,
  as it gives all definitions in an arity.  The user will have to do
  data-flow analysis to recover the set of variables that are actually
  available at any given point.
  (arity->arguments-alist): Remove crufty code.
2014-04-15 22:24:48 +02:00
Andy Wingo
4cbe4d72aa Fix rtl tests
* module/system/vm/assembler.scm (write-arities): Add a diagnostic.

* test-suite/tests/rtl.test: Fix tests to emit "definition"
  instructions.
2014-04-15 22:00:30 +02:00
Andy Wingo
c271065e54 Fix frame-call-representation for primitive applications
* module/system/vm/frame.scm (frame-call-representation): Fix to work
  for primitives.

* test-suite/tests/eval.test ("stacks"): Update expected result for
  substring.
2014-04-15 21:47:46 +02:00
Andy Wingo
67ddb7e264 Assembler residualizes local variable definition locations
* module/system/vm/assembler.scm (write-arities): Serialize definition
  locations after names.
  (definition): Store definition as a byte offset.
2014-04-15 20:25:16 +02:00
Andy Wingo
1a82c2012b Bump minor objcode version for recent changes
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2014-04-15 20:20:01 +02:00
Andy Wingo
c3651bd55b Write all local variable names into the arities section
* module/system/vm/assembler.scm (put-uleb128, put-sleb128)
  (port-position): Lift out these helpers.
  (arity-header-len, write-arities, link-arities): Add "nlocals" to the
  arity headers.  Write names of all locals into the arities section,
  not just the arguments.  Write them as uleb128's instead of uint32's,
  to save space.

* module/system/vm/debug.scm (arity-header-len, arity-nlocals*)
  (arity-nlocals, arity-locals, arity-arguments-alist): Adapt to new
  encoding for arities.
2014-04-15 18:24:25 +02:00
Andy Wingo
cade4c8fe1 Tweak arities debugging representation
* module/system/vm/assembler.scm (meta-arities-size, write-arity-links):
* module/system/vm/debug.scm (arity-keyword-args)
  (arity-arguments-alist): Rewrite to put they keyword literals link
  first.  Unfortunately requires a recompile :/
2014-04-15 15:27:19 +02:00
Andy Wingo
78351d1065 Beginnings of local variable information
* module/system/vm/assembler.scm (<arity>, begin-kw-arity, end-arity):
  (definition): Add definition macro-instruction.  Arrange to record
  variable definitions.

* module/language/cps/compile-bytecode.scm (compile-fun): Emit
  definition macro-instructions as appropriate.
2014-04-15 14:14:15 +02:00
Andy Wingo
bec786c1fe Better backtraces for optimized closures
* module/system/vm/debug.scm (arity-keyword-args, find-program-arity):
  New exports.

* module/system/vm/frame.scm (frame-call-representation): Prefer to use
  the frame IP to get the procedure.
2014-04-15 11:18:50 +02:00
Andy Wingo
560bfa9241 Improve disassembly for optimized closures
* module/system/vm/disassembler.scm (code-annotation): Add call-label
  and tail-call-label cases.
  (disassemble-addr): With call-label we can see sets of mutually
  recursive functions, so keep a global "visited?" set.
2014-04-13 14:40:22 +02:00
Andy Wingo
0534735314 Remove unneeded local exact-integer? definition
* module/system/vm/assembler.scm (link-debug): Remove unneeded
  exact-integer? definition.
2014-03-31 18:20:55 +02:00
Andy Wingo
9a1dfb7d2e Continuation labels and variable identifiers may be integers
* module/language/cps.scm (label-counter, var-counter): New parameters,
  for producing fresh label and var names.
  (fresh-label, fresh-var): New procedures.
  (let-fresh): New macro, will replace let-gensyms.
  (build-cps-term): Use let-fresh.

* module/language/tree-il/compile-cps.scm: Use let-fresh to generate
  fresh names.

* module/system/vm/assembler.scm (make-meta, begin-kw-arity): Allow
  exact integers as labels.
  (link-debug): Explicitly mark low-pc as being an "addr" value.
2014-03-31 18:20:55 +02:00
Andy Wingo
c2247b782a Out-of-memory situations raise exceptions instead of aborting
* libguile/gc.c (scm_oom_fn, scm_init_gc): Install an out-of-memory
  handler that raises an unwind-only out-of-memory exception.
  (scm_gc_warn_proc, scm_init_gc): Install a warning proc that tries to
  print to the current warning port, if the current warning port is a
  file port.
  (scm_gc_after_nonlocal_exit): New interface.  Should be called after a
  nonlocal return to potentially collect memory; otherwise allocations
  could try to expand again when they should collect.

* libguile/continuations.c (scm_i_make_continuation):
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/vm.c (scm_call_n): Call scm_gc_after_nonlocal_exit after
  nonlocal returns.

* libguile/throw.c (abort_to_prompt, throw_without_pre_unwind): Rework
  to avoid allocating memory.
  (scm_report_out_of_memory): New interface.
  (scm_init_throw): Pre-allocate the arguments for stack-overflow and
  out-of-memory errors.

* module/ice-9/boot-9.scm: Add an out-of-memory exception printer.
* module/system/repl/error-handling.scm (call-with-error-handling): Add
  out-of-memory to the report-keys set.

* libguile/gc-malloc.c (scm_realloc): Call scm_report_out_of_memory if
  realloc fails.

* libguile/error.h:
* libguile/error.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_memory_error): Deprecate.

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-out-of-memory: New test case.
2014-03-22 15:49:31 +01:00
Andy Wingo
22806c244a Document stack-overflow handlers, limits, and unwind-only exceptions
* module/system/repl/error-handling.scm (call-with-error-handling): Add
  #:report-keys kwarg, so that unwind-only exceptions (stack-overflow in
  particular) get reported.

* doc/ref/api-debug.texi (Pre-Unwind Debugging): Add documentation for
  #:report-keys kwarg of call-with-error-handling.
  (Stack Overflow): New subsubsection.
  (Debug Options): Remove discussion of stack overflow.
2014-03-16 15:32:39 +01:00
Mark H Weaver
f2de4fac88 Fix (system base types) on big-endian systems.
* module/system/base/types.scm (cell->object): When reading stringbufs,
  use UTF-32BE on big-endian systems.
2014-03-15 13:23:21 -04:00
Andy Wingo
f764e2590f Remove default soft stack limit; add call-with-stack-overflow-handler
* libguile/vm.h:
* libguile/vm.c (default_max_stack_size, initialize_default_stack_size):
  Remove the default stack limit.  In this way, programs run from the
  command line or outside of the REPL will have no soft stack limit.
  (make_vm): Change `max_stack_size' field to be a stack of limits and
  handlers.
  (current_overflow_size, should_handle_stack_overflow)
  (reset_stack_limit, wind_overflow_handler, unwind_overflow_handler)
  (vm_expand_stack): If the stack surpasses a user-set limit, call the
  user-specified handler within its outer stack limit.
  (call-with-stack-overflow-handler): New interface.

* module/system/vm/vm.scm: Export call-with-stack-overflow-handler.
2014-03-12 17:18:13 +01:00
Andy Wingo
ce47749045 (system vm program) exports primitive?
* module/system/vm/program.scm: Export primitive?.  Primitive
  program-code doesn't map uniquely to the primitive, which may be of
  interest to various meta-level utilities like statprof.
2014-02-28 17:42:45 +01:00
Ludovic Courtès
5f4b817df9 Add (system base types).
* module/system/base/types.scm, test-suite/tests/types.test: New files.
* module/Makefile.am (SYSTEM_BASE_SOURCES): Add system/base/types.scm.
* test-suite/Makefile.am (SCM_TESTS): Add tests/types.test.
2014-02-18 23:04:30 +01:00
Andy Wingo
26c19d79d9 PT_DYNAMIC inside some other PT_LOAD segment
* libguile/loader.c (load_thunk_from_memory): Only load PT_LOAD
  segments, as libc does.  The PT_DYNAMIC segment should be inside some
  other PT_LOAD segment.

* module/system/vm/linker.scm (segment-kind): Give the .dynamic segment
  PT_LOAD kind, so that it is written in a PT_LOAD segment.
  (count-segments): Add one if there is a SHT_DYNAMIC segment.
  (allocate-segment): Set the paddr to the addr, as binutils do.
  (record-special-segments): New routine, to write out special segments
  like PT_DYNAMIC.
  (allocate-elf): Call record-special-segments.
2014-02-17 14:15:34 +01:00
Andy Wingo
3c08b6c1b2 Add elf-symbol-value-offset, for properly relocating symtab entries
* module/system/vm/elf.scm (elf-symbol-value-offset): New export.
2014-02-16 15:58:44 +01:00