Skip to content

Commit

Permalink
more shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Apr 18, 2024
1 parent e3864b7 commit df5ec74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
33 changes: 15 additions & 18 deletions compiler/lib/flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,21 @@ let rec the_shape_of info x =
get_approx
info
(fun x ->
if Var.ISet.mem info.info_possibly_mutable x
then Shape.Top "possibly_mutable"
else
match Shape.get x with
| Some shape -> shape
| None -> (
match info.info_defs.(Var.idx x) with
| Expr (Block (_, a, _, Immutable)) ->
Shape.Block (List.map ~f:(the_shape_of info) (Array.to_list a))
| Expr (Closure (l, _)) ->
Shape.Function { arity = List.length l; pure = false; res = Top "unk" }
| Expr (Special (Alias_prim name)) -> (
try
let arity = Primitive.arity name in
let pure = Primitive.is_pure name in
Shape.Function { arity; pure; res = Top "unk" }
with _ -> Top "other")
| _ -> Shape.Top "other"))
match Shape.get x with
| Some shape -> shape
| None -> (
match info.info_defs.(Var.idx x) with
| Expr (Block (_, a, _, Immutable)) ->
Shape.Block (List.map ~f:(the_shape_of info) (Array.to_list a))
| Expr (Closure (l, _)) ->
Shape.Function { arity = List.length l; pure = false; res = Top "unk" }
| Expr (Special (Alias_prim name)) -> (
try
let arity = Primitive.arity name in
let pure = Primitive.is_pure name in
Shape.Function { arity; pure; res = Top "unk" }
with _ -> Top "other")
| _ -> Shape.Top "other"))
(Top "init")
(fun _u _v -> Shape.Top "merge")
x
Expand Down
17 changes: 8 additions & 9 deletions compiler/tests-full/stdlib.cma.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@

//# unitInfo: Provides: Stdlib
//# unitInfo: Requires: CamlinternalFormatBasics
//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2),F(2),F(1),N,N,F(1),N,N,N,N,N,N,F(2),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),N,F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1),F(2),F(1),F(1),F(1),F(4),N,N]
//# shape: Stdlib:[F(1),F(1),N,N,N,N,N,N,N,N,N,N,N,N,N,F(2),F(2),F(1),N,N,F(1),N,N,N,N,N,N,F(2),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(2),N,N,N,F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(1),F(3),F(1),F(1),F(2),F(2),F(2),F(4),F(4),F(2),F(2),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(1),F(1),F(3),F(1),F(1),F(4),F(4),F(2),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),N,F(1),F(2),F(1),F(1),F(1),F(4),F(1),N]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -1634,7 +1634,7 @@

