Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aoh committed May 9, 2018
2 parents 69197a8 + 2856c68 commit 2dd7f77
Show file tree
Hide file tree
Showing 136 changed files with 5,027 additions and 4,621 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ fasl/bootp.fasl
fasl/ol.fasl
tmp
bin/ol
bin/ol-old
bin/vm
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ fasl/boot.fasl: fasl/init.fasl
# start bootstrapping with the bundled init.fasl image
cp fasl/init.fasl fasl/boot.fasl

fasl/ol.fasl: bin/vm fasl/boot.fasl owl/*.scm scheme/*.scm
fasl/ol.fasl: bin/vm fasl/boot.fasl owl/*.scm scheme/*.scm tests/*.scm tests/*.sh
# selfcompile boot.fasl until a fixed point is reached
bin/vm fasl/boot.fasl --run owl/ol.scm -s none -o fasl/bootp.fasl
ls -la fasl/bootp.fasl
ls -l fasl/bootp.fasl
# check that the new image passes tests
CC="$(CC)" tests/run all bin/vm fasl/bootp.fasl
CC="$(CC)" sh tests/run all bin/vm fasl/bootp.fasl
# copy new image to ol.fasl if it is a fixed point, otherwise recompile
diff -q fasl/boot.fasl fasl/bootp.fasl && cp fasl/bootp.fasl fasl/ol.fasl || cp fasl/bootp.fasl fasl/boot.fasl && make fasl/ol.fasl
cmp -s fasl/boot.fasl fasl/bootp.fasl && cp fasl/bootp.fasl fasl/ol.fasl || cp fasl/bootp.fasl fasl/boot.fasl && make fasl/ol.fasl


## building just the virtual machine to run fasl images

Expand All @@ -46,6 +46,12 @@ c/vm.c: c/ovm.c
echo "unsigned char *heap = 0;" > c/vm.c
cat c/ovm.c >> c/vm.c

manual.md: doc/manual.md owl/*.scm scheme/*.scm
cat doc/manual.md > manual.md
bin/find-documentation.sh >> manual.md

manual.pdf: manual.md
pandoc --latex-engine xelatex -o manual.pdf manual.md

## building standalone image out of the fixed point fasl image

Expand All @@ -59,22 +65,22 @@ c/diet-ol.c: fasl/ol.fasl
bin/ol: c/ol.c
# compile the real owl repl binary
$(CC) $(CFLAGS) $(LDFLAGS) -o bin/olp c/ol.c
CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" tests/run all bin/olp
CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh tests/run all bin/olp
test -f bin/ol && mv bin/ol bin/ol-old || true
mv bin/olp bin/ol


## running unit tests manually

fasltest: bin/vm fasl/ol.fasl
CC="$(CC)" tests/run all bin/vm fasl/ol.fasl
CC="$(CC)" sh tests/run all bin/vm fasl/ol.fasl

test: bin/ol
CC="$(CC)" tests/run all bin/ol
CC="$(CC)" sh tests/run all bin/ol

random-test: bin/vm bin/ol fasl/ol.fasl
CC="$(CC)" tests/run random bin/vm fasl/ol.fasl
CC="$(CC)" tests/run random bin/ol
CC="$(CC)" sh tests/run random bin/vm fasl/ol.fasl
CC="$(CC)" sh tests/run random bin/ol


## data
Expand Down Expand Up @@ -127,4 +133,3 @@ todo: bin/vm
bin/vm fasl/ol.fasl -n owl/*.scm | less

.PHONY: all owl install uninstall todo test fasltest random-test owl standalone fasl-update clean simple-ol

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ functions. To make programs run faster, one can use for example:

For further documentation and updates, see:

https://haltp.org/n/owl

https://github.com/aoh/owl-lisp

https://haltp.org/f/owl-manual.pdf


3 changes: 2 additions & 1 deletion THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ has gotten many useful bug reports, suggestions and patches during the
course of development. Here is a partial list of people who have helped
in the development:

Jo Henke A ton of improvements
Doug Currie GC improvements, data representation optimizations, etc.
Jown Cowan A slew of filed bugs.
John Cowan A slew of filed bugs.
Pekka Pietikäinen Portability suggestions and patches.
Erno Kuusela Portability suggestions and general insight.

Expand Down
10 changes: 3 additions & 7 deletions bench/indexed.owl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
; - iff (integer finite map)
; - rlist (random access list)
; - vector (a wide-branched tree)
;
;
; notice that these are not otherwise equal data structures
; rlists have O(1) cons, vectors O(1) length, iffs can be
; sparse but take a bit more memory etc. still, useful to
; know how they do for reading.
;
;

(define cutoff-time 50) ; run each test until elaped time is over >cutoff-time ms

Expand Down Expand Up @@ -85,7 +85,7 @@

(define (battle len participants ordered? op)
;(print* (list (if ordered? "in order " "random access ") "read of " len " elems"))
(mail 1 (render (length participants) '())) (flush-port 1)
(mail 1 (render (length participants) '()))
(if (null? participants)
(begin
(print ")")
Expand All @@ -112,26 +112,22 @@ numbers can be before reading/writing each value once takes
over " cutoff-time "ms."))
(print "--- READ BENCHMARK ----------------------------")
(display " - in-order access (")
(flush-port 1)
(for-each
(λ (p) (print* (list " + " (cdr p) " " (car p))))
(battle 1 '(list rlist vector iff) #t read-each))
(print "")
(display " - random access (")
(flush-port 1)
(for-each
(λ (p) (print* (list " + " (cdr p) " " (car p))))
(battle 1 '(list rlist vector iff) #f read-each))
(print "")
(print "--- WRITE BENCHMARK ----------------------------")
(print "vectors have no write yet..")
(display " - in-order write (")
(flush-port 1)
(for-each
(λ (p) (print* (list " + " (cdr p) " " (car p))))
(battle 1 '(list rlist iff) #t write-each))
(display " - random order write (")
(flush-port 1)
(for-each
(λ (p) (print* (list " + " (cdr p) " " (car p))))
(battle 1 '(list rlist iff) #f write-each))
Expand Down
37 changes: 27 additions & 10 deletions bin/builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# and run randomized tests in the meantime.
# you probably don't want to run this.

renice +20 $$

DELAY=60 # sleep n seconds between test runs
TESTMINS=15 # minutes of random unit tests
THEOREMS=5000 # iterations of theorem test
Expand All @@ -18,11 +16,13 @@ MD5=md5sum
echo "" | $MD5 | grep -q 68b329da9893e34099c7d8ad5cb9c940 || MD5="md5"
ME=$($MD5 < bin/builder)

echo "My version is $ME"
die() {
echo "$@"
exit 1
}

fail() {
echo "error: $@"
exit 1
die "ERROR: $@"
}

check_exe() {
Expand All @@ -32,7 +32,7 @@ check_exe() {

notify() {
echo "MAIL: $@"
mailx -S "from=Note <$(whoami)@$(hostname --long)>" -S smtp=$SMTP -s "$(echo $@)" $EMAIL
heirloom-mailx -S "from=Note <$(whoami)@$(hostname --long)>" -S smtp=$SMTP -s "$(echo $@)" $EMAIL
}

notify_irc() {
Expand All @@ -49,8 +49,24 @@ thisgit() {
git log | head -n 1 | sed -e 's/.* \(......\).*/\1.../'
}

