Skip to content

Commit

Permalink
Hash Table interfaces (#1123)
Browse files Browse the repository at this point in the history
This brings hash table interfaces to the runtime, with native
(specializable) implementations using open addressing and quadratic
probing. The impetus for implementing gerbil-native hash tables is SMP
read-safety and the ability to internally wrap
mutexes/(fail-fast-)read-write-locks if the user so desires. The problem
stems from the lazy rehashing in gambit native hash tables, which means
a read can actually write, which can lead to disaster at so many fronts
as concurrent reads can crash in SMP. Bonus points increased
performance, from better locality.

Work Items:
- [x] raw table implementation with common specializations
- [x] use symbolic tables in keyword-dispatch
- [x] use symbolic tables in the mop
- [x] bring interfaces into the core
- [x] HashTable interface and implementation of hash-* primitives with
it
- [x] fix tests

Follow Up:
- [ ] implement interface method specializations now that they are in
the core
  • Loading branch information
vyzo authored Feb 19, 2024
1 parent 18e60a9 commit 4e5070c
Show file tree
Hide file tree
Showing 155 changed files with 108,279 additions and 95,159 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/bootstrap/** linguist-generated
14 changes: 7 additions & 7 deletions doc/reference/dev/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ $ mkdir bootstrap/gerbil
$ cp gerbil/prelude/builtin.ssxi.ss bootstrap/gerbil
# compile the bootstrap with the current compiler
$ gxc -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,system,loader,control,c3,mop,error,thread,syntax,eval,repl,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
$ gxc -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,table,control,system,c3,mop,error,interface,hash,thread,syntax,eval,repl,loader,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
```

### Recursively Recompiling the bootstrap
Expand All @@ -193,15 +193,15 @@ bootstrap recompilation.
```
$ cd src
$ rm -rf bootstrap/*
$ gxc -no-ssxi -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,system,loader,control,c3,mop,error,thread,syntax,eval,repl,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
$ gxc -no-ssxi -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,table,control,system,c3,mop,error,interface,hash,thread,syntax,eval,repl,loader,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
```

If you have made changes in the compiler optimizer meta and the extant
compiler does not accept your code, you may want to try without
optimizations:
compiler does not accept your code (or generates broken code), you may
want to try without optimizations:

```
$ gxc -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,system,loader,control,c3,mop,error,thread,syntax,eval,repl,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
$ gxc -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,table,control,system,c3,mop,error,interface,hash,thread,syntax,eval,repl,loader,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
```

Otherwise, you are likely violating some of the bootstrap strictures; see below.
Expand All @@ -217,7 +217,7 @@ $ ../build.sh stage1

If you compiled the base bootstrap without optimization, you will also have to set `GERBIL_BUILD_NOOPT` during the stage1 build:
```
GERBIL_BUILD_NOOPT=t ../build.sh stage1
$ GERBIL_BUILD_NOOPT=t ../build.sh stage1
```

After you have built stage1, you can use it to build the recursive
Expand All @@ -229,7 +229,7 @@ $ cd src
$ rm -rf bootstrap/*
$ mkdir -p bootstrap/gerbil
$ cp gerbil/prelude/builtin.ssxi.ss bootstrap/gerbil
$ ../build.sh env gxc -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,system,loader,control,c3,mop,error,thread,syntax,eval,repl,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
$ ../build.sh env gxc -O -d bootstrap -s -S gerbil/prelude/core.ss gerbil/runtime/{gambit,util,table,control,system,c3,mop,error,interface,hash,thread,syntax,eval,repl,loader,init}.ss gerbil/runtime.ss gerbil/expander/{common,stx,core,top,module,compile,root,stxcase}.ss gerbil/expander.ss gerbil/compiler/{base,compile,optimize-base,optimize-xform,optimize-top,optimize-spec,optimize-ann,optimize-call,optimize,driver,ssxi}.ss gerbil/compiler.ss gerbil/prelude/gambit.ss
```

And you have a brand new recursive bootstrap you can use. From here
Expand Down
Loading

0 comments on commit 4e5070c

Please sign in to comment.