Commit Graph

6689 Commits

Author SHA1 Message Date
Dan Doel
d9e0806011 Ormolu changes 2023-09-07 16:46:37 -04:00
Dan Doel
dfc3814c13 Increment code serialization version 2023-09-07 16:41:17 -04:00
Dan Doel
0f52e01f73 Fix up tests w/r/t new ANF constructors 2023-09-07 16:04:25 -04:00
Dan Doel
d91de0ef39 Add fake builtins for sequence split patterns
Previous implementation was directly including primops into the
generated intermediate code, which involved unboxed literal arguments.
These fake builtins allow for generating boxed literals so that no
unboxed data is on the surface stack.

I believe this was the last source of unboxed data on captured stacks.
2023-09-07 16:01:58 -04:00
Dan Doel
9da57e92e9 Store Char in interchange literals
The serialization is the same, but this is a bit less strange as a
representation.
2023-09-07 02:20:45 -04:00
Dan Doel
9c9654d0b4 Alignment for new code constructors
This is necessary for checking equality of code.
2023-09-07 02:18:43 -04:00
Dan Doel
42458974fd Add more literals to value serialization format.
This covers values that are stored as pseudo data types in the Haskell
runtime, which would otherwise need to be serialized using unboxed data
in the byte format.
2023-09-05 17:14:39 -04:00
Dan Doel
bd51afea26 stdHandle didn't match its calling convention
The implementation was producing Maybe, but the calling convention just
called the primop in tail position. This would leave the Just tag on the
unboxed stack afterwards.
2023-09-01 14:10:15 -04:00
Dan Doel
360e8298ee Introduce some new runtime functionality for cases/lits
The goal of these changes is to remove unboxed details from the
interchange formats, and instead exchange values that somewhat resemble
surface level unison values. In some cases, the way this works is
obvious. For instance, the MatchNumeric/NMatch and BLit constructs avoid
having unboxed details in code. However, what might not be so obvious is
the request/data matching constructs. These prevent unboxed values from
occurring on the stack in normal unison functions, which means they no
longer end up in captured continuations.

The unboxed details were originally intended to support optimizations
that would turn surface unison functions into more efficient versions
that operate without any boxing. However, that didn't materialize, and
it seems unlikely that we'll implement it for the Haskell end of things
(we aren't really obliged to do this ourselves for good performance in
scheme). So, some of these new methods of doing things might actually be
more efficient than what was happening previously.
2023-09-01 12:59:29 -04:00
mergify[bot]
e7b891914b
Merge pull request #4265 from unisonweb/pg/name-lookups-hasql
Port Name lookups to Postgres
2023-08-31 22:35:33 +00:00
Chris Penner
fee42779f3 Apply perf optimization: don't call callback unless there are changes 2023-08-31 15:11:18 -07:00
Mitchell Rosen
8e97fc693d allow pulling <project>/releases/latest 2023-08-29 00:34:42 -04:00
Chris Penner
524700d778 Merge remote-tracking branch 'origin/trunk' into pg/name-lookups-hasql 2023-08-22 13:00:01 -07:00
Paul Chiusano
25e67ed5e7 fix #4272 2023-08-21 10:00:37 -05:00
Chris Penner
c3938a8551 Merge remote-tracking branch 'origin/trunk' into pg/name-lookups-hasql 2023-08-18 12:11:32 -07:00
Paul Chiusano
7f9db5f15b comments 2023-08-17 17:38:48 -05:00
pchiusano
a824eb8308 automatically run ormolu 2023-08-17 22:17:12 +00:00
Paul Chiusano
95dd8747ff Merge remote-tracking branch 'origin/trunk' into fix/sig-cleanup
# Conflicts:
#	unison-src/transcripts-round-trip/main.output.md
#	unison-src/transcripts-round-trip/reparses.u
2023-08-17 16:59:32 -05:00
Paul Chiusano
46e28766d6 working 2023-08-17 16:55:28 -05:00
Chris Penner
e5c7ff7e9e
Merge pull request #4260 from kylegoetz/4239/cases-infix
fixes #4239, pretty printing for single arg infix op terms no longer displays "error"
2023-08-17 09:59:24 -07:00
Chris Penner
4cefceedc7 Ormolu 2023-08-16 21:14:16 -07:00
Paul Chiusano
f7d67069ad fix to record printing 2023-08-16 22:25:23 -05:00
Paul Chiusano
13f3aad25f Everything reparses with an identical hash now 2023-08-16 22:17:27 -05:00
Paul Chiusano
355ee4f846 wip 2023-08-16 16:21:30 -05:00
Arya Irani
c1abbe102b
Merge pull request #4246 from unisonweb/cp/project-ui-command 2023-08-15 11:53:11 -04:00
Chris Penner
3bdf3fcf9e Merge remote-tracking branch 'origin/trunk' into pg/name-lookups-hasql 2023-08-14 14:30:53 -07:00
Paul Chiusano
8a88523f63
Merge pull request #4255 from unisonweb/topic/rehashing
Change runtime term link representation to allow code validation
2023-08-14 13:06:12 -04:00
Dan Doel
a8ce3ec559 Make rehash less crashy on bad SCCs
If a user arbitrarily permutes the links associated with code, it's
possible to end up with a load request that appears to have mutually
recursive definitions without common hashes. So, this has been made into
a catchable exception instead of throwing a Haskell error.

