Use full length hashes for jit names

This should avoid any possibility of picking conflicting names for
distinct functions. I'm not aware of any actual examples of this, but it
could in principle happen.

I decided to use the full length hashes because picking just-long-enough
names starts to become very cumbersome when doing dynamic loading. You
need to keep track of all your past choices, not just the choices for
the module you're loading, because the one you're loading could refer to
things in previously loaded modules. It would be possible to use shorter
names in a compile-time context, since you have all the names up front.
But you'd still have to remember _those_ for runtime loading, and it
seemed not worth it.

This doesn't include any custom error formatting, because I'd like to
see error messages in the wild before doing anything, but if they're too
verbose, it's possible to override the Racket error reporting to produce
shorter names there, rather than generating them up front.
This commit is contained in:
Dan Doel 2024-05-06 14:59:06 -04:00
parent 9739cfedb2
commit a1ef6a76d1
3 changed files with 7 additions and 6 deletions

View File

@ -221,10 +221,11 @@
[(unison-termlink-builtin name)
(string-append "builtin-" name)]
[(unison-termlink-derived bs i)
(let ([hs (bytevector->base32-string bs #:alphabet 'hex)]
[po (if (= i 0) "" (string-append "." (number->string i)))])
(let* ([hs (bytevector->base32-string bs #:alphabet 'hex)]
[tm (string-trim hs "=" #:repeat? #t)]
[po (if (= i 0) "" (string-append "." (number->string i)))])
(string->symbol
(string-append "ref-" (substring hs 0 8) po)))]))
(string-append "ref-" tm po)))]))
(define (ref-bytes r)
(sum-case (decode-ref r)

View File

@ -5,7 +5,7 @@ Next, we'll download the jit project and generate a few Racket files from it.
```ucm
.> project.create-empty jit-setup
jit-setup/main> pull @unison/internal/releases/0.0.15 lib.jit
jit-setup/main> pull @unison/internal/releases/0.0.16 lib.jit
```
```unison

View File

@ -20,9 +20,9 @@ Next, we'll download the jit project and generate a few Racket files from it.
🎉 🥳 Happy coding!
jit-setup/main> pull @unison/internal/releases/0.0.15 lib.jit
jit-setup/main> pull @unison/internal/releases/0.0.16 lib.jit
Downloaded 15060 entities.
Downloaded 15091 entities.