% cat limited.scm
#! /usr/bin/env gsi -:max-heap=100M
(##gc-report-set! #t)
(##gc)
(define (go)
(let loop ((size 1000000) (last #f))
(println size)
(loop (* size 2) (make-vector size))))
(with-exception-catcher pp go)
% chmod +x limited.scm
% ./limited.scm
*** GC: 135us, 130K alloc, 12M heap, 84K live (1% 84288+1488)
1000000
2000000
*** GC: 2.4ms, 135K alloc, 52M heap, 23M live (44% 85168+24001584)
4000000
*** GC: 5.1ms, 139K alloc, 101M heap, 46M live (46% 85168+48001584)
8000000
*** GC: 9.3ms, 143K alloc, 105M heap, 92M live (88% 85168+96001584)
16000000
*** GC: 17ms, 147K alloc, 108M heap, 61M live (57% 85168+64001536)
#<heap-overflow-exception #2>
% gsc -exe limited.scm
% ./limited
*** GC: 109us, 71K alloc, 12M heap, 64K live (1% 64464+1488)
1000000
2000000
*** GC: 525us, 75K alloc, 36M heap, 15M live (42% 64928+16001536)
4000000
*** GC: 260us, 79K alloc, 69M heap, 31M live (45% 64928+32001536)
8000000
*** GC: 1.9ms, 82K alloc, 108M heap, 61M live (57% 64928+64001536)
16000000
*** GC: 3.4ms, 86K alloc, 12M heap, 65K live (1% 64928+1488)
#<heap-overflow-exception #2>
misc/build-gambit-emscripten.tgz
... it is quite likely that it has suffered from bitrot, but it shouldn't be too hard to get it working again. This biggest problem is probably the evolution of emscripten, so doing a checkout of an old version of emscripten may be needed if you just want to quickly experiment with this.
(eval '(begin
(##namespace ("c#"))
(##include "~~/lib/header.scm")))
This seems to work
heine:~/programs/gambit/gambit> gsi -:=. gsc/igsc.scm
loading "~~/gsc/_host.scm"
loading "~~/gsc/_utils.scm"
loading "~~/gsc/_source.scm"
loading "~~/gsc/_parms.scm"
loading "~~/gsc/_env.scm"
loading "~~/gsc/_ptree1.scm"
loading "~~/gsc/_ptree2.scm"
loading "~~/gsc/_gvm.scm"
loading "~~/gsc/_back.scm"
loading "~~/gsc/_front.scm"
loading "~~/gsc/_prims.scm"
loading "~~/gsc/_assert.scm"
loading "~~/gsc/_asm.scm"
loading "~~/gsc/_x86.scm"
loading "~~/gsc/_arm.scm"
loading "~~/gsc/_riscv.scm"
loading "~~/gsc/_codegen.scm"
loading "~~/gsc/_t-univ-1.scm"
loading "~~/gsc/_t-univ-2.scm"
loading "~~/gsc/_t-univ-3.scm"
loading "~~/gsc/_t-univ-4.scm"
loading "~~/gsc/_t-cpu-abstract-machine.scm"
loading "~~/gsc/_t-cpu-primitives.scm"
loading "~~/gsc/_t-cpu-object-desc.scm"
loading "~~/gsc/_t-cpu-utils.scm"
loading "~~/gsc/_t-cpu-backend-x86.scm"
loading "~~/gsc/_t-cpu-backend-arm.scm"
loading "~~/gsc/_t-cpu-backend-riscv.scm"
loading "~~/gsc/_t-cpu.scm"
loading "~~/gsc/_t-c-1.scm"
loading "~~/gsc/_t-c-3.scm"
loading "~~/gsc/_t-c-2.scm"
loading "~~/gsc/_gsclib.scm"
loading "~~/gsc/_gsc.scm"
loading "~~/gsc/_gscdebug.scm"
Gambit v4.9.3-1234-g6acd87df
> (compile-file "c.scm")
"/home/lucier/programs/gambit/gambit/c.o1"
This is in the Gambit source directory after a build.
libs/srfi
instead, which aren't present in the last tagged version.
README
for both head and tagged versions.
@erkin The SRFIs that are builtin are in the list returned by the R7RS procedurefeatures
:
SRFI-0 SRFI-4 SRFI-6 SRFI-8 SRFI-9 SRFI-16 SRFI-18 SRFI-21 SRFI-22 SRFI-23 SRFI-27 SRFI-30 SRFI-39 SRFI-88
Gambit has some additional SRFIs implemented as modules that can be imported with import
:
(import (srfi 28)) ;; Basic Format Strings
(import (srfi 41)) ;; Streams.
(import (srfi 64)) ;; A Scheme API for test suites
(import (srfi 69)) ;; Basic hash tables
(import (srfi 132)) ;; Sort Libraries
(import (srfi 158)) ;; Generators and Accumulators
I’ll look into how best to add that information to Gambit’s README.
@VincentToups https://mailman.iro.umontreal.ca/pipermail/gambit-list/2020-March/009363.html is
a great overview.
Marc Feeley goes into some detail here:
https://gitter.im/gambit/gambit?at=5bc7fb95435c2a518ec448d1
-target js
is all that's really needed
I have a question about style: I'm trying to use case-lambda
and error checking in a reasonable way, and I came up with
(define vector->array
(let ()
(define (five-args vec interval storage-class mutable? safe?)
(if (not (boolean? safe?))
(error "raw-vector->array: The fifth argument is not a boolean: "
vec interval storage-class mutable? safe?)
(four-args vec interval storage-class mutable? safe?)))
(define (four-args vec interval storage-class mutable? safe?)
(if (not (boolean? mutable?))
(error "raw-vector->array: The fourth argument is not a boolean: "
vec interval storage-class mutable?)
(three-args vec interval storage-class mutable? safe?)))
(define (three-args vec interval storage-class mutable? safe?)
(if (not (storage-class? storage-class))
(error "raw-vector->array: The third argument is not a storage-class: "
vec interval storage-class)
(two-args vec interval storage-class mutable? safe?)))
(define (two-args vec interval storage-class mutable? safe?)
(if (not (interval? interval))
(error "raw-vector->array: The second argument is not an interval: "
vec interval)
(let ((indexer (%%interval->basic-indexer interval))
(body-length (storage-class-length storage-class))
(body? (storage-class-body? storage-class)))
(cond ((not (body? vec))
(error "raw-vector->array: The first argument is not suitable for a body of the given storage-class: "
vec interval storage-class))
((not (= (body-length vec) (interval-volume interval)))
(error "vector->array: The length of the first argument is not equal to the volume of the second: "
vec interval))
(else
(%%finish-specialized-array interval
storage-class
vec
indexer
mutable?
safe?))))))
(case-lambda
((vec interval)
(two-args vec interval generic-storage-class (specialized-array-default-mutable?) (specialized-array-default-safe?)))
((vec interval storage-class)
(three-args vec interval storage-class (specialized-array-default-mutable?) (specialized-array-default-safe?)))
((vec interval storage-class mutable?)
(four-args vec interval storage-class mutable? (specialized-array-default-safe?)))
((vec interval storage-class mutable? safe?)
(five-args vec interval storage-class mutable? safe?)))))
Is this reasonable? What do others do?
gambiteer on master
Speed up implementation of SRFI… (compare)
feeley on master
Universal backend: add URL whit… (compare)