The initial hashing in the runtime just calls error when this happens,
since it means some internal code generation generated bad SCCs, not
that some kind of user error happened.
2023-08-14 12:21:38 -04:00
Paul Chiusano
2528ef2008
Update parser-typechecker/src/Unison/Syntax/TermPrinter.hs 2023-08-14 10:05:38 -05:00
Kyle Goetz
c287cf4108 fixes #4239, pretty printing for single arg infix op terms no longer displays "error" 2023-08-12 00:00:41 -05:00
Dan Doel
53919fe4bb Be more thorough about applying forward reference mappings
Solves one observed problem and potentially some others.

The observed problem was the process of unhashing and rehashing does not
replace any term links in the original terms. This is because term link
literals can't be turned into variables and subsequently replaced with
new hashes. So, instead we use our available variable mappings to
replace the literals manually.

A superior methodology might be to replicate the SCC behavior already in
hashTermComponents, and incrementally remap individual components.
However, that is a considerable amount of additional work, and the
post-floating references are just used as a translation layer between
the codebase and verifiable hashes, so making them completely consistent
doesn't seem necessary.

I've also added some codebase->verifiable replacements from the context
in some places. It's possible not doing this would have caused problems
during UCM sessions where some terms are loaded incrementally due to
multiple calls into the runtime. I didn't observe any failing tests due
to this, though.
2023-08-11 20:27:05 -04:00
Dan Doel
2000803b3c Fix some type errors from lamLift in tests 2023-08-11 12:59:44 -04:00
Dan Doel
196552c8ba Ormolu 2023-08-11 12:48:29 -04:00
Dan Doel
b29c8985a3 Remove some commented, dead code 2023-08-11 12:46:35 -04:00
Dan Doel
c356dbb75a Remember remappings from file loads
When the interpreter is called for things in a scratch file, the code
path is slightly different, because all the definitions are pre-combined
into a letrec. If the definitions are subsequently added to the
codebase, we will have already loaded and compiled their code. However,
previously the remapping from base to floated references would not
exist, because that was only being generated for loaded dependencies in
the other path.

So, this code adds a similar remapping for a top-level letrec in this
code path. This fixes a problem with compiling a definition that had
just been added from a scratch file. The remap was expected to be there,
but it wasn't, so the compiler could find the code to emit.
2023-08-11 12:41:44 -04:00
dolio
af4dc89f1a automatically run ormolu 2023-08-10 21:14:34 +00:00
Dan Doel
cad8cb2db9 Add validation to random deserial tests, and fix some bugs
The pair marshaling code was mistakenly using only a single layer of
data nesting, but unison pairs are like 2-element cons lists.

The rehashing code was not sorting the SCCs into a canonical order, so
the exact input order for components with more than one binding could
influence the hash. Sorting by input reference order fixes this, as all
references in an SCC are required to have the same hash, and differ only
by index.
2023-08-10 17:10:31 -04:00
Dan Doel
c8e09f0a96 Ormolu and transcripts 2023-08-10 16:34:55 -04:00
Dan Doel
9402fef658 Hadn't revised validateLinks type based on actual implementation 2023-08-10 16:13:46 -04:00
Dan Doel
8306ff82a3 Add a builtin for validating code hashes before loading. 2023-08-10 15:48:28 -04:00
Dan Doel
190b6d2888 Backmap references in stack traces 2023-08-10 00:25:21 -04:00
Dan Doel
865301752c Fix decompile info
I had mistakenly been putting floated terms in the decompile info, and
that was causing some mismatches with previous decompiling outputs.
Switching back to remembering the unfloated definitions seems to have
cleared up the discrepancies.
2023-08-09 20:31:52 -04:00
Dan Doel
661df84b65 Add version byte to intermediate hash. 2023-08-09 18:39:53 -04:00
Dan Doel
ca5505ab32 Rework intermediate code generation to support rehashing
Previously, we were taking already hashed terms as input to the various
intermediate compiler stages. We would then do things like lambda
lifting, and hash the resulting definitions afterwards. However, this
leads to problems like mutually recursive definitions that do not share
a common hash.

To rectify this, we instead do the intermediate operations on an
_unhashed_ version of code looked up from the codebase. Essentially, we
turn relevant definitions back into a letrec, do the floating, then hash
the results of that processing. This gives proper hashes to the
processed terms so that the compiled terms can be rehashed with relative
ease.

The system for this is unfortunately quite intricate. To get good
decompiled output, we need to keep track of associations between
original and floated terms _and_ floated and rehashed terms, then
mediate between them in various places.
2023-08-09 18:33:27 -04:00
Chris Penner
d81aa9ae15 Merge remote-tracking branch 'origin/trunk' into cp/project-ui-command 2023-08-09 10:06:46 -07:00
Kyle Goetz
cd048f7bdd fixes #4233 - term declarations should not allow hashes in term names 2023-08-06 15:41:15 -05:00
Chris Penner
a9117b6bee WIP resolve project branch ref to root hash 2023-08-04 15:45:36 -07:00
Dan Doel
8f824f16e5 Add a module for rehashing ANF code 2023-07-31 14:45:08 -04:00
runarorama
a32914041f automatically run ormolu 2023-07-31 16:15:00 +00:00
Rúnar
01ad6fc9b4
Update parser-typechecker/src/Unison/PrintError.hs
Co-authored-by: Paul Chiusano <paul.chiusano@gmail.com>
2023-07-31 12:13:22 -04:00