Skip to content

Commit

Permalink
Merge pull request #1161 from andrew-johnson-4/cache-normal
Browse files Browse the repository at this point in the history
Cache normal
  • Loading branch information
andrew-johnson-4 authored Jan 25, 2025
2 parents 6010cff + 1cbb623 commit 812c977
Show file tree
Hide file tree
Showing 9 changed files with 22,204 additions and 21,967 deletions.
44,113 changes: 22,168 additions & 21,945 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lambda_mountain"
version = "1.20.43"
version = "1.20.44"
authors = ["Andrew <[email protected]>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
4 changes: 4 additions & 0 deletions PLATFORM/C/LIB/hashtable.lm
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

type HashtableIs<k,v> (HashtableIs( occupied:U64 , capacity:U64 , contents:Tuple<k,v>[] ));

mk-hashtable-is := λ(: key Type<k>)(: value Type<v>). (: (
(HashtableIs( 0_u64 0_u64 (as 0_u64 Tuple<k,v>[]) ))
) HashtableIs<k,v>);

.bind := λ(: table HashtableIs<k,v>)(: key k)(: value v). (: (
(let occupied (.3 table))
(let capacity (.2 table))
Expand Down
8 changes: 0 additions & 8 deletions SRC/denormalize.lm

This file was deleted.

14 changes: 14 additions & 0 deletions SRC/denormalize.lsts
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@

let denormalize-cache = mk-hashtable-is(type(Type), type(Type));

let denormalize(tt: Type): Type = (
let ct = denormalize-cache.lookup(tt, TAny);
if non-zero(ct) then ct else (
ct = tt.rewrite-type-alias;
ct = with-size(ct);
ct = with-tag(ct);
ct = enrich-quick-prop(ct);
denormalize-cache = denormalize-cache.bind(tt, ct);
ct
)
);

let denormalize-arrow(pt: Type): Type = (
match pt {
TAnd{ left=left, right=right } => denormalize-arrow(left) && denormalize-arrow(right);
Expand Down
2 changes: 1 addition & 1 deletion SRC/index-types.lm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import SRC/without-size-unless-class.lm;
import SRC/without-size.lm;

import SRC/normalize.lm;
import SRC/denormalize.lm;
import SRC/normalize.lsts;
import SRC/denormalize.lsts;
import SRC/type-of-s.lm;
import SRC/type-of-s-with-fields.lm;
Expand Down
11 changes: 0 additions & 11 deletions SRC/normalize.lm
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@

normalize := λ(: tt Type). (: (
(let rt tt)
(set rt (.rewrite-type-alias rt))
(set rt (.without-tag rt))
# Sized can serve as a datatype if nothing else is available
(set rt (without-size-unless-class rt))
(set rt (with-phi rt))
(set rt (weaken-quick-prop rt))
rt
) Type);

normalize := λ(: tctx TContext). (: (
(match tctx (
()
Expand Down
15 changes: 15 additions & 0 deletions SRC/normalize.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

let normalize-cache = mk-hashtable-is(type(Type), type(Type));

let normalize(tt: Type): Type = (
let ct = normalize-cache.lookup(tt, TAny);
if non-zero(ct) then ct else (
ct = tt.rewrite-type-alias;
ct = ct.without-tag;
ct = without-size-unless-class(ct);
ct = without-phi(ct);
ct = weaken-quick-prop(ct);
normalize-cache = normalize-cache.bind(tt, ct);
ct
);
);
2 changes: 1 addition & 1 deletion SRC/type-index.lsts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

let type-index = HashtableIs{ 0, 0, 0 as Tuple<AST,Type>[] };
let type-index = mk-hashtable-is(type(AST), type(Type));

let typeof(t: AST): Type = type-index.lookup(t,TAny);
let ascript(t: AST, tt: Type): Nil = type-index = type-index.bind(t, tt);

0 comments on commit 812c977

Please sign in to comment.