confirm_or_exit() {
echo "$@"
read -p "yes/no? " RESPONSE
echo $RESPONSE | grep -Eqi "^y(es)?$" || die "taking that as a no"
}

# check that user knows what this script does and really wants to run it
# unless --really is given as first argument

test "$1" = "--really" \
|| confirm_or_exit "Owl is built with make. This script starts continuous builds and related tool tests at $WORK. Is this what you are trying to do?"

echo "My version is $ME"

renice +20 $$

echo "Checking deps:"
for DEP in nc $MD5 mailx
for DEP in nc $MD5 heirloom-mailx
do
check_exe $DEP
done
Expand All @@ -70,15 +86,15 @@ esac
date | notify "Builder.sh started on $(hostname)"
date | notify_irc "builder started on $(hostname) ($(uname), $(uname -m), $(echo $ME | dd bs=1 count=5 2>/dev/null))"

test -d $WORK || fail "work directory '$WORK' doesn't exist"

mkdir -p $WORK || die "cannot have $WORK"
cd $WORK

echo "*** GETTING SOURCES ***"
for project in owl-lisp $RELATEDPROJECTS
do
echo " - $project"
test -d $project || git clone https://github.com/aoh/$project.git
cd $project && git checkout develop || echo "no develop branch for $project"
done

while true
Expand All @@ -94,7 +110,7 @@ do
git pull
NEWME=$($MD5 < bin/builder)
echo "old me $ME, new me $NEWME"
test "$ME" = "$NEWME" || { notify_irc "I sense bin/builder has changed."; cd "$MYDIR"; git pull; exec bin/builder; }
test "$ME" = "$NEWME" || { notify_irc "I sense bin/builder has changed."; cd "$MYDIR"; git pull; exec bin/builder --really; }
make clean >/dev/null 2>&1
VERSION=$(thisgit)
echo building owl
Expand All @@ -118,6 +134,7 @@ do
echo "*** BUILDING SIDE PROJECTS ***"
for project in $RELATEDPROJECTS
do
mkdir -p $HOME/ram
cd $HOME/ram
echo " - fresh $project build"
cd $project
Expand Down
12 changes: 12 additions & 0 deletions bin/find-documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

for FILE in owl/*.scm scheme/*.scm
do
head -n 1 "$FILE" | grep -q "^;;; " || continue
NAME=$(grep "^(define-library " $FILE | head -n 1 | sed -e 's/.define-library //')
echo "## $NAME"
echo ""
grep "^;;;" "$FILE" | sed -re 's/;;; ?//'
echo ""
echo
done
60 changes: 60 additions & 0 deletions c/lib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* library mode init */
void init() {
int nobjs=0, nwords=0;
hp = (byte *) &heap; /* builtin heap */
state = IFALSE;
heap_metrics(&nwords, &nobjs);
max_heap_mb = (W == 4) ? 4096 : 65535;
nwords += nobjs + INITCELLS;
memstart = genstart = fp = (word *) realloc(NULL, (nwords + MEMPAD)*W);
if (!memstart) exit(4);
memend = memstart + nwords - MEMPAD;
state = (word) load_heap(nobjs);
}

/* bvec → value library call test with preserved state */
word library_call(size_t len, char *ptr) {
char *pos;
int pads;
word *bvec;
word res;
word program_state = state;
int size;
state = IFALSE;
if (program_state == IFALSE) {
printf("no program state - cannot continue");
exit(1);
}
if (len > FMAX) {
return (char *) NULL;
}
size = ((len % W) == 0) ? (len/W)+1 : (len/W) + 2;
printf("making an argument byte vector with %d bytes in %d words\n", len, size);
pads = (size-1)*W - len;
bvec = fp;
fp += size;
printf("libary call from state %d\n", state);
*bvec = make_raw_header(size, TBVEC, pads);
pos = ((byte *) bvec) + W;
while(len--) *pos++ = *ptr++;
res = vm(program_state, bvec);
if(fixnump(res)) {
printf("Returned %d\n", fixval(res));
} else {
printf("Returned descriptor %d\n", res);
}
return res;
}

int main(int nargs, char **argv) {
init();
char foo[] = {1, 2, 3}; // 0
char bar[] = {4, 5}; // 6
char baz[] = {6, 7, 8, 9}; // 15
library_call(3, &foo);
library_call(2, &bar);
library_call(4, &baz);
return 0;
}


Loading

0 comments on commit 2dd7f77

Please sign in to comment.