//# unitInfo: Provides: Stdlib__Seq
//# unitInfo: Requires: CamlinternalLazy, Stdlib, Stdlib__Atomic, Stdlib__Lazy
//# shape: Stdlib__Seq:[F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(2),F(3),F(4),F(3),F(3),F(3),F(3),N,F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(3),F(2),F(3),F(3),F(3),F(2),F(2),F(3),F(3),F(3),F(1),N,F(1),F(2),F(3),F(2),F(3),F(3),F(3),F(4),F(3),F(4),F(2),F(3),F(1),F(1),F(2),F(2),F(1),F(1),F(2)]
//# shape: Stdlib__Seq:[F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(2),F(3),F(4),F(3),F(3),F(3),F(3),F(1),F(2),F(3),F(2),F(3),F(2),F(2),F(2),F(2),F(3),F(2),F(3),F(3),F(3),F(2),F(2),F(3),F(3),F(3),F(1),N,F(1),F(2),F(3),F(2),F(3),F(3),F(3),F(4),F(3),F(4),F(2),F(3),F(1),F(1),F(2),F(2),F(1),F(1),F(2)]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -21372,8 +21372,7 @@
? empty_backtrace
: /*<<printexc.ml:331:4>>*/ caml_get_exception_raw_backtra(0);
/*<<printexc.ml:345:4>>*/ try{
/*<<printexc.ml:345:9>>*/ /*<<printexc.ml:345:9>>*/ caml_call1
(Stdlib[103], 0);
/*<<printexc.ml:345:9>>*/ Stdlib[103].call(null, 0);
}
catch(_C_){}
/*<<printexc.ml:346:4>>*/ try{
Expand Down Expand Up @@ -23038,7 +23037,7 @@

//# unitInfo: Provides: Stdlib__Hashtbl
//# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__Atomic, Stdlib__Domain, Stdlib__Int, Stdlib__Random, Stdlib__Seq, Stdlib__String, Stdlib__Sys
//# shape: Stdlib__Hashtbl:[N,N,N,N,F(3),F(2),F(2),F(2),F(2),F(2),F(3),N,N,N,N,F(1),F(1),F(2),N,N,N,N,F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)]
//# shape: Stdlib__Hashtbl:[F(2),F(1),F(1),F(1),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(2),F(3),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -24079,7 +24078,7 @@

//# unitInfo: Provides: Stdlib__Weak
//# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__Int, Stdlib__Obj, Stdlib__Sys
//# shape: Stdlib__Weak:[F(1),N,N,F(2),F(2),F(2),F(4),F(5),F(1)]
//# shape: Stdlib__Weak:[F(1),F(1),F(3),F(2),F(2),F(2),F(4),F(5),F(1)]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -24632,7 +24631,7 @@

//# unitInfo: Provides: Stdlib__Format
//# unitInfo: Requires: CamlinternalFormat, Stdlib, Stdlib__Array, Stdlib__Buffer, Stdlib__Bytes, Stdlib__Domain, Stdlib__Int, Stdlib__List, Stdlib__Queue, Stdlib__Seq, Stdlib__Stack, Stdlib__String
//# shape: Stdlib__Format:[F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),N,F(1),F(3),F(2),F(3),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(3),F(2),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),N,F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(1),N,F(1),N,F(1),F(1),N,F(1),N,F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(1),F(2),F(1),F(5),F(4),F(4),F(4),F(2),F(4),F(4),F(4),F(1),F(1),F(1),F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2)]
//# shape: Stdlib__Format:[F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(3),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(3),F(2),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),N,F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(3),F(2),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(2),F(1),F(1),F(1),N,F(1),N,F(1),F(1),N,F(1),N,F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(1),F(2),F(1),F(5),F(4),F(4),F(4),F(2),F(4),F(4),F(4),F(1),F(1),F(1),F(1),F(1),F(1),F(2),F(3),F(2),F(3),F(2),F(2)]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -28906,7 +28905,7 @@

//# unitInfo: Provides: CamlinternalOO
//# unitInfo: Requires: Stdlib, Stdlib__Array, Stdlib__List, Stdlib__Map, Stdlib__Obj, Stdlib__Sys
//# shape: CamlinternalOO:[N,F(1),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(4),F(1),F(2),N,F(1),F(1),F(6),F(2),F(3),F(1),F(1),F(1),F(2),F(2),F(3),F(2),F(2),N,F(1)]
//# shape: CamlinternalOO:[F(1),F(1),F(2),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(4),F(1),F(2),N,F(1),F(1),F(6),F(2),F(3),F(1),F(1),F(1),F(2),F(2),F(3),F(2),F(2),N,F(1)]
(function
(globalThis){
"use strict";
Expand Down Expand Up @@ -33108,7 +33107,7 @@

//# unitInfo: Provides: Stdlib__MoreLabels
//# unitInfo: Requires: Stdlib__Hashtbl, Stdlib__Map, Stdlib__Set
//# shape: Stdlib__MoreLabels:[[N,N,N,N,F(3),F(2),F(2),F(2),F(2),F(2),F(3),N,N,N,N,F(1),F(1),F(2),N,N,N,N,F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)],[F(1)],[F(1)]]
//# shape: Stdlib__MoreLabels:[[F(2),F(1),F(1),F(1),F(3),F(2),F(2),F(2),F(2),F(2),F(3),F(2),F(2),F(3),F(1),F(1),F(1),F(2),F(1),F(1),F(1),F(1),F(2),F(2),F(1),F(1),F(1),F(1),F(2),F(3),F(4)],[F(1)],[F(1)]]
(function
(globalThis){
"use strict";
Expand Down

0 comments on commit df5ec74

Please sign in to comment.