Skip to content

Commit

Permalink
Static con-switch and decon-con elimination (#156)
Browse files Browse the repository at this point in the history
* decon-con and static con-switch elimination
* repl lib precompile
* block mutability support
  • Loading branch information
melsman authored Dec 13, 2023
1 parent 8b01692 commit 0cc0070
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 70 deletions.
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ all: mlkit mlkit_basislibs smltojs smltojs_basislibs

.PHONY: mlkit_basislibs
mlkit_basislibs: mlkit
(cd basis && SML_LIB=.. ../bin/mlkit -c -no_gc basis.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -no_gc -par basis.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -no_gc repl.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -no_gc -par repl.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -gc basis.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -gc -prof basis.mlb)
(cd basis && SML_LIB=.. ../bin/mlkit -c -no_gc -prof -Pcee -Prfg -Ppp -print_rho_types -log_to_file basis.mlb)
Expand Down
24 changes: 16 additions & 8 deletions basis/REAL64_BLOCK_BASE.sml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ signature REAL64_BLOCK_BASE2 = sig
type t
val sub0 : t -> real
val sub1 : t -> real
val upd0 : t * real -> unit
val upd1 : t * real -> unit
end

signature REAL64_BLOCK_BASE3 = sig include REAL64_BLOCK_BASE2 val sub2 : t -> real end
signature REAL64_BLOCK_BASE4 = sig include REAL64_BLOCK_BASE3 val sub3 : t -> real end
signature REAL64_BLOCK_BASE5 = sig include REAL64_BLOCK_BASE4 val sub4 : t -> real end
signature REAL64_BLOCK_BASE6 = sig include REAL64_BLOCK_BASE5 val sub5 : t -> real end
signature REAL64_BLOCK_BASE7 = sig include REAL64_BLOCK_BASE6 val sub6 : t -> real end
signature REAL64_BLOCK_BASE8 = sig include REAL64_BLOCK_BASE7 val sub7 : t -> real end
signature REAL64_BLOCK_BASE9 = sig include REAL64_BLOCK_BASE8 val sub8 : t -> real end
signature REAL64_BLOCK_BASE10 = sig include REAL64_BLOCK_BASE9 val sub9 : t -> real end
signature REAL64_BLOCK_BASE3 = sig include REAL64_BLOCK_BASE2 val sub2 : t -> real val upd2 : t * real -> unit end
signature REAL64_BLOCK_BASE4 = sig include REAL64_BLOCK_BASE3 val sub3 : t -> real val upd3 : t * real -> unit end
signature REAL64_BLOCK_BASE5 = sig include REAL64_BLOCK_BASE4 val sub4 : t -> real val upd4 : t * real -> unit end
signature REAL64_BLOCK_BASE6 = sig include REAL64_BLOCK_BASE5 val sub5 : t -> real val upd5 : t * real -> unit end
signature REAL64_BLOCK_BASE7 = sig include REAL64_BLOCK_BASE6 val sub6 : t -> real val upd6 : t * real -> unit end
signature REAL64_BLOCK_BASE8 = sig include REAL64_BLOCK_BASE7 val sub7 : t -> real val upd7 : t * real -> unit end
signature REAL64_BLOCK_BASE9 = sig include REAL64_BLOCK_BASE8 val sub8 : t -> real val upd8 : t * real -> unit end
signature REAL64_BLOCK_BASE10 = sig include REAL64_BLOCK_BASE9 val sub9 : t -> real val upd9 : t * real -> unit end
signature REAL64_BLOCK_BASE11 = sig include REAL64_BLOCK_BASE10 val sub10 : t -> real val upd10 : t * real -> unit end

signature REAL64_BLOCK2 = sig include REAL64_BLOCK_BASE2
val pack : real*real -> t
Expand Down Expand Up @@ -57,3 +60,8 @@ signature REAL64_BLOCK10 = sig include REAL64_BLOCK_BASE10
val pack : real*real*real*real*real*real*real*real*real*real -> t
val unpack : t -> real*real*real*real*real*real*real*real*real*real
end

signature REAL64_BLOCK11 = sig include REAL64_BLOCK_BASE11
val pack : real*real*real*real*real*real*real*real*real*real*real -> t
val unpack : t -> real*real*real*real*real*real*real*real*real*real*real
end
11 changes: 2 additions & 9 deletions basis/Real.sml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ structure Real : REAL =
fun (x:real) / (y:real) : real = prim ("divFloat", (x, y))
fun rem (x:real, y:real) : real = prim ("remFloat", (x, y))

local
fun repair_negnan (s:string) : string =
if s = "~nan" then "nan" else s
in
fun to_string_gen (s : string) (x : real) : string =
repair_negnan (prim ("generalStringOfFloat", (s,x)))
fun toString (x:real) : string =
repair_negnan (prim ("stringOfFloat", x))
end
fun to_string_gen (s : string) (x : real) : string = prim ("generalStringOfFloat", (s,x))
fun toString (x:real) : string = prim ("stringOfFloat", x)

fun sub_unsafe (s:string, i:int) : char = prim ("__bytetable_sub", (s,i))
fun isNan (x:real) : bool = prim ("isnanFloat", x)
Expand Down
38 changes: 27 additions & 11 deletions basis/Real64Blocks.sml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
local

structure B = struct
type t = string
fun sub (t:t,i:int) : real = prim("__blockf64_sub_real", (t,i))
type t = string
fun sub (t:t,i:int) : real = prim("__blockf64_sub_real", (t,i))
fun upd (t:t,i:int,v:real) : unit = prim ("__blockf64_update_real", (t,i,v))
end

structure B2 = struct type t = B.t fun sub0 t = B.sub(t,0) and sub1 t = B.sub(t,1) end
structure B3 = struct open B2 fun sub2 t = B.sub(t,2) end
structure B4 = struct open B3 fun sub3 t = B.sub(t,3) end
structure B5 = struct open B4 fun sub4 t = B.sub(t,4) end
structure B6 = struct open B5 fun sub5 t = B.sub(t,5) end
structure B7 = struct open B6 fun sub6 t = B.sub(t,6) end
structure B8 = struct open B7 fun sub7 t = B.sub(t,7) end
structure B9 = struct open B8 fun sub8 t = B.sub(t,8) end
structure B10 = struct open B9 fun sub9 t = B.sub(t,9) end
structure B2 = struct type t = B.t
fun sub0 t = B.sub(t,0)
fun sub1 t = B.sub(t,1)
fun upd0 (t,v) = B.upd(t,0,v)
fun upd1 (t,v) = B.upd(t,1,v)
end
structure B3 = struct open B2 fun sub2 t = B.sub(t,2) and upd2 (t,v) = B.upd(t,2,v) end
structure B4 = struct open B3 fun sub3 t = B.sub(t,3) and upd3 (t,v) = B.upd(t,3,v) end
structure B5 = struct open B4 fun sub4 t = B.sub(t,4) and upd4 (t,v) = B.upd(t,4,v) end
structure B6 = struct open B5 fun sub5 t = B.sub(t,5) and upd5 (t,v) = B.upd(t,5,v) end
structure B7 = struct open B6 fun sub6 t = B.sub(t,6) and upd6 (t,v) = B.upd(t,6,v) end
structure B8 = struct open B7 fun sub7 t = B.sub(t,7) and upd7 (t,v) = B.upd(t,7,v) end
structure B9 = struct open B8 fun sub8 t = B.sub(t,8) and upd8 (t,v) = B.upd(t,8,v) end
structure B10 = struct open B9 fun sub9 t = B.sub(t,9) and upd9 (t,v) = B.upd(t,9,v) end
structure B11 = struct open B10 fun sub10 t = B.sub(t,10) and upd10 (t,v) = B.upd(t,10,v) end

in

structure Real64Block2 :> REAL64_BLOCK2 = struct
Expand Down Expand Up @@ -73,4 +82,11 @@ fun pack (r0:real,r1:real,r2:real,r3:real,r4:real,r5:real,r6:real,r7:real,r8:rea
fun unpack t = (sub0 t, sub1 t, sub2 t, sub3 t, sub4 t, sub5 t, sub6 t, sub7 t, sub8 t, sub9 t)
end

structure Real64Block11 :> REAL64_BLOCK11 = struct
open B11
fun pack (r0:real,r1:real,r2:real,r3:real,r4:real,r5:real,r6:real,r7:real,r8:real,r9:real,r10:real) : t =
prim ("__blockf64", (r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10))
fun unpack t = (sub0 t, sub1 t, sub2 t, sub3 t, sub4 t, sub5 t, sub6 t, sub7 t, sub8 t, sub9 t, sub10 t)
end

end
Loading

0 comments on commit 0cc0070

Please sign in to